WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 03-20-2008, 02:45 AM
Andy Andy is offline
Member
 
Join Date: Mar 2008
Location: Germany
Posts: 36
navigation in cave environment

I have a problem by understanding a cave-configuration and navigation respectively. I hope somebody can help me. In my configuration I have one wall (stereo render by two clients), one Polhemus-Fastrak for Head-Tracking and my Keybord for navigation. My Problem is: who can I navigate through my VR-World?

I see a cave-wall like a window by which I see through. Now, when I would like to navigate through my VR-World, in my opinion I have two options: first I can move the Wall an my Viewpoint or second I move the whole world (and my Body\Head is the central point).

Who can I do this with Vizard?

Code:
import viz
import vizcave
import viztracker

viz.go()
viz.MainWindow.stereo(viz.STEREO_RIGHT)

viz.pushmask(viz.CLIENT1)
viz.MainWindow.stereo(viz.STEREO_RIGHT)
viz.popmask()

viz.pushmask(viz.CLIENT2)
viz.MainWindow.stereo(viz.STEREO_LEFT)
viz.popmask()

c0 = -1,2,0
c1 = 1.,2,0
c2 = 1.,0.6,0
c3 = -1,0.6,0
vp = [0, 1.2, -1.6]
vr = [0,0,0]

cave = vizcave.Cave()

#Add a sensor.
tracker = viz.add('fastrak.dls')

FrontWall = vizcave.Wall(upperLeft=c0,upperRight=c1,lowerLeft= c3,lowerRight=c2,name='Front Wall' )
cave.addWall(FrontWall, mask =None, window = viz.MainWindow)

def drawWall():
	viz.startlayer(viz.LINE_STRIP)
	viz.vertex(c0)
	viz.vertex(c1)
	viz.vertex(c2)
	viz.vertex(c3)
	viz.vertex(c0)
	viz.vertexcolor(1,1,0.1)
	viz.startlayer(viz.LINES)
	viz.vertex(c0)
	viz.vertex(vp)
	viz.vertex(c1)
	viz.vertex(vp)
	viz.vertex(c2)
	viz.vertex(vp)
	viz.vertex(c3)
	viz.vertex(vp)
	wall_frame = viz.endlayer()

def UpdateCave():
	# Key's for offsetting my Tracking-data (Position)
	if viz.key.isDown('j'):
		vp[0] -= 1*viz.elapsed()
	if viz.key.isDown('u'):
		vp[0] += 1*viz.elapsed()
	if viz.key.isDown('k'):
		vp[1] -= 1*viz.elapsed()
	if viz.key.isDown('i'):
		vp[1] += 1*viz.elapsed()
	if viz.key.isDown('l'):
		vp[2] -= 0.5*viz.elapsed()
	if viz.key.isDown('o'):
		vp[2] += 0.5*viz.elapsed()
	# Key's for offsetting my Tracking-data (Orientation)
	if viz.key.isDown('f'):
		vr[0] -= 0.5
	if viz.key.isDown('r'):
		vr[0] += 0.5
	if viz.key.isDown('g'):
		vr[1] -= 0.5
	if viz.key.isDown('t'):
		vr[1] += 0.5
	if viz.key.isDown('h'):
		vr[2] -= 0.5
	if viz.key.isDown('z'):
		vr[2] += 0.5
	
	TP = tracker.getPosition()
	TO = tracker.getEuler()
	NewTO = vizmat.EulerToQuat((vr[0]+TO[1]),(vr[1]+TO[0]),(vr[2]+TO[2])) #swap X-Y and transform in quaternion
	NewTP = [(vp[0]*-1)+TP[0],vp[1]+(TP[1]*-1),vp[2]+(TP[2]*-1)]
	cave.update(pos = NewTP,ori =NewTO)
	viz.MainView.translate(NewTP)
	
	print "Tracker_P: ", (NewTP)
	print "Tracker_O: ", NewTO
	print "MV_P: ", viz.MainView.getPosition()
	print "MV_O: ", viz.MainView.getEuler()
	
