Control camera?

Aug 27, 2007 at 11:31pm

Control camera?

Hi,

Have you ever seem the movie “Matrix”?? I want to use the same way to control the camera so it can keep surrounding an object. However I don’t know what I did wrong. This is supposed to be very simple…..but camera just couldn’t listen to me.

In the jit.gl.render, I use “ortho 0″, my object position is “0. 0. 0.”. I use “pak camera 0. 0. 4.” and try to adjust the numbers of camera. What I should do if I want to surround the object. I thought I only need to adjust y but the result is not what I want. The object just fly away from camera. What should I do to make a beautiful circle around the object?

thank you so much

#33435
Aug 27, 2007 at 11:45pm

Quote: CKNY wrote on Mon, 27 August 2007 17:31
—————————————————-
> Hi,
>
> Have you ever seem the movie “Matrix”?? I want to use the same way to control the camera so it can keep surrounding an object. However I don’t know what I did wrong. This is supposed to be very simple…..but camera just couldn’t listen to me.
>
> In the jit.gl.render, I use “ortho 0″, my object position is “0. 0. 0.”. I use “pak camera 0. 0. 4.” and try to adjust the numbers of camera. What I should do if I want to surround the object. I thought I only need to adjust y but the result is not what I want. The object just fly away from camera. What should I do to make a beautiful circle around the object?
>
> thank you so much
—————————————————-

Hi,

Sorry I want to make up something here. The reason I want to use camera to circle the object is I will need to create more shaders if possible. Each shader will have different positions. So I can not only rotate the shaders. I need to use camera to circle around those shaders. So if I have 3 different objects in 3 different positions, I hope I still can use camera to make what people called “arc” around those objects based in the center 0. 0. 0. Please tell me how to do it.

thank you,

CK

#111386
Aug 27, 2007 at 11:52pm

Sounds like a job for polar coordinates:

#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P comment 207 57 100 196617 angle;
#P newex 159 170 20 196617 t b;
#P flonum 181 170 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P window linecount 2;
#P newex 235 118 224 196617 jit.gl.gridshape foo @shape cube @scale 0.5
0.5 0.15 @lighting_enable 1 @position 0.9 0.1 0.7;
#P window linecount 1;
#P newex 150 228 81 196617 prepend camera;
#P newex 150 207 66 196617 pack 0. 0. 0.;
#P flonum 187 137 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 150 137 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 150 33 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 170 73 29 196617 t b f;
#P flonum 170 55 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 150 103 47 196617 poltocar;
#P newex 41 252 147 196617 jit.window foo @depthbuffer 1;
#P newex 232 95 339 196617 jit.gl.gridshape foo @shape torus @scale 0.5
0.5 0.55 @lighting_enable 1;
#P toggle 40 31 15 0;
#P newex 40 90 50 196617 t b erase;
#P newex 40 174 82 196617 jit.gl.render foo;
#P newex 40 63 51 196617 qmetro 5;
#P comment 189 30 100 196617 distance;
#P connect 16 0 17 0;
#P connect 16 0 13 1;
#P connect 17 0 13 0;
#P connect 8 0 9 0;
#P connect 9 1 7 1;
#P connect 9 0 7 0;
#P connect 10 0 7 0;
#P connect 7 0 11 0;
#P connect 7 1 12 0;
#P connect 14 0 2 0;
#P connect 13 0 14 0;
#P connect 12 0 13 2;
#P connect 11 0 13 0;
#P connect 4 0 1 0;
#P fasten 3 1 2 0 85 113 45 113;
#P connect 3 0 2 0;
#P connect 1 0 3 0;
#P window clipboard copycount 19;

#111387
Aug 28, 2007 at 9:46am

i posted a similar question a few months back but never got a reply… i got as far as andrew’s solution, but i was trying to implement a “spherical” orbit where the Y axis is also part of the equation (like a satellite) that’s where my (basic) trigononmetry skills fell apart, any ideas?

http://en.wikipedia.org/wiki/Spherical_trigonometry

j

#111388
Aug 28, 2007 at 6:31pm

Quote: andrewb@cycling74.com wrote on Mon, 27 August 2007 17:52
—————————————————-
> Sounds like a job for polar coordinates:
>
> #P window setfont “Sans Serif” 9.;
> #P window linecount 1;
> #P comment 207 57 100 196617 angle;
> #P newex 159 170 20 196617 t b;
> #P flonum 181 170 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
> #P window linecount 2;
> #P newex 235 118 224 196617 jit.gl.gridshape foo @shape cube @scale 0.5
> 0.5 0.15 @lighting_enable 1 @position 0.9 0.1 0.7;
> #P window linecount 1;
> #P newex 150 228 81 196617 prepend camera;
> #P newex 150 207 66 196617 pack 0. 0. 0.;
> #P flonum 187 137 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
> #P flonum 150 137 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
> #P flonum 150 33 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
> #P newex 170 73 29 196617 t b f;
> #P flonum 170 55 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
> #P newex 150 103 47 196617 poltocar;
> #P newex 41 252 147 196617 jit.window foo @depthbuffer 1;
> #P newex 232 95 339 196617 jit.gl.gridshape foo @shape torus @scale 0.5
> 0.5 0.55 @lighting_enable 1;
> #P toggle 40 31 15 0;
> #P newex 40 90 50 196617 t b erase;
> #P newex 40 174 82 196617 jit.gl.render foo;
> #P newex 40 63 51 196617 qmetro 5;
> #P comment 189 30 100 196617 distance;
> #P connect 16 0 17 0;
> #P connect 16 0 13 1;
> #P connect 17 0 13 0;
> #P connect 8 0 9 0;
> #P connect 9 1 7 1;
> #P connect 9 0 7 0;
> #P connect 10 0 7 0;
> #P connect 7 0 11 0;
> #P connect 7 1 12 0;
> #P connect 14 0 2 0;
> #P connect 13 0 14 0;
> #P connect 12 0 13 2;
> #P connect 11 0 13 0;
> #P connect 4 0 1 0;
> #P fasten 3 1 2 0 85 113 45 113;
> #P connect 3 0 2 0;
> #P connect 1 0 3 0;
> #P window clipboard copycount 19;
>
>
—————————————————-

Hey thanks, that’s exactly what I want. One thing I wandering is that is it possible to change the center point and do the arc of camera? I mean, if I want to change the center point from (0,0,0) to (0,9,5) or (10,8,4), what should I fix with this patch? Just in case I need to do this way……

again, thanks for the patch, actually I didn’t know “poltocar” before. This is a very useful object.

best,

CK

#111389
Aug 29, 2007 at 3:34am

Here’s a patch that allows for spherical rotation. You can rotate around the y axis (as in Andrew’s patch), and you can rotate around the x or z axes (depending on where you are). Check it out.

max v2;
#N vpatcher 439 100 1229 615;
#P origin 0 -13;
#P window setfont Geneva 9.;
#P window linecount 3;
#P comment 390 94 317 196617 choose y-rotation behavior ; 1 is like doing flips around the ball ; 2 will keep your view oriented so your up is always in “above” you ;;
#P window linecount 1;
#P hidden newex 498 164 24 196617 t 1.;
#P hidden newex 471 164 24 196617 t 0.;
#P message 406 134 14 196617 2;
#P message 390 134 14 196617 1;
#P newex 390 186 51 196617 gate 2 1;
#P newex 431 164 37 196617 abs 0.;
#P newex 431 208 331 196617 if ($f1 > 1.2 && $f1 < 1.7) || ($f1 > 4.4 && $f1 < 5.) then 0.02 else 0.;
#P window linecount 2;
#P comment 267 136 106 196617 change amplitude (distance from object);
#P flonum 230 137 35 9 0 0 0 3 0 0 0 94 232 0 222 222 222 0 0 0;
#P window linecount 1;
#P newex 390 228 240 196617 if $f1 < 1.570796 || $f1 > 4.71239 then 1. else -1.;
#P window setfont Times 10.;
#P comment 396 256 48 1310730 up vector;
#P comment 447 270 39 1310730 z;
#P comment 405 270 39 1310730 y;
#P comment 362 270 39 1310730 x;
#P window setfont “Fixedwidth Serif” 9.;
#P flonum 431 286 39 9 0 0 0 22 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 390 286 39 9 0 0 0 22 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 349 286 39 9 0 0 0 22 0 0 0 221 221 221 222 222 222 0 0 0;
#P window setfont “Fixedwidth Serif” 10.;
#P newex 308 308 133 1441802 pak up 0. 1. 0.;
#P window setfont Geneva 9.;
#P flonum 169 34 35 9 0 0 0 3 0 0 0 94 232 0 222 222 222 0 0 0;
#P newex 10 471 468 196617 jit.gl.gridshape sphere_rotate @shape cube @scale 1.5 0.05 0.5 @lighting_enable 1 @depth_enable 1;
#P newex 171 308 131 196617 pak camera 0. 0. 0.;
#P newex 10 449 450 196617 jit.gl.gridshape sphere_rotate @shape sphere @scale 1. 1. 1. @lighting_enable 1 @depth_enable 1;
#P toggle 203 334 15 0;
#P newex 203 379 50 196617 t b erase;
#P newex 203 357 52 196617 metro 20;
#P newex 203 406 363 196617 jit.gl.render sphere_rotate @erase_color 0. 0. 0. 1 @axes 1 @camera 4. 0. 0.;
#P newex 10 428 197 196617 jit.window sphere_rotate @depthbuffer 1;
#P comment 268 184 112 196617 x-z rotation in radians;
#P comment 207 35 102 196617 y rotation in radians;
#P comment 302 265 14 196617 z;
#P comment 224 265 14 196617 x;
#P newex 229 205 29 196617 t b f;
#P flonum 251 281 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 291 281 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 211 281 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 229 183 35 9 0 0 0 3 0 0 0 94 232 0 222 222 222 0 0 0;
#P newex 211 232 47 196617 poltocar;
#P newex 211 159 29 196617 * 4.;
#P newex 169 159 29 196617 * 4.;
#P flonum 211 117 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 169 117 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 169 56 67 196617 % 6.283186;
#P newex 211 94 23 196617 cos;
#P newex 169 94 21 196617 sin;
#P comment 259 265 14 196617 y;
#P connect 26 0 3 0;
#P connect 3 0 1 0;
#P connect 1 0 4 0;
#P connect 4 0 6 0;
#P fasten 36 0 6 1 235 155 193 155;
#P connect 22 0 20 0;
#P fasten 20 0 21 0 208 378;
#P fasten 27 0 19 0 313 401 208 401;
#P fasten 21 1 19 0 248 401 208 401;
#P connect 21 0 19 0;
#P fasten 24 0 19 0 176 401 208 401;
#P fasten 3 0 2 0 174 76 216 76;
#P connect 2 0 5 0;
#P connect 5 0 7 0;
#P fasten 13 0 8 0 234 227 216 227;
#P connect 7 0 8 0;
#P connect 8 0 10 0;
#P connect 10 0 24 1;
#P connect 9 0 13 0;
#P connect 36 0 7 1;
#P connect 13 1 8 1;
#P connect 6 0 12 0;
#P connect 12 0 24 2;
#P fasten 8 1 11 0 253 257 296 257;
#P connect 11 0 24 3;
#P connect 28 0 27 1;
#P fasten 42 0 40 0 411 167 395 167;
#P connect 41 0 40 0;
#P connect 40 0 35 0;
#P hidden connect 44 0 29 0;
#P connect 35 0 29 0;
#P connect 29 0 27 2;
#P fasten 3 0 39 0 174 76 436 76;
#P connect 39 0 40 1;
#P connect 40 1 38 0;
#P hidden connect 43 0 30 0;
#P connect 38 0 30 0;
#P connect 30 0 27 3;
#P hidden connect 41 0 43 0;
#P hidden connect 42 0 44 0;
#P pop;

#111390
Aug 29, 2007 at 4:02am

One correction with changing the amplitude. Here’s the correct patch.

