WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #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
  #2  
Old 10-06-2008, 08:36 AM
Andy Andy is offline
Member
 
Join Date: Mar 2008
Location: Germany
Posts: 36
For the second "problem" I found a posible solution:

Code:
if key == 'z': #forward
	origin.setPosition(
		(origin.getPosition()[0]+(math.sin(vizmat.DEG_TO_RAD*origin.getEuler()[0])*0.1)),
		(origin.getPosition()[1]),
		(origin.getPosition()[2]+(math.cos(vizmat.DEG_TO_RAD*origin.getEuler()[0])*0.1))
	)
if key == 'b': #backwards
	origin.setPosition(
		(origin.getPosition()[0]-(math.sin(vizmat.DEG_TO_RAD*origin.getEuler()[0])*0.1)),
		(origin.getPosition()[1]),
		(origin.getPosition()[2]-(math.cos(vizmat.DEG_TO_RAD*origin.getEuler()[0])*0.1))
	)
and so on

Do you know a better way?
Reply With Quote
  #3  
Old 10-06-2008, 02:49 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
You can use the viztracker.Keyboard6DOF() object to setup keyboard navigation and link it to the CaveView object. Here is sample code:
Code:
import viztracker
keyTracker = viztracker.Keyboard6DOF()
viz.link(keyTracker, origin)
The Keyboard6DOF object uses the WASD keys by default for navigation. You can customize the keys by passing the following optional keyword arguments to the constructor:

forward - key for moving forward
backward - key for moving backward
right - key for strafing right
left - key for strafing left
turnRight - key for rotating right
turnLeft - key for rotating left

For example, if you wanted to use the arrow keys for moving around you would use the following code to create the keyboard tracker object:
Code:
keyTracker = viztracker.Keyboard6DOF(forward=viz.KEY_UP,backward=viz.KEY_DOWN,left=viz.KEY_LEFT,right=viz.KEY_RIGHT)
Reply With Quote
Reply

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Reading bone movement from animations Enlil Vizard 5 08-14-2008 02:29 PM
Mouse/Keyboard Movement joeymax Vizard 1 04-02-2007 10:43 AM
viewpoint movement spacefarer Vizard 4 12-02-2004 07:23 AM
eye movement epl Vizard 1 06-04-2004 12:29 PM
movement problems keastman Precision Position Tracker (PPT) 1 09-09-2003 11:41 AM


All times are GMT -7. The time now is 11:04 AM.


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