WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 06-14-2012, 07:16 AM
Marcel Marcel is offline
Member
 
Join Date: Jun 2012
Posts: 1
Post 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
Reply With Quote
  #2  
Old 06-22-2012, 09:56 PM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,471
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')
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
[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


All times are GMT -7. The time now is 02:07 PM.


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