max v2;
#N vpatcher 439 100 1229 615;
#P origin 0 -13;
#P window setfont Geneva 9.;
#P window linecount 1;
#P newex 249 131 53 196617 t b b f f;
#P window linecount 3;
#P comment 390 94 317 196617 choose y-rotation behavior ; 1 is like doing flips around the ball ; 2 will keep your view oriented so your up is always in “above” you ;;
#P window linecount 1;
#P hidden newex 498 164 24 196617 t 1.;
#P hidden newex 471 164 24 196617 t 0.;
#P message 406 134 14 196617 2;
#P message 390 134 14 196617 1;
#P newex 390 186 51 196617 gate 2 1;
#P newex 431 164 37 196617 abs 0.;
#P newex 431 208 331 196617 if ($f1 > 1.2 && $f1 < 1.7) || ($f1 > 4.4 && $f1 < 5.) then 0.02 else 0.;
#P window linecount 2;
#P comment 249 85 106 196617 change amplitude (distance from object);
#P flonum 249 111 35 9 0 0 0 3 0 0 0 94 232 0 222 222 222 0 0 0;
#P window linecount 1;
#P newex 390 228 240 196617 if $f1 < 1.570796 || $f1 > 4.71239 then 1. else -1.;
#P window setfont Times 10.;
#P comment 396 256 48 1310730 up vector;
#P comment 447 270 39 1310730 z;
#P comment 405 270 39 1310730 y;
#P comment 362 270 39 1310730 x;
#P window setfont “Fixedwidth Serif” 9.;
#P flonum 431 286 39 9 0 0 0 22 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 390 286 39 9 0 0 0 22 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 349 286 39 9 0 0 0 22 0 0 0 221 221 221 222 222 222 0 0 0;
#P window setfont “Fixedwidth Serif” 10.;
#P newex 308 308 133 1441802 pak up 0. 1. 0.;
#P window setfont Geneva 9.;
#P flonum 169 34 35 9 0 0 0 3 0 0 0 94 232 0 222 222 222 0 0 0;
#P newex 10 471 468 196617 jit.gl.gridshape sphere_rotate @shape cube @scale 1.5 0.05 0.5 @lighting_enable 1 @depth_enable 1;
#P newex 171 308 131 196617 pak camera 0. 0. 0.;
#P newex 10 449 450 196617 jit.gl.gridshape sphere_rotate @shape sphere @scale 1. 1. 1. @lighting_enable 1 @depth_enable 1;
#P toggle 203 334 15 0;
#P newex 203 379 50 196617 t b erase;
#P newex 203 357 52 196617 metro 20;
#P newex 203 406 363 196617 jit.gl.render sphere_rotate @erase_color 0. 0. 0. 1 @axes 1 @camera 4. 0. 0.;
#P newex 10 428 197 196617 jit.window sphere_rotate @depthbuffer 1;
#P comment 268 184 112 196617 x-z rotation in radians;
#P comment 207 35 102 196617 y rotation in radians;
#P comment 302 265 14 196617 z;
#P comment 224 265 14 196617 x;
#P newex 229 205 29 196617 t b f;
#P flonum 251 281 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 291 281 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 211 281 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 229 183 35 9 0 0 0 3 0 0 0 94 232 0 222 222 222 0 0 0;
#P newex 211 232 47 196617 poltocar;
#P newex 211 159 29 196617 * 4.;
#P newex 169 159 29 196617 * 4.;
#P flonum 211 117 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 169 117 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 169 56 67 196617 % 6.283186;
#P newex 211 94 23 196617 cos;
#P newex 169 94 21 196617 sin;
#P comment 259 265 14 196617 y;
#P connect 26 0 3 0;
#P connect 3 0 1 0;
#P connect 1 0 4 0;
#P fasten 46 0 6 0 254 153 174 153;
#P connect 4 0 6 0;
#P fasten 46 2 6 1 282 153 193 153;
#P connect 22 0 20 0;
#P fasten 20 0 21 0 208 378;
#P fasten 24 0 19 0 176 401 208 401;
#P connect 21 0 19 0;
#P fasten 21 1 19 0 248 401 208 401;
#P fasten 27 0 19 0 313 401 208 401;
#P fasten 3 0 2 0 174 76 216 76;
#P connect 2 0 5 0;
#P fasten 46 1 7 0 268 153 216 153;
#P connect 5 0 7 0;
#P connect 7 0 8 0;
#P fasten 13 0 8 0 234 227 216 227;
#P connect 8 0 10 0;
#P connect 10 0 24 1;
#P connect 9 0 13 0;
#P fasten 46 3 7 1 296 153 235 153;
#P connect 13 1 8 1;
#P connect 36 0 46 0;
#P connect 6 0 12 0;
#P connect 12 0 24 2;
#P fasten 8 1 11 0 253 257 296 257;
#P connect 11 0 24 3;
#P connect 28 0 27 1;
#P connect 41 0 40 0;
#P fasten 42 0 40 0 411 167 395 167;
#P connect 40 0 35 0;
#P connect 35 0 29 0;
#P hidden connect 44 0 29 0;
#P connect 29 0 27 2;
#P fasten 3 0 39 0 174 76 436 76;
#P connect 39 0 40 1;
#P connect 40 1 38 0;
#P connect 38 0 30 0;
#P hidden connect 43 0 30 0;
#P connect 30 0 27 3;
#P hidden connect 41 0 43 0;
#P hidden connect 42 0 44 0;
#P pop;

#111391
Aug 29, 2007 at 9:22am

nice patch zachary, that’s exactly what i was trying to do… but i was getting stuck with the 3d relationships between each axis. i also like the up vector part, so you get a choice of how it responds.

in terms of changing the central point of the sphere (or orbit), i’m assuming all you need to do is add the values (new centre coords) to the output of the equation, before it goes to [pack camera 0. 0. 0.].

thanks,

j

#111392
Aug 29, 2007 at 1:26pm

Thanks Justin, this trig reviewing that I’ve been doing seems to be paying off.

You need to alter the lookat coordinate AND add those values to the camera coordinates. Here’s the patch with that addition.

max v2;
#N vpatcher 439 100 1228 672;
#P origin 0 -13;
#P window setfont Geneva 9.;
#P window linecount 1;
#P newex 153 280 40 196617 t f b f;
#P newex 111 280 40 196617 t f b f;
#P newex 69 280 40 196617 t f b f;
#P comment 72 224 121 196617 adjust center of rotation;
#P comment 164 243 14 196617 z;
#P comment 82 243 14 196617 x;
#P flonum 111 259 35 9 0 0 0 3 0 0 0 94 232 0 222 222 222 0 0 0;
#P flonum 153 259 35 9 0 0 0 3 0 0 0 94 232 0 222 222 222 0 0 0;
#P flonum 69 259 35 9 0 0 0 3 0 0 0 94 232 0 222 222 222 0 0 0;
#P comment 119 243 14 196617 y;
#P newex 291 322 27 196617 + 0.;
#P newex 251 322 27 196617 + 0.;
#P newex 211 322 27 196617 + 0.;
#P newex 27 345 138 196617 pak lookat 0. 0. 0.;
#P newex 10 531 618 196617 jit.gl.gridshape sphere_rotate @shape cube @scale 10. 10. 10. @poly_mode 1 1 @lighting_enable 1 @depth_enable 1 @color 1. 1. 0. 1.;
#P newex 249 131 53 196617 t b b f f;
#P window linecount 3;
#P comment 390 94 317 196617 choose y-rotation behavior ; 1 is like doing flips around the ball ; 2 will keep your view oriented so your up is always “above” you ;;
#P window linecount 1;
#P hidden newex 498 164 24 196617 t 1.;
#P hidden newex 471 164 24 196617 t 0.;
#P message 406 134 14 196617 2;
#P message 390 134 14 196617 1;
#P newex 390 186 51 196617 gate 2 1;
#P newex 431 164 37 196617 abs 0.;
#P newex 431 208 331 196617 if ($f1 > 1.2 && $f1 < 1.7) || ($f1 > 4.4 && $f1 < 5.) then 0.02 else 0.;
#P window linecount 2;
#P comment 249 85 106 196617 change amplitude (distance from object);
#P flonum 249 111 35 9 0 0 0 3 0 0 0 94 232 0 222 222 222 0 0 0;
#P window linecount 1;
#P newex 390 228 240 196617 if $f1 < 1.570796 || $f1 > 4.71239 then 1. else -1.;
#P window setfont Times 10.;
#P comment 396 256 48 1310730 up vector;
#P comment 447 270 39 1310730 z;
#P comment 405 270 39 1310730 y;
#P comment 362 270 39 1310730 x;
#P window setfont “Fixedwidth Serif” 9.;
#P flonum 431 286 39 9 0 0 0 22 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 390 286 39 9 0 0 0 22 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 349 286 39 9 0 0 0 22 0 0 0 221 221 221 222 222 222 0 0 0;
#P window setfont “Fixedwidth Serif” 10.;
#P newex 308 345 133 1441802 pak up 0. 1. 0.;
#P window setfont Geneva 9.;
#P flonum 169 34 35 9 0 0 0 3 0 0 0 94 232 0 222 222 222 0 0 0;
#P newex 10 508 468 196617 jit.gl.gridshape sphere_rotate @shape cube @scale 1.5 0.05 0.5 @lighting_enable 1 @depth_enable 1;
#P newex 171 345 131 196617 pak camera 0. 0. 0.;
#P newex 10 486 450 196617 jit.gl.gridshape sphere_rotate @shape sphere @scale 1. 1. 1. @lighting_enable 1 @depth_enable 1;
#P toggle 203 371 15 0;
#P newex 203 416 50 196617 t b erase;
#P newex 203 394 52 196617 metro 20;
#P newex 203 443 363 196617 jit.gl.render sphere_rotate @erase_color 0. 0. 0. 1 @axes 1 @camera 4. 0. 0.;
#P newex 10 465 197 196617 jit.window sphere_rotate @depthbuffer 1;
#P comment 268 184 112 196617 rotation around y axis;
#P comment 207 35 123 196617 rotation around x/z axes;
#P comment 302 265 14 196617 z;
#P comment 224 265 14 196617 x;
#P newex 229 205 29 196617 t b f;
#P flonum 251 281 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 291 281 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 211 281 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 229 183 35 9 0 0 0 3 0 0 0 94 232 0 222 222 222 0 0 0;
#P newex 211 232 47 196617 poltocar;
#P newex 211 159 29 196617 * 4.;
#P newex 169 159 29 196617 * 4.;
#P flonum 211 117 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 169 117 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 169 56 67 196617 % 6.283186;
#P newex 211 94 23 196617 cos;
#P newex 169 94 21 196617 sin;
#P comment 259 265 14 196617 y;
#P connect 53 0 59 0;
#P connect 59 0 48 1;
#P connect 55 0 60 0;
#P connect 60 0 48 2;
#P connect 54 0 61 0;
#P connect 61 0 48 3;
#P connect 26 0 3 0;
#P connect 3 0 1 0;
#P connect 1 0 4 0;
#P connect 4 0 6 0;
#P fasten 46 0 6 0 254 153 174 153;
#P fasten 46 2 6 1 282 153 193 153;
#P connect 22 0 20 0;
#P fasten 20 0 21 0 208 415;
#P fasten 48 0 19 0 32 438 208 438;
#P fasten 27 0 19 0 313 438 208 438;
#P fasten 21 1 19 0 248 438 208 438;
#P connect 21 0 19 0;
#P fasten 24 0 19 0 176 438 208 438;
#P fasten 3 0 2 0 174 76 216 76;
#P connect 2 0 5 0;
#P connect 5 0 7 0;
#P fasten 46 1 7 0 268 153 216 153;
#P fasten 13 0 8 0 234 227 216 227;
#P connect 7 0 8 0;
#P connect 8 0 10 0;
#P connect 59 1 49 0;
#P lcolor 10;
#P connect 10 0 49 0;
#P connect 49 0 24 1;
#P connect 59 2 49 1;
#P lcolor 10;
#P connect 9 0 13 0;
#P fasten 46 3 7 1 296 153 235 153;
#P connect 13 1 8 1;
#P connect 36 0 46 0;
#P connect 6 0 12 0;
#P connect 60 1 50 0;
#P lcolor 10;
#P connect 12 0 50 0;
#P connect 50 0 24 2;
#P connect 60 2 50 1;
#P lcolor 10;
#P fasten 8 1 11 0 253 257 296 257;
#P connect 61 1 51 0;
#P lcolor 10;
#P connect 11 0 51 0;
#P connect 51 0 24 3;
#P connect 61 2 51 1;
#P lcolor 10;
#P connect 28 0 27 1;
#P connect 41 0 40 0;
#P fasten 42 0 40 0 411 167 395 167;
#P connect 40 0 35 0;
#P hidden connect 44 0 29 0;
#P connect 35 0 29 0;
#P connect 29 0 27 2;
#P fasten 3 0 39 0 174 76 436 76;
#P connect 39 0 40 1;
#P connect 40 1 38 0;
#P hidden connect 43 0 30 0;
#P connect 38 0 30 0;
#P connect 30 0 27 3;
#P hidden connect 41 0 43 0;
#P hidden connect 42 0 44 0;
#P pop;

#111393
Aug 30, 2007 at 9:01am

Quote: Zachary Seldess wrote on Wed, 29 August 2007 14:26
—————————————————-
> Thanks Justin, this trig reviewing that I’ve been doing seems to be paying off.
>
> You need to alter the lookat coordinate AND add those values to the camera coordinates. Here’s the patch with that addition.
—————————————————-

well now i feel like i’m still novice in the trig domain!

and of course the lookat coords… makes perfect sense (need coffee)! will have to check out that other patch of yours (the 3d nav)….

thanks again.

j

#111394
Sep 4, 2007 at 7:10am

