## how to rotate a quad, math pls

Sep 25, 2007 at 8:42pm

# how to rotate a quad, math pls

I’m looking to rotate a mesh based quad(s). idle with a changeable center of
rotation. a patch would be lovely but the expression used or a link to
further info would help. much.
i wish i could combine mesh based rendering with glrotate…
yair

#33815
Sep 25, 2007 at 9:01pm

attachment, rotation equation taken from an opengl book

On 9/25/07, yair reshef wrote:
>
> I’m looking to rotate a mesh based quad(s). idle with a changeable center
> of rotation. a patch would be lovely but the expression used or a link to
> further info would help. much.
> i wish i could combine mesh based rendering with glrotate…
> yair
>

#113138
Sep 25, 2007 at 9:29pm

Hello,
Here are some jit.expr objects that will do x, y, z rotations with an
anchor at 0. I had this lying around, so I can’t tell you what is what.

#P window setfont “Sans Serif” 9.;
#P window linecount 2;
#P newex 188 205 310 196617 jit.expr @expr in[0]
“in[0].p[1]*cos(in[1])-in[0].p[2]*sin(in[1])”
“in[0].p[2]*cos(in[1])+in[0].p[1]*sin(in[1])” in[0] in[0];
#P newex 188 170 290 196617 jit.expr @expr
“in[0].p[0]*cos(in[1])+in[0].p[2]*sin(in[1])” in[0]
“in[0].p[2]*cos(in[1])-in[0].p[0]*sin(in[1])” in[0] in[0];
#P newex 188 134 297 196617 jit.expr @expr “in[0].p[0]*cos(in[1]) –
in[0].p[1]*sin(in[1])” “in[0].p[1]*cos(in[1]) + in[0].p[0]*sin(in[1])”
in[0] in[0] in[0];
#P connect 1 0 2 0;
#P connect 0 0 1 0;
#P window clipboard copycount 3;

I don’t have the time to work it out right now, but you could probably
use a vertex shader to rotate the geometry in a much more efficient way
by passing in vertex attributes or by using one of the jit.gl.mesh
inputs for the rotation amount for each quad and doing the matrix
transformation in the vertex program. See the recent thread called
on using vertex attributes in a shader.

Best,
Andrew B.

yair reshef wrote:
> attachment, rotation equation taken from an opengl book
>
> On 9/25/07, *yair reshef* >
> wrote:
>
> I’m looking to rotate a mesh based quad(s). idle with a changeable
> center of rotation. a patch would be lovely but the expression used
> or a link to further info would help. much.
> i wish i could combine mesh based rendering with glrotate…
> yair
>
>
>
> ————————————————————————
>
>
> ————————————————————————
>

#113139
Sep 26, 2007 at 12:55am

On that note, I checked in the 1.6 docs, and did not see anything

Also, this is one thing that GEM does quite quite well, using nested
translation and rotation objects to geometry for transforms. 2.0 PLZ?
K THNX BAI!
:)

On Sep 25, 2007, at 5:29 PM, andrew benson wrote:

> Hello,
> Here are some jit.expr objects that will do x, y, z rotations with
> an anchor at 0. I had this lying around, so I can’t tell you what
> is what.
>
> #P window setfont “Sans Serif” 9.;
> #P window linecount 2;
> #P newex 188 205 310 196617 jit.expr @expr in[0] “in[0].p[1]*cos(in
> [1])-in[0].p[2]*sin(in[1])” “in[0].p[2]*cos(in[1])+in[0].p[1]*sin(in
> [1])” in[0] in[0];
> #P newex 188 170 290 196617 jit.expr @expr “in[0].p[0]*cos(in[1])+in
> [0].p[2]*sin(in[1])” in[0] “in[0].p[2]*cos(in[1])-in[0].p[0]*sin(in
> [1])” in[0] in[0];
> #P newex 188 134 297 196617 jit.expr @expr “in[0].p[0]*cos(in[1]) –
> in[0].p[1]*sin(in[1])” “in[0].p[1]*cos(in[1]) + in[0].p[0]*sin(in
> [1])” in[0] in[0] in[0];
> #P connect 1 0 2 0;
> #P connect 0 0 1 0;
> #P window clipboard copycount 3;
>
> I don’t have the time to work it out right now, but you could
> probably use a vertex shader to rotate the geometry in a much more
> efficient way by passing in vertex attributes or by using one of
> the jit.gl.mesh inputs for the rotation amount for each quad and
> doing the matrix transformation in the vertex program. See the
> recent thread called “Setting GLSL attribute variables per vertex
>
> Best,
> Andrew B.
>
>
>
> yair reshef wrote:
>> attachment, rotation equation taken from an opengl book
>> On 9/25/07, *yair reshef* >> > wrote:
>> I’m looking to rotate a mesh based quad(s). idle with a
>> changeable
>> center of rotation. a patch would be lovely but the expression
>> used
>> or a link to further info would help. much.
>> i wish i could combine mesh based rendering with glrotate…
>> yair
>> ———————————————————————
>> —
>> ———————————————————————
>> —

v a d e //

#113140
Sep 26, 2007 at 8:12am

thanks Andraw. i have no problem as of yet with mesh vertex performances.
works great. included is a patch implemnting your math for the internet to
store.

>
> On that note, I checked in the 1.6 docs, and did not see anything about
> vertex attributes.
> Also, this is one thing that GEM does quite quite well, using nested
> translation and rotation objects to geometry for transforms. 2.0 PLZ?
> K THNX BAI!
> :)
>
> On Sep 25, 2007, at 5:29 PM, andrew benson wrote:
>
> Hello,
> Here are some jit.expr objects that will do x, y, z rotations with an
> anchor at 0. I had this lying around, so I can’t tell you what is what.
>
> #P window setfont “Sans Serif” 9.;
> #P window linecount 2;
> #P newex 188 205 310 196617 jit.expr @expr in[0]
> “in[0].p[1]*cos(in[1])-in[0].p[2]*sin(in[1])”
> “in[0].p[2]*cos(in[1])+in[0].p[1]*sin(in[1])” in[0] in[0];
> #P newex 188 170 290 196617 jit.expr @expr
> “in[0].p[0]*cos(in[1])+in[0].p[2]*sin(in[1])” in[0]
> “in[0].p[2]*cos(in[1])-in[0].p[0]*sin(in[1])” in[0] in[0];
> #P newex 188 134 297 196617 jit.expr @expr “in[0].p[0]*cos(in[1]) -
> in[0].p[1]*sin(in[1])” “in[0].p[1]*cos(in[1]) + in[0].p[0]*sin(in[1])” in[0]
> in[0] in[0];
> #P connect 1 0 2 0;
> #P connect 0 0 1 0;
> #P window clipboard copycount 3;
>
> I don’t have the time to work it out right now, but you could probably use
> a vertex shader to rotate the geometry in a much more efficient way by
> passing in vertex attributes or by using one of the jit.gl.mesh inputs for
> the rotation amount for each quad and doing the matrix transformation in the
> vertex program. See the recent thread called “Setting GLSL attribute
> variables per vertex with Jitter” for more info on using vertex attributes
>
> Best,
> Andrew B.
>
>
>
> yair reshef wrote:
>
> attachment, rotation equation taken from an opengl book
> On 9/25/07, *yair reshef* >>
> wrote:
> I’m looking to rotate a mesh based quad(s). idle with a changeable
> center of rotation. a patch would be lovely but the expression used
> or a link to further info would help. much.
> i wish i could combine mesh based rendering with glrotate…
> yair
> ————————————————————————
> ————————————————————————
>
>
>
> *v a d e //*
>
>
>
>
>
>
>

#113141
Sep 26, 2007 at 8:14am

