From: Astan C. <st...@al...> - 2008-03-26 00:37:55
|
Hi, Sorry, my mistake. It does work properly. The z-position of the camera doesnt change and the camera strafes to the left or right properly, but it does this disregarding where the camera is facing. Also, I have several other questions about VPython: 1. Is it possible to put the VPython frame in a wxFrame from wxPython? 2. Has anyone tried to place a camera or affix in on a moving object, so that the camera moves according to the object it is placed on? Thanks again for the help. Cheers Astan Astan Chee wrote: > Hi, > Sorry, I turned off scene.userspin and what I mean about the problem is > that if I move the camera to the right abit, turn it to 20 degrees to > the left and then move it to the right abit more, the second time it > moves to the right, it seems to also move further away from the sphere. > Why does this happen? > Thanks again for your help. > Cheers > Astan > > Bruce Sherwood wrote: > >> 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 >>> >>> >>> >> > > -- "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. |