Quote: Zachary Seldess wrote on Wed, 29 August 2007 07:26
—————————————————-
> Thanks Justin, this trig reviewing that I’ve been doing seems to be paying off.
>
> You need to alter the lookat coordinate AND add those values to the camera coordinates. Here’s the patch with that addition.
>
> max v2;
> #N vpatcher 439 100 1228 672;
> #P origin 0 -13;
> #P window setfont Geneva 9.;
> #P window linecount 1;
> #P newex 153 280 40 196617 t f b f;
> #P newex 111 280 40 196617 t f b f;
> #P newex 69 280 40 196617 t f b f;
> #P comment 72 224 121 196617 adjust center of rotation;
> #P comment 164 243 14 196617 z;
> #P comment 82 243 14 196617 x;
> #P flonum 111 259 35 9 0 0 0 3 0 0 0 94 232 0 222 222 222 0 0 0;
> #P flonum 153 259 35 9 0 0 0 3 0 0 0 94 232 0 222 222 222 0 0 0;
> #P flonum 69 259 35 9 0 0 0 3 0 0 0 94 232 0 222 222 222 0 0 0;
> #P comment 119 243 14 196617 y;
> #P newex 291 322 27 196617 + 0.;
> #P newex 251 322 27 196617 + 0.;
> #P newex 211 322 27 196617 + 0.;
> #P newex 27 345 138 196617 pak lookat 0. 0. 0.;
> #P newex 10 531 618 196617 jit.gl.gridshape sphere_rotate @shape cube @scale 10. 10. 10. @poly_mode 1 1 @lighting_enable 1 @depth_enable 1 @color 1. 1. 0. 1.;
> #P newex 249 131 53 196617 t b b f f;
> #P window linecount 3;
> #P comment 390 94 317 196617 choose y-rotation behavior ; 1 is like doing flips around the ball ; 2 will keep your view oriented so your up is always “above” you ;;
> #P window linecount 1;
> #P hidden newex 498 164 24 196617 t 1.;
> #P hidden newex 471 164 24 196617 t 0.;
> #P message 406 134 14 196617 2;
> #P message 390 134 14 196617 1;
> #P newex 390 186 51 196617 gate 2 1;
> #P newex 431 164 37 196617 abs 0.;
> #P newex 431 208 331 196617 if ($f1 > 1.2 && $f1 < 1.7) || ($f1 > 4.4 && $f1 < 5.) then 0.02 else 0.;
> #P window linecount 2;
> #P comment 249 85 106 196617 change amplitude (distance from object);
> #P flonum 249 111 35 9 0 0 0 3 0 0 0 94 232 0 222 222 222 0 0 0;
> #P window linecount 1;
> #P newex 390 228 240 196617 if $f1 < 1.570796 || $f1 > 4.71239 then 1. else -1.;
> #P window setfont Times 10.;
> #P comment 396 256 48 1310730 up vector;
> #P comment 447 270 39 1310730 z;
> #P comment 405 270 39 1310730 y;
> #P comment 362 270 39 1310730 x;
> #P window setfont “Fixedwidth Serif” 9.;
> #P flonum 431 286 39 9 0 0 0 22 0 0 0 221 221 221 222 222 222 0 0 0;
> #P flonum 390 286 39 9 0 0 0 22 0 0 0 221 221 221 222 222 222 0 0 0;
> #P flonum 349 286 39 9 0 0 0 22 0 0 0 221 221 221 222 222 222 0 0 0;
> #P window setfont “Fixedwidth Serif” 10.;
> #P newex 308 345 133 1441802 pak up 0. 1. 0.;
> #P window setfont Geneva 9.;
> #P flonum 169 34 35 9 0 0 0 3 0 0 0 94 232 0 222 222 222 0 0 0;
> #P newex 10 508 468 196617 jit.gl.gridshape sphere_rotate @shape cube @scale 1.5 0.05 0.5 @lighting_enable 1 @depth_enable 1;
> #P newex 171 345 131 196617 pak camera 0. 0. 0.;
> #P newex 10 486 450 196617 jit.gl.gridshape sphere_rotate @shape sphere @scale 1. 1. 1. @lighting_enable 1 @depth_enable 1;
> #P toggle 203 371 15 0;
> #P newex 203 416 50 196617 t b erase;
> #P newex 203 394 52 196617 metro 20;
> #P newex 203 443 363 196617 jit.gl.render sphere_rotate @erase_color 0. 0. 0. 1 @axes 1 @camera 4. 0. 0.;
> #P newex 10 465 197 196617 jit.window sphere_rotate @depthbuffer 1;
> #P comment 268 184 112 196617 rotation around y axis;
> #P comment 207 35 123 196617 rotation around x/z axes;
> #P comment 302 265 14 196617 z;
> #P comment 224 265 14 196617 x;
> #P newex 229 205 29 196617 t b f;
> #P flonum 251 281 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
> #P flonum 291 281 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
> #P flonum 211 281 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
> #P flonum 229 183 35 9 0 0 0 3 0 0 0 94 232 0 222 222 222 0 0 0;
> #P newex 211 232 47 196617 poltocar;
> #P newex 211 159 29 196617 * 4.;
> #P newex 169 159 29 196617 * 4.;
> #P flonum 211 117 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
> #P flonum 169 117 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
> #P newex 169 56 67 196617 % 6.283186;
> #P newex 211 94 23 196617 cos;
> #P newex 169 94 21 196617 sin;
> #P comment 259 265 14 196617 y;
> #P connect 53 0 59 0;
> #P connect 59 0 48 1;
> #P connect 55 0 60 0;
> #P connect 60 0 48 2;
> #P connect 54 0 61 0;
> #P connect 61 0 48 3;
> #P connect 26 0 3 0;
> #P connect 3 0 1 0;
> #P connect 1 0 4 0;
> #P connect 4 0 6 0;
> #P fasten 46 0 6 0 254 153 174 153;
> #P fasten 46 2 6 1 282 153 193 153;
> #P connect 22 0 20 0;
> #P fasten 20 0 21 0 208 415;
> #P fasten 48 0 19 0 32 438 208 438;
> #P fasten 27 0 19 0 313 438 208 438;
> #P fasten 21 1 19 0 248 438 208 438;
> #P connect 21 0 19 0;
> #P fasten 24 0 19 0 176 438 208 438;
> #P fasten 3 0 2 0 174 76 216 76;
> #P connect 2 0 5 0;
> #P connect 5 0 7 0;
> #P fasten 46 1 7 0 268 153 216 153;
> #P fasten 13 0 8 0 234 227 216 227;
> #P connect 7 0 8 0;
> #P connect 8 0 10 0;
> #P connect 59 1 49 0;
> #P lcolor 10;
> #P connect 10 0 49 0;
> #P connect 49 0 24 1;
> #P connect 59 2 49 1;
> #P lcolor 10;
> #P connect 9 0 13 0;
> #P fasten 46 3 7 1 296 153 235 153;
> #P connect 13 1 8 1;
> #P connect 36 0 46 0;
> #P connect 6 0 12 0;
> #P connect 60 1 50 0;
> #P lcolor 10;
> #P connect 12 0 50 0;
> #P connect 50 0 24 2;
> #P connect 60 2 50 1;
> #P lcolor 10;
> #P fasten 8 1 11 0 253 257 296 257;
> #P connect 61 1 51 0;
> #P lcolor 10;
> #P connect 11 0 51 0;
> #P connect 51 0 24 3;
> #P connect 61 2 51 1;
> #P lcolor 10;
> #P connect 28 0 27 1;
> #P connect 41 0 40 0;
> #P fasten 42 0 40 0 411 167 395 167;
> #P connect 40 0 35 0;
> #P hidden connect 44 0 29 0;
> #P connect 35 0 29 0;
> #P connect 29 0 27 2;
> #P fasten 3 0 39 0 174 76 436 76;
> #P connect 39 0 40 1;
> #P connect 40 1 38 0;
> #P hidden connect 43 0 30 0;
> #P connect 38 0 30 0;
> #P connect 30 0 27 3;
> #P hidden connect 41 0 43 0;
> #P hidden connect 42 0 44 0;
> #P pop;
>
—————————————————-

Hi Zachary,

First of all. Your patch is soooo cool and really gave me so much fun. Thanks a lot!! Here I have one thought………….what if I want to set the camera in position 0. 0. 0. and only “look around” it? like stand in one position and looking around? I used “lookat 0. 0. 0.” but I couldn’t make camera really like “look around”. Do you know how to do it?

thank you so much

CK

#111395
Sep 4, 2007 at 3:06pm

Hi CK,

I’m glad you like the patch!

To look around while staying still, you need to keep your camera set to 0. 0. 0. and change your lookat points. How you do this is the question, there are many ways. I know you’ve already checked out my glNavigator abstractions, they allows for infinite rotation around the y axis by using the mouse. You might want to look closely at that stuff. Otherwise, manually adjusting the lookat coordinates with number boxes will work, but to get the values to form a smooth sphere will take a little trig. Again, you might find what you want in the glNavigator abstractions. Fool around with it and tell me how it goes.

Zachary

#111396
Sep 4, 2007 at 3:08pm

forgot to add the link to the glNavigators:

http://www.cycling74.com/forums/index.php?t=rview&th=27757&rid=3109

#111397
Sep 5, 2007 at 1:51am

Here’s a quick example patch that uses a dial for infinite lookat rotation along the x/z plane and a multislider for rotation along the y axis. Hope it helps clarify.

max v2;
#N vpatcher 473 283 986 786;
#P origin 0 -13;
#P window setfont Geneva 9.;
#P window linecount 1;
#P hidden newex 298 158 41 196617 t 90 4.;
#P hidden newex 298 135 48 196617 loadbang;
#P comment 218 26 46 196617 y lookat;
#P user multiSlider 229 42 21 108 -1. 1. 1 2681 47 0 0 2 0 0 0;
#M frgb 0 0 0;
#M brgb 255 255 255;
#M rgb2 127 127 127;
#M rgb3 0 0 0;
#M rgb4 37 52 91;
#M rgb5 74 105 182;
#M rgb6 112 158 18;
#M rgb7 149 211 110;
#M rgb8 187 9 201;
#M rgb9 224 62 37;
#M rgb10 7 114 128;
#P newex 329 238 40 196617 t b f f;
#P newex 287 238 40 196617 t b f f;
#P newex 245 238 40 196617 t b f f;
#P comment 248 182 121 196617 adjust camera position;
#P comment 340 201 14 196617 z;
#P comment 258 201 14 196617 x;
#P flonum 287 217 35 9 0 0 0 3 0 0 0 94 232 0 222 222 222 0 0 0;
#P flonum 329 217 35 9 0 0 0 3 0 0 0 94 232 0 222 222 222 0 0 0;
#P flonum 245 217 35 9 0 0 0 3 0 0 0 94 232 0 222 222 222 0 0 0;
#P comment 295 201 14 196617 y;
#P newex 233 303 137 196617 pak camera 0. 0. 0.;
#P newex 191 278 27 196617 + 0.;
#P newex 149 278 27 196617 + 0.;
#P newex 107 278 27 196617 + 0.;
#N vpatcher 118 244 465 511;
#P outlet 68 210 15 0;
#P outlet 31 210 15 0;
#P inlet 31 35 15 0;
#P window setfont Geneva 9.;
#P comment 82 163 164 196617 generate x/z values;
#P comment 159 109 164 196617 convert from degrees into radians;
#P window setfont “Sans Serif” 9.;
#P newex 31 133 47 131137545 t 1. f;
#P window setfont Geneva 9.;
#P flonum 31 186 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 68 186 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P window setfont “Sans Serif” 9.;
#P newex 31 107 125 131137545 expr ($f1 * 3.141593) / 180.;
#P window setfont Geneva 9.;
#P newex 31 160 47 196617 poltocar;
#P newex 31 82 40 196617 % 360;
#P newex 31 57 37 196617 + 181;
#P comment 73 84 100 196617 straigth up is now 0;
#P connect 10 0 1 0;
#P connect 1 0 2 0;
#P connect 2 0 4 0;
#P connect 4 0 7 0;
#P connect 7 0 3 0;
#P connect 3 0 6 0;
#P connect 6 0 11 0;
#P connect 7 1 3 1;
#P connect 3 1 5 0;
#P connect 5 0 12 0;
#P pop;
#P hidden newobj 107 156 94 196617 p lookat_x/z;
#B color 12;
#P user dial 107 42 108 108 360 1 0 0 157 359 1 1. 101 85 147 221 221 221 120 120 120 225 225 225 0 0 0 0 0 0;
#P newex 191 237 27 196617 t f f;
#P newex 149 237 27 196617 t f f;
#P newex 107 237 27 196617 t f f;
#P comment 110 181 121 196617 adjust center of rotation;
#P comment 202 200 14 196617 z;
#P comment 120 200 14 196617 x;
#P flonum 149 216 35 9 0 0 0 3 0 0 0 94 232 0 222 222 222 0 0 0;
#P flonum 191 216 35 9 0 0 0 3 0 0 0 94 232 0 222 222 222 0 0 0;
#P flonum 107 216 35 9 0 0 0 3 0 0 0 94 232 0 222 222 222 0 0 0;
#P comment 157 200 14 196617 y;
#P newex 65 302 138 196617 pak lookat 0. 0. 0.;
#P window linecount 2;
#P newex 9 439 468 196617 jit.gl.gridshape sphere_rotate @shape cube @scale 10. 10. 10. @poly_mode 1 1 @lighting_enable 1 @depth_enable 1 @color 1. 1. 0. 1.;
#P window linecount 1;
#P newex 9 416 468 196617 jit.gl.gridshape sphere_rotate @shape cube @scale 1.5 0.05 0.5 @lighting_enable 1 @depth_enable 1;
#P newex 9 394 450 196617 jit.gl.gridshape sphere_rotate @shape sphere @scale 1. 1. 1. @lighting_enable 1 @depth_enable 1;
#P toggle 9 279 15 0;
#P newex 9 324 50 196617 t b erase;
#P newex 9 302 52 196617 metro 20;
#P newex 9 351 363 196617 jit.gl.render sphere_rotate @erase_color 0. 0. 0. 1 @axes 1 @camera 0. 0. 4.;
#P newex 9 373 197 196617 jit.window sphere_rotate @depthbuffer 1;
#P comment 131 25 57 196617 x/z lookat;
#P connect 5 0 3 0;
#P fasten 3 0 4 0 14 323;
#P fasten 25 0 2 0 238 346 14 346;
#P connect 4 0 2 0;
#P fasten 4 1 2 0 54 346 14 346;
#P fasten 9 0 2 0 70 346 14 346;
#P hidden connect 39 0 20 0;
#P hidden connect 20 0 21 0;
#P hidden connect 21 0 11 0;
#P connect 11 0 17 0;
#P connect 17 0 22 0;
#P connect 33 0 22 0;
#P lcolor 10;
#P connect 22 0 9 1;
#P connect 33 1 22 1;
#P lcolor 10;
#P hidden connect 36 0 13 0;
#P connect 13 0 18 0;
#P connect 18 0 23 0;
#P connect 34 0 23 0;
#P lcolor 10;
#P connect 23 0 9 2;
#P connect 34 1 23 1;
#P lcolor 10;
#P hidden connect 21 1 12 0;
#P connect 12 0 19 0;
#P connect 19 0 24 0;
#P connect 35 0 24 0;
#P lcolor 10;
#P connect 24 0 9 3;
#P connect 35 1 24 1;
#P lcolor 10;
#P connect 27 0 33 0;
#P connect 33 2 25 1;
#P connect 29 0 34 0;
#P hidden connect 38 0 39 0;
#P connect 34 2 25 2;
#P hidden connect 39 1 28 0;
#P connect 28 0 35 0;
#P connect 35 2 25 3;
#P pop;

