View Single Post
  #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