jit.gl.multiple – aligning to camera

Nov 19, 2008 at 7:34pm

jit.gl.multiple – aligning to camera

Dear all,

I’ve been doing a fair amount of work with jit.gl.multiple, and finding it fantastically useful. However, one thing I’d like to be able to achieve has got me stumped.

I have a matrix representing points in 3d space. I’m drawing these points with a jit.gl.multiple, and panning around the scene with my camera. What I’d like to do is get all the shapes drawn by the jit.gl.multiple to align with the camera. I’m basically drawing simple quads with a bitmap texture on them, and always want this texture pointing at the camera. I know of the viewalign property, but turning it on doesn’t seem to do any good. Does anyone have any suggestions?

Thanks,

Tom

#40933
Nov 19, 2008 at 8:17pm

I think you are looking for ‘billboarding’. I haven’t got a shader that
does this, but I’m sure that you will find lots of examples googling it.
pelado

http://www.pelado.co.uk

I have a matrix representing points in 3d space. I’m drawing these points
> with a jit.gl.multiple, and panning around the scene with my camera. What
> I’d like to do is get all the shapes drawn by the jit.gl.multiple to align
> with the camera. I’m basically drawing simple quads with a bitmap texture on
> them, and always want this texture pointing at the camera. I know of the
> viewalign property, but turning it on doesn’t seem to do any good. Does
> anyone have any suggestions?
>

#145298
Nov 20, 2008 at 6:19am

Hi Tom,

Here’s a patch that perpetually orients all elements of gl.multiple to face the camera – this requires a 3D cartesian to polar conversion. Look inside the [p to_multiple] subpatch to see how it’s done. Hope it helps.

best,
Zachary

