![]() |
#5
|
|||
|
|||
Of course! This is my script.
################################################## ######### MOVE_SPEED = 10 TURN_SPEED = 90 import viz viz.go() import vizinfo vizinfo.add('This is a car driving test by wiimote') viz.phys.enable() ground = viz.add('tut_ground.wrl') ground.collidePlane() car = viz.add('mini.osgx') car.setPosition(0,0,-10) car.setScale(1,1,1) car.setEuler(0,0,0) car.collideBox() wii = viz.add('wiimote.dle') wiimote = wii.addWiimote() wiimote.led = wii.LED_1 def updateCar(): if wiimote.isButtonDown(wii.BUTTON_UP): forwardMovementAmount = viz.elapsed() * MOVE_SPEED car.setPosition( [ 0, 0, forwardMovementAmount], viz.REL_LOCAL ) if wiimote.isButtonDown(wii.BUTTON_DOWN): forwardMovementAmount = viz.elapsed() * MOVE_SPEED car.setPosition( [ 0, 0, -forwardMovementAmount], viz.REL_LOCAL ) if wiimote.isButtonDown(wii.BUTTON_LEFT): rotationAmount = viz.elapsed() * TURN_SPEED car.setEuler( [ -rotationAmount, 0 , 0 ] , viz.REL_LOCAL ) if wiimote.isButtonDown(wii.BUTTON_RIGHT): rotationAmount = viz.elapsed() * TURN_SPEED car.setEuler( [ rotationAmount, 0 , 0 ] , viz.REL_LOCAL ) vizact.onsensordown(wiimote,wii.BUTTON_UP,updateCa r) vizact.onsensordown(wiimote,wii.BUTTON_DOWN,update Car) vizact.onsensordown(wiimote,wii.BUTTON_LEFT,update Car) vizact.onsensordown(wiimote,wii.BUTTON_RIGHT,updat eCar) viz.MainView.move(0,0,-15) ################################################## ######### And I also have a question. Why my car can jump in the beginning? I'd like it to be static in the beginning. How can I do ? Thanks for your help, Jeff !! Kevin Last edited by superantTTY; 05-15-2010 at 09:16 PM. |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Create Button or Text | Chrissy2009 | Vizard | 1 | 07-15-2009 05:34 PM |
Wiimote in 4 sided Cave | Sjaak | Vizard | 2 | 05-20-2009 01:05 PM |
Mac Mini Sound Server ? | djdesmangles | Vizard | 3 | 05-14-2009 12:44 PM |
wiimote and sensor bar | masaki | Vizard | 1 | 03-06-2008 03:07 PM |
driving simulator | paulpars | Vizard | 1 | 05-12-2006 11:46 AM |