Sequence of .obj files

Hi,

I am developing an app that involves reading various .obj files and being able to play all of them, similar to a video. I am using the ObjLoaderApp as based. The example allocates a .obj into a TriMesh and then binds it to a Batch. If I want to play all the objs would I load all of the objs to multiples TriMeshs and then update the points to a single Batch?.

What would be the best appraoch for it?

Thanks
Thomas

Hi Thomas,

If you have a blend shape animation, an object changing shape, but keeping its structure and the number of vertices, you can create a VboMesh and update the changing attributes every frame dynamically. If you have many large .obj files it is worth considering using cinder’s internal mesh format for much faster loading.

Some sample code (not tested):

// creating the batch from the first TriMesh you loaded
std::vector< gl::VboMesh::Layout > bufferLayout = {
        gl::VboMesh::Layout().usage( GL_DYNAMIC_DRAW ).attrib( geom::Attrib::POSITION, 3 ),
        gl::VboMesh::Layout().usage( GL_DYNAMIC_DRAW ).attrib( geom::Attrib::NORMAL, 3 ),
        gl::VboMesh::Layout().usage( GL_STATIC_DRAW ).attrib( geom::Attrib::TEX_COORD_0, 2 ) };

mVboMesh = gl::VboMesh::create( *mTriMesh, bufferLayout );
mBatch = gl::Batch::create( mVboMesh, glsl );

// updating animation
mVboMesh->bufferAttrib( geom::Attrib::POSITION, mPositionsSize, mTriMeshFrames[ mCurrentFrameId ]->getBufferPositions().data() );
mVboMesh->bufferAttrib( geom::Attrib::NORMAL, mPositionsSize, (float *)mTriMeshFrames[ mCurrentFrameId ]->getNormals(),data() );

-Gabor

We have a simple example of that in this block: https://github.com/redpaperheart/Cinder-TextureSequence
(It’s called TextureSequence but it’s templated so you can use it with batches, too)

Thank you, Gabor and Navadria!,

Navadria, the example, and the block are really helpful. I am going to try yours out, before trying Gabor’s approach of updating the VboMesh by changing the attributes dynamically

Thomas