WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 10-28-2013, 04:37 AM
apmx apmx is offline
Member
 
Join Date: Oct 2013
Posts: 1
A problem with cave

Hello,I am doing a project about car simulation,but I don't know how to link the cave view point with the car,the result should be more like sitting in the car and if the car is moving the view point should follow.

Here is my code:
Code:
import cavelib2
import math
import viz
import vizact
import random
import vizshape
import vizcave
import viztracker

hangle=0
vangle=0

#Param: True = DesktopMode on
#		False = DesktopMode off

print "Initializing CaveLib"
cave = cavelib2.CaveLib(True)

import vizshape

#wiimote update code

#Speed for the wiimote movement
MOVE_SPEED = 1

#Initial values of camera angles
hangle = 0
vangle = 0

#object id's that are ignored with raycasting


drawing  = None

print "Adding a model"
#position camera in startingposition
cave_origin=cave.getOriginTracker().setPosition(0,3,0)
#cave.caveorigin.setPosition(0,2,0)
#cave.caveorigin.setEuler(90,0,0)

#adding the models
world = viz.add('road1002.OSGB')
world.setPosition(0,0,0)
world.enable(viz.LIGHTING)

truck = viz.add('truck1005.OSGB')
truck.setPosition(1,2,-8)







def WiiMove():
	global hangle
	global vangle
	
	elapsed = viz.elapsed()	#the amount of time elapsed
	
	state = cave.wiimote.getState()
	
	#process buttons
	if state & cave.wiimote.BUTTON_LEFT:
		#cave.caveorigin.setPosition([-MOVE_SPEED*elapsed,0,0],viz.REL_LOCAL)
		sun.setPosition([-MOVE_SPEED*elapsed,0,0],viz.REL_LOCAL)
		
	if state & cave.wiimote.BUTTON_RIGHT:
		#cave.caveorigin.setPosition([MOVE_SPEED*elapsed,0,0],viz.REL_LOCAL)
		sun.setPosition([MOVE_SPEED*elapsed,0,0],viz.REL_LOCAL)
		
	if state & cave.wiimote.BUTTON_UP:
		#cave.caveorigin.setPosition([0,0,MOVE_SPEED*elapsed],viz.REL_LOCAL)
		sun.setPosition([0,MOVE_SPEED*elapsed,0],viz.REL_LOCAL)
		
	if state & cave.wiimote.BUTTON_DOWN:
		#cave.caveorigin.setPosition([0,0,-MOVE_SPEED*elapsed],viz.REL_LOCAL)
		sun.setPosition([0,-MOVE_SPEED*elapsed,0],viz.REL_LOCAL)
		
	if state & cave.wiimote.BUTTON_1:
		cave.caveorigin.setPosition([0,-.001,0],viz.REL_LOCAL)
	if state & cave.wiimote.BUTTON_2:
		cave.caveorigin.setPosition([0,.001,0],viz.REL_LOCAL)
	
	hangle = hangle + 90 * cave.wiimote.getJoystick()[0] * elapsed
	cave.caveorigin.setEuler([hangle,vangle,0])	
	
#Set input function		
vizact.ontimer(0, WiiMove)

#onUpdate callback function
def onUpdate(e): 
	cave.getWandPosition()
	cave.getWandQuat()
	cave.getWandMatrix()
		
viz.callback(viz.UPDATE_EVENT,onUpdate)


print "Setting the headlight"

#Get a handle to the main headlight and disable it


print "Setting the antialiasing factor"

viz.setMultiSample(4)

print "Start the simulation"

cave.go()
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
Cave GUI Rudi Vizard 3 06-14-2012 04:12 AM
Intermittent orthographic stereo projection problems AySz88 Vizard 10 02-17-2012 12:50 PM
[New here] Cave joy navigation esuna114 Vizard 2 06-11-2010 04:36 PM
Flipped floor in a CAVE shivanangel Vizard 1 03-10-2010 10:12 AM
problem with female animations vmonkey Vizard 1 10-07-2005 10:36 AM


All times are GMT -7. The time now is 07:52 AM.


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