From: Bruce S. <Bru...@nc...> - 2008-03-25 15:00:31
|
I don't understand your question. All of the keys seem to do what you say they should do. There's no way to rotate the camera (at least in the usual VPython sense) because you've set scene.userspin = 0. As for scene.forward, it is a vector pointing from the camera position toward scene.center. The magnitude of the vector scene.forward is irrelevant; it's just a direction. Bruce Sherwood Astan Chee wrote: > Hi, > So now I've had abit of success. I can move the camera around using > keyboard shortcuts but whenever the camera is rotated, the move up/down > and strafe left/right becomes inconsistent. How do I update these? Im > thinking I have to change the scene.forward somewhere, but to what value? > Thanks again for any advice. > Astan > Below is my code > > from __future__ import division > from visual import * > import random > > if __name__ == '__main__': > > # Set up window and sceen. > scene = display() > scene.fullscreen = 0 > scene.autocenter = 0 > scene.autoscale = 0 > scene.userzoom = 0 > scene.userspin = 0 > scene.ambient = 0 > outer = 10 > outer*= 2 > scene.range = (outer,outer,outer) > > rate(50) > > sunpos = [0,0,0] > color = [ 3, 1.5, .75] > sunradius = 2 > sun = sphere( pos=sunpos, radius=sunradius, color=color) > > while True: > if scene.kb.keys: > s = scene.kb.getkey() > angle = 0 > #move in / out > if s == 'w' or s == 's': > ray = 1 > if s == 's': > ray = -1 > scene.center = scene.center+scene.forward*ray/2. > #strafe left / right > if s == 'a' or s == 'd': > move = vector(-0.5,0,0) > if s == 'd': > move = vector(0.5,0,0) > scene.center = scene.center+move > #look left / right > if s == 'left' or s == 'right': > ray = 0 > angle = 0.6 > if s == 'right': > angle = -0.6 > newforward = rotate(scene.forward, axis=scene.up, > angle=angle/10.) > scene.center = > scene.mouse.camera+newforward*mag(scene.center-scene.mouse.camera) > scene.forward = newforward > scene.center = scene.center+scene.forward*ray/2. > #move up / down > if s == 'f' or s == 'v': > move = vector(0,-0.5,0) > if s == 'v': > move = vector(0,0.5,0) > scene.center = scene.center+move > > > > > |