Translating .obj files to jit.matrix

Mar 20, 2006 at 1:32pm

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
http://www.timara.oberlin.edu/GaryLeeNelson

#24982
Mar 20, 2006 at 6:06pm

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

#72936
Mar 20, 2006 at 6:48pm

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 //

http://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!

#72937
May 24, 2006 at 1:06pm

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

max v2;
#N vpatcher 75 182 1094 724;
#P origin 0 12;
#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P newex 496 439 99 9109513 jit.matrix morphbuffer;
#B color 5;
#P button 428 329 15 0;
#N vpatcher 77 44 814 444;
#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P message 88 134 116 9109513 drawmatrix buffer tri_strip;
#P outlet 199 307 15 0;
#P newex 196 260 48 9109513 r sketchy;
#P hidden newex 19 217 104 9109513 bgcolor 255 230 230;
#P window linecount 2;
#P newex 585 124 156 9109513 jit.gl.gridshape nowhere @name squeamish @shape torus;
#P window linecount 4;
#P message 586 161 155 9109513 glcolor 1 0 0 , glscale 0.2 0.2 0.2 , drawobject squeamish 1 , glrotate 90 0 1 0 , glcolor 0 1 0 , drawobject squeamish 1;
#P window linecount 1;
#P newex 473 72 84 9109513 prepend shape;
#P user umenu 473 49 85 9109543 1 64 65 1;
#X add sphere;
#X add cylinder;
#X add opencylinder;
#X add torus;
#X add circle;
#X add cube;
#X add opencube;
#X add plane;
#P newex 473 171 82 9109513 jit.matrix blotto;
#P newex 473 95 255 9109513 jit.gl.gridshape nowhere @shape cube @matrixoutput 1;
#P window setfont “Sans Serif” 18.;
#P comment 60 25 162 9109522 object commands;
#P button 17 127 15 0;
#P window setfont “Sans Serif” 9.;
#P window linecount 2;
#P newex 17 160 127 9109513 jit.noise 12 float32 10 10 @out_name blitto;
#P window linecount 1;
#P message 197 159 132 9109513 drawmatrix blitto tri_strip;
#P newex 197 235 51 9109513 s sketchy;
#P window linecount 3;
#P comment 61 54 402 9109513 drawobject ; drawmatrix

; dimorient <0/1> (affects drawmatrix command. initial state is 0);
#P window linecount 1;
#P message 210 199 373 9109513 reset , drawmatrix blotto line_strip , dimorient 1 , drawmatrix blotto line_strip;
#P button 417 117 15 0;
#P window linecount 4;
#P comment 184 93 185 9109513 texflag: 0=use , 1=ignore , 2=auto ; normalflag: 0=use , 1=ignore , 2=auto ; colorflag: 0=use , 1=ignore ; edgeflag: 0=use , 1=ignore;
#P connect 7 0 6 0;
#P connect 7 0 18 0;
#P fasten 7 0 5 0 22 150 202 150;
#P fasten 13 0 4 0 591 230 202 230;
#P fasten 2 0 4 0 215 228 202 228;
#P connect 5 0 4 0;
#P connect 18 0 4 0;
#P connect 16 0 17 0;
#P fasten 1 0 2 0 422 191 215 191;
#P fasten 11 1 12 0 553 69 478 69;
#P fasten 1 0 9 0 422 151 468 151 468 92 478 92;
#P connect 12 0 9 0;
#P connect 9 0 10 0;
#P pop;
#P newobj 253 205 44 9109513 p sketch;
#P flonum 428 279 35 9 0. 1. 3 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P message 428 300 48 9109513 xfade $1;
#P newex 496 386 42 9109513 jit.xfade;
#P message 528 297 26 9109513 read;
#P newex 528 351 154 9109513 jit.gl.model morph @matrixoutput 1;
#B color 5;
#P toggle 341 96 15 0;
#P message 341 119 94 9109513 smooth_shading $1;
#P toggle 440 96 15 0;
#P message 440 119 90 9109513 lighting_enable $1;
#P hidden newex 341 21 50 9109513 loadbang;
#P toggle 253 96 15 0;
#P message 253 119 81 9109513 depth_enable $1;
#P hidden message 341 49 14 9109513 1;
#P message 316 179 29 9109513 reset;
#P message 399 182 108 9109513 drawmatrix morphbuffer;
#P newex 33 281 242 9109513 jit.gl.handle morph @inherit_transform 1 @auto_rotate 1;
#P message 351 181 45 9109513 cube 0.2;
#P newex 341 228 85 9109513 jit.gl.sketch morph;
#P message 683 111 68 9109513 fullscreen $1;
#P toggle 665 111 15 0;
#P newex 665 91 50 9109513 select 27;
#P newex 665 71 50 9109513 key;
#P newex 683 137 291 9109513 jit.window morph @depthbuffer 1 @rect 614 76 934 316 @floating 1;
#P message 496 297 26 9109513 read;
#P newex 496 329 122 9109513 jit.gl.model @matrixoutput1;
#B color 5;
#P button 15 49 15 0;
#P newex 35 72 37 9109513 jit.qball;
#P number 80 23 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P toggle 35 22 15 0;
#P newex 35 49 55 9109513 metro 20;
#P newex 35 96 55 9109513 t b b erase;
#P newex 35 247 83 9109513 jit.gl.render morph;
#P connect 3 0 2 0;
#P connect 2 0 5 0;
#P connect 6 0 5 0;
#P connect 5 0 1 0;
#P connect 16 0 0 0;
#P connect 1 2 0 0;
#P connect 1 0 0 0;
#P connect 4 0 2 1;
#P hidden fasten 19 0 21 0 346 74 258 74;
#P connect 21 0 20 0;
#P hidden connect 22 0 19 0;
#P hidden fasten 19 0 26 0 346 74 346 74;
#P connect 26 0 25 0;
#P connect 25 0 14 0;
#P connect 15 0 14 0;
#P connect 17 0 14 0;
#P connect 18 0 14 0;
#P connect 20 0 14 0;
#P connect 32 0 14 0;
#P connect 23 0 14 0;
#P connect 31 0 30 0;
#P connect 30 0 33 0;
#P hidden fasten 19 0 24 0 346 74 445 74;
#P connect 24 0 23 0;
#P connect 33 0 7 0;
#P connect 8 0 7 0;
#P connect 7 0 29 0;
#P connect 30 0 29 0;
#P connect 29 0 34 0;
#P connect 33 0 27 0;
#P connect 28 0 27 0;
#P connect 27 0 29 1;
#P connect 10 0 11 0;
#P connect 11 0 12 0;
#P connect 12 0 13 0;
#P connect 13 0 9 0;
#P pop;