#111398
Sep 5, 2007 at 6:21pm

Quote: Zachary Seldess wrote on Tue, 04 September 2007 19:51
—————————————————-
> Here’s a quick example patch that uses a dial for infinite lookat rotation along the x/z plane and a multislider for rotation along the y axis. Hope it helps clarify.
>
>
> max v2;
> #N vpatcher 473 283 986 786;
> #P origin 0 -13;
> #P window setfont Geneva 9.;
> #P window linecount 1;
> #P hidden newex 298 158 41 196617 t 90 4.;
> #P hidden newex 298 135 48 196617 loadbang;
> #P comment 218 26 46 196617 y lookat;
> #P user multiSlider 229 42 21 108 -1. 1. 1 2681 47 0 0 2 0 0 0;
> #M frgb 0 0 0;
> #M brgb 255 255 255;
> #M rgb2 127 127 127;
> #M rgb3 0 0 0;
> #M rgb4 37 52 91;
> #M rgb5 74 105 182;
> #M rgb6 112 158 18;
> #M rgb7 149 211 110;
> #M rgb8 187 9 201;
> #M rgb9 224 62 37;
> #M rgb10 7 114 128;
> #P newex 329 238 40 196617 t b f f;
> #P newex 287 238 40 196617 t b f f;
> #P newex 245 238 40 196617 t b f f;
> #P comment 248 182 121 196617 adjust camera position;
> #P comment 340 201 14 196617 z;
> #P comment 258 201 14 196617 x;
> #P flonum 287 217 35 9 0 0 0 3 0 0 0 94 232 0 222 222 222 0 0 0;
> #P flonum 329 217 35 9 0 0 0 3 0 0 0 94 232 0 222 222 222 0 0 0;
> #P flonum 245 217 35 9 0 0 0 3 0 0 0 94 232 0 222 222 222 0 0 0;
> #P comment 295 201 14 196617 y;
> #P newex 233 303 137 196617 pak camera 0. 0. 0.;
> #P newex 191 278 27 196617 + 0.;
> #P newex 149 278 27 196617 + 0.;
> #P newex 107 278 27 196617 + 0.;
> #N vpatcher 118 244 465 511;
> #P outlet 68 210 15 0;
> #P outlet 31 210 15 0;
> #P inlet 31 35 15 0;
> #P window setfont Geneva 9.;
> #P comment 82 163 164 196617 generate x/z values;
> #P comment 159 109 164 196617 convert from degrees into radians;
> #P window setfont “Sans Serif” 9.;
> #P newex 31 133 47 131137545 t 1. f;
> #P window setfont Geneva 9.;
> #P flonum 31 186 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
> #P flonum 68 186 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
> #P window setfont “Sans Serif” 9.;
> #P newex 31 107 125 131137545 expr ($f1 * 3.141593) / 180.;
> #P window setfont Geneva 9.;
> #P newex 31 160 47 196617 poltocar;
> #P newex 31 82 40 196617 % 360;
> #P newex 31 57 37 196617 + 181;
> #P comment 73 84 100 196617 straigth up is now 0;
> #P connect 10 0 1 0;
> #P connect 1 0 2 0;
> #P connect 2 0 4 0;
> #P connect 4 0 7 0;
> #P connect 7 0 3 0;
> #P connect 3 0 6 0;
> #P connect 6 0 11 0;
> #P connect 7 1 3 1;
> #P connect 3 1 5 0;
> #P connect 5 0 12 0;
> #P pop;
> #P hidden newobj 107 156 94 196617 p lookat_x/z;
> #B color 12;
> #P user dial 107 42 108 108 360 1 0 0 157 359 1 1. 101 85 147 221 221 221 120 120 120 225 225 225 0 0 0 0 0 0;
> #P newex 191 237 27 196617 t f f;
> #P newex 149 237 27 196617 t f f;
> #P newex 107 237 27 196617 t f f;
> #P comment 110 181 121 196617 adjust center of rotation;
> #P comment 202 200 14 196617 z;
> #P comment 120 200 14 196617 x;
> #P flonum 149 216 35 9 0 0 0 3 0 0 0 94 232 0 222 222 222 0 0 0;
> #P flonum 191 216 35 9 0 0 0 3 0 0 0 94 232 0 222 222 222 0 0 0;
> #P flonum 107 216 35 9 0 0 0 3 0 0 0 94 232 0 222 222 222 0 0 0;
> #P comment 157 200 14 196617 y;
> #P newex 65 302 138 196617 pak lookat 0. 0. 0.;
> #P window linecount 2;
> #P newex 9 439 468 196617 jit.gl.gridshape sphere_rotate @shape cube @scale 10. 10. 10. @poly_mode 1 1 @lighting_enable 1 @depth_enable 1 @color 1. 1. 0. 1.;
> #P window linecount 1;
> #P newex 9 416 468 196617 jit.gl.gridshape sphere_rotate @shape cube @scale 1.5 0.05 0.5 @lighting_enable 1 @depth_enable 1;
> #P newex 9 394 450 196617 jit.gl.gridshape sphere_rotate @shape sphere @scale 1. 1. 1. @lighting_enable 1 @depth_enable 1;
> #P toggle 9 279 15 0;
> #P newex 9 324 50 196617 t b erase;
> #P newex 9 302 52 196617 metro 20;
> #P newex 9 351 363 196617 jit.gl.render sphere_rotate @erase_color 0. 0. 0. 1 @axes 1 @camera 0. 0. 4.;
> #P newex 9 373 197 196617 jit.window sphere_rotate @depthbuffer 1;
> #P comment 131 25 57 196617 x/z lookat;
> #P connect 5 0 3 0;
> #P fasten 3 0 4 0 14 323;
> #P fasten 25 0 2 0 238 346 14 346;
> #P connect 4 0 2 0;
> #P fasten 4 1 2 0 54 346 14 346;
> #P fasten 9 0 2 0 70 346 14 346;
> #P hidden connect 39 0 20 0;
> #P hidden connect 20 0 21 0;
> #P hidden connect 21 0 11 0;
> #P connect 11 0 17 0;
> #P connect 17 0 22 0;
> #P connect 33 0 22 0;
> #P lcolor 10;
> #P connect 22 0 9 1;
> #P connect 33 1 22 1;
> #P lcolor 10;
> #P hidden connect 36 0 13 0;
> #P connect 13 0 18 0;
> #P connect 18 0 23 0;
> #P connect 34 0 23 0;
> #P lcolor 10;
> #P connect 23 0 9 2;
> #P connect 34 1 23 1;
> #P lcolor 10;
> #P hidden connect 21 1 12 0;
> #P connect 12 0 19 0;
> #P connect 19 0 24 0;
> #P connect 35 0 24 0;
> #P lcolor 10;
> #P connect 24 0 9 3;
> #P connect 35 1 24 1;
> #P lcolor 10;
> #P connect 27 0 33 0;
> #P connect 33 2 25 1;
> #P connect 29 0 34 0;
> #P hidden connect 38 0 39 0;
> #P connect 34 2 25 2;
> #P hidden connect 39 1 28 0;
> #P connect 28 0 35 0;
> #P connect 35 2 25 3;
> #P pop;
>
—————————————————-

Hi,

I did check your flyingSims patch and it does give me the answer of “looking around” questions. This simple example helps me more about something I didn’t understand before. Thank you so much. I am very appreciate your kindly help. :)

CK

#111399
Sep 10, 2007 at 4:14pm

have been modifying this orbital rotation patch to integrate it with the 3d navigator we have recently purchased.

FYI:

http://www.3dconnexion.com/index.php

aka.navigator object – http://www.iamas.ac.jp/~aka/max/#aka_spacenavigator

so far so good, will post a patch soon.

however, have been trying to add another feature into this patch. i would like to be able to rotate the camera on its own axis whilst staying locked on the object. i have attached a patch with my attempt but my trig keeps letting me down… feel like i’m close, but brain is starting to throb! there are some comments which should explain where i’m at.

thanks,

j

