Forums > Jitter

clustering videoplanes?

August 17, 2009 | 11:22 pm

Hi all,
I am in need some pointers. For the sake of simplicity, let’s say I have 3 images: a background, a spaceship, and thrust for the spaceship. Rendering for each jit.qt.movie >> jit.gl.videoplane >> jit.gl.render. I need to process each image with its own videoplane to play with scale, alpha, etc. individually. The goal is to rotate and translate the spaceship and thrust, but not the background. My current solution is to send rotating and position messages to jit.gl.render, and send the opposite values to the background videoplane. It works fine with rotation and translation along one axis, but can’t seem to get my math right for rotation and translation along 2 axis, but more importantly, occasionally the translations are off by a frame so I get some unwanted movement in the background image…and am thinking there must be a better way!

Is it possible to group/cluster videoplanes together, e.g. spaceship and thrust in one group, background in another, and then have them both appear in the same window? Am I using the wrong tools here?

Thanks for any pointers.

Best,
David


August 18, 2009 | 12:41 am

OK, got the math, and am now turning on/off rendering until I know the adjustments have been calculated, so no more sudden background shifts. If there is a more elegant solution, I certainly wouldn’t mind hearing about it, tho.

Thanks,
David


August 18, 2009 | 9:55 am

In this case, sending position and rotation data to render will work as most of your objects move at the same time. Generally I prefer to keep the ‘world’ in the same spot and just move the objects around, it’s easier for my brain to understand.

There are ways of rendering things in groups. One is to use ‘push’ and ‘pop’ using [jit.gl.sketch], but you need to get into openGL a little bit more for that. It basically involves objects to be drawn in a tree like structure, where you can jump back to the previous node.

You could also do it manually, by just specifying a position for the group (spaceship + thrust), where the two elements in the group have their own relative position to the group position. You just add using [vexpr] and you’re good to go. I’d try this first.

Turning rendering off and on just to calculate a position makes me wonder what kind of calculation this is. Are you calculating the path of the Hubble telescope until the year 2046 by any chance? Seriously, this shouldn’t take too much time…


August 18, 2009 | 5:19 pm

Thanks for the advice!
The translation isn’t a problem really, it’s rotation that gets confusing, especially when each of the elements have their own "axis" point. I can rotate both the ship and thrust, however in order to keep the thrust where it suppose to be relative to the ship, I also need to then do some xy translating with the rotation…so it gets a bit confusing when I have translation due to rotations, and translations due to intensional xy movements. It hurts my head, especially when I add more elements to the ship.

So far my method above is working. It isn’t the number of calculations wrt this problem that might cause a delay, but in combination with a bunch of other things happening at the same time…AND the hubble path…actually to 2076 Smile Just trying to find a way that ensures all calculations are made before the next rendering bang is processed.

Thanks again,
David


August 18, 2009 | 6:04 pm

here’s an old patch jkc posted regarding using the matrix stack with gl.sketch to do complex transformations.

might give you some ideas.