vizact.ontimer(0,UpdateCave)
viz.add('tut_ground.wrl')
mini = viz.add("mini.osgx")
mini.translate(0,0.7,0)
mini.setScale(0.3, 0.3, 0.3)
mini.add(vizact.spin(0,1,0,15))
drawWall()

viz.starttimer(0,0.01,viz.FOREVER)
Reply With Quote
  #2  
Old 03-20-2008, 09:49 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
The position/rotation values you pass to cave.update() need to be in the same coordinate system as the position values used to specify the wall corners. These are usually the physical coordinates from your tracking system.

The position/rotation of the viewpoint is used for navigation through the virtual world. These values have no relation to the physical tracker units.

When setting up a cave you should use the raw position of your tracker to measure the wall corners. Then at run-time you pass the raw position of your tracker to the cave.update() function. Your keyboard navigation should NOT affect the position values passed to cave.update(), it should only affect the values used to update viz.MainView.
Reply With Quote
  #3  
Old 03-25-2008, 01:25 AM
Andy Andy is offline
Member
 
Join Date: Mar 2008
Location: Germany
Posts: 36
Thank you for your reply, it was very helpful.
I have post my new code is it right so? I only set trackeroffset-values and with the keyboard I move my MainViewpoint. It seems like it works correct…

Code:
import viz
import vizcave
import viztracker

viz.go()
viz.MainWindow.stereo(viz.STEREO_RIGHT)

c0 = -1,2,0
c1 = 1.,2,0
c2 = 1.,0.6,0
c3 = -1,0.6,0

cave = vizcave.Cave()
FrontWall = vizcave.Wall(upperLeft=c0,upperRight=c1,lowerLeft= c3,lowerRight=c2,name='Front Wall' )
cave.addWall(FrontWall, mask =None, window = viz.MainWindow)

#Add a sensor.
tracker = viz.add('fastrak.dls')

vpT = [0, 1.2, -1.6] # tracker-offset-values
vpM = [0, 1.2, -1.6] # set the Main-ViewPoint in the center of the tracker
viz.MainView.translate(vpM)

viz.add('tut_ground.wrl')
mini = viz.add("mini.osgx")
mini.translate(0,0.7,0)
mini.setScale(0.3, 0.3, 0.3)
mini.add(vizact.spin(0,1,0,15))

def UpdateCave():
	TP = tracker.getPosition()
	TO = tracker.getEuler()
	NewTO = vizmat.EulerToQuat(TO[1],TO[0],TO[2]) #swap X-Y and transform in quaternion
	NewTP = [-TP[0]+vpT[0],-TP[1]+vpT[1],-TP[2]+vpT[2]] #invert the tracker-position-data and set offsetvalues
	cave.update(pos = NewTP,ori =NewTO)
	
	print "Tracker_P: ", NewTP
	print "Tracker_O: ", NewTO
	print "Main_VP: ", viz.MainView.getPosition()
	print "Main_VO: ", viz.MainView.getEuler()

vizact.ontimer(0,UpdateCave)

def onKeyDown(key):
	#move the main-ViewPoint
	if viz.key.isDown('q'): #left
		vpM[0] -= 1*viz.elapsed()
	if viz.key.isDown('a'): #right
		vpM[0] += 1*viz.elapsed()
	if viz.key.isDown('e'): #forward
		vpM[2] += 1*viz.elapsed()
	if viz.key.isDown('d'): #backward
		vpM[2] -= 1*viz.elapsed()
	if viz.key.isDown('w'): #up
		vpM[1] += 1*viz.elapsed()
	if viz.key.isDown('s'): #down
		vpM[1] -= 1*viz.elapsed()
	viz.MainView.translate(vpM)
	
viz.callback(viz.KEYDOWN_EVENT,onKeyDown) 

viz.starttimer(0,0.01,viz.FOREVER)
Reply With Quote
  #4  
Old 03-25-2008, 12:36 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
You still need to apply the tracking data to the main view. In your UpdateCave function you will need add the tracker position and the vpM together to update the viewpoint.
Reply With Quote
  #5  