#P window setfont “Sans Serif” 9.;
#P window linecount 3;
#P comment 934 230 123 196617 < < almost there but its interfering with previous orbit equation....;
#P window linecount 1;
#P comment 229 70 153 196617 camera rotation around its orbit;
#P comment 829 39 153 196617 camera rotation on its own axis;
#P comment 894 104 123 196617 * fix offset;
#P newex 829 104 64 196617 + 1.570796;
#P flonum 829 60 35 9 0 0 0 3 0 0 0 94 232 0 222 222 222 0 0 0;
#P comment 867 61 123 196617 rotation around x/z axes;
#P newex 871 302 47 196617 poltocar;
#P newex 871 229 29 196617 * 1.;
#P newex 829 229 29 196617 * 1.;
#P flonum 871 187 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 829 187 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 829 126 67 196617 % 6.283186;
#P newex 871 164 23 196617 cos;
#P newex 829 164 21 196617 sin;
#P newex 213 340 40 196617 t f b f;
#P newex 171 340 40 196617 t f b f;
#P newex 129 340 40 196617 t f b f;
#P comment 132 284 121 196617 adjust center of rotation;
#P comment 224 303 14 196617 z;
#P comment 142 303 14 196617 x;
#P flonum 171 319 35 9 0 0 0 3 0 0 0 94 232 0 222 222 222 0 0 0;
#P flonum 213 319 35 9 0 0 0 3 0 0 0 94 232 0 222 222 222 0 0 0;
#P flonum 129 319 35 9 0 0 0 3 0 0 0 94 232 0 222 222 222 0 0 0;
#P comment 179 303 14 196617 y;
#P newex 351 382 27 196617 + 0.;
#P newex 311 382 27 196617 + 0.;
#P newex 271 382 27 196617 + 0.;
#P newex 87 405 138 196617 pak lookat 0. 0. 0.;
#P newex 70 591 618 196617 jit.gl.gridshape sphere_rotate @shape cube @scale 10. 10. 10. @poly_mode 1 1 @lighting_enable 1 @depth_enable 1 @color 1. 1. 0. 1.;
#P newex 309 191 53 196617 t b b f f;
#P window linecount 3;
#P comment 450 154 317 196617 choose y-rotation behavior ; 1 is like doing flips around the ball ; 2 will keep your view oriented so your up is always “above” you ;;
#P window linecount 1;
#P hidden newex 558 224 24 196617 t 1.;
#P hidden newex 531 224 24 196617 t 0.;
#P message 466 194 14 196617 2;
#P message 450 194 14 196617 1;
#P newex 450 246 51 196617 gate 2 1;
#P newex 491 224 37 196617 abs 0.;
#P newex 491 268 331 196617 if ($f1 > 1.2 && $f1 < 1.7) || ($f1 > 4.4 && $f1 < 5.) then 0.02 else 0.;
#P window linecount 2;
#P comment 309 145 106 196617 change amplitude (distance from object);
#P flonum 309 171 35 9 0 0 0 3 0 0 0 94 232 0 222 222 222 0 0 0;
#P window linecount 1;
#P newex 450 288 240 196617 if $f1 < 1.570796 || $f1 > 4.71239 then 1. else -1.;
#P window setfont Times 10.;
#P comment 456 316 48 1310730 up vector;
#P comment 507 330 39 1310730 z;
#P comment 465 330 39 1310730 y;
#P comment 422 330 39 1310730 x;
#P window setfont “Fixedwidth Serif” 9.;
#P flonum 491 346 39 9 0 0 0 22 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 450 346 39 9 0 0 0 22 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 409 346 39 9 0 0 0 22 0 0 0 221 221 221 222 222 222 0 0 0;
#P window setfont “Fixedwidth Serif” 10.;
#P newex 368 405 133 1441802 pak up 0. 1. 0.;
#P window setfont “Sans Serif” 9.;
#P flonum 229 94 35 9 0 0 0 3 0 0 0 94 232 0 222 222 222 0 0 0;
#P newex 70 568 468 196617 jit.gl.gridshape sphere_rotate @shape cube @scale 1.5 0.05 0.5 @lighting_enable 1 @depth_enable 1;
#P newex 231 405 131 196617 pak camera 0. 0. 0.;
#P newex 70 546 450 196617 jit.gl.gridshape sphere_rotate @shape sphere @scale 1. 1. 1. @lighting_enable 1 @depth_enable 1;
#P toggle 263 431 15 0;
#P newex 263 476 50 196617 t b erase;
#P newex 263 454 52 196617 metro 20;
#P newex 263 503 363 196617 jit.gl.render sphere_rotate @erase_color 0. 0. 0. 1 @axes 1 @camera 4. 0. 0.;
#P newex 70 525 197 196617 jit.window sphere_rotate @depthbuffer 1;
#P comment 328 244 112 196617 rotation around y axis;
#P comment 267 95 123 196617 rotation around x/z axes;
#P comment 362 325 14 196617 z;
#P comment 284 325 14 196617 x;
#P newex 289 265 29 196617 t b f;
#P flonum 311 341 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 351 341 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 271 341 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 289 243 35 9 0 0 0 3 0 0 0 94 232 0 222 222 222 0 0 0;
#P newex 271 292 47 196617 poltocar;
#P newex 271 219 29 196617 * 4.;
#P newex 229 219 29 196617 * 4.;
#P flonum 271 177 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 229 177 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 229 116 67 196617 % 6.283186;
#P newex 271 154 23 196617 cos;
#P newex 229 154 21 196617 sin;
#P comment 319 325 14 196617 y;
#P connect 64 0 62 0;
#P fasten 64 0 63 0 834 146 876 146;
#P connect 72 0 64 0;
#P connect 71 0 72 0;
#P connect 68 0 69 0;
#P connect 66 0 68 0;
#P connect 63 0 66 0;
#P connect 65 0 67 0;
#P connect 62 0 65 0;
#P hidden connect 42 0 44 0;
#P connect 41 0 40 0;
#P hidden connect 41 0 43 0;
#P connect 30 0 27 3;
#P connect 38 0 30 0;
#P hidden connect 43 0 30 0;
#P fasten 69 1 30 0 913 344 496 344;
#P connect 40 1 38 0;
#P connect 39 0 40 1;
#P connect 3 0 1 0;
#P fasten 3 0 2 0 234 136 276 136;
#P fasten 3 0 39 0 234 136 496 136;
#P connect 29 0 27 2;
#P connect 35 0 29 0;
#P hidden connect 44 0 29 0;
#P fasten 67 0 29 0 834 342 455 342;
#P connect 40 0 35 0;
#P fasten 42 0 40 0 471 227 455 227;
#P connect 28 0 27 1;
#P fasten 69 0 28 0 876 342 414 342;
#P connect 61 2 51 1;
#P lcolor 10;
#P connect 51 0 24 3;
#P connect 11 0 51 0;
#P connect 61 1 51 0;
#P lcolor 10;
#P fasten 8 1 11 0 313 317 356 317;
#P connect 60 2 50 1;
#P lcolor 10;
#P connect 50 0 24 2;
#P connect 12 0 50 0;
#P connect 60 1 50 0;
#P lcolor 10;
#P connect 6 0 12 0;
#P connect 36 0 46 0;
#P connect 13 1 8 1;
#P fasten 46 3 7 1 356 213 295 213;
#P connect 9 0 13 0;
#P connect 59 2 49 1;
#P lcolor 10;
#P connect 49 0 24 1;
#P connect 10 0 49 0;
#P connect 59 1 49 0;
#P lcolor 10;
#P connect 8 0 10 0;
#P connect 7 0 8 0;
#P fasten 13 0 8 0 294 287 276 287;
#P fasten 46 1 7 0 328 213 276 213;
#P connect 5 0 7 0;
#P connect 2 0 5 0;
#P fasten 24 0 19 0 236 498 268 498;
#P connect 21 0 19 0;
#P fasten 21 1 19 0 308 498 268 498;
#P fasten 27 0 19 0 373 498 268 498;
#P fasten 48 0 19 0 92 498 268 498;
#P fasten 20 0 21 0 268 475;
#P connect 22 0 20 0;
#P fasten 46 2 6 1 342 213 253 213;
#P fasten 46 0 6 0 314 213 234 213;
#P connect 4 0 6 0;
#P connect 1 0 4 0;
#P connect 26 0 3 0;
#P connect 61 0 48 3;
#P connect 54 0 61 0;
#P connect 60 0 48 2;
#P connect 55 0 60 0;
#P connect 59 0 48 1;
#P connect 53 0 59 0;
#P window clipboard copycount 77;

#111400
Sep 11, 2007 at 3:55am

Hi Justin,

What do you mean by “locked on the object” – do you mean that you want to rotate your camera while keeping your lookat point focussed on the object? Or something else?

Zachary

#111401
Sep 11, 2007 at 9:37am

Quote: Zachary Seldess wrote on Tue, 11 September 2007 04:55
—————————————————-
> Hi Justin,
>
> What do you mean by “locked on the object” – do you mean that you want to rotate your camera while keeping your lookat point focussed on the object? Or something else?
>
> Zachary
—————————————————-

yes, so that as the camera is “orbiting” around the object, it is also spinning on its own axis. but only on an axis which will enable it to remain focused on the object, otherwise it would not be looking at the central object.

i’ve had another go at it this morning, but the problem seems to be different then i first thought. the rotation now sort of works but it’s not steady, seems to accelerate at certain points…. hmmm, back to the trig then – and cheers for looking into it.

below is a new version of the patch with comments.

j

#P window setfont “Sans Serif” 12.;
#P window linecount 4;
#P comment 198 72 227 196620 2. experiment with the x/z and the y axes – you should notice flips when at 0. and strange accelerations in rotation on other than 0.;
#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P newex 680 125 32 196617 r rot;
#P comment 771 516 123 196617 turn rotation lfo on / off;
#P toggle 744 515 15 0;
#P newex 744 535 29 196617 gate;
#P newex 753 667 32 196617 s rot;
#P comment 855 624 123 196617 reset;
#P comment 874 580 123 196617 direction;
#P message 840 624 14 196617 0;
#P message 840 580 33 196617 -360;
#P message 815 580 26 196617 360;
#P comment 824 561 123 196617 degrees per render bang;
#P flonum 788 561 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 764 580 32 196617 f 0.1;
#P newex 744 558 30 196617 t b b;
#P flonum 744 694 57 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 764 620 68 196617 * 6.283185;
#P newex 764 599 40 196617 / 360.;
#P newex 744 643 50 196617 accum 0.;
#P newex 435 330 29 196617 t b f;
#P newex 427 354 37 196617 * 1.;
#P window setfont “Sans Serif” 12.;
#P window linecount 3;
#P comment 730 430 179 196620 1. turn this rotation lfo on to set the camera rotating on its own axis.;
#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P comment 206 140 153 196617 camera rotation around its orbit;
#P comment 680 105 153 196617 camera rotation on its own axis;
#P comment 745 170 123 196617 * fix offset;
#P newex 680 170 64 196617 + 1.570796;
#P flonum 680 151 35 9 0 0 0 3 0 0 0 94 232 0 222 222 222 0 0 0;
#P comment 718 152 123 196617 rotation around x/z axes;
#P newex 722 318 47 196617 poltocar;
#P newex 722 295 29 196617 * 1.;
#P newex 680 295 29 196617 * 1.;
#P flonum 722 253 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 680 253 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 680 192 67 196617 % 6.283186;
#P newex 722 230 23 196617 cos;
#P newex 680 230 21 196617 sin;
#P newex 190 410 40 196617 t f b f;
#P newex 148 410 40 196617 t f b f;
#P newex 106 410 40 196617 t f b f;
#P comment 109 354 121 196617 adjust center of rotation;
#P comment 201 373 14 196617 z;
#P comment 119 373 14 196617 x;
#P flonum 148 389 35 9 0 0 0 3 0 0 0 94 232 0 222 222 222 0 0 0;
#P flonum 190 389 35 9 0 0 0 3 0 0 0 94 232 0 222 222 222 0 0 0;
#P flonum 106 389 35 9 0 0 0 3 0 0 0 94 232 0 222 222 222 0 0 0;
#P comment 156 373 14 196617 y;
#P newex 328 452 27 196617 + 0.;
#P newex 288 452 27 196617 + 0.;
#P newex 248 452 27 196617 + 0.;
#P newex 64 475 138 196617 pak lookat 0. 0. 0.;
#P newex 47 661 618 196617 jit.gl.gridshape sphere_rotate @shape cube @scale 10. 10. 10. @poly_mode 1 1 @lighting_enable 1 @depth_enable 1 @color 1. 1. 0. 1.;
#P newex 286 261 53 196617 t b b f f;
#P window linecount 2;
#P comment 451 226 168 196617 choose y-rotation behavior ; 1 is like doing flips around the ball ;;
#P window linecount 1;
#P newex 427 272 37 196617 abs 0.;
#P window linecount 2;
#P comment 286 215 106 196617 change amplitude (distance from object);
#P flonum 286 241 35 9 0 0 0 3 0 0 0 94 232 0 222 222 222 0 0 0;
#P window linecount 1;
#P newex 427 295 240 196617 if $f1 < 1.570796 || $f1 > 4.71239 then 1. else -1.;
#P window setfont Times 10.;
#P comment 433 386 48 1310730 up vector;
#P comment 484 400 39 1310730 z;
#P comment 442 400 39 1310730 y;
#P comment 399 400 39 1310730 x;
#P window setfont “Fixedwidth Serif” 9.;
#P flonum 468 416 39 9 0 0 0 22 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 427 416 39 9 0 0 0 22 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 386 416 39 9 0 0 0 22 0 0 0 221 221 221 222 222 222 0 0 0;
#P window setfont “Fixedwidth Serif” 10.;
#P newex 345 475 133 1441802 pak up 0. 1. 0.;
#P window setfont “Sans Serif” 9.;
#P flonum 206 164 35 9 0 0 0 3 0 0 0 94 232 0 222 222 222 0 0 0;
#P newex 47 638 468 196617 jit.gl.gridshape sphere_rotate @shape cube @scale 1.5 0.05 0.5 @lighting_enable 1 @depth_enable 1;
#P newex 208 475 131 196617 pak camera 0. 0. 0.;
#P newex 47 616 450 196617 jit.gl.gridshape sphere_rotate @shape sphere @scale 1. 1. 1. @lighting_enable 1 @depth_enable 1;
#P toggle 574 419 15 0;
#P newex 574 464 58 196617 t b b erase;
#P newex 574 442 52 196617 metro 20;
#P newex 240 573 363 196617 jit.gl.render sphere_rotate @erase_color 0. 0. 0. 1 @axes 1 @camera 4. 0. 0.;
#P newex 47 595 251 196617 jit.window sphere_rotate @depthbuffer 1 @floating 1;
#P comment 305 314 112 196617 rotation around y axis;
#P comment 244 165 123 196617 rotation around x/z axes;
#P comment 339 395 14 196617 z;
#P comment 261 395 14 196617 x;
#P newex 266 335 29 196617 t b f;
#P flonum 288 411 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 328 411 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 248 411 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 266 313 35 9 0 0 0 3 0 0 0 94 232 0 222 222 222 0 0 0;
#P newex 248 362 47 196617 poltocar;
#P newex 248 289 29 196617 * 4.;
#P newex 206 289 29 196617 * 4.;
#P flonum 248 247 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 206 247 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 206 186 67 196617 % 6.283186;
#P newex 248 224 23 196617 cos;
#P newex 206 224 21 196617 sin;
#P comment 296 395 14 196617 y;
#P connect 73 0 76 0;
#P connect 73 0 86 0;
#P connect 58 0 56 0;
#P fasten 58 0 57 0 685 212 727 212;
#P connect 3 0 1 0;
#P fasten 3 0 2 0 211 206 253 206;
#P fasten 3 0 38 0 211 206 432 206;
#P connect 79 0 78 1;
#P connect 77 1 78 0;
#P connect 78 0 74 0;
#P connect 90 0 65 0;
#P connect 88 0 87 0;
#P fasten 21 1 87 1 603 508 768 508;
#P connect 87 0 77 0;
#P fasten 83 0 73 0 845 641 749 641;
#P connect 82 0 74 1;
#P connect 81 0 74 1;
#P connect 77 0 73 0;
#P fasten 21 2 19 0 627 527 245 527;
#P fasten 21 0 19 0 579 527 245 527;
#P fasten 20 0 21 0 579 463;
#P connect 75 0 73 1;
#P connect 74 0 75 0;
#P connect 47 0 53 0;
#P connect 53 0 42 1;
#P connect 49 0 54 0;
#P connect 54 0 42 2;
#P connect 48 0 55 0;
#P connect 55 0 42 3;
#P connect 26 0 3 0;
#P connect 1 0 4 0;
#P connect 4 0 6 0;
#P fasten 40 0 6 0 291 283 211 283;
#P fasten 40 2 6 1 319 283 230 283;
#P connect 22 0 20 0;
#P fasten 42 0 19 0 69 568 245 568;
#P fasten 27 0 19 0 350 568 245 568;
#P fasten 24 0 19 0 213 568 245 568;
#P connect 2 0 5 0;
#P connect 5 0 7 0;
#P fasten 40 1 7 0 305 283 253 283;
#P fasten 13 0 8 0 271 357 253 357;
#P connect 7 0 8 0;
#P connect 8 0 10 0;
#P connect 53 1 43 0;
#P lcolor 10;
#P connect 10 0 43 0;
#P connect 43 0 24 1;
#P connect 53 2 43 1;
#P lcolor 10;
#P connect 9 0 13 0;
#P fasten 40 3 7 1 333 283 272 283;
#P connect 13 1 8 1;
#P connect 36 0 40 0;
#P connect 6 0 12 0;
#P connect 54 1 44 0;
#P lcolor 10;
#P connect 12 0 44 0;
#P connect 44 0 24 2;
#P connect 54 2 44 1;
#P lcolor 10;
#P fasten 8 1 11 0 290 387 333 387;
#P connect 55 1 45 0;
#P lcolor 10;
#P connect 11 0 45 0;
#P connect 45 0 24 3;
#P connect 55 2 45 1;
#P lcolor 10;
#P fasten 63 0 28 0 727 377 391 377;
#P connect 28 0 27 1;
#P connect 38 0 35 0;
#P connect 72 0 71 0;
#P connect 35 0 71 0;
#P connect 71 0 29 0;
#P connect 29 0 27 2;
#P fasten 61 0 72 0 685 323 440 323;
#P connect 72 1 71 1;
#P fasten 63 1 30 0 764 377 473 377;
#P connect 30 0 27 3;
#P connect 65 0 66 0;
#P connect 66 0 58 0;
#P connect 56 0 59 0;
#P connect 59 0 61 0;
#P connect 57 0 60 0;
#P connect 60 0 62 0;
#P connect 62 0 63 0;
#P window clipboard copycount 92;

