|
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.
>
>
>
>
>
>
>
|