|
From: Astan C. <st...@al...> - 2008-03-25 05:38:54
|
Hi,
I have a simple VPython simulation that attempts to move the camera
based on keyboard input.
For some reason the amount of movement is not consistent in any
particular direction regardless of value. Can anyone tell me why? Is
there something wrong with my code?
Thanks for the help.
Here 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()
#move in
if s == 'up':
newforward = vector(0,0,1.25)
scene.center =
scene.mouse.camera-newforward*mag(scene.center-scene.mouse.camera)
#move out
if s == 'down':
newbackward = vector(0,0,-1.25)
scene.center =
scene.mouse.camera-newbackward*mag(scene.center-scene.mouse.camera)
#move left
if s == 'left':
newbackward = vector(-1.25,0,0)
scene.center =
scene.mouse.camera-newbackward*mag(scene.center-scene.mouse.camera)
#move right
if s == 'right':
newbackward = vector(1.25,0,0)
scene.center =
scene.mouse.camera-newbackward*mag(scene.center-scene.mouse.camera)
--
"Formulations of number theory: Complete, Consistent, Non-trivial. Choose two."
Animal Logic
http://www.animallogic.com
Please think of the environment before printing this email.
This email and any attachments may be confidential and/or privileged. If you are not the intended recipient of this email, you must not disclose or use the information contained in it. Please notify the sender immediately and delete this document if you have received it in error. We do not guarantee this email is error or virus free.
|