#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P newex 210 326 56 9109513 jit.unpack 3;
#P user jit.cellblock 396 349 488 386 139 9 2 2 45 17 0 1 1 0 0 0 0 0 1 0 0
0 255 255 255 0 0 0 0 0 0 191 191 191 0 0 0 215 215 240 1 1 1 0 4 0 0 0;
#P user jit.cellblock 303 349 395 386 139 9 2 2 45 17 0 1 1 0 0 0 0 0 1 0 0
0 255 255 255 0 0 0 0 0 0 191 191 191 0 0 0 215 215 240 1 1 1 0 4 0 0 0;
#P user jit.cellblock 210 349 302 386 139 9 2 2 45 17 0 1 1 0 0 0 0 0 1 0 0
0 255 255 255 0 0 0 0 0 0 191 191 191 0 0 0 215 215 240 1 1 1 0 4 0 0 0;
#P message 433 130 29 9109513 reset;
#B color 3;
#P newex 434 150 43 9109513 t 0 reset;
#P message 97 335 29 9109513 reset;
#P newex 125 335 72 9109513 jit.gl.handle rott;
#P flonum 460 280 35 9 0 0 0 139 0 0 0 255 227 23 222 222 222 0 0 0;
#P flonum 460 241 35 9 0 0 0 139 0 0 0 255 227 23 222 222 222 0 0 0;
#P flonum 454 189 35 9 0 0 0 139 0 0 0 255 227 23 222 222 222 0 0 0;
#P newex 26 299 469 9109513 jit.expr @expr in[0]
“in[0].p[1]*cos(in[1])-in[0].p[2]*sin(in[1])”
“in[0].p[2]*cos(in[1])+in[0].p[1]*sin(in[1])” in[0] in[0];
#P newex 26 259 469 9109513 jit.expr @expr
“in[0].p[0]*cos(in[1])+in[0].p[2]*sin(in[1])” in[0]
“in[0].p[2]*cos(in[1])-in[0].p[0]*sin(in[1])” in[0] in[0];
#P newex 26 206 463 9109513 jit.expr @expr “in[0].p[0]*cos(in[1]) -
in[0].p[1]*sin(in[1])” “in[0].p[1]*cos(in[1]) + in[0].p[0]*sin(in[1])” in[0]
in[0];
#N vpatcher 15 55 281 431;
#P window setfont “Sans Serif” 9.;
#P window linecount 0;
#P newex 144 280 27 9109513 * -1.;
#P window linecount 3;
#P comment 198 315 23 9109513 min scale;
#P window linecount 1;
#P comment 82 302 58 9109513 max scale;
#P newex 41 204 27 9109513 * 1.;
#P window setfont “Sans Serif” 12.;
#P number 57 182 35 12 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P window setfont “Sans Serif” 9.;
#P newex 41 156 57 9109513 t f f;
#P newex 41 279 27 9109513 – 0.;
#P message 41 325 59 9109513 0.8284;
#B color 4;
#P message 41 304 34 9109513 set \$1;
#P newex 27 29 54 9109513 delay 1000;
#P newex 83 27 23 9109513 r fs;
#P newex 172 182 50 9109513 / 2.;
#P message 172 226 50 9109513 0.8284;
#P message 172 205 50 9109513 set \$1;
#P newex 88 211 27 9109513 / 2.;
#P message 144 324 46 9109513 -0.8284;
#B color 4;
#P message 144 303 34 9109513 set \$1;
#P newex 106 89 64 9109513 r fromRender;
#P window linecount 2;
#P comment 125 56 100 9109513 2. Calculate width and height in GL;
#P window linecount 1;
#P comment 181 140 35 9109513 height;
#P flonum 106 156 59 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 172 156 59 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P window linecount 3;
#P message 27 50 72 9109513 getdest_dim , getcamera , getlens_angle;
#P window linecount 1;
#N vpatcher 385 97 759 364;
#P outlet 131 150 15 0;
#P window setfont “Sans Serif” 9.;
#P window linecount 0;
#P newex 131 128 29 9109513 * 1.;
#P window linecount 1;
#P message 270 77 20 9109513 \$2;
#P message 248 77 20 9109513 \$1;
#P newex 248 95 32 9109513 / 1.;
#P message 102 70 20 9109513 \$3;
#P newex 50 92 184 9109513 expr \$f2*2*tan(\$f1/2*3.1415/180);
#P newex 50 50 164 9109513 route lens_angle camera dest_dim;
#P inlet 50 30 15 0;
#P outlet 166 152 15 0;
#P connect 1 0 2 0;
#P connect 2 0 3 0;
#P connect 2 1 4 0;
#P fasten 3 0 8 0 55 115 136 115;
#P connect 8 0 9 0;
#P fasten 5 0 8 1 253 118 155 118;
#P fasten 3 0 0 0 55 115 171 115;
#P fasten 4 0 3 1 107 88 229 88;
#P fasten 2 2 6 0 157 73 253 73;
#P connect 6 0 5 0;
#P fasten 2 2 7 0 157 73 275 73;
#P connect 7 0 5 1;
#P pop;
#P newobj 106 112 76 9109513 p CalcGLHeight;
#P comment 113 140 35 9109513 width;
#P newex 27 101 42 9109513 s render;
#P connect 15 0 16 0;
#P connect 16 0 3 0;
#P fasten 3 0 0 0 32 97 32 97;
#P fasten 2 0 20 0 111 137 46 137;
#P connect 20 0 22 0;
#P connect 22 0 19 0;
#P connect 19 0 17 0;
#P connect 17 0 18 0;
#P connect 21 0 22 1;
#P fasten 11 0 19 1 93 254 63 254;
#P connect 20 1 11 0;
#P connect 8 0 2 0;
#P fasten 2 0 5 0 111 135 111 135;
#P fasten 11 0 25 0 93 254 149 254;
#P connect 25 0 9 0;
#P connect 9 0 10 0;
#P fasten 2 1 4 0 177 135 177 135;
#P fasten 4 0 14 0 177 176 177 176;
#P connect 14 0 12 0;
#P connect 12 0 13 0;
#P pop;
#P newobj 142 84 44 9109513 p glwidth;
#P user jit.pwindow 261 26 162 122 0 0 0 0 1 0;
#X name rott;
#P objectname rott;
#P flonum 70 49 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P toggle 23 32 33 0;
#P newex 23 74 57 9109513 qmetro 33;
#P newex 26 362 142 9109513 jit.gl.mesh rott @poly_mode 1 1;
#P newex 23 96 53 9109513 t b b erase;
#P newex 26 175 164 9109513 jit.matrix data 3 float32 2 2 @adapt 0;
#P newex 26 152 306 9109513 jit.gl.gridshape @automatic 0 @dim 2 2
@matrixoutput 1 @shape plane;
#P newex 23 125 138 9109513 jit.gl.render rott @camera 0 0 4;
#P window linecount 2;
#P comment 134 45 100 9109513 how to roatte a mesh based quad;
#P connect 7 0 6 0;
#P connect 6 0 4 0;
#P connect 4 0 1 0;
#P fasten 4 2 1 0 70 119 28 119;
#P fasten 4 1 2 0 49 147 31 147;
#P connect 2 0 3 0;
#P connect 3 0 11 0;
#P connect 11 0 12 0;
#P connect 12 0 13 0;
#P connect 13 0 5 0;
#P fasten 17 0 5 0 130 357 31 357;
#P connect 8 0 6 1;
#P connect 18 0 17 0;
#P hidden fasten 19 1 17 0 472 175 130 175;
#P fasten 13 0 24 0 31 322 215 322;
#P connect 24 0 21 0;
#P fasten 24 1 22 0 230 346 308 346;
#P fasten 24 2 23 0 245 346 401 346;
#P connect 20 0 19 0;
#P hidden fasten 19 0 14 0 439 186 459 186;
#P hidden fasten 19 0 15 0 439 238 465 238;
#P hidden fasten 19 0 16 0 439 279 465 279;
#P connect 14 0 11 1;
#P connect 15 0 12 1;
#P connect 16 0 13 1;
#P window clipboard copycount 25;

