WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Thread Tools Rate Thread Display Modes
Old 09-16-2004, 11:17 AM
ChrisB ChrisB is offline
Join Date: May 2004
Location: Hamilton, Ontario
Posts: 4
Send a message via ICQ to ChrisB
Viewpoint Manipulation


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
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

(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
Old 09-16-2004, 11:25 AM
farshizzo farshizzo is offline
WorldViz Team Member
Join Date: Mar 2003
Posts: 2,849

The trick is to use a timer to check if the key is down. Here's some sample code:
view = viz.get(viz.MAIN_VIEWPOINT)
ROTATION_SPEED = 20.0 #Degrees/second

def ontimer(num):
	if viz.iskeydown(viz.KEY_RIGHT):
	elif viz.iskeydown(viz.KEY_LEFT):

Reply With Quote

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT -7. The time now is 02:44 PM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2021, vBulletin Solutions, Inc.
Copyright 2002-2018 WorldViz LLC