Old 03-28-2008, 01:32 AM
Andy Andy is offline
Member
 
Join Date: Mar 2008
Location: Germany
Posts: 36
OK fine, now it looks much better…

Code:
import viz
import vizcave
import viztracker

viz.go()
viz.MainWindow.stereo(viz.STEREO_RIGHT)

c0 = -1,2,0
c1 = 1.,2,0
c2 = 1.,0.6,0
c3 = -1,0.6,0

cave = vizcave.Cave()
FrontWall = vizcave.Wall(upperLeft=c0,upperRight=c1,lowerLeft= c3,lowerRight=c2,name='Front Wall' )
cave.addWall(FrontWall, mask =None, window = viz.MainWindow)

#Add a sensor.
tracker = viz.add('fastrak.dls')

vpT = [0, 1.82, -1.6] # tracker-offset-values
vpM = [0, 0, -1.6] # set the Main-ViewPoint in the center of the tracker
#viz.MainView.translate(vpM)

viz.add('tut_ground.wrl')
mini = viz.add("mini.osgx")
mini.translate(0,0.7,0)
mini.setScale(1, 1, 1)
mini.add(vizact.spin(0,1,0,15))

def UpdateCave():
	TP = tracker.getPosition()
	TO = tracker.getEuler()
	NewTO = vizmat.EulerToQuat(TO[1],TO[0],TO[2]) #swap X-Y and transform in quaternion
	NewTP = [-TP[0]+vpT[0],-TP[1]+vpT[1],-TP[2]+vpT[2]] #invert the tracker-position-data and set offsetvalues
	cave.update(pos = NewTP,ori =NewTO)
	viz.MainView.translate(vpM[0]+NewTP[0],vpM[1]+NewTP[1],vpM[2]+NewTP[2])
	print "Tracker_P: ", NewTP
	print "Tracker_O: ", NewTO
	print "Main_VP: ", viz.MainView.getPosition()
	print "Main_VO: ", viz.MainView.getEuler()

vizact.ontimer(0,UpdateCave)

TURN_SPEED = 60
def onKeyDown(key):
	#move the main-ViewPoint
	#move the ViewPoint
	if viz.key.isDown('w'): #plus
		vpM[2] += 1*viz.elapsed()
	if viz.key.isDown('s'): #minus
		vpM[2] -= 1*viz.elapsed()
	if viz.key.isDown('e'): #down
		vpM[1] += 1*viz.elapsed()
	if viz.key.isDown('d'): #up
		vpM[1] -= 1*viz.elapsed()
	#Rotate the ViewPoint
	if viz.key.isDown('q'): #left
		viz.MainView.rotate(0,1,0,-TURN_SPEED*viz.elapsed(),viz.BODY_ORI,viz.RELATIVE_WORLD)
	if viz.key.isDown('a'): #right
		viz.MainView.rotate(0,1,0,TURN_SPEED*viz.elapsed(),viz.BODY_ORI,viz.RELATIVE_WORLD)	
viz.callback(viz.KEYDOWN_EVENT,onKeyDown) 

viz.starttimer(0,0.01,viz.FOREVER)
Now I have a new problem. I want to navigate but I have to use “vpM” and “NewTP” to update the “MainView” function. When I use “viz.MainView.rotate” for ViewPoint-rotation it seems to by ok, but I can not use “viz.MainView.move” because so I do not include the position I get from the Tracker (NewTP).
Do you have an idea?
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
Problems implementing Vizard in a CAVE with Shutter Glasses shivanangel Vizard 7 05-20-2009 11:47 AM
data glove navigation arielasso Vizard 6 10-24-2007 02:15 PM
environment maps, scenes, and you! vadrian Vizard 1 01-12-2005 04:04 PM
Basic Joystick Navigation Question Plasma Vizard 2 01-29-2004 07:08 PM
Navigation Speed/Too Slow Plasma Vizard 2 01-28-2004 11:07 AM


All times are GMT -7. The time now is 05:30 AM.


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