Translating .obj files to jit.matrix
I have accumulated a number of 3D graphics programs to make .obj files for
jit.gl.model. Now, I would like to manipulate the data directly to warp the
shapes in real time. I am wondering if someone has created a method or tool
to translate .obj files so they can be loaded into jit.matrix. I have seen
the examples where a sphere is created directly into a matrix with plane
messages specifying each point and I love the example that creates "ghosts"
with jit.noise. I'm looking for something in between.
And a related issue in openGL...There are many examples in the openGL
manuals that could be plugged into jit.gl.sketch. However, the format of
the sketch messages is different so as not to allow simple cut and paste.
Has anyone dealt with this? Would this be a thing to do with Java?
Cheers,
Gary Lee Nelson
TIMARA Department
Oberlin College
www.timara.oberlin.edu/GaryLeeNelson
I did a bit of this recently.
A) [Jit.gl.model @matrixoutput 1] -> [jit.matrix] -> [jit.gl.mesh]
Watch out for large obj files slowing down your frame rate though. Bang the
jit.gl.model once to dump it into a jit.matrix, then do transforms on that
matrix at frame rate and send to jit.gl.mesh. The output will be a Nx1
matrix; depending upon what primitive you use to render (triangles, lines,
quad strips etc etc) it might be helpful to reorganise the matrix into an
Nx3 or Nx4 shape. Start with some really simple .objs (like, cubes) to get
an idea of what is happening.
It's pretty hard to get transforms that make much sense visually (apart from
the obvious 'exploding triangles' and 'jittery noisy shapes' effects...) and
it's especially dependent upon the order of vertices in the .obj file.
Different packages seem to export in different ways; I've seen some with a
lot of zero vertices in there.
Oh, and quite a few .obj files don't have their normals set (they will look
weird if you have lighting enabled), so try sending a make_normals message
to your jit.gl.model after loading.
B) yes, or Javascript which might be simpler to write a parser in
If you create models with the same program, (Maya for instance) and
count the number of verts and make sure they are the same, you can do
very convincing morphs.
basically, what I have is this:
2 x jit.gl.model @matrixoutput 1
each feeds into a jit.xfade
jit.xfade into a named jit.matrix
whenever I change the xfade value, I also bang the 2 jit.gl.models,
which then supply the morphed vertices into the 'bottom' jit.matrix.
This way, I incur no penalty for having the xfades, the jitter matrix
chain is inactive until I decide to morph again. the last jit.matrix
is essentially a vertex 'buffer' that is then rendered with
jit.gl.sketch with drawmatrix . Add a line or two to
make morphing smooth, and it works well.
I just played with it live last night at an open jam, and really
enjoyed it.
The hardest part is making the models.
v a d e //
www.vade.info
abstrakt.vade.info
I LIVE! I LIVE! I LIVE! I LIVE! I LIVE! I LIVE! I LIVE! I LIVE! I
LIVE! I LIVE! I LIVE! I LIVE!
You will not be saved by the Holy Ghost. You will not be saved by the
God Plutonium.
In fact, YOU WILL NOT BE SAVED!
I want to work with modelmorphing but i cant get the basics to work. Probably something i'm too blind to see because i tried everything described in the forums/tutorials.
Max loads the models seperately but after an xfade i can't get the matrix to work.
I tried vade's method and the gl.sketch alternative as described in the patch below.
Please your opinion about this, I'm getting headaches!
Tim
got it finaly..
forgot to include the drawingmethod. i wanted to bang my head for forgetting it, but instead i'll let max bang for me
here is the patch which works for me: