.obj sequence via js

Robert White's icon

I've used vbomesh to load .obj sequence files. I'm looking to do the same in GL3. I want to know if it's possible and maybe some tips on where to start?

thanks, -=Bob

Federico-AmazingMaxStuff's icon

That would be jit.gl.mesh : )

Robert White's icon

Thanks Federico, and thanks to your recent class. That's what inspired this question :)

The only thread I can find is from Rob Ramirez about "Loading multiple .OBJs into Jitter" . I assume he means creating say 30 jit.gl.mesh objects in javascript. And then somehow swapping between them at 30+ fps? That's what I'm looking to do.

And then.... next step, attaching the obj meshes onto point via jit.gl.TF :)

Rob Ramirez's icon

you can use jit.gl.model to load an obj, and enable matrixoutput on it to bang out the loaded model as a matrix that can be displayed by jit.gl.mesh @drawmode triangles. You could create some patch structure (either JS or vanilla patching) that filled a structure up from a folder of obj files (jit.matrixset might be the easiest structure for this) in some intialization routine. then you can iterate through the matrices in your structure however you wish, drawing the geometry with gl.mesh.

of course if you can export as a skeleton based animation in a supporting 3d format (e.g. collada .dae) then you can simply load and animate all from jit.gl.model.

Federico-AmazingMaxStuff's icon

This sounds like a cool solution Rob! But isn't matrixset only good for matrices with same size and planecount?

Robert White's icon

To be clear. The obj files have different vertex counts. Think of a sweep or extrude sequence starting from zero vertices. For collada it just bones and global positioning... I'm pretty sure. Alembic (.abc) would be more along the lines of how to describe it.

Robert White's icon

Finally attempted a solution here and now I'm trying to get this to render with a jit.gl.pbr via js. Tried Rob's and Federico's suggestions but I couldn't figure out how to build an array of matrix_outputs, each a different dimension. So instead I created an array of jit.gl.models, loaded in .obj files, and this works but I'm not sure if it's the best solution.

Now I'm trying to take this a step further using pbr but I'm having trouble getting the textures bound to the jit.gl.model(s) in js. Any suggestions how to assign texture to jit.gl.pbr via js? My code is not working. See attached patch, js (line 116),

07_starBurstObj_OBJ_Seq.zip
application/zip 1.25 MB

JS-objSeq-pbr-noTextures.maxpat
Max Patch

objSeq.js
text/javascript 5.09 KB

and zip of .obj files. Thanks,

Federico-AmazingMaxStuff's icon

Hey Robert!

We already solved this on Discord but I'm going to post the solution here as well:
when assigning the pbr.albedo_texture to null, it broke the JS object.
If that part is removed and the texture assignments are called as functions, then it works:

pbr.albedo_texture(pbr_jit_matrix.name);

Also, jitter matrices and gl objects should be freed with the "freepeer()" method before they go out of scope or the patch is closed.

Robert White's icon

Thank you @Federico! I was having trouble with the js syntax.

Here is the corrected .js file . First, load an array of .obj files all to create the animated .obj sequence. Second, render with a jit.gl.pbr texture and environment map.

.obj sequences are a precursor to alembic (.abc) files [https://www.alembic.io/ ] and are good for short animations of 3d models with different vertex counts (i.e. growing plants and vines, polygon effects)

objSeq.js
text/javascript 4.40 KB