View Single Post
  #1  
Old 09-16-2004, 11:17 AM
ChrisB ChrisB is offline
Member
 
Join Date: May 2004
Location: Hamilton, Ontario
Posts: 4
Send a message via ICQ to ChrisB
Viewpoint Manipulation

Hi,

I'm working on an experiment in vizard where I want the user to be stationary in the environment, and only be able to rotate left and right to survey the room. I want to use the left and right arrow keys to control the rotation, but I find that when using a callback function to adjust the viewpoint angle on a keypress, the program runs too choppy . What I have is something similar to this:

def GetUserInput(input):
global myView
global angle
if input == viz.KEY_LEFT:
angle = angle - 1
myView.rotate(0,1,0,angle)
elif input == viz.KEY_RIGHT:
angle = angle + 1
myView.rotate(0, 1, 0, angle)

Increasing the angle of rotation makes it faster but choppier. I went through some of the help files, and it recommended the use of the viz.iskeydown() for when a user would be holding down a key. I was hoping to use something like this:

while viz.iskeydown(viz.KEY_LEFT) == 1:
angle = angle - 2
myView.rotate(0,1,0,angle/delayfactor)

(or alternatively a spinto option)

but when this happens there seems to be some blocking occuring, it waits until you have released the direction key, before rotating the viewpoint afterwards, with the amount of rotation depending on how long you held the key down for.

Maybe I am totally going about this the wrong way though, is there an easier method, or am I just missing something? I tried putting the while loop in a director function as well thinking that would not be blocking but it had the same effect, the screen only rotates after you release the key, not while you're holding it down.
Reply With Quote