WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rating: Thread Rating: 2 votes, 5.00 average. Display Modes
  #1  
Old 06-10-2010, 10:12 AM
esuna114 esuna114 is offline
Member
 
Join Date: Jun 2010
Posts: 2
[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')
And here is my joy navigation device ( joyLITE )

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)
The rotations are very weird, and the view won't translate at all, why so?
I tried my joystick navigation file with another non-cave demo and it worked well.

Thank you by advance.
Reply With Quote
  #2  
Old 06-11-2010, 10:07 AM
esuna114 esuna114 is offline
Member
 
Join Date: Jun 2010
Posts: 2
Nobody could give me a hint?
Thanks.
Reply With Quote
  #3  
Old 06-11-2010, 05:36 PM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,471
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)
When using the vizcave module the viewpoint should not be updated with:
Code:
viz.MainView.setPosition()
The viewpoint will update properly if you set a tracker for the CAVE and use the CaveOrigin object to drive the CAVE around.
Reply With Quote
Reply


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
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


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


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