#113142
Sep 26, 2007 at 4:45pm

On Sep 25, 2007, at 5:55 PM, vade wrote:

> On that note, I checked in the 1.6 docs, and did not see anything

Relatively experimental feature at the time of doc writing. Forum for
vertex attr info is best.

> Also, this is one thing that GEM does quite quite well, using
> nested translation and rotation objects to geometry for transforms.
> 2.0 PLZ? K THNX BAI!

These objects are just a bang chain with the gltranslate, glrotate,
glscale calls. You can easily simulate this stuff in jit.gl.sketch.
If you need a bang chain, just make a few jit.gl.sketch @immediate 1
wrappers and use @automatic 0 for the objects. It’s *really* simple
if you want to program procedural bang chains like this. It’s just
not the paradigm we’re going to focus our object set on.

-Joshua

#113143
Sep 26, 2007 at 8:19pm

Hi, Im either having a brain fart or I am misunderstanding

would you mind explaining?

#P window setfont “Sans Serif” 9.;
#P flonum 379 133 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 344 131 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P window linecount 1;
#P newex 265 180 113 196617 pak gltranslate 0. 0. 0.;
#P flonum 294 131 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 167 311 238 196617 jit.gl.gridshape v001 @automatic 0 @shape
sphere;
#P newex 232 209 221 196617 jit.gl.sketch v001 @automatic 0
@immediate 1;
#P user jit.fpsgui 17 277 60 196617 0;
#P newex 172 141 66 196617 t b b b b b;
#P toggle 17 32 15 0;
#P newex 17 58 51 196617 qmetro 2;
#P newex 17 96 58 196617 t b b erase;
#P newex 17 249 92 196617 jit.gl.render v001;
#P window linecount 2;
#P comment 432 37 341 196617 this patch does not have render to
texture enabled for simplicities sake , so just disabled the
videoplane if you wish to test your geometry effects.;
#P connect 10 0 7 0;
#P connect 5 4 7 0;
#P connect 12 0 10 3;
#P connect 11 0 10 2;
#P connect 5 0 8 0;
#P connect 9 0 10 1;
#P connect 4 0 3 0;
#P connect 3 0 2 0;
#P connect 2 0 1 0;
#P connect 2 2 1 0;
#P connect 1 0 6 0;
#P fasten 2 1 5 0 46 127 177 127;
#P window clipboard copycount 13;