#111402
Sep 11, 2007 at 9:48am

Don’t have max at my disposal to try your patch, but maybe this can be of
help…
(you might be able to get the rotation of your camera, while staying
focussed, figured out using the ‘up’ of the cam)

max v2;
#N vpatcher 72 44 1024 767;
#P origin 13 -12;
#P newex 532 25 45 196617 loadbang;
#P toggle 246 89 15 0;
#P newex 246 108 51 196617 metro 40;
#P message 238 159 14 196617 1;
#P message 223 159 14 196617 0;
#P message 208 159 14 196617 0;
#P message 193 159 14 196617 1;
#P message 58 134 14 196617 1;
#P message 16 134 14 196617 1;
#P message 154 134 14 196617 0;
#P message 112 134 14 196617 0;
#P newex 58 159 27 196617 gate;
#P newex 16 159 27 196617 gate;
#P newex 16 110 95 196617 select 28 29 30 31;
#P newex 112 89 40 196617 keyup;
#P newex 112 110 95 196617 select 28 29 30 31;
#P newex 16 89 40 196617 key;
#P newex 16 212 39 196617 / 100.;
#N counter 1 628;
#X flags 0 0;
#P newobj 16 189 73 196617 counter 1 628;
#P button 446 105 15 0;
#P newex 419 136 72 196617 expr $f1*$f2;
#P button 395 99 15 0;
#P newex 315 136 101 196617 expr ($f1*-1)* $f2;
#P newex 439 78 23 196617 cos;
#P newex 406 78 21 196617 sin;
#P flonum 406 57 56 9 0.001 6.28318 3 3 0 0 0 221 221 221 222 222 222 0
0 0;
#P newex 358 78 23 196617 cos;
#P newex 325 78 21 196617 sin;
#P flonum 315 163 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P message 702 154 23 196617 0.1;
#P newex 667 134 45 196617 select 1;
#P message 667 154 29 196617 -0.1;
#P newex 667 114 38 196617 > 3.14;
#P flonum 703 174 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 667 174 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 631 174 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 625 202 73 196617 pak up 0. 0. 0.;
#P newex 90 212 39 196617 / 100.;
#N counter 1 628;
#X flags 0 0;
#P newobj 90 189 73 196617 counter 1 628;
#P flonum 325 57 56 9 0.001 6.283 3 3 0 0 0 221 221 221 222 222 222 0 0
0;
#P flonum 387 163 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 351 163 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 303 185 95 196617 pak camera 0. 0. 0.;
#P message 294 292 161 196617 reset , cube 0.2 , lighting_enable 1;
#P newex 294 312 80 196617 jit.gl.sketch obj;
#P newex 445 247 54 196617 fullscreen;
#P newex 445 267 128 196617 jit.window obj @floating 1;
#P button 502 182 15 0;
#P newex 495 202 129 196617 pak erase_color 0. 0. 0. 1.;
#P newex 445 202 49 196617 t b erase;
#P toggle 445 164 15 0;
#P newex 445 182 55 196617 qmetro 40;
#P newex 445 226 81 196617 jit.gl.render obj;
#P comment 11 266 232 196617 left/right arrowkeys = mx = range of 0 to
2 pi up/down arrowkeys = my = range of 0 to 2 pi x , y , x = y =
cos(my) x = -cos(mx) * sin(my) z = sin(mx) * sin(my);
#P comment 11 239 192 196617 arrowkeys move the camera over the surface
of a sphere looking at it’s center.;
#P connect 38 0 41 0;
#P fasten 41 1 46 0 42 129 21 129;
#P connect 41 0 46 0;
#P connect 46 0 42 0;
#P fasten 44 0 42 0 117 152 21 152;
#P fasten 42 0 36 0 21 196 21 196;
#P connect 36 0 37 0;
#P fasten 49 0 36 1 213 181 36 181;
#P fasten 48 0 36 1 198 179 36 179;
#P fasten 52 0 42 1 251 152 38 152;
#P fasten 41 3 47 0 84 129 63 129;
#P connect 41 2 47 0;
#P connect 47 0 43 0;
#P fasten 45 0 43 0 159 152 63 152;
#P fasten 52 0 43 1 251 152 80 152;
#P fasten 43 0 16 0 63 183 95 183;
#P connect 16 0 17 0;
#P fasten 51 0 16 1 243 185 110 185;
#P fasten 50 0 16 1 228 183 110 183;
#P connect 40 0 39 0;
#P fasten 39 1 44 0 138 129 117 129;
#P connect 39 0 44 0;
#P fasten 39 3 45 0 180 129 159 129;
#P connect 39 2 45 0;
#P fasten 41 0 48 0 21 131 198 131;
#P fasten 41 1 49 0 42 131 213 131;
#P fasten 41 2 50 0 63 131 228 131;
#P fasten 41 3 51 0 84 131 243 131;
#P fasten 54 0 53 0 537 44 251 44;
#P connect 53 0 52 0;
#P fasten 54 0 11 0 537 44 299 44;
#P connect 11 0 10 0;
#P fasten 33 0 32 0 400 121 320 121;
#P fasten 28 0 32 0 363 100 320 100;
#P connect 32 0 26 0;
#P fasten 37 0 15 0 21 233 13 233 13 54 330 54;
#P connect 15 0 27 0;
#P fasten 26 0 12 1 320 181 336 181;
#P fasten 31 0 13 0 444 155 356 155;
#P fasten 15 0 28 0 330 75 363 75;
#P fasten 13 0 12 2 356 181 364 181;
#P fasten 34 0 14 0 424 158 392 158;
#P connect 14 0 12 3;
#P fasten 30 0 33 0 411 97 400 97;
#P fasten 17 0 29 0 95 235 11 235 11 52 411 52;
#P connect 29 0 30 0;
#P connect 30 0 32 1;
#P fasten 35 0 34 0 451 133 424 133;
#P fasten 27 0 34 0 330 118 424 118;
#P fasten 29 0 31 0 411 75 444 75;
#P fasten 54 0 4 0 537 159 450 159;
#P connect 4 0 3 0;
#P connect 3 0 5 0;
#P fasten 12 0 2 0 308 269 450 269;
#P fasten 6 0 2 0 500 222 450 222;
#P fasten 5 1 2 0 489 222 450 222;
#P connect 5 0 2 0;
#P fasten 18 0 2 0 630 222 450 222;
#P connect 9 0 8 0;
#P fasten 30 0 35 0 411 102 451 102;
#P fasten 30 0 34 1 411 97 486 97;
#P fasten 7 0 6 0 507 198 500 198;
#P fasten 4 0 7 0 450 179 507 179;
#P fasten 19 0 18 1 636 195 651 195;
#P fasten 29 0 22 0 411 75 672 75;
#P connect 22 0 24 0;
#P connect 24 0 23 0;
#P fasten 25 0 20 0 707 171 672 171;
#P connect 23 0 20 0;
#P connect 20 0 18 2;
#P fasten 21 0 18 3 708 195 693 195;
#P connect 24 1 25 0;
#P pop;

