I am animating vertices (using an audio input in a vertex shader) of a geometry using a batch. I need to import this animation into a 360 video, so I thought it would be cool if I could export the batch being drawn into a 3d object sequence, which I could then import into a compositing software.
TriMeshRef triMesh = Trimesh::create(batch->getVboMesh()); //something like that
ObjLoader::write( writeFile( "~/output.obj" ), triMesh );
Is the above possible in principle and will the resulting triMesh capture the frame state of the vertices?
It won’t output them if you’re moving them in a vertex shader unfortunately since it’s just translated on the GPU side. You’d need to update the trimesh itself on the CPU side, and then it would save correctly.
If you want to still use a shader, check out the TransformFeedback sample which I believe will allow a shader to affect your CPU buffer.
Another consideration: there is no OBJ export from Cinder, so you’d have to roll your own or find a library that can do it for you. Also, the OBJ format is very limited and slow to import. Instead of OBJ, you could export and import using
TriMesh::write. The data will be written to a binary file that is much quicker to import.
@paul.houx There is cinder:writeObj method –– I assume it exports trimeshes as obj files. No?
@sharkbox As far as getting triMesh out of VboMesh, I hoped it would be possible to download to CPU the current state of the mesh, similarly to how one can create a Surface out of a Texture.