From: Chris L. <chr...@sp...> - 2006-12-14 21:48:39
|
I'm trying to rotate the camera around an object: from visual import * scene.background = (.6,.6,.6) from visual import frame, cylinder groundframe = frame() g = cylinder(frame = groundframe, radius =10 , red = 0, blue = 0, axis = (0,0,-.1),opacity= .2) from visual import frame, arrow, label opacity = 0.1 shaftwidth = .005 axisframe = frame() labelframe = frame() xeaxis = arrow(frame = axisframe, shaftwidth = shaftwidth, axis=(10,0,0), color =(1,0,0),opacity = opacity) # xe red xwaxis = arrow(frame = axisframe, shaftwidth = shaftwidth, axis=(-10,0,0), color =(0,1,1),opacity = opacity) # xw cyan ynaxis = arrow(frame = axisframe, shaftwidth = shaftwidth, axis=(0,10,0), color =(0,1,0),opacity = opacity) # yn green ysaxis = arrow(frame = axisframe, shaftwidth = shaftwidth, axis=(0,-10,0), color =(1,0,1),opacity = opacity) # ys magenta zpaxis = arrow(frame = axisframe, axis=(0,0,1), color =(0,0,1),opacity = opacity) # zp blue zmaxis =arrow(frame = axisframe, axis=(0,0,-1), color =(1,1,0),opacity = opacity) # zm yellow nlabel = label(frame = labelframe, pos = ynaxis.axis, text = 'N',opacity = opacity) elabel = label(frame = labelframe, pos = xeaxis.axis, text = 'E',opacity = opacity) wlabel = label(frame = labelframe, pos = xwaxis.axis, text = 'W',opacity = opacity) slabel = label(frame = labelframe, pos = ysaxis.axis, text = 'S',opacity = opacity) scene.forward = (0,.7,-.6) Gives me a view over the south axis towards the centre of the frame. I want to rotate the camera so I can look over the E W and North axis but maintain the overall 'display' If I had a box drawn at 0,0,0 I would like to look at the four vertical faces inturn. by using the rotate command. I am trying to use rotate to enact 3 buttons which act out the following three commands. scene.forward = rotate( scene.forward, axis = (0,0,-1), angle = pi/2 ) scene.forward = rotate( scene.forward, axis = (0,0,-1), angle = pi ) scene.forward = rotate( scene.forward, axis = (0,0,-1), angle = (3 *pi)/2 ) i reckon I'm not really understanding up's effect on all this but i've got to the randomly poking in numbers which isn't having much useful effect. I am trying to build an environment that i can rotate easily in 90 degree chunks at the press of a command button but maintain the overall 'appearance'. In essence so I view the scene from a similar elevation above the groundplane bu the position rotated appropriately round the centre point. -- No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.1.409 / Virus Database: 268.15.18/584 - Release Date: 12/12/2006 |
From: Bruce S. <Bru...@nc...> - 2006-12-15 01:25:56
|
Here is a working program. The key point is that since you want to move the camera around the z axis, you need to make scene.up = (0,0,1), so that the "groundplane" is the ground. Also, you need to rotate by pi/2 each time, not pi and 3*pi/2 the second and third times. There's no point in importing cylinder etc. separately, once you've said "from visual import *". Just for clarity I made the rotation gradual to make it easier to see what was happening. from visual import * scene.background = (.6,.6,.6) scene.up = (0,0,1) scene.forward = (0,.7,-.6) groundframe = frame() g = cylinder(frame = groundframe, radius =10 , red = 0, blue = 0, axis = (0,0,-.1), opacity= .5) opacity = 0.5 shaftwidth = 0.2 axisframe = frame() labelframe = frame() xeaxis = arrow(frame = axisframe, shaftwidth = shaftwidth, axis=(10,0,0), color=color.red,opacity = opacity) # xe red xwaxis = arrow(frame = axisframe, shaftwidth = shaftwidth, axis=(-10,0,0), color=color.cyan,opacity = opacity) # xw cyan ynaxis = arrow(frame = axisframe, shaftwidth = shaftwidth, axis=(0,10,0), color=color.black,opacity = opacity) # yn black ysaxis = arrow(frame = axisframe, shaftwidth = shaftwidth, axis=(0,-10,0), color=color.magenta,opacity = opacity) # ys magenta zpaxis = arrow(frame = axisframe, axis=(0,0,4), color=color.yellow,opacity = opacity, shaftwidth = shaftwidth) # zp yellow zmaxis =arrow(frame = axisframe, axis=(0,0,-4), color=color.blue,opacity = opacity, shaftwidth = shaftwidth) # zm blue nlabel = label(frame = labelframe, pos = ynaxis.axis, text = 'N', opacity = opacity) elabel = label(frame = labelframe, pos = xeaxis.axis, text = 'E', opacity = opacity) wlabel = label(frame = labelframe, pos = xwaxis.axis, text = 'W', opacity = opacity) slabel = label(frame = labelframe, pos = ysaxis.axis, text = 'S', opacity = opacity) while True: scene.mouse.getclick() steps = 50 for step in range(steps): rate(2*steps) scene.forward = rotate( scene.forward, axis = (0,0,-1), angle = pi/2/steps ) Chris Lyon wrote: > Gives me a view over the south axis towards the centre of the frame. > I want to rotate the camera so I can look over the E W and North axis > but maintain the overall 'display' If I had a box drawn at 0,0,0 I would > like to look at the four vertical faces inturn. by using the rotate command. > > I am trying to use rotate to enact 3 buttons which act out the following > three commands. > > scene.forward = rotate( scene.forward, axis = (0,0,-1), angle = pi/2 ) > scene.forward = rotate( scene.forward, axis = (0,0,-1), angle = pi ) > scene.forward = rotate( scene.forward, axis = (0,0,-1), angle = (3 *pi)/2 ) > > i reckon I'm not really understanding up's effect on all this but i've > got to the randomly poking in numbers which isn't having much useful effect. > > I am trying to build an environment that i can rotate easily in 90 > degree chunks at the press of a command button but maintain the overall > 'appearance'. In essence so I view the scene from a similar elevation > above the groundplane bu the position rotated appropriately round the > centre point. > > > > > > > |