|
#1
|
|||
|
|||
[New here] Cave joy navigation
Hello everybody,
I'm very new to Vizard, so maybe my questions will be stupid. Right now i've got a problem with joystick navigation in my cave. I've tried to make it from examples. (We have no tracking devices for now) Here is the cave file: Code:
# The same script must be run on all machines in the cluster import viz import vizcave import viztracker # Activate full screen on all nodes with quad buffering # Disable the mouse cursor visibility on all machines except the master viz.cluster.setMask(viz.ALLCLIENTS & ~viz.MASTER) viz.setOption('viz.fullscreen',1) viz.setOption('viz.stereo',viz.QUAD_BUFFER) viz.mouse.setVisible(viz.OFF) viz.cluster.setMask(viz.ALLCLIENTS) # Declare constants defining the CAVE dimensions W1 = 3.048 # wideness (X) H1 = 2.286 # height (Y) D1 = 0.56 # deepnees (Z) C0 = -2,2.25,2 # Front Wall: C0,C1,C2,C3 C1 = 2,2.25,2 # Roof Wall: C4,C5,C0,C1 C2 = -2,0,2 C3 = 2,0,2 C4 = -2,3.9736,0.5537 C5 = 2,3.9736,0.5537 #Create front wall FrontWall = vizcave.Wall( upperLeft=C0, upperRight=C1, lowerLeft=C2, lowerRight=C3, name='Front Wall' ) #Create left wall RoofWall = vizcave.Wall( upperLeft=C4, upperRight=C5, lowerLeft=C0, lowerRight=C1, name='Roof Wall' ) #Initialize graphics window viz.go() #Create cave object LITE = vizcave.Cave() #Add each wall, make sure that they are ordered in the cluster software correctly to match this ordering LITE.addWall(FrontWall, mask=viz.CLIENT2) LITE.addWall(RoofWall, mask=viz.CLIENT1) import joyLITE #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 the exact center of the CAVE viewtracker = viztracker.KeyboardPos() viewtracker.setPosition (0,1.7,0) #Pass the viewpoint tracker into the cave object so it can be automatically updated LITE.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) #Create another tracker using the keyboard and mouse (arrow keys adjust position, mouse changes orientation) #origintracker = viztracker.KeyboardMouse6DOF() #originlink = viz.link (origintracker, caveorigin) #Set the MainView in a good position vpos= caveorigin.getPosition() viz.MainView.setPosition(vpos,viz.BODY_ORI) vrot= caveorigin.getEuler() viz.MainView.setEuler(vrot,viz.BODY_ORI) #viz.MainView.setEuler(-90,0,0,viz.BODY_EULER) #FOR LINKS: FIRST: DESTINATION, SECOND:SOURCE originlink = viz.link ( caveorigin,viz.MainView) #caveorigin.parent(viz.MainView) #Link the keyboard/mouse so that it moves the cave and user around the virtual environment #originlink = viz.link (origintracker, caveorigin) #Add gallery environment model gallery = viz.add('gallery.ive') Code:
import vizact import viz #Import the vizjoy module and add one joystick. import vizjoy joy = vizjoy.add() def update_joystick(): node3d = viz.MainView #Get the joystick position x,y,z = joy.getPosition() #Get the twist of the joystick twist = joy.getTwist() slider = joy.getSlider() state = joy.getButtonState() #Move the viewpoint forward/ #backward based on y-axis value #Make sure value is above a certain #threshold. if abs(x) > 0.2: node3d.move(0,0,x*0.01,viz.BODY_ORI) #Move the viewpoint left/right based #on x-axis value. Make sure value is #above a certain threshold if abs(y) > 0.2: node3d.move(y*0.01,0,0,viz.BODY_ORI) #Turn the viewpoint left/right based #on twist value. Make sure value is #above a certain threshold. if abs(slider) > 0.2: node3d.rotate(0,1,0,slider,viz.BODY_ORI,viz.ABS_LOCAL) if abs(twist) > 0.2: node3d.rotate(1,0,0,twist,viz.BODY_ORI,viz.ABS_LOCAL) #Up/down with buttons if state & vizjoy.BUTTON6: node3d.move(0,0.01,0,viz.BODY_ORI) if state & vizjoy.BUTTON8: node3d.move(0,-0.01,0,viz.BODY_ORI) #UpdateJoystick every frame vizact.ontimer(0,update_joystick) I tried my joystick navigation file with another non-cave demo and it worked well. Thank you by advance. |
#2
|
|||
|
|||
Nobody could give me a hint?
Thanks. |
#3
|
|||
|
|||
If you are using the keyboard to update the projections and the joystick to drive the CAVE around you can do something like this.
Code:
#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 the exact center of the CAVE viewtracker = viztracker.KeyboardPos() viewtracker.setPosition (W/2.0,H/2.0,D/2.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) #update caveorigin with joystick MOVE_SPEED = 5 # meters/sec def joyMove(): #Use y position of joystick to drive CAVE forward forwardMovement = viz.elapsed() * MOVE_SPEED * -joyPOS[1] caveorigin.setPosition([0,0,forwardMovement],viz.REL_LOCAL) #Use x position of joystick to drive CAVE side to side sideMovement = viz.elapsed() * MOVE_SPEED * joyPOS[0] caveorigin.setPosition([sideMovement,0,0],viz.REL_LOCAL) vizact.ontimer(0, joyMove) Code:
viz.MainView.setPosition() |
Thread Tools | |
Display Modes | Rate This Thread |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Mouselook & Keyboard Navigation | EnvisMJ | Vizard | 9 | 06-22-2010 05:52 PM |
Flipped floor in a CAVE | shivanangel | Vizard | 1 | 03-10-2010 11:12 AM |
CAVE, navigation, tracked wand, coordinate systems | JimC | Vizard | 6 | 10-09-2009 01:43 PM |
right-hand to left-hand coordinate System for a cave setup | Andy | Vizard | 1 | 09-16-2009 11:17 AM |
navigation in cave environment | Andy | Vizard | 4 | 03-28-2008 02:32 AM |