max v2;
#N vpatcher 815 51 1253 576;
#P origin 12 -14;
#P window setfont “Sans Serif” 9.;
#P flonum 360 169 35 9 0. 1. 3 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 324 169 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 288 169 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P window linecount 1;
#P newex 259 194 97 196617 pak lookat 0. 0. 1.;
#P flonum 250 169 35 9 0. 1. 3 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 214 169 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 178 169 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 149 194 97 196617 pak camera 0. 0. 1.;
#P comment 64 148 300 196617 use z.glNav2 abstraction to move/look around , or do it manually;
#N vpatcher 30 89 204 254;
#P outlet 46 103 15 0;
#P window setfont “Sans Serif” 9.;
#P message 46 75 68 196617 fullscreen $1;
#P toggle 29 75 15 0;
#P newex 71 50 35 196617 sel 27;
#P newex 29 50 40 196617 key;
#P fasten 1 0 2 0 76 72 34 72;
#P fasten 2 0 3 0 45 90 45 75;
#P connect 3 0 4 0;
#P fasten 0 0 1 0 70 67 70 52;
#P pop;
#P newobj 183 264 52 196617 p fscreen;
#B color 12;
#P comment 116 240 223 196617 < -- send camera coords to 3Dcartopol subpatch;
#P newex 57 238 57 196617 s fromNav;
#P message 170 398 70 196617 rad_minor $1;
#P flonum 170 372 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P comment 208 372 55 196617 for torus;
#P comment 112 473 57 196617 look inside;
#N vpatcher 743 275 1324 876;
#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P comment 121 556 75 196617 < -- look inside;
#N vpatcher 706 334 1015 493;
#P window setfont “Sans Serif” 9.;
#P hidden newex 216 19 77 196617 loadmess set 1;
#P outlet 125 114 15 0;
#P toggle 216 51 15 0;
#P window linecount 1;
#P message 216 75 47 196617 right $1;
#P toggle 169 51 15 0;
#P message 169 75 41 196617 left $1;
#P toggle 95 51 15 0;
#P message 95 75 68 196617 backward $1;
#P toggle 27 51 15 0;
#P window linecount 0;
#P message 27 75 62 196617 forward $1;
#P comment 12 29 272 196617 turn keyboard navigation control on/off (all on by default);
#P hidden connect 10 0 2 0;
#P connect 2 0 1 0;
#P hidden connect 10 0 4 0;
#P connect 4 0 3 0;
#P fasten 1 0 9 0 32 102 130 102;
#P fasten 3 0 9 0 100 102 130 102;
#P fasten 5 0 9 0 174 102 130 102;
#P fasten 7 0 9 0 221 102 130 102;
#P hidden connect 10 0 6 0;
#P connect 6 0 5 0;
#P hidden connect 10 0 8 0;
#P connect 8 0 7 0;
#P pop;
#P newobj 51 554 67 196617 p keyControl;
#B color 13;
#P comment 153 524 268 196617 NOTE: THIS WORKS REGARDLESS OF CONSTRAIN_LOOKAT;
#P message 50 530 87 196617 lookat_anglev $1;
#P flonum 50 507 35 9 0. 172. 3 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P comment 89 508 299 196617 change vertical lookat angle (min 0. , max 172. – default 172.);
#P outlet 9 564 15 0;
#P comment 153 487 251 196617 NOTE: only applicable when constrain_lookat on;
#P comment 153 431 251 196617 NOTE: only applicable when constrain_lookat on;
#P message 50 486 87 196617 lookat_center $1;
#P flonum 50 458 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P window linecount 2;
#P comment 88 459 378 196617 change center of lookat rotation (0.=along negative z axis / 90.=along positive x axis / 180.=along positive z axis / 270.=along negative x axis / etc. – default 0.);
#P window linecount 1;
#P message 50 437 86 196617 lookat_angleh $1;
#P flonum 50 414 35 9 0. 360. 3 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P comment 89 415 299 196617 change horizontal lookat angle (min 0. , max 360. – default 360.);
#P comment 69 370 255 196617 turn horizontal lookat constraining on/off (default off);
#P toggle 50 369 15 0;
#P message 50 392 100 196617 constrain_lookat $1;
#P message 50 347 85 196617 roll_strength $1;
#P flonum 50 324 35 9 0. 1. 3 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P comment 89 326 323 196617 amount of roll as you turn (0. = min roll , 1 = max roll – default 0.85);
#P comment 69 280 134 196617 turn roll on/off (default 0);
#P toggle 50 279 15 0;
#P message 50 302 41 196617 roll $1;
#P message 50 214 78 196617 lens_angle1 $1;
#P flonum 50 191 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P comment 88 192 184 196617 change normal lens_angle (default 45.);
#P message 50 258 78 196617 lens_angle2 $1;
#P flonum 50 235 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P comment 89 236 176 196617 change zoom lens_angle (default 10.);
#P message 50 78 53 196617 easing $1;
#P flonum 50 55 35 9 0. 1. 3 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P comment 88 56 343 196617 change easing behavior (1 = no easing , 0.01 = lots of easing – default 0.1);
#P message 50 34 50 196617 speed $1;
#P flonum 131 145 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 93 145 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 50 145 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 50 168 91 196617 pak lookat 0. 0. 0.;
#P comment 170 146 322 196617 manually set lookat coords (as list of x y z values – default 0. 0. 0.);
#P flonum 130 99 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 92 99 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 50 99 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 50 122 100 196617 pak camera 0. 0. 2.;
#P flonum 50 11 35 9 0. 0 1 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P comment 89 12 267 196617 camera speed in world units/second (default 1 unit/sec);
#P comment 168 100 323 196617 manually set camera coords (as list of x y z values – default 0. 0. 2.);
#P window linecount 6;
#P comment 287 166 273 196617 NOTE ; the lookat point changes when you toggle navigation on ; when manually adjusting camera , you should also adjust ; lookat for best results (and vice versa) ; this feature becomes increasingly innacurate as ; lookat_angleh decreases from 360 (hope to fix soon).;
#P connect 43 0 40 0;
#P lcolor 11;
#P connect 37 0 40 0;
#P lcolor 11;
#P connect 34 0 40 0;
#P lcolor 11;
#P connect 29 0 40 0;
#P lcolor 11;
#P connect 28 0 40 0;
#P lcolor 11;
#P connect 23 0 40 0;
#P lcolor 11;
#P connect 19 0 40 0;
#P lcolor 11;
#P connect 22 0 40 0;
#P lcolor 11;
#P connect 9 0 40 0;
#P lcolor 11;
#P connect 4 0 40 0;
#P lcolor 11;
#P connect 16 0 40 0;
#P lcolor 11;
#P connect 13 0 40 0;
#P lcolor 11;
#P connect 45 0 40 0;
#P lcolor 11;
#P connect 3 0 13 0;
#P connect 15 0 16 0;
#P connect 21 0 22 0;
#P connect 18 0 19 0;
#P connect 24 0 23 0;
#P connect 27 0 28 0;
#P connect 30 0 29 0;
#P connect 33 0 34 0;
#P connect 36 0 37 0;
#P connect 42 0 43 0;
#P fasten 10 0 9 1 55 164 82 164;
#P fasten 5 0 4 1 55 118 85 118;
#P fasten 11 0 9 2 98 164 109 164;
#P fasten 6 0 4 2 97 118 115 118;
#P fasten 12 0 9 3 136 164 136 164;
#P fasten 7 0 4 3 68 120 136 120;
#P pop;
#P newobj 30 169 113 196617 p messages_to_glNav2;
#B color 14;
#P number 110 372 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P message 110 398 56 196617 dim $1 $1;
#P newex 33 398 71 196617 prepend shape;
#P user ubumenu 33 372 72 196617 0 1 1 0;
#X add sphere;
#X add torus;
#X add cylinder;
#X add opencylinder;
#X add cube;
#X add opencube;
#X add plane;
#X add circle;
#X prefix_set 0 0 0;
#P newex 39 109 71 196617 s fromRender;
#P user jit.fpsgui 15 329 60 196617 0;
#P newex 30 194 91 196617 z.glNav2 source 1;
#B color 12;
#P comment 26 488 93 196617 (for matrixoutput);
#N vpatcher 216 223 1195 699;
#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P newex 698 57 48 196617 loadbang;
#P newex 751 84 70 196617 prepend basis;
#P user ubumenu 752 58 111 196617 0 1 1 0;
#X add distance.euclidean;
#X add distance.euclidean.squared;
#X add distance.manhattan;
#X add distance.manhattan.radial;
#X add distance.chebychev;
#X add distance.minkovsky;
#X add filter.bessel;
#X add filter.box;
#X add filter.catmullrom;
#X add filter.disk;
#X add filter.gaussian;
#X add filter.lanczossinc;
#X add filter.mitchell;
#X add filter.sinc;
#X add filter.triangle;
#X add transfer.step;
#X add transfer.smoothstep;
#X add transfer.bias;
#X add transfer.cubic;
#X add transfer.saw;
#X add transfer.quintic;
#X add transfer.gain;
#X add transfer.pulse;
#X add transfer.smoothpulse;
#X add transfer.sine;
#X add transfer.linear;
#X add transfer.solarize;
#X add noise.cell;
#X add noise.checker;
#X add noise.distorted;
#X add noise.gradient;
#X add noise.simplex;
#X add noise.voronoi;
#X add noise.value.cubicspline;
#X add noise.value.convolution;
#X add noise.sparse.convolution;
#X add fractal.mono;
#X add fractal.hetero;
#X add fractal.multi;
#X add fractal.multi.hybrid;
#X add fractal.multi.ridged;
#X add fractal.turbulence;
#X prefix_set 0 0
0;
#X pattrmode 1;
#P button 698 82 15 0;
#P newex 698 135 65 196617 jit.normalize;
#P newex 698 110 243 196617 jit.bfg 3 float32 256 256 @basis fractal.turbulence;
#B color 5;
#P newex 698 161 154 196617 jit.gl.texture source @name tex;
#P window linecount 0;
#N vpatcher 30 89 319 372;
#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P newex 138 103 76 196617 unpack 0. 0. 1.;
#P newex 138 78 70 196617 route camera;
#P newex 48 204 53 196617 jit.pack 3;
#P newex 90 178 100 196617 jit.op @op – @val 1.;
#P newex 48 103 74 196617 jit.unpack 3;
#P newex 69 155 100 196617 jit.op @op – @val 0.;
#P newex 48 133 100 196617 jit.op @op – @val 0.;
#P newex 138 55 57 196617 r fromNav;
#P inlet 48 71 15 0;
#P outlet 48 235 15 0;
#P window linecount 0;
#P comment 25 34 204 196617 subtract camera coord from multiple coord;
#P connect 2 0 6 0;
#P connect 6 0 4 0;
#P connect 4 0 8 0;
#P connect 8 0 1 0;
#P connect 6 1 5 0;
#P connect 5 0 8 1;
#P connect 6 2 7 0;
#P connect 7 0 8 2;
#P connect 3 0 9 0;
#P connect 9 0 10 0;
#P connect 10 0 4 1;
#P connect 10 1 5 1;
#P connect 10 2 7 1;
#P pop;
#P newobj 683 248 125 196617 p multiple_minus_camera;
#B color 12;
#P window linecount 2;
#P comment 711 330 153 196617 Here’s a 2nd way to do it (same result , slightly different math);
#P window linecount 1;
#P newex 714 386 209 196617 jit.matrix 3 float32 20 20 @planemap 1 0 2;
#N vpatcher 534 502 838 679;
#P origin -712 -216;
#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#N vpatcher 30 89 508 542;
#P window setfont “Sans Serif” 10.;
#P window linecount 2;
#P comment 46 104 274 196618 angle is expresssed in pi-radians like cartopol object: 0 to pi and 0 to -pi;
#P window linecount 1;
#P comment 30 149 154 196618 -distance (vector magnitude);
#P comment 30 133 212 196618 -elevation (rotation relative to xz plane);
#P comment 30 88 244 196618 -azimuth (y-axis rotation);
#P window setfont “Sans Serif” 14.;
#P comment 30 36 383 196622 3D CARTESIAN TO POLAR CONVERSION WITH MATRICES;
#P window setfont “Sans Serif” 9.;
#P newex 65 338 55 196617 jit.matrix;
#P newex 65 306 27 196617 t b l;
#N comlet (3p matrix) as , el , dist;
#P outlet 65 393 15 0;
#N comlet (3p matrix) x , y , z;
#P inlet 65 181 15 0;
#P window setfont “Sans Serif” 12.;
#P comment 30 58 277 196620 (jit.cartopol modified from cv.jit.cartopol);
#P window setfont “Sans Serif” 9.;
#P newex 65 211 251 196617 jit.unpack 3;
#P newex 65 364 170 196617 jit.pack 3;
#N vpatcher 60 263 482 583;
#P window setfont “Sans Serif” 9.;
#P newex 197 218 88 196617 jit.op @op *;
#P newex 275 186 93 196617 jit.op @op – @val 1.;
#P newex 275 160 94 196617 jit.op @op * @val 2.;
#P newex 275 133 100 196617 jit.op @op >= @val 0.;
#P comment 217 248 53 196617 phase;
#P newex 197 186 75 196617 jit.op @op acos;
#P newex 197 133 65 196617 jit.op @op !/;
#P newex 108 133 64 196617 jit.op @op *;
#P newex 40 186 75 196617 jit.op @op sqrt;
#P newex 40 160 78 196617 jit.op @op +;
#P newex 40 133 64 196617 jit.op @op *;
#N comlet (matrix) phase;
#P outlet 197 248 15 0;
#N comlet (matrix) amplitude;
#P outlet 40 248 15 0;
#N comlet (matrix) imaginary/y input;
#P inlet 108 54 15 0;
#N comlet (matrix) real/x input;
#P inlet 40 54 15 0;
#P comment 58 248 53 196617 amplitude;
#P connect 1 0 5 0;
#P connect 5 0 6 0;
#P connect 6 0 7 0;
#P connect 7 0 3 0;
#P fasten 1 0 5 1 45 125 99 125;
#P connect 2 0 8 0;
#P connect 8 0 6 1;
#P fasten 2 0 8 1 113 126 167 126;
#P fasten 7 0 9 0 45 215 184 215 184 125 202 125;
#P connect 9 0 10 0;
#P connect 10 0 15 0;
#P connect 15 0 4 0;
#P fasten 1 0 9 1 45 101 257 101;
#P fasten 2 0 12 0 113 84 280 84;
#P connect 12 0 13 0;
#P connect 13 0 14 0;
#P connect 14 0 15 1;
#P pop;
#P newobj 65 281 90 196617 p jit.cartopol;
#B color 12;
#N vpatcher 60 263 482 583;
#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P newex 197 218 88 196617 jit.op @op *;
#P newex 275 186 93 196617 jit.op @op – @val 1.;
#P newex 275 160 94 196617 jit.op @op * @val 2.;
#P newex 275 133 100 196617 jit.op @op >= @val 0.;
#P comment 217 248 53 196617 phase;
#P newex 197 186 75 196617 jit.op @op acos;
#P newex 197 133 65 196617 jit.op @op !/;
#P newex 108 133 64 196617 jit.op @op *;
#P newex 40 186 75 196617 jit.op @op sqrt;
#P newex 40 160 78 196617 jit.op @op +;
#P newex 40 133 64 196617 jit.op @op *;
#N comlet (matrix) phase;
#P outlet 197 248 15 0;
#N comlet (matrix) amplitude;
#P outlet 40 248 15 0;
#N comlet (matrix) imaginary/y input;
#P inlet 108 54 15 0;
#N comlet (matrix) real/x input;
#P inlet 40 54 15 0;
#P window linecount 0;
#P comment 58 248 53 196617 amplitude;
#P connect 1 0 5 0;
#P connect 5 0 6 0;
#P connect 6 0 7 0;
#P connect 7 0 3 0;
#P fasten 1 0 5 1 45 125 99 125;
#P connect 2 0 8 0;
#P connect 8 0 6 1;
#P fasten 2 0 8 1 113 126 167 126;
#P fasten 7 0 9 0 45 215 184 215 184 125 202 125;
#P connect 9 0 10 0;
#P connect 10 0 15 0;
#P connect 15 0 4 0;
#P fasten 2 0 9 1 113 90 257 90;
#P fasten 1 0 12 0 45 96 280 96;
#P connect 12 0 13 0;
#P connect 13 0 14 0;
#P connect 14 0 15 1;
#P pop;
#P newobj 65 253 69 196617 p jit.cartopol;
#B color 12;
#P connect 5 0 3 0;
#P connect 3 0 0 0;
#P connect 0 0 1 0;
#P connect 1 0 7 0;
#P connect 0 1 8 0;
#P connect 7 0 8 0;
#P connect 8 0 2 0;
#P connect 2 0 6 0;
#P fasten 3 2 0 1 230 240 129 240;
#P lcolor 13;
#P connect 3 1 1 1;
#P connect 1 1 2 1;
#P fasten 7 1 2 2 87 329 230 329;
#P pop;
#P newobj 43 56 89 196617 p z.jit.3Dcartopol;
#P window linecount 2;
#P newex 43 83 219 196617 jit.expr @expr “(in[0].p[0] / PI) * 180.” “(in[0].p[1] / PI) * -180.” “(in[0].p[2] * 0.)”;
#N comlet (3p matrix) as , el , dist;
#P outlet 43 124 15 0;
#N comlet 3p matrix in;
#P inlet 43 28 15 0;
#P connect 0 0 3 0;
#P connect 3 0 2 0;
#P connect 2 0 1 0;
#P pop;
#P newobj 714 358 85 196617 p 3Dcartopol_v2;
#B color 12;
#N vpatcher 724 258 1125 695;
#P window setfont “Sans Serif” 9.;
#P newex 17 353 114 196617 jit.op @op * @val 180.;
#P newex 17 325 137 196617 jit.op @op / @val 3.141593;
#P newex 17 58 53 196617 t l l;
#P newex 191 119 27 196617 t b l;
#P newex 17 91 169 196617 jit.unpack 3;
#P inlet 17 30 15 0;
#P outlet 17 383 15 0;
#P newex 17 296 53 196617 jit.pack 3;
#P newex 17 185 77 196617 jit.op @op sqrt;
#P newex 17 159 79 196617 jit.op @op +;
#P newex 86 131 65 196617 jit.op @op *;
#P newex 17 131 65 196617 jit.op @op *;
#P newex 17 249 142 196617 jit.op @op – @val 1.570796;
#P newex 17 220 83 196617 jit.op @op atan2;
#P newex 191 206 142 196617 jit.op @op – @val 1.570796;
#P newex 191 91 127 196617 jit.unpack 3;
#P newex 264 147 107 196617 jit.op @op * @val -1.;
#P newex 191 177 83 196617 jit.op @op atan2;
#P connect 12 0 15 0;
#P connect 15 0 13 0;
#P connect 13 0 6 0;
#P connect 6 0 8 0;
#P connect 8 0 9 0;
#P connect 9 0 4 0;
#P connect 4 0 5 0;
#P connect 5 0 10 0;
#P connect 10 0 16 0;
#P connect 16 0 17 0;
#P connect 17 0 11 0;
#P fasten 3 0 10 1 196 281 43 281;
#P connect 13 0 6 1;
#P connect 13 2 7 0;
#P connect 7 0 8 1;
#P connect 13 1 4 1;
#P connect 13 2 7 1;
#P fasten 15 1 2 0 65 83 196 83;
#P connect 2 0 14 0;
#P connect 14 0 0 0;
#P connect 2 2 0 0;
#P connect 0 0 3 0;
#P fasten 14 1 1 0 213 141 269 141;
#P connect 1 0 0 1;
#P pop;
#P newobj 683 275 67 196617 p 3Dcartopol;
#B color 12;
#P newex 407 274 27 196617 t l l;
#P newex 424 299 87 196617 jit.matrix prerot;
#P newex 683 223 87 196617 jit.matrix prerot;
#P message 315 364 70 196617 rad_minor $1;
#P flonum 315 337 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 240 364 71 196617 prepend shape;
#P user ubumenu 240 338 72 196617 0 1 1 0;
#X add sphere;
#X add torus;
#X add cylinder;
#X add opencylinder;
#X add cube;
#X add opencube;
#X add plane;
#X add circle;
#X prefix_set 0 0
0;
#P comment 314 323 51 196617 for torus;
#P flonum 136 286 35 9 0. 0 1 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 99 286 35 9 0. 0 1 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 62 286 35 9 0. 0 1 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 29 310 109 196617 pak rotatexyz 0. 0. 0.;
#P flonum 558 319 35 9 0. 0 1 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 595 349 35 9 0. 0 1 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 558 349 35 9 0. 0 1 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 521 349 35 9 0. 0 1 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 496 373 104 196617 pak scale 1. 1. 1.;
#P newex 683 300 54 196617 jit.change;
#P window linecount 3;
#P newex 12 398 324 196617 jit.gl.gridshape source @shape plane @dim 10 10 @name plan @scale 0.02 0.02 0.02 @lighting_enable 1 @automatic 0 @color 1 1 1 1 @blend_enable 1 @blend_mode 6 1 @automatic 0 @texture tex;
#P toggle 158 229 15 0;
#P window linecount 1;
#P message 158 251 92 196617 lighting_enable $1;
#P newex 407 84 53 196617 jit.pack 3;
#P newex 407 56 267 196617 jit.unpack 12;
#P flonum 202 338 35 9 0. 1. 3 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 165 338 35 9 0. 1. 3 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 128 338 35 9 0. 1. 3 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 91 338 35 9 0. 1. 3 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 61 362 131 196617 pak color 1. 1. 1. 1.;
#P number 119 229 35 9 0 9 3 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 75 229 35 9 0 9 3 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 31 250 98 196617 pak blend_mode 6 1;
#P flonum 472 205 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P message 472 225 134 196617 slide_up $1 , slide_down $1;
#P newex 407 246 196 196617 jit.slide @slide_up 100 @slide_down 100;
#P newex 407 110 53 196617 t getdim l;
#P newex 683 197 71 196617 r fromRender;
#P newex 407 143 55 196617 jit.matrix;
#P hidden newex 12 51 75 196617 loadmess 0.02;
#P user jit.fpsgui 342 56 60 196617 3;
#P newex 29 167 77 196617 vexpr 1. / $f1;
#P newex 12 144 27 196617 t l l;
#P newex 12 120 66 196617 pack 0. 0. 0.;
#P message 12 208 78 196617 scale $1 $2 $2;
#P newex 407 349 65 196617 jit.op @op *;
#P flonum 12 82 35 9 0 0 0 3 0 0 0 102 102 204 222 222 222 0 0 0;
#P window linecount 2;
#P newex 407 405 286 196617 jit.gl.multiple source 2 @targetname plan @glparams position rotatexyz @scale 1 1 1 @lighting_enable 1 @texture tex;
#P inlet 407 24 15 0;
#P flonum 499 131 50 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P window linecount 1;
#P message 499 153 39 196617 val $1;
#P newex 407 175 102 196617 jit.op @op * @val 1.;
#P comment 13 67 33 196617 scale;
#P comment 553 130 105 196617 scale position matrix;
#P window linecount 0;
#P comment 753 278 157 196617 3D cartesian to polar conversion;
#P comment 776 139 44 196617 texture;
#P hidden connect 16 0 9 0;
#P connect 9 0 12 0;
#P connect 12 0 13 0;
#P connect 13 0 11 0;
#P fasten 50 0 35 0 320 389 17 389;
#P fasten 48 0 35 0 245 389 17 389;
#P connect 11 0 35 0;
#P fasten 23 0 35 0 36 272 17 272;
#P fasten 26 0 35 0 66 389 17 389;
#P fasten 33 0 35 0 163 272 17 272;
#P fasten 42 0 35 0 34 362 17 362;
#P connect 13 1 14 0;
#P fasten 9 0 12 1 17 108 45 108;
#P connect 43 0 42 1;
#P fasten 9 0 12 2 17 108 73 108;
#P connect 24 0 23 1;
#P connect 27 0 26 1;
#P connect 44 0 42 2;
#P connect 25 0 23 2;
#P connect 28 0 26 2;
#P connect 45 0 42 3;
#P connect 29 0 26 3;
#P connect 34 0 33 0;
#P connect 30 0 26 4;
#P fasten 47 1 48 0 276 359 245 359;
#P connect 49 0 50 0;
#P fasten 7 0 15 0 412 48 347 48;
#P connect 7 0 31 0;
#P connect 31 0 32 0;
#P connect 32 0 19 0;
#P connect 19 0 17 0;
#P fasten 19 1 17 0 455 135 412 135;
#P connect 17 0 4 0;
#P connect 4 0 20 0;
#P fasten 21 0 20 0 477 241 412 241;
#P connect 20 0 53 0;
#P connect 53 0 10 0;
#P fasten 37 0 8 0 501 397 412 397;
#P connect 10 0 8 0;
#P connect 53 1 52 0;
#P connect 31 1 32 1;
#P connect 31 2 32 2;
#P fasten 14 0 10 1 34 200 467 200;
#P lcolor 12;
#P connect 22 0 21 0;
#P connect 6 0 5 0;
#P connect 5 0 4 1;
#P connect 41 0 38 0;
#P connect 38 0 37 1;
#P connect 41 0 39 0;
#P connect 39 0 37 2;
#P connect 40 0 37 3;
#P connect 41 0 40 0;
#P connect 18 0 51 0;
#P connect 51 0 58 0;
#P connect 58 0 54 0;
#P connect 54 0 36 0;
#P connect 36 0 8 1;
#P connect 65 0 62 0;
#P connect 62 0 60 0;
#P fasten 64 0 60 0 756 105 703 105;
#P connect 60 0 61 0;
#P connect 61 0 59 0;
#P connect 55 0 56 0;
#P connect 17 1 56 0;
#P fasten 63 1 64 0 807 79 756 79;
#P pop;
#P newobj 33 470 76 196617 p to_multiple;
#B color 12;
#P comment 15 21 100 196617 • start drawing;
#P number 62 38 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P toggle 15 37 15 0;
#P newex 15 59 57 196617 qmetro 16;
#P newex 15 81 58 196617 t b b erase;
#P window linecount 2;
#P newex 33 429 321 196617 jit.gl.gridshape source @shape plane @lighting_enable 0 @smooth_shading 0 @depth_enable 0 @automatic 1 @matrixoutput 1;
#B color 5;
#P newex 15 288 161 196617 jit.gl.render source @camera 0. 0. 1. @erase_color 0. 0. 0. 1.;
#P newex 183 288 159 196617 jit.window source @depthbuffer 1 @pos 10 50 @size 800 600;
#P connect 5 0 4 0;
#P connect 4 0 3 0;
#P fasten 26 0 1 0 154 222 20 222;
#P connect 3 0 1 0;
#P connect 3 2 1 0;
#P fasten 30 0 1 0 264 222 20 222;
#P fasten 10 0 1 0 35 222 20 222;
#P connect 1 0 11 0;
#P connect 17 0 10 0;
#P fasten 13 1 14 0 69 393 38 393;
#P connect 14 0 2 0;
#P fasten 15 0 2 0 115 420 38 420;
#P fasten 21 0 2 0 175 420 38 420;
#P connect 2 0 8 0;
#P connect 3 1 12 0;
#P connect 10 0 22 0;
#P connect 26 0 22 0;
#P connect 6 0 4 1;
#P connect 16 0 15 0;
#P connect 20 0 21 0;
#P connect 27 0 26 1;
#P connect 24 0 0 0;
#P connect 28 0 26 2;
#P connect 29 0 26 3;
#P connect 31 0 30 1;
#P connect 32 0 30 2;
#P connect 33 0 30 3;
#P pop;

#145299
Nov 20, 2008 at 9:34am

Thanks – this is fantastic and a far more comprehensive response than I’d hoped for! I will try it now and let you know how I get on.

#145300
Nov 20, 2008 at 10:25am

Update – I’ve tried the technique you demonstrated, and despite taking me a while to get my head around what was happening, I’ve got it working and it’s exactly what I needed. Thanks so much!

By the way, I love the shape-morphing you’ve done using jit.slide – I did something like this years ago in a fake 3d engine for director and it was clunky and inelegant – it’s great to see it done properly!

Best wishes,

Tom

(here’s a screenshot of the code working)

[img]index.php?t=getfile&id=2192&private=0[/img]

#145301

You must be logged in to reply to this topic.