is not working as I expect?

Curious,

thanks,

#113144
Sep 26, 2007 at 9:45pm

On Sep 26, 2007, at 1:19 PM, vade wrote:

> would you mind explaining?

Below is a patch that demonstrates the basics, along with a little
bit of fun. There are a few important things you were lacking:

1. specify the modelview matrix mode
2. push/pop the modelview matrix before/after bang chain
3. use the drawraw message to any objects you are drawing. otherwise
a variety of state is reset.

Also, you need to make sure you don’t dispose/recreate the window
while this stuff is happening or else you could crash. immediate mode
doesn’t seem to be 100% safe at the moment for that case. Let me know
if it still isn’t clear.

Anyway, this is basically the model GEM uses from what I understand,
and can be simulated with abstractions, without much overhead. FWIW,
in Jitter 2.0, we are definitely going to think about issues of
hierarchy, but not within this procedural bang chain model.

-Joshua

#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P newex 298 451 69 196617 loadmess 0.5;
#P newex 296 532 69 196617 loadmess 0.2;
#P window setfont “Sans Serif” 14.;
#P comment 352 169 570 196622 fun time uzi zone (switch to the uzi
for iterated multiple drawing);
#P user gswitch2 282 165 39 32 0 0;
#P window setfont “Sans Serif” 9.;
#P flonum 351 353 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 326 372 35 196617 * 36.;
#P newex 311 211 40 196617 uzi 10;
#P window setfont “Sans Serif” 14.;
#P comment 189 34 570 196622 simple jit.gl.sketch “bang chain”
example ;;
#P comment 353 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 278 579 53 196617 p scale;
#P flonum 368 554 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 331 554 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 295 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 353 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 278 498 59 196617 p translate;
#P flonum 368 473 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 331 473 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 295 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 353 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 278 421 63 196617 p rotatexyz;
#P flonum 368 396 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 331 396 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 295 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 353 611 364 196622 drawraw!!!;
#P comment 353 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 278 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 278 311 59 196617 p translate;
#P flonum 368 286 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 331 286 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 295 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 278 258 32 196617 p top;
#P newex 277 661 157 196617 jit.window v001 @depthbuffer 1;
#P user jit.fpsgui 77 337 60 196617 0;
#P toggle 82 58 15 0;
#P newex 82 84 51 196617 qmetro 2;
#P newex 82 122 58 196617 t b b erase;
#P newex 78 298 179 196617 jit.gl.render v001 @lighting_enable 1;
#P window setfont “Sans Serif” 14.;
#P comment 353 259 570 196622 matrixmode + push + pop on completion!!!;
#P window linecount 3;
#P comment 190 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 fasten 32 2 33 0 826 244 808 310 334 352;
#P connect 38 0 21 0;
#P connect 38 0 22 0;
#P connect 38 0 23 0;
#P connect 37 0 26 0;
#P connect 37 0 27 0;
#P connect 37 0 28 0;
#P connect 34 0 33 1;
#P connect 18 0 19 3;
#P connect 23 0 24 3;
#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 3 0 2 0;
#P connect 3 2 2 0;
#P connect 2 0 6 0;
#P connect 4 0 3 0;
#P connect 5 0 4 0;
#P window clipboard copycount 39;