>
> Quote: Zachary Seldess wrote on Tue, 11 September 2007 04:55
> —————————————————-
>> Hi Justin,
>>
>> What do you mean by “locked on the object” – do you mean that you want
>> to rotate your camera while keeping your lookat point focussed on the
>> object? Or something else?
>>
>> Zachary
> —————————————————-
>
> yes, so that as the camera is “orbiting” around the object, it is also
> spinning on its own axis. but only on an axis which will enable it to
> remain focused on the object, otherwise it would not be looking at the
> central object.
>
> i’ve had another go at it this morning, but the problem seems to be
> different then i first thought. the rotation now sort of works but it’s
> not steady, seems to accelerate at certain points…. hmmm, back to the
> trig then – and cheers for looking into it.
>
> below is a new version of the patch with comments.
>
> j
>
> #P window setfont “Sans Serif” 12.;
> #P window linecount 4;
> #P comment 198 72 227 196620 2. experiment with the x/z and the y axes -
> you should notice flips when at 0. and strange accelerations in rotation
> on other than 0.;
> #P window setfont “Sans Serif” 9.;
> #P window linecount 1;
> #P newex 680 125 32 196617 r rot;
> #P comment 771 516 123 196617 turn rotation lfo on / off;
> #P toggle 744 515 15 0;
> #P newex 744 535 29 196617 gate;
> #P newex 753 667 32 196617 s rot;
> #P comment 855 624 123 196617 reset;
> #P comment 874 580 123 196617 direction;
> #P message 840 624 14 196617 0;
> #P message 840 580 33 196617 -360;
> #P message 815 580 26 196617 360;
> #P comment 824 561 123 196617 degrees per render bang;
> #P flonum 788 561 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
> #P newex 764 580 32 196617 f 0.1;
> #P newex 744 558 30 196617 t b b;
> #P flonum 744 694 57 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
> #P newex 764 620 68 196617 * 6.283185;
> #P newex 764 599 40 196617 / 360.;
> #P newex 744 643 50 196617 accum 0.;
> #P newex 435 330 29 196617 t b f;
> #P newex 427 354 37 196617 * 1.;
> #P window setfont “Sans Serif” 12.;
> #P window linecount 3;
> #P comment 730 430 179 196620 1. turn this rotation lfo on to set the
> camera rotating on its own axis.;
> #P window setfont “Sans Serif” 9.;
> #P window linecount 1;
> #P comment 206 140 153 196617 camera rotation around its orbit;
> #P comment 680 105 153 196617 camera rotation on its own axis;
> #P comment 745 170 123 196617 * fix offset;
> #P newex 680 170 64 196617 + 1.570796;
> #P flonum 680 151 35 9 0 0 0 3 0 0 0 94 232 0 222 222 222 0 0 0;
> #P comment 718 152 123 196617 rotation around x/z axes;
> #P newex 722 318 47 196617 poltocar;
> #P newex 722 295 29 196617 * 1.;
> #P newex 680 295 29 196617 * 1.;
> #P flonum 722 253 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
> #P flonum 680 253 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
> #P newex 680 192 67 196617 % 6.283186;
> #P newex 722 230 23 196617 cos;
> #P newex 680 230 21 196617 sin;
> #P newex 190 410 40 196617 t f b f;
> #P newex 148 410 40 196617 t f b f;
> #P newex 106 410 40 196617 t f b f;
> #P comment 109 354 121 196617 adjust center of rotation;
> #P comment 201 373 14 196617 z;
> #P comment 119 373 14 196617 x;
> #P flonum 148 389 35 9 0 0 0 3 0 0 0 94 232 0 222 222 222 0 0 0;
> #P flonum 190 389 35 9 0 0 0 3 0 0 0 94 232 0 222 222 222 0 0 0;
> #P flonum 106 389 35 9 0 0 0 3 0 0 0 94 232 0 222 222 222 0 0 0;
> #P comment 156 373 14 196617 y;
> #P newex 328 452 27 196617 + 0.;
> #P newex 288 452 27 196617 + 0.;
> #P newex 248 452 27 196617 + 0.;
> #P newex 64 475 138 196617 pak lookat 0. 0. 0.;
> #P newex 47 661 618 196617 jit.gl.gridshape sphere_rotate @shape cube
> @scale 10. 10. 10. @poly_mode 1 1 @lighting_enable 1 @depth_enable 1
> @color 1. 1. 0. 1.;
> #P newex 286 261 53 196617 t b b f f;
> #P window linecount 2;
> #P comment 451 226 168 196617 choose y-rotation behavior ; 1 is like
> doing flips around the ball ;;
> #P window linecount 1;
> #P newex 427 272 37 196617 abs 0.;
> #P window linecount 2;
> #P comment 286 215 106 196617 change amplitude (distance from object);
> #P flonum 286 241 35 9 0 0 0 3 0 0 0 94 232 0 222 222 222 0 0 0;
> #P window linecount 1;
> #P newex 427 295 240 196617 if $f1 < 1.570796 || $f1 > 4.71239 then 1.
> else -1.;
> #P window setfont Times 10.;
> #P comment 433 386 48 1310730 up vector;
> #P comment 484 400 39 1310730 z;
> #P comment 442 400 39 1310730 y;
> #P comment 399 400 39 1310730 x;
> #P window setfont “Fixedwidth Serif” 9.;
> #P flonum 468 416 39 9 0 0 0 22 0 0 0 221 221 221 222 222 222 0 0 0;
> #P flonum 427 416 39 9 0 0 0 22 0 0 0 221 221 221 222 222 222 0 0 0;
> #P flonum 386 416 39 9 0 0 0 22 0 0 0 221 221 221 222 222 222 0 0 0;
> #P window setfont “Fixedwidth Serif” 10.;
> #P newex 345 475 133 1441802 pak up 0. 1. 0.;
> #P window setfont “Sans Serif” 9.;
> #P flonum 206 164 35 9 0 0 0 3 0 0 0 94 232 0 222 222 222 0 0 0;
> #P newex 47 638 468 196617 jit.gl.gridshape sphere_rotate @shape cube
> @scale 1.5 0.05 0.5 @lighting_enable 1 @depth_enable 1;
> #P newex 208 475 131 196617 pak camera 0. 0. 0.;
> #P newex 47 616 450 196617 jit.gl.gridshape sphere_rotate @shape sphere
> @scale 1. 1. 1. @lighting_enable 1 @depth_enable 1;
> #P toggle 574 419 15 0;
> #P newex 574 464 58 196617 t b b erase;
> #P newex 574 442 52 196617 metro 20;
> #P newex 240 573 363 196617 jit.gl.render sphere_rotate @erase_color 0. 0.
> 0. 1 @axes 1 @camera 4. 0. 0.;
> #P newex 47 595 251 196617 jit.window sphere_rotate @depthbuffer 1
> @floating 1;
> #P comment 305 314 112 196617 rotation around y axis;
> #P comment 244 165 123 196617 rotation around x/z axes;
> #P comment 339 395 14 196617 z;
> #P comment 261 395 14 196617 x;
> #P newex 266 335 29 196617 t b f;
> #P flonum 288 411 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
> #P flonum 328 411 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
> #P flonum 248 411 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
> #P flonum 266 313 35 9 0 0 0 3 0 0 0 94 232 0 222 222 222 0 0 0;
> #P newex 248 362 47 196617 poltocar;
> #P newex 248 289 29 196617 * 4.;
> #P newex 206 289 29 196617 * 4.;
> #P flonum 248 247 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
> #P flonum 206 247 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
> #P newex 206 186 67 196617 % 6.283186;
> #P newex 248 224 23 196617 cos;
> #P newex 206 224 21 196617 sin;
> #P comment 296 395 14 196617 y;
> #P connect 73 0 76 0;
> #P connect 73 0 86 0;
> #P connect 58 0 56 0;
> #P fasten 58 0 57 0 685 212 727 212;
> #P connect 3 0 1 0;
> #P fasten 3 0 2 0 211 206 253 206;
> #P fasten 3 0 38 0 211 206 432 206;
> #P connect 79 0 78 1;
> #P connect 77 1 78 0;
> #P connect 78 0 74 0;
> #P connect 90 0 65 0;
> #P connect 88 0 87 0;
> #P fasten 21 1 87 1 603 508 768 508;
> #P connect 87 0 77 0;
> #P fasten 83 0 73 0 845 641 749 641;
> #P connect 82 0 74 1;
> #P connect 81 0 74 1;
> #P connect 77 0 73 0;
> #P fasten 21 2 19 0 627 527 245 527;
> #P fasten 21 0 19 0 579 527 245 527;
> #P fasten 20 0 21 0 579 463;
> #P connect 75 0 73 1;
> #P connect 74 0 75 0;
> #P connect 47 0 53 0;
> #P connect 53 0 42 1;
> #P connect 49 0 54 0;
> #P connect 54 0 42 2;
> #P connect 48 0 55 0;
> #P connect 55 0 42 3;
> #P connect 26 0 3 0;
> #P connect 1 0 4 0;
> #P connect 4 0 6 0;
> #P fasten 40 0 6 0 291 283 211 283;
> #P fasten 40 2 6 1 319 283 230 283;
> #P connect 22 0 20 0;
> #P fasten 42 0 19 0 69 568 245 568;
> #P fasten 27 0 19 0 350 568 245 568;
> #P fasten 24 0 19 0 213 568 245 568;
> #P connect 2 0 5 0;
> #P connect 5 0 7 0;
> #P fasten 40 1 7 0 305 283 253 283;
> #P fasten 13 0 8 0 271 357 253 357;
> #P connect 7 0 8 0;
> #P connect 8 0 10 0;
> #P connect 53 1 43 0;
> #P lcolor 10;
> #P connect 10 0 43 0;
> #P connect 43 0 24 1;
> #P connect 53 2 43 1;
> #P lcolor 10;
> #P connect 9 0 13 0;
> #P fasten 40 3 7 1 333 283 272 283;
> #P connect 13 1 8 1;
> #P connect 36 0 40 0;
> #P connect 6 0 12 0;
> #P connect 54 1 44 0;
> #P lcolor 10;
> #P connect 12 0 44 0;
> #P connect 44 0 24 2;
> #P connect 54 2 44 1;
> #P lcolor 10;
> #P fasten 8 1 11 0 290 387 333 387;
> #P connect 55 1 45 0;
> #P lcolor 10;
> #P connect 11 0 45 0;
> #P connect 45 0 24 3;
> #P connect 55 2 45 1;
> #P lcolor 10;
> #P fasten 63 0 28 0 727 377 391 377;
> #P connect 28 0 27 1;
> #P connect 38 0 35 0;
> #P connect 72 0 71 0;
> #P connect 35 0 71 0;
> #P connect 71 0 29 0;
> #P connect 29 0 27 2;
> #P fasten 61 0 72 0 685 323 440 323;
> #P connect 72 1 71 1;
> #P fasten 63 1 30 0 764 377 473 377;
> #P connect 30 0 27 3;
> #P connect 65 0 66 0;
> #P connect 66 0 58 0;
> #P connect 56 0 59 0;
> #P connect 59 0 61 0;
> #P connect 57 0 60 0;
> #P connect 60 0 62 0;
> #P connect 62 0 63 0;
> #P window clipboard copycount 92;
>
>

#111403
Sep 11, 2007 at 1:04pm

You’re going to have to contanstly manipulate the up vector as you rotate. I’ll look into this when I have more time. Here’s a modified version of my previous patch. Toggle the gate to off and, change the ‘up’ and then rotate. You’ll see that the ‘up’ doesn’t get redefined as you rotate – that’s the tricky part. If you only manipulate two of the three axis of the up vector you’re going to get an unsteady rate of rotation – markedly as you get close to aligning with one of the changing axes. So we have to figure out the formula for changing all three up axes.

Also, Brecht, nice patch. It offers a slightly different approach.

max v2;
#N vpatcher 448 132 1281 833;
#P origin 0 -13;
#P toggle 431 189 15 0;
#P window setfont Geneva 9.;
#P flonum 431 300 35 9 0 0 0 3 0 0 0 94 232 0 222 222 222 0 0 0;
#P window linecount 1;
#P comment 469 301 128 196617 rotate camera’s up vector;
#P newex 431 322 67 196617 % 6.283186;
#P newex 390 349 23 196617 cos;
#P newex 431 349 21 196617 sin;
#P hidden newex 183 160 38 196617 t 0. 0.;
#P newex 293 175 53 196617 t b f b f;
#P newex 211 213 67 196617 % 6.283186;
#P newex 291 262 29 196617 * 4.;
#P newex 211 262 29 196617 * 4.;
#P newex 291 239 23 196617 cos;
#P newex 211 239 21 196617 sin;
#P comment 42 492 133 196617 type ‘t’ toggle trails on/off;
#P toggle 122 528 15 0;
#N vpatcher 10 59 198 227;
#P outlet 67 112 15 0;
#P window setfont Geneva 9.;
#P newex 67 59 40 196617 itoa;
#P newex 67 82 30 196617 sel t;
#P newex 67 36 40 196617 key;
#P connect 0 0 2 0;
#P connect 2 0 1 0;
#P connect 1 0 3 0;
#P pop;
#P newobj 122 507 47 196617 p on/off;
#B color 12;
#P window setfont “Sans Serif” 9.;
#P message 88 507 31 131137545 reset;
#P window setfont Geneva 9.;
#N vpatcher 71 371 364 615;
#P window setfont Geneva 9.;
#P window linecount 1;
#P newex 44 147 44 196617 qlim 50;
#P inlet 44 46 15 0;
#P toggle 44 70 15 0;
#P window linecount 0;
#P newex 44 94 29 196617 gate;
#P inlet 63 46 15 0;
#P inlet 23 46 15 0;
#P newex 44 125 70 196617 route camera;
#P window setfont “Sans Serif” 9.;
#P message 44 169 135 131137545 glcolor 1. 1. 1. , point $1 $2 $3;
#P message 12 27 31 131137545 reset;
#P window setfont Geneva 9.;
#P newex 44 193 213 196617 jit.gl.sketch sphere_rotate @color 1. 0. 0. 1.;
#P connect 8 0 7 0;
#P connect 7 0 6 0;
#P connect 6 0 3 0;
#P connect 3 0 9 0;
#P connect 9 0 2 0;
#P fasten 4 0 0 0 28 188 49 188;
#P fasten 1 0 0 0 17 188 49 188;
#P connect 2 0 0 0;
#P connect 5 0 6 1;
#P pop;
#P newobj 88 547 78 196617 p trails;
#B color 12;
#P hidden newex 183 136 48 196617 loadbang;
#P newex 153 407 40 196617 t f b f;
#P newex 111 407 40 196617 t f b f;
#P newex 69 407 40 196617 t f b f;
#P comment 72 351 121 196617 adjust center of rotation;
#P comment 164 370 14 196617 z;
#P comment 82 370 14 196617 x;
#P flonum 111 386 35 9 0 0 0 3 0 0 0 94 232 0 222 222 222 0 0 0;
#P flonum 153 386 35 9 0 0 0 3 0 0 0 94 232 0 222 222 222 0 0 0;
#P flonum 69 386 35 9 0 0 0 3 0 0 0 94 232 0 222 222 222 0 0 0;
#P comment 119 370 14 196617 y;
#P newex 291 449 27 196617 + 0.;
#P newex 251 449 27 196617 + 0.;
#P newex 211 449 27 196617 + 0.;
#P newex 27 472 138 196617 pak lookat 0. 0. 0.;
#P newex 10 658 618 196617 jit.gl.gridshape sphere_rotate @shape cube @scale 10. 10. 10. @poly_mode 1 1 @lighting_enable 1 @depth_enable 1 @color 1. 1. 0. 1.;
#P newex 331 125 53 196617 t b b f f;
#P window linecount 3;
#P comment 432 146 317 196617 choose y-rotation behavior ; 1 is like doing flips around the ball ; 0 will keep your view oriented so your up is always “above” you ;;
#P window linecount 1;
#P newex 431 213 47 196617 gate 1 1;
#P newex 468 191 37 196617 abs 0.;
#P window linecount 2;
#P comment 331 79 106 196617 change amplitude (distance from object);
#P flonum 331 105 35 9 0 0 0 3 0 0 0 94 232 0 222 222 222 0 0 0;
#P window linecount 1;
#P newex 431 238 271 196617 if $f1 < 1.570796 || $f1 > 4.71239 then 0. else 3.141593;
#P window setfont Times 10.;
#P comment 396 397 48 1310730 up vector;
#P comment 447 411 39 1310730 z;
#P comment 405 411 39 1310730 y;
#P comment 362 411 39 1310730 x;
#P window setfont “Fixedwidth Serif” 9.;
#P flonum 431 427 39 9 0 0 0 22 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 390 427 39 9 0 0 0 22 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 349 427 39 9 0 0 0 22 0 0 0 221 221 221 222 222 222 0 0 0;
#P window setfont “Fixedwidth Serif” 10.;
#P newex 308 472 133 1441802 pak up 0. 1. 0.;
#P window setfont Geneva 9.;
#P flonum 251 28 35 9 0 0 0 3 0 0 0 94 232 0 222 222 222 0 0 0;
#P newex 10 635 468 196617 jit.gl.gridshape sphere_rotate @shape cube @scale 1.5 0.05 0.5 @lighting_enable 1 @depth_enable 1;
#P newex 171 472 131 196617 pak camera 0. 0. 0.;
#P newex 10 613 450 196617 jit.gl.gridshape sphere_rotate @shape sphere @scale 1. 1. 1. @lighting_enable 1 @depth_enable 1;
#P toggle 203 498 15 0;
#P newex 203 543 50 196617 t b erase;
#P newex 203 521 52 196617 metro 20;
#P newex 203 570 363 196617 jit.gl.render sphere_rotate @erase_color 0. 0. 0. 1 @axes 1 @camera 4. 0. 0.;
#P newex 10 592 197 196617 jit.window sphere_rotate @depthbuffer 1;
#P comment 98 192 112 196617 rotation around y axis;
#P comment 289 29 123 196617 rotation around x/z axes;
#P comment 302 392 14 196617 z;
#P comment 224 392 14 196617 x;
#P flonum 251 408 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 291 408 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 211 408 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 211 191 35 9 0 0 0 3 0 0 0 94 232 0 222 222 222 0 0 0;
#P newex 293 153 29 196617 * 4.;
#P newex 251 153 29 196617 * 4.;
#P flonum 293 111 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 251 111 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 251 50 67 196617 % 6.283186;
#P newex 293 88 23 196617 cos;
#P newex 251 88 21 196617 sin;
#P comment 259 392 14 196617 y;
#P connect 46 0 52 0;
#P connect 52 0 41 1;
#P connect 57 0 56 0;
#P connect 48 0 53 0;
#P connect 53 0 41 2;
#P connect 58 0 59 0;
#P connect 59 0 56 1;
#P connect 47 0 54 0;
#P connect 54 0 41 3;
#P fasten 22 0 56 2 176 539 161 539;
#P hidden connect 55 0 67 0;
#P connect 20 0 18 0;
#P fasten 18 0 19 0 208 542;
#P fasten 22 0 17 0 176 565 208 565;
#P connect 19 0 17 0;
#P fasten 19 1 17 0 248 565 208 565;
#P fasten 25 0 17 0 313 565 208 565;
#P fasten 41 0 17 0 32 565 208 565;
#P hidden connect 67 1 8 0;
#P connect 8 0 65 0;
#P connect 65 0 61 0;
#P connect 61 0 63 0;
#P connect 66 0 63 0;
#P lcolor 3;
#P connect 63 0 9 0;
#P connect 9 0 42 0;
#P connect 52 1 42 0;
#P lcolor 10;
#P connect 42 0 22 1;
#P connect 52 2 42 1;
#P lcolor 10;
#P connect 66 1 63 1;
#P lcolor 3;
#P hidden connect 67 0 24 0;
#P connect 24 0 3 0;
#P connect 3 0 1 0;
#P connect 1 0 4 0;
#P fasten 39 0 6 0 336 147 256 147;
#P connect 4 0 6 0;
#P connect 6 0 11 0;
#P connect 11 0 43 0;
#P connect 53 1 43 0;
#P lcolor 10;
#P connect 43 0 22 2;
#P connect 53 2 43 1;
#P lcolor 10;
#P fasten 39 2 6 1 364 147 275 147;
#P fasten 65 0 62 0 216 234 296 234;
#P connect 62 0 64 0;
#P connect 66 2 64 0;
#P lcolor 3;
#P connect 64 0 10 0;
#P connect 10 0 44 0;
#P connect 54 1 44 0;
#P lcolor 10;
#P connect 44 0 22 3;
#P fasten 3 0 2 0 256 70 298 70;
#P connect 2 0 5 0;
#P fasten 39 1 7 0 350 147 298 147;
#P connect 5 0 7 0;
#P connect 7 0 66 0;
#P connect 54 2 44 1;
#P lcolor 10;
#P connect 66 3 64 1;
#P lcolor 3;
#P fasten 39 3 7 1 378 147 317 147;
#P connect 34 0 39 0;
#P connect 26 0 25 1;
#P fasten 70 0 69 0 436 344 395 344;
#P connect 69 0 27 0;
#P connect 27 0 25 2;
#P connect 73 0 37 0;
#P connect 37 0 33 0;
#P connect 33 0 72 0;
#P connect 72 0 70 0;
#P connect 70 0 68 0;
#P connect 68 0 28 0;
#P connect 28 0 25 3;
#P fasten 3 0 36 0 256 70 473 70;
#P connect 36 0 37 1;
#P pop;