#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P newex 288 451 69 196617 loadmess 0.5;
#P newex 286 532 69 196617 loadmess 0.2;
#P window setfont "Sans Serif" 14.;
#P comment 342 169 570 196622 fun time uzi zone (switch to the uzi for iterated multiple drawing);
#P user gswitch2 272 165 39 32 1 0;
#P window setfont "Sans Serif" 9.;
#P flonum 341 353 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 316 372 35 196617 * 36.;
#P newex 301 211 40 196617 uzi 10;
#P window setfont "Sans Serif" 14.;
#P comment 179 34 570 196622 simple jit.gl.sketch "bang chain" example ;;
#P comment 343 585 364 196622 matrixmode + scale;
#P window setfont "Sans Serif" 9.;
#N vpatcher 30 89 630 489;
#P window setfont "Sans Serif" 9.;
#P message 218 76 123 196617 glmatrixmode modelview;
#P newex 134 123 100 196617 pack glscale 1. 1. 1.;
#P newex 50 50 179 196617 t b b b;
#P newex 134 151 221 196617 jit.gl.sketch v001 @automatic 0 @immediate 1;
#P inlet 50 30 15 0;
#P inlet 170 103 15 0;
#P inlet 206 103 15 0;
#P inlet 242 103 15 0;
#P outlet 50 154 15 0;
#P connect 4 0 6 0;
#P connect 6 0 0 0;
#P connect 6 1 7 0;
#P fasten 8 0 5 0 223 96 271 96 271 144 139 144;
#P connect 7 0 5 0;
#P connect 3 0 7 1;
#P connect 2 0 7 2;
#P connect 6 2 8 0;
#P connect 1 0 7 3;
#P pop;
#P newobj 268 579 53 196617 p scale;
#P flonum 358 554 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 321 554 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 285 554 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P window setfont "Sans Serif" 14.;
#P comment 343 504 364 196622 matrixmode + translate;
#P window setfont "Sans Serif" 9.;
#N vpatcher 30 89 630 489;
#P window setfont "Sans Serif" 9.;
#P message 218 76 123 196617 glmatrixmode modelview;
#P newex 134 123 118 196617 pack gltranslate 0. 0. 0.;
#P newex 50 50 179 196617 t b b b;
#P newex 134 151 221 196617 jit.gl.sketch v001 @automatic 0 @immediate 1;
#P inlet 50 30 15 0;
#P inlet 170 103 15 0;
#P inlet 206 103 15 0;
#P inlet 242 103 15 0;
#P outlet 50 154 15 0;
#P connect 4 0 6 0;
#P connect 6 0 0 0;
#P connect 6 1 7 0;
#P connect 7 0 5 0;
#P fasten 8 0 5 0 223 96 271 96 271 144 139 144;
#P connect 3 0 7 1;
#P connect 2 0 7 2;
#P connect 6 2 8 0;
#P connect 1 0 7 3;
#P pop;
#P newobj 268 498 59 196617 p translate;
#P flonum 358 473 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 321 473 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 285 473 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P window setfont "Sans Serif" 14.;
#P comment 343 424 632 196622 matrixmode + rotate (XYZ , one for each axis , could do one angle/axis pair , if preferred);
#P window setfont "Sans Serif" 9.;
#N vpatcher 30 89 689 495;
#P window setfont "Sans Serif" 9.;
#P newex 134 183 117 196617 pack glrotate 0. 1. 0. 0.;
#P inlet 160 127 15 0;
#P newex 295 180 117 196617 pack glrotate 0. 0. 1. 0.;
#P inlet 321 124 15 0;
#P message 386 79 123 196617 glmatrixmode modelview;
#P newex 451 179 117 196617 pack glrotate 0. 0. 0. 1.;
#P newex 50 50 347 196617 t b b b b b;
#P newex 134 243 221 196617 jit.gl.sketch v001 @automatic 0 @immediate 1;
#P inlet 50 30 15 0;
#P inlet 477 123 15 0;
#P outlet 50 154 15 0;
#P connect 2 0 4 0;
#P connect 4 0 0 0;
#P connect 4 3 10 0;
#P connect 10 0 3 0;
#P fasten 6 0 3 0 391 103 628 103 628 197;
#P connect 5 0 3 0;
#P connect 8 0 3 0;
#P connect 9 0 10 1;
#P connect 4 2 8 0;
#P connect 7 0 8 1;
#P connect 4 4 6 0;
#P connect 4 1 5 0;
#P connect 1 0 5 1;
#P pop;
#P newobj 268 421 63 196617 p rotatexyz;
#P flonum 358 396 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 321 396 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 285 396 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P window setfont "Sans Serif" 14.;
#P comment 343 611 364 196622 drawraw!!!;
#P comment 343 317 364 196622 matrixmode + translate;
#P window setfont "Sans Serif" 9.;
#N vpatcher 30 89 630 489;
#P window setfont "Sans Serif" 9.;
#P newex 66 88 66 196617 t b drawraw;
#P newex 122 147 238 196617 jit.gl.gridshape v001 @automatic 0 @shape sphere;
#P outlet 66 221 15 0;
#P inlet 66 55 15 0;
#P connect 0 0 3 0;
#P connect 3 0 1 0;
#P connect 3 1 2 0;
#P pop;
#P newobj 268 611 48 196617 p shpere;
#N vpatcher 30 89 630 489;
#P window setfont "Sans Serif" 9.;
#P message 218 76 123 196617 glmatrixmode modelview;
#P newex 134 123 118 196617 pack gltranslate 0. 0. 0.;
#P newex 50 50 179 196617 t b b b;
#P newex 134 151 221 196617 jit.gl.sketch v001 @automatic 0 @immediate 1;
#P inlet 50 30 15 0;
#P inlet 170 103 15 0;
#P inlet 206 103 15 0;
#P inlet 242 103 15 0;
#P outlet 50 154 15 0;
#P connect 4 0 6 0;
#P connect 6 0 0 0;
#P connect 6 1 7 0;
#P fasten 8 0 5 0 223 96 271 96 271 144 139 144;
#P connect 7 0 5 0;
#P connect 3 0 7 1;
#P connect 2 0 7 2;
#P connect 6 2 8 0;
#P connect 1 0 7 3;
#P pop;
#P newobj 268 311 59 196617 p translate;
#P flonum 358 286 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 321 286 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 285 286 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#N vpatcher 30 89 630 489;
#P window setfont "Sans Serif" 9.;
#P window linecount 0;
#P message 15 187 184 196617 glmatrixmode modelview , glpopmatrix;
#P newex 40 125 40 196617 t b b b;
#P window linecount 1;
#P message 205 187 189 196617 glmatrixmode modelview , glpushmatrix;
#P newex 147 247 221 196617 jit.gl.sketch v001 @automatic 0 @immediate 1;
#P outlet 55 271 15 0;
#P inlet 40 98 15 0;
#P connect 4 0 5 0;
#P connect 0 0 4 0;
#P connect 4 1 1 0;
#P connect 5 0 2 0;
#P connect 3 0 2 0;
#P connect 4 2 3 0;
#P pop;
#P newobj 268 258 32 196617 p top;
#P newex 267 661 157 196617 jit.window v001 @depthbuffer 1;
#P user jit.fpsgui 67 337 60 196617 0;
#P toggle 72 58 15 0;
#P newex 72 84 51 196617 qmetro 2;
#P newex 72 122 58 196617 t b b erase;
#P newex 68 298 179 196617 jit.gl.render v001 @lighting_enable 1;
#P window setfont "Sans Serif" 14.;
#P comment 343 259 570 196622 matrixmode + push + pop on completion!!!;
#P window linecount 3;
#P comment 180 57 635 196622 – use modelview matrix for modelview transforms ; – push/pop matrix before/after bang chain ; – to draw objects , need to use "drawraw" message , otherwise other state is reset;
#P connect 37 0 26 0;
#P connect 37 0 27 0;
#P connect 37 0 28 0;
#P connect 38 0 21 0;
#P connect 38 0 22 0;
#P connect 38 0 23 0;
#P connect 34 0 33 1;
#P connect 18 0 19 3;
#P connect 23 0 24 3;
#P fasten 32 2 33 0 816 244 798 310 324 352;
#P connect 11 0 12 3;
#P connect 28 0 29 3;
#P connect 17 0 19 2;
#P connect 35 1 32 0;
#P connect 3 1 35 1;
#P connect 22 0 24 2;
#P connect 10 0 12 2;
#P connect 27 0 29 2;
#P connect 16 0 19 1;
#P connect 33 0 16 0;
#P connect 21 0 24 1;
#P connect 9 0 12 1;
#P connect 26 0 29 1;
#P connect 29 0 13 0;
#P connect 24 0 29 0;
#P connect 19 0 24 0;
#P connect 12 0 19 0;
#P connect 8 0 12 0;
#P connect 35 0 8 0;
#P connect 32 0 8 0;
#P connect 4 0 3 0;
#P connect 5 0 4 0;
#P connect 3 0 2 0;
#P connect 3 2 2 0;
#P connect 2 0 6 0;
#P window clipboard copycount 39;


July 31, 2012 | 11:50 am

How do you inject anything like color or a texture into the gl in this example? I’ve tried

glmatrixmode modelview, glpushmatrix, glloadidentity, gltranslate 0 0 -4, glenable texture, glbindtexture texturename,
and then…
glmatrixmode modelview, glpopmatrix

in the top subpatch but on the first bang of the uzi I get "jit.gl.texture: error enabling transform: GL Error: Stack overflow". Strangely the error only occurs once for each rendered item and the texture does get applied.

Garrett


Viewing 6 posts - 1 through 6 (of 6 total)