#113145
Sep 26, 2007 at 9:48pm

p.s. jit.gl.mesh will be *oodles* faster for cases like the one Yair
was actually interested in, and AB’s solution would be recommended.
If using the geometry many times in the sort of iterative
jit.gl.gridshape case, use @displaylist 1, for performance improvements.

-Joshua

#113146
May 6, 2008 at 9:33am

revisited the formulas, added rotation origin math and visualization

#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P comment 288 430 112 9109513 visualize roatation center;
#P newex 199 415 70 9109513 vexpr \$f1* – 1.;
#P message 199 437 79 9109513 position \$1 \$2 \$3;
#P window linecount 2;
#P newex 199 456 156 9109513 jit.gl.gridshape rott @shape circle @scale 0.1
0.1 0.1 @color 1 0 0 1;
#P flonum 158 214 35 9 0 0 0 139 0 0 0 255 227 23 222 222 222 0 0 0;
#P flonum 120 214 35 9 0 0 0 139 0 0 0 255 227 23 222 222 222 0 0 0;
#P flonum 84 214 35 9 0 0 0 139 0 0 0 255 227 23 222 222 222 0 0 0;
#P window linecount 1;
#P newex 84 231 88 9109513 pak 0. 0. 0.;
#P newex 26 253 58 9109513 jit.op @op +;
#P newex 26 441 68 9109513 jit.op @op -;
#P message 495 169 29 9109513 reset;
#B color 5;
#P newex 496 189 22 9109513 t 0;
#P flonum 460 353 35 9 0 0 0 139 0 0 0 255 227 23 222 222 222 0 0 0;
#P flonum 460 313 35 9 0 0 0 139 0 0 0 255 227 23 222 222 222 0 0 0;
#P flonum 454 259 35 9 0 0 0 139 0 0 0 255 227 23 222 222 222 0 0 0;
#P newex 26 371 469 9109513 jit.expr @expr in[0]
“in[0].p[1]*cos(in[1])-in[0].p[2]*sin(in[1])”
“in[0].p[2]*cos(in[1])+in[0].p[1]*sin(in[1])” in[0] in[0];
#P newex 26 331 469 9109513 jit.expr @expr
“in[0].p[0]*cos(in[1])+in[0].p[2]*sin(in[1])” in[0]
“in[0].p[2]*cos(in[1])-in[0].p[0]*sin(in[1])” in[0] in[0];
#P newex 26 278 463 9109513 jit.expr @expr “in[0].p[0]*cos(in[1]) -
in[0].p[1]*sin(in[1])” “in[0].p[1]*cos(in[1]) + in[0].p[0]*sin(in[1])” in[0]
in[0];- Show quoted text -

