Forums > MaxMSP

Re: [max-msp] faking jit.gl.handle autorotate

May 16, 2006 | 4:19 pm

Coming back on this old post I never got a reply to…Not that I’ve spent a
whole year on this but I still can’t figure it out:-)

If you use the mouse input to autorotate a jit.gl.handle all axis are
rotating most of the time. How is this calculated? I can’t get my head
around it. I guess the mouse input generates a vector that is used to
compute the rotation and speed on every axis, but how?

I’d like to store/recall the vector and speed to compute the rotate or
rotatexyz parameters without using jit.gl.handle and without actual mouse
input. Can someone with better math skills help me out please?

-thijs


May 16, 2006 | 4:40 pm

Hi Thijs,
Try this patch out. It’s really basic, but a start. The next
modification I would make would be to add the ability to change
rotation speed on the fly and not just at the end of a revolution as
it now stands.

best,
wes

#P window setfont "Sans Serif" 9.;
#P number 291 254 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 107 237 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P button 226 211 15 0;
#P window linecount 1;
#P newex 226 231 30 196617 t b b;
#P message 246 254 14 196617 0;
#P newex 226 275 75 196617 pack 359. 100;
#P newex 170 203 43 196617 bline 0.;
#P newex 170 289 29 196617 t b f;
#P newex 170 316 114 196617 pack rotatexyz 0. 0. 0.;
#P window linecount 2;
#P newex 170 348 236 196617 jit.gl.gridshape rot @shape torus
@lighting_enable 1 @blend_enable 1 @smooth_shading 1;
#P toggle 140 74 15 0;
#P window linecount 1;
#P message 140 94 68 196617 fullscreen $1;
#N vpatcher 30 89 166 253;
#P window setfont "Sans Serif" 9.;
#P newex 50 71 35 196617 sel 27;
#P newex 50 50 40 196617 key;
#P outlet 50 93 15 0;
#P connect 1 0 2 0;
#P connect 2 0 0 0;
#P pop;
#P newobj 140 54 33 196617 p Esc;
#P newex 38 72 48 196617 loadbang;
#P newex 140 112 147 196617 jit.window rot @depthbuffer 1;
#P message 101 112 34 196617 reset;
#P newex 101 133 182 196617 jit.gl.handle rot @inherit_transform 1;
#P toggle 38 93 15 0;
#P newex 38 112 57 196617 qmetro 60;
#P newex 38 133 50 196617 t b erase;
#P newex 38 158 82 196617 jit.gl.render rot;
#P comment 257 210 100 196617 < = start rotation;
#P connect 21 0 16 1;
#P connect 18 1 17 0;
#P connect 18 0 16 0;
#P connect 19 0 18 0;
#P connect 15 1 18 0;
#P connect 14 1 13 1;
#P connect 13 0 12 0;
#P connect 14 0 13 0;
#P connect 15 0 20 0;
#P connect 15 0 14 0;
#P connect 16 0 15 0;
#P connect 17 0 15 0;
#P fasten 2 0 1 0 43 154 43 154;
#P connect 2 0 15 0;
#P connect 10 0 7 0;
#P connect 11 0 10 0;
#P connect 9 0 11 0;
#P connect 6 0 5 0;
#P fasten 5 0 1 0 106 154 43 154;
#P fasten 2 1 1 0 83 154 43 154;
#P connect 3 0 2 0;
#P connect 4 0 3 0;
#P connect 8 0 4 0;
#P window clipboard copycount 22;


May 16, 2006 | 6:01 pm

Hi Wes, from what I understand your approach is similar to the one I use
right now (rotating one axis – the other 2 fixed offsets – moving the camera
around).
The problem is that using the mouse input on a handle, there are 3 axis
involved in the rotation. Your patch doesn’t explain to me how to generate a
rotation like that. (without moving around the camera/scene)

I think this is more obvious looking at a plane then a torus. Forgive me if
I’m being stupid, but I don’t know how I can explain myself otherwise.

best, -thijs


May 16, 2006 | 6:09 pm

HI Thijs,

I’m not sure if the Jitter3DUtils or even JavaScript support was
available when you first asked your question. But now the answer is
simple: use the quaternion rotation code from the Jitter3dUtils.
Keep track of your rotation as a quaternion, accumulating it with
add_quats. Use quat_to_axis to convert into axis/angle format.
Plenty of intro-to-quaternions stuff from the gave development world
should be available through Google.