#111404
Sep 12, 2007 at 9:24am

thanks for the replies.

zachary’s example is close to what i’m trying to achieve, but seems to suffer the same problem i had – which is the pole / acceleration issue.

hmm… think i’ll leave this on the shelf until i have more time to think about it!

j

#111405
Sep 12, 2007 at 4:38pm

Ok, here’s a version that “rolls” the camera smoothly no matter where the camera is rotated around the y axis, but the angle made between the pos y axis and the lookat point -> camera point vector must be 90 degrees. I’ve changed the patch to make it clearer. It’s getting there…

max v2;
#N vpatcher 448 132 1192 716;
#P origin 0 -13;
#P window setfont Geneva 9.;
#P window linecount 3;
#P comment 455 85 251 196617 Use the “adjust center of rotation coordinates to move camera around” , and “roll” will remain smooth. It’s a start!;
#P window linecount 1;
#P newex 395 132 29 196617 t b f;
#P newex 431 252 29 196617 * 1.;
#P newex 349 132 29 196617 t b f;
#P newex 349 252 29 196617 * 1.;
#N vpatcher 28 429 430 749;
#P window setfont Geneva 9.;
#P newex 179 79 107 196617 expr 6.283186 + $f1;
#P window linecount 0;
#P newex 23 55 166 196617 if $f1 >= 0. then $f1 else out2 $f1;
#P outlet 135 263 15 0;
#P window linecount 1;
#P newex 135 235 40 196617 change;
#P outlet 23 263 15 0;
#P inlet 23 32 15 0;
#P window linecount 0;
#P newex 23 235 40 196617 change;
#P window linecount 1;
#P newex 335 184 32 196617 t 1 1;
#P newex 219 184 37 196617 t -1 1;
#P newex 219 162 126 196617 split 3.141593 4.712389;
#P newex 23 139 37 196617 t 1 -1;
#P newex 103 141 126 196617 split 1.570796 3.141593;
#P newex 103 164 42 196617 t -1 -1;
#P newex 23 116 90 196617 split 0. 1.570796;
#P connect 8 0 12 0;
#P fasten 13 0 0 0 184 106 28 106;
#P connect 12 0 0 0;
#P connect 0 0 3 0;
#P connect 6 0 7 0;
#P connect 5 0 7 0;
#P connect 1 0 7 0;
#P connect 3 0 7 0;
#P connect 7 0 9 0;
#P connect 0 1 2 0;
#P connect 2 0 1 0;
#P connect 6 1 10 0;
#P connect 5 1 10 0;
#P connect 1 1 10 0;
#P connect 3 1 10 0;
#P connect 10 0 11 0;
#P connect 12 1 13 0;
#P connect 2 1 4 0;
#P connect 4 0 5 0;
#P connect 4 1 6 0;
#P pop;
#P newobj 349 107 56 196617 p routeSin;
#B color 12;
#P flonum 431 168 35 9 0 0 0 3 0 0 0 94 232 0 222 222 222 0 0 0;
#P comment 469 169 165 196617 rotate camera’s up vector (“roll”);
#P newex 431 190 67 196617 % 6.283186;
#P newex 390 217 23 196617 cos;
#P newex 431 217 21 196617 sin;
#P newex 211 81 67 196617 % 6.283186;
#P newex 291 130 29 196617 * 4.;
#P newex 211 130 29 196617 * 4.;
#P newex 291 107 23 196617 cos;
#P newex 211 107 21 196617 sin;
#P hidden newex 211 33 63 196617 loadmess 0.;
#P newex 153 275 40 196617 t f b f;
#P newex 111 275 40 196617 t f b f;
#P newex 69 275 40 196617 t f b f;
#P comment 72 219 121 196617 adjust center of rotation;
#P comment 164 238 14 196617 z;
#P comment 82 238 14 196617 x;
#P flonum 111 254 35 9 0 0 0 3 0 0 0 94 232 0 222 222 222 0 0 0;
#P flonum 153 254 35 9 0 0 0 3 0 0 0 94 232 0 222 222 222 0 0 0;
#P flonum 69 254 35 9 0 0 0 3 0 0 0 94 232 0 222 222 222 0 0 0;
#P comment 119 238 14 196617 y;
#P newex 291 317 27 196617 + 0.;
#P newex 251 317 27 196617 + 0.;
#P newex 211 317 27 196617 + 0.;
#P newex 27 340 138 196617 pak lookat 0. 0. 0.;
#P newex 10 526 618 196617 jit.gl.gridshape sphere_rotate @shape cube @scale 10. 10. 10. @poly_mode 1 1 @lighting_enable 1 @depth_enable 1 @color 1. 1. 0. 1.;
#P window setfont Times 10.;
#P comment 396 290 48 1310730 up vector;
#P comment 447 304 39 1310730 z;
#P comment 405 304 39 1310730 y;
#P comment 362 304 39 1310730 x;
#P window setfont “Fixedwidth Serif” 9.;
#P flonum 431 320 39 9 0 0 0 22 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 390 320 39 9 0 0 0 22 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 349 320 39 9 0 0 0 22 0 0 0 221 221 221 222 222 222 0 0 0;
#P window setfont “Fixedwidth Serif” 10.;
#P newex 308 340 133 1441802 pak up 0. 1. 0.;
#P window setfont Geneva 9.;
#P newex 10 503 468 196617 jit.gl.gridshape sphere_rotate @shape cube @scale 1.5 0.05 0.5 @lighting_enable 1 @depth_enable 1;
#P newex 171 340 131 196617 pak camera 0. 0. 0.;
#P newex 10 481 450 196617 jit.gl.gridshape sphere_rotate @shape sphere @scale 1. 1. 1. @lighting_enable 1 @depth_enable 1;
#P toggle 203 366 15 0;
#P newex 203 411 50 196617 t b erase;
#P newex 203 389 52 196617 metro 20;
#P newex 203 438 363 196617 jit.gl.render sphere_rotate @erase_color 0. 0. 0. 1 @axes 1 @camera 4. 0. 0.;
#P newex 10 460 197 196617 jit.window sphere_rotate @depthbuffer 1;
#P comment 98 60 112 196617 rotation around y axis;
#P comment 302 260 14 196617 z;
#P comment 224 260 14 196617 x;
#P flonum 251 276 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 291 276 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 211 276 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 211 59 35 9 0 0 0 3 0 0 0 94 232 0 222 222 222 0 0 0;
#P comment 259 260 14 196617 y;
#P window linecount 3;
#P comment 455 41 251 196617 Camera “rolls” smoothly now , as long as the vector from lookat point to camera creates a 90 degree angle with positive y axis.;
#P user panel 450 32 262 100;
#X brgb 163 172 233;
#X frgb 0 0 0;
#X border 0;
#X rounded 0;
#X shadow 0;
#X done;
#P connect 32 0 38 0;
#P connect 38 0 27 1;
#P connect 34 0 39 0;
#P connect 39 0 27 2;
#P connect 33 0 40 0;
#P connect 40 0 27 3;
#P connect 14 0 12 0;
#P fasten 12 0 13 0 208 410;
#P fasten 16 0 11 0 176 433 208 433;
#P connect 13 0 11 0;
#P fasten 13 1 11 0 248 433 208 433;
#P fasten 18 0 11 0 313 433 208 433;
#P fasten 27 0 11 0 32 433 208 433;
#P hidden connect 41 0 3 0;
#P connect 3 0 46 0;
#P connect 46 0 42 0;
#P connect 42 0 44 0;
#P connect 44 0 4 0;
#P connect 4 0 28 0;
#P connect 38 1 28 0;
#P lcolor 10;
#P connect 28 0 16 1;
#P connect 38 2 28 1;
#P lcolor 10;
#P connect 6 0 29 0;
#P connect 39 1 29 0;
#P lcolor 10;
#P connect 29 0 16 2;
#P connect 39 2 29 1;
#P lcolor 10;
#P fasten 46 0 43 0 216 102 296 102;
#P connect 43 0 45 0;
#P connect 45 0 5 0;
#P connect 5 0 30 0;
#P connect 40 1 30 0;
#P lcolor 10;
#P connect 30 0 16 3;
#P connect 40 2 30 1;
#P lcolor 10;
#P fasten 46 0 52 0 216 102 354 102;
#P connect 52 0 54 0;
#P connect 47 0 53 0;
#P connect 53 0 19 0;
#P connect 19 0 18 1;
#P connect 54 1 53 1;
#P lcolor 2;
#P fasten 49 0 48 0 436 212 395 212;
#P connect 48 0 20 0;
#P connect 20 0 18 2;
#P connect 52 1 56 0;
#P connect 51 0 49 0;
#P connect 49 0 47 0;
#P connect 56 0 47 0;
#P lcolor 2;
#P connect 54 0 47 0;
#P lcolor 2;
#P connect 47 0 55 0;
#P connect 55 0 21 0;
#P connect 21 0 18 3;
#P connect 56 1 55 1;
#P lcolor 2;
#P pop;

#111406
Sep 12, 2007 at 4:50pm

correction: lookat point -> camera point vector must be perpendicular to y axis (not just pos y).

#111407
Sep 13, 2007 at 10:13am

presumably the perpendicular angle is to keep the camera focused on object whilst keeping it at the right distance from the centre?
so the equation needs to maintain that angle as it rotates round the x axis and / or the y axis…

i’m trying to come up with something helpful but need more coffee – keep em coming!

j

#111408
Sep 14, 2007 at 3:46am

The perpendicular angle with the y axis has to do with the way the x and z axes relate. As you “roll, the x and z up values are either the same or oppositely signed – depending on how the camera is rotated around the y axis. Look in “p modSin” to see how this works. And watch how the x and z axes either rotate together or in exact opposite directions depending on where the camera is.

This seems like a fine way to do it, if we don’t want to vertically rotate. The math is more complex if we do though…

#111409

You must be logged in to reply to this topic.