Thread: 3d-movement
View Single Post
  #1  
Old 10-06-2008, 07:41 AM
Andy Andy is offline
Member
 
Join Date: Mar 2008
Location: Germany
Posts: 36
3d-movement

I use "vizcave" and I would like to navigate the vitual viewpoint via keyboard. For the real-position of the user I use a tracking-system and for navigation I would like to use the keyboard.

Code:
#Virtual viewpoint (Translate view origin 1 meter up and back)
vp = [0, 1, -1]

#Use tracker for automatically updating cave
cave.setTracker(pos=tracker)

#Create vizcave.CaveView object for manipulating viewpoint in cave environment
origin = vizcave.CaveView(tracker)

#Translate view origin
origin.setPosition(vp)
now I use the "viz.KEYDOWN_EVENT" to set an new origin:
Code:
def onKeyDown(key):
	if key == 'z': #forward
		vp[2] += 5*viz.elapsed()
	if key == 'b': #backwards
		vp[2] -= 5*viz.elapsed()
	if key == 'g': #left
		vp[0] -= 5*viz.elapsed()
	if key == 'h': #right
		vp[0] += 5*viz.elapsed()
	origin.setPosition(vp)
There are two problems:
- First, the movement is not very smooth
and
- If I rotate the viewpoint (origin.setEuler()) the direction of the movement is the same as before (if I rotate -90 degrees yaw, I have to press "go left" to move forward).

How can I smoothen the movement?
Is there a function to automatically adapt the movement to the current pos?
Reply With Quote