WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #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
 


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 01:10 PM.


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