#N vpatcher 15 55 281 431;
#P window setfont “Sans Serif” 9.;
#P window linecount 0;
#P newex 144 280 27 9109513 * -1.;
#P window linecount 3;
#P comment 198 315 23 9109513 min scale;
#P window linecount 1;
#P comment 82 302 58 9109513 max scale;
#P newex 41 204 27 9109513 * 1.;
#P window setfont “Sans Serif” 12.;
#P number 57 182 35 12 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P window setfont “Sans Serif” 9.;
#P newex 41 156 57 9109513 t f f;
#P newex 41 279 27 9109513 – 0.;
#P message 41 325 59 9109513 0.8284;
#B color 4;
#P message 41 304 34 9109513 set \$1;
#P newex 27 29 54 9109513 delay 1000;
#P newex 83 27 23 9109513 r fs;
#P newex 172 182 50 9109513 / 2.;
#P message 172 226 50 9109513 0.8284;
#P message 172 205 50 9109513 set \$1;
#P newex 88 211 27 9109513 / 2.;
#P message 144 324 46 9109513 -0.8284;
#B color 4;
#P message 144 303 34 9109513 set \$1;
#P newex 106 89 64 9109513 r fromRender;
#P window linecount 2;
#P comment 125 56 100 9109513 2. Calculate width and height in GL;
#P window linecount 1;
#P comment 181 140 35 9109513 height;
#P flonum 106 156 59 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 172 156 59 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P window linecount 3;
#P message 27 50 72 9109513 getdest_dim , getcamera , getlens_angle;
#P window linecount 1;
#N vpatcher 385 97 759 364;
#P outlet 131 150 15 0;
#P window setfont “Sans Serif” 9.;
#P window linecount 0;
#P newex 131 128 29 9109513 * 1.;
#P window linecount 1;
#P message 270 77 20 9109513 \$2;
#P message 248 77 20 9109513 \$1;
#P newex 248 95 32 9109513 / 1.;
#P message 102 70 20 9109513 \$3;
#P newex 50 92 184 9109513 expr \$f2*2*tan(\$f1/2*3.1415/180);
#P newex 50 50 164 9109513 route lens_angle camera dest_dim;
#P inlet 50 30 15 0;
#P outlet 166 152 15 0;
#P connect 1 0 2 0;
#P connect 2 0 3 0;
#P connect 2 1 4 0;
#P fasten 3 0 8 0 55 115 136 115;
#P connect 8 0 9 0;
#P fasten 5 0 8 1 253 118 155 118;
#P fasten 3 0 0 0 55 115 171 115;
#P fasten 4 0 3 1 107 88 229 88;
#P fasten 2 2 6 0 157 73 253 73;
#P connect 6 0 5 0;
#P fasten 2 2 7 0 157 73 275 73;
#P connect 7 0 5 1;
#P pop;
#P newobj 106 112 76 9109513 p CalcGLHeight;
#P comment 113 140 35 9109513 width;
#P newex 27 101 42 9109513 s render;
#P connect 15 0 16 0;
#P connect 16 0 3 0;
#P fasten 3 0 0 0 32 97 32 97;
#P fasten 2 0 20 0 111 137 46 137;
#P connect 20 0 22 0;
#P connect 22 0 19 0;
#P connect 19 0 17 0;
#P connect 17 0 18 0;
#P connect 21 0 22 1;
#P fasten 11 0 19 1 93 254 63 254;
#P connect 20 1 11 0;
#P connect 8 0 2 0;
#P fasten 2 0 5 0 111 135 111 135;
#P fasten 11 0 25 0 93 254 149 254;
#P connect 25 0 9 0;
#P connect 9 0 10 0;
#P fasten 2 1 4 0 177 135 177 135;
#P fasten 4 0 14 0 177 176 177 176;
#P connect 14 0 12 0;
#P connect 12 0 13 0;
#P pop;
#P newobj 142 84 44 9109513 p glwidth;
#P user jit.pwindow 261 26 162 122 0 0 0 0 1 0;
#X name rott;
#P objectname rott;
#P toggle 23 32 33 0;
#P newex 23 74 57 9109513 qmetro 33;
#P newex 26 469 142 9109513 jit.gl.mesh rott @poly_mode 1 1;
#P newex 23 96 53 9109513 t b b erase;
#P newex 26 175 164 9109513 jit.matrix data 3 float32 2 2 @adapt 0;
#P newex 26 152 306 9109513 jit.gl.gridshape @automatic 0 @dim 2 2
@matrixoutput 1 @shape plane;
#P newex 23 125 138 9109513 jit.gl.render rott @camera 0 0 4;
#P window linecount 2;
#P comment 134 45 100 9109513 how to roatte a mesh based quad;
#P window linecount 1;
#P comment 195 214 100 9109513 change rotation center;
#P connect 8 0 7 0;
#P connect 7 0 5 0;
#P fasten 5 2 2 0 70 119 28 119;
#P connect 5 0 2 0;
#P fasten 5 1 3 0 49 147 31 147;
#P connect 3 0 4 0;
#P connect 4 0 20 0;
#P connect 20 0 11 0;
#P connect 11 0 12 0;
#P connect 12 0 13 0;
#P connect 13 0 19 0;
#P connect 19 0 6 0;
#P fasten 21 0 20 1 89 251 79 251;
#P hidden fasten 17 0 22 0 501 213 89 213;
#P connect 22 0 21 0;
#P connect 21 0 19 1;
#P hidden fasten 17 0 23 0 501 213 125 213;
#P connect 23 0 21 1;
#P hidden fasten 17 0 24 0 501 213 163 213;
#P connect 24 0 21 2;
#P fasten 21 0 27 0 89 251 204 251;
#P connect 27 0 26 0;
#P connect 26 0 25 0;
#P hidden fasten 17 0 14 0 501 254 459 254;
#P hidden fasten 17 0 15 0 501 306 465 306;
#P hidden fasten 17 0 16 0 501 351 465 351;
#P fasten 14 0 11 1 459 276 484 276;
#P fasten 15 0 12 1 465 329 490 329;
#P fasten 16 0 13 1 465 369 490 369;
#P connect 18 0 17 0;
#P window clipboard copycount 29;

On Thu, Sep 27, 2007 at 12:48 AM, Joshua Kit Clayton wrote:

>
>
> p.s. jit.gl.mesh will be *oodles* faster for cases like the one Yair was
> actually interested in, and AB’s solution would be recommended. If using the
> geometry many times in the sort of iterative jit.gl.gridshape case, use
> @displaylist 1, for performance improvements.
>
>
>

#113147
May 7, 2008 at 9:33am

Quote: yair r. wrote on Tue, 06 May 2008 10:33
—————————————————-
> revisited the formulas, added rotation origin math and visualization

interested in seeing the patch, but there seems to be some problems with copy + paste… perhaps some forum patch scrambling?

thanks,

j

#113148
May 7, 2008 at 9:45am

here ya go

#113149
May 12, 2008 at 3:12pm

thanks, but still cant open…. is it done in max v5?
am going to update sometime this summer, still have projects i need to finish!

j

#113150
May 1, 2010 at 7:07pm

Hi Yair,

Would you mind reposting your patch because there seems to be some problem with the copy / paste ?

cheers !

#113151

You must be logged in to reply to this topic.