#1
|
|||
|
|||
Cave car simulation
Hello there,
We are currently working on a school project that includes Vizard and a CAVE, and a WII remote controller. The project contains a city where you can drive through and a car. I have the city working, our problem is however, we need to simulate that the person is driving a car. I found this tutorial : http://docs.worldviz.com/vizard/VizH...d_and_body.htm And it works perfect while you are running it in viz.go. But if i am going to implement it with the CAVE lib, we have the problem that the car is behind and moves separately with the "white" character while they both react on the arrow keys. My question is, how can i get the car simulation working within the CAVE while having the same effect as the tutorial above. (that the car model is moving and turning together with the white character) With regards, Marcel |
#2
|
|||
|
|||
You could try linking the cave origin to the car's movements that are updated using the wiimote. Do you also have some type of head tracker so the user can move around within the car?
In the following example a keyboard tracker (wasd keys) is used in place of a head tracker and updates the projection matrices. The arrow keys move the car and the cave origin around the environment: Code:
import viz import vizcave import viztracker #Dimension of PowerWall in meters WIDTH = 3.0 HEIGHT = 3.0 DISTANCE = 2.0 #Initialize graphics window viz.go() #Create single power wall PowerWall = vizcave.Wall( upperLeft=(-WIDTH/2.0,HEIGHT,DISTANCE), upperRight=(WIDTH/2.0,HEIGHT,DISTANCE), lowerLeft=(-WIDTH/2.0,0.0,DISTANCE), lowerRight=(WIDTH/2.0,0.0,DISTANCE), name='Power Wall' ) #Create cave object with power wall cave = vizcave.Cave() cave.addWall(PowerWall) #Create tracker object using the keyboard (WASD keys control the viewpoint, the user's eye location) #Make the starting location for the user's eye above origin viewtracker = viztracker.KeyboardPos() viewtracker.setPosition(0.0,1.8,0.0) #Pass the viewpoint tracker into the cave object so it can be automatically updated cave.setTracker(pos=viewtracker) #Create CaveView object for manipulating the entire cave environment #The caveorigin is a node that can be adjusted to move the entire cave around the virtual environment caveorigin = vizcave.CaveView(viewtracker) #link caveorigin to mini mini = viz.addChild('mini.osg') originLink = viz.link(mini,caveorigin) originLink.preTrans([-0.3,-0.6,-0.1]) MOVE_SPEED = 5 TURN_SPEED = 60 def updatecar(): #move car forward and backward if viz.key.isDown(viz.KEY_UP): mini.setPosition([0,0,MOVE_SPEED*viz.elapsed()],viz.REL_LOCAL) elif viz.key.isDown(viz.KEY_DOWN): mini.setPosition([0,0,-MOVE_SPEED*viz.elapsed()],viz.REL_LOCAL) #rotate car left and right if viz.key.isDown(viz.KEY_RIGHT): mini.setEuler([TURN_SPEED*viz.elapsed(),0,0],viz.REL_LOCAL) elif viz.key.isDown(viz.KEY_LEFT): mini.setEuler([-TURN_SPEED*viz.elapsed(),0,0],viz.REL_LOCAL) vizact.ontimer(0,updatecar) #Add gallery environment model viz.add('ground.osgb') |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[New here] Cave joy navigation | esuna114 | Vizard | 2 | 06-11-2010 04:36 PM |
How to pause the Vizard simulation? | 4711 | Vizard | 4 | 03-18-2010 04:45 PM |
Flipped floor in a CAVE | shivanangel | Vizard | 1 | 03-10-2010 10:12 AM |
CAVE, navigation, tracked wand, coordinate systems | JimC | Vizard | 6 | 10-09-2009 12:43 PM |
right-hand to left-hand coordinate System for a cave setup | Andy | Vizard | 1 | 09-16-2009 10:17 AM |