#72938
May 24, 2006 at 11:05pm

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:

#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P message 974 231 26 9109513 read;
#P newex 974 269 394 9109513 jit.gl.model morph @depth_enable 1 @smooth_shading 1 @lighting_enable 1 matrixoutput $1;
#B color 5;
#P window setfont “Proportional Serif” 10.;
#P comment 1033 221 107 9175050 Turn matrixoutput on/off;
#P toggle 1012 220 15 0;
#P window setfont “Fixedwidth Serif” 10.;
#P message 1012 240 98 9240586 matrixoutput $1;
#P window setfont “Sans Serif” 9.;
#P message 904 151 26 9109513 read;
#P newex 904 190 394 9109513 jit.gl.model morph @depth_enable 1 @smooth_shading 1 @lighting_enable 1 matrixoutput $1;
#B color 5;
#P newex 1071 416 60 9109513 prepend set;
#P window setfont “Proportional Serif” 10.;
#P comment 1040 376 95 9175050 Drawing Primitive;
#P window setfont “Sans Serif” 9.;
#P user ubumenu 1042 393 68 9109513 0 1 1 0;
#X add points;
#X add lines;
#X add line_strip;
#X add line_loop;
#X add triangles;
#X add tri_strip;
#X add tri_fan;
#X add quads;
#X add quad_strip;
#X add polygon;
#X add tri_grid;
#X add quad_grid;
#X prefix_set 0 0 0;
#P newex 903 437 85 9109513 append quad_grid;
#P window setfont “Proportional Serif” 10.;
#P comment 974 335 95 9175050 Crossfade Value;
#P comment 963 141 107 9175050 Turn matrixoutput on/off;
#P window setfont “Sans Serif” 9.;
#P flonum 976 351 35 9 0. 1. 3 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P window setfont “Fixedwidth Serif” 10.;
#P message 975 371 55 9240586 xfade $1;
#P newex 904 499 53 9240586 s render;
#P toggle 942 140 15 0;
#P message 942 160 98 9240586 matrixoutput $1;
#P newex 903 397 62 9240586 jit.xfade;
#P connect 14 0 17 0;
#P connect 18 0 17 0;
#P connect 17 0 0 1;
#P connect 12 0 0 0;
#P connect 1 0 12 0;
#P connect 13 0 12 0;
#P fasten 4 0 0 0 980 391 908 391;
#P connect 15 0 14 0;
#P fasten 8 0 3 0 908 457 909 457;
#P connect 0 0 8 0;
#P fasten 11 0 8 0 1076 435 908 435;
#P connect 2 0 1 0;
#P connect 5 0 4 0;
#P connect 9 1 11 0;
#P window clipboard copycount 19;

#72939

You must be logged in to reply to this topic.