|
From: Astan C. <st...@al...> - 2008-03-25 07:12:11
|
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
--
"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.
|