best
Randy


May 16, 2006 | 6:14 pm

The JS3dutils xyz_to_quat is a good place to look for what Randy is
talking about. In the previous patch, you can add more rotation by
the following:

#P window setfont "Sans Serif" 9.;
#P number 483 254 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P window linecount 1;
#P newex 418 231 30 196617 t b b;
#P message 438 254 14 196617 0;
#P newex 418 275 69 196617 pack 359. 50;
#P newex 362 203 43 196617 bline 0.;
#P number 291 254 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 107 237 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P button 226 211 15 0;
#P newex 226 231 30 196617 t b b;
#P message 246 254 14 196617 0;
#P newex 226 275 75 196617 pack 359. 100;
#P newex 170 203 43 196617 bline 0.;
#P newex 170 289 29 196617 t b f;
#P newex 170 316 114 196617 pack rotatexyz 0. 0. 0.;
#P window linecount 2;
#P newex 170 348 236 196617 jit.gl.gridshape rot @shape torus
@lighting_enable 1 @blend_enable 1 @smooth_shading 1;
#P toggle 140 74 15 0;
#P window linecount 1;
#P message 140 94 68 196617 fullscreen $1;
#N vpatcher 30 89 166 253;
#P window setfont "Sans Serif" 9.;
#P newex 50 71 35 196617 sel 27;
#P newex 50 50 40 196617 key;
#P outlet 50 93 15 0;
#P connect 1 0 2 0;
#P connect 2 0 0 0;
#P pop;
#P newobj 140 54 33 196617 p Esc;
#P newex 38 72 48 196617 loadbang;
#P newex 140 112 147 196617 jit.window rot @depthbuffer 1;
#P message 101 112 34 196617 reset;
#P newex 101 133 182 196617 jit.gl.handle rot @inherit_transform 1;
#P toggle 38 93 15 0;
#P newex 38 112 57 196617 qmetro 60;
#P newex 38 133 50 196617 t b erase;
#P newex 38 158 82 196617 jit.gl.render rot;
#P comment 257 210 100 196617 < = start rotation;
#P connect 8 0 4 0;
#P connect 4 0 3 0;
#P connect 3 0 2 0;
#P fasten 2 0 1 0 43 154 43 154;
#P fasten 5 0 1 0 106 154 43 154;
#P fasten 2 1 1 0 83 154 43 154;
#P connect 6 0 5 0;
#P connect 15 0 20 0;
#P connect 9 0 11 0;
#P connect 11 0 10 0;
#P connect 10 0 7 0;
#P connect 2 0 15 0;
#P connect 16 0 15 0;
#P connect 17 0 15 0;
#P connect 15 0 14 0;
#P connect 14 0 13 0;
#P connect 13 0 12 0;
#P connect 14 1 13 1;
#P connect 19 0 18 0;
#P connect 15 1 18 0;
#P connect 18 0 16 0;
#P connect 22 0 13 2;
#P connect 18 1 17 0;
#P connect 21 0 16 1;
#P connect 23 0 22 0;
#P connect 2 0 22 0;
#P connect 24 0 22 0;
#P connect 19 0 25 0;
#P connect 22 1 25 0;
#P connect 25 0 23 0;
#P connect 25 1 24 0;
#P connect 26 0 23 1;
#P window clipboard copycount 27;


May 16, 2006 | 6:15 pm

Hey Thijs,

I’d suggest looking at both the Jitter3DUtils.js (c74:/js-extensions)
and the topic on joyrotate/nudgexyz which has some of these things
duplicated, but provides a nudgexyz method.

http://www.cycling74.com/forums/index.php?t=msg&goto=417 63

We could add this in a future version of Jitter3DUtils.js

-Joshua


May 16, 2006 | 8:18 pm

Thanks guys! that’s exactly what I need. Last time I looked at Jitter3DUtils
I didn’t understand anything so I couldn’t remember whats in it either.
Quaternions is still a bit blurry but I’m getting there. The nudgexyz code
will definitely get me going. Thanks again.

Best, -thijs


May 16, 2006 | 9:09 pm

In case someone else cares to learn about quaternion rotations… I found
this really clear and helpful

http://www.ogre3d.org/wiki/index.php/Quaternion_and_Rotation _Primer

-thijs


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