Notifications
Clear all
[Closed] Set vertex keyframes with C++ SDK
Page 3 / 3
Prev
Dec 03, 2014 6:49 am
I wrote a .pts file format exporter in c++, it was very easy to do.
This enables you to load it up in a pointcache modifier.
Example file:
http://bullet4max.com/wp-content/uploads/2014/11/softbodycache.zip
(the normals seems to flip in my example file when applied, but the basic implementation works).
screenshot:
Code: (adapt to your own needs)
//define the file during init.
File *tmpFile;
//open the file
fopen_s(&tmpFile, "c:\ est.pts", "wb");
//Get the object vert count\frames\samplerate
int vertcount = p_trimesh->getNumVerts();
int numframes = 100;
int cachesamples =1;
//write out the vertcount, samplerate and number of frames to the file:
fwrite (&vertcount, 4, 1, tmpFile);
fwrite (&cachesamples, 4, 1, tmpFile);
fwrite (&numframes, 4, 1, tmpFile);
//For each frame get the vertex xyz and write it out:
float valueX = vert.x;
float valueY = vert.y;
float valueZ = vert.z;
fwrite (&valueX, 4, 1, tmpFile);
fwrite (&valueY, 4, 1, tmpFile);
fwrite (&valueZ, 4, 1, tmpFile);
//close the file when done:
fclose(tmpFile);
Dec 03, 2014 6:49 am
you would probably use fwrite more like…
fwrite(&vert,sizeof(Point3),1,tmpFile);
or a whole array of verts in a single call for example…
fwrite(mesh->verts, sizeof(Point3) ,mesh->numverts, tmpFile);
so if you arrange your vert data correctly in memory you should be be able write it in one disk access something like…
fwrite(&vertdata,sizeof(Point3),numverts*numframes,tmpFile);
Dec 03, 2014 6:49 am
Thanks Klvnk, it was the first version of my code (have not had time to work more on it since then), but yes – you are right. Thanks for the hints, more optimized that way.
Page 3 / 3
Prev