Vizcave is Vizard's representation of a virtual reality cave. Essentially a virtual reality cave is an environment where a screen represents the view at a physical location in that environment. Typically this is done in a special cave setup where the front, left, right and bottom walls are projected onto and the display is updated as the person's position changes.
In a very simple setup one can use a single monitor to act as a window to the outside world. With proper position tracking the information shown in the display would show what can be seen from that position through the window. As one moves nearer to the screen more of the outside world reveals itself, and as one moves to the left of the screen more of the world to the right becomes visible.
For more information on the Virtual Reality Cave see the wikipedia article.
In the typical cave setup the first part of defining a vizcave is acquiring the proper dimensions of the room's walls relative to the tracking system's coordinates. The position of each corner of each wall needs to be measured after the tracking system has been calibrated. In the typical Cave setup there are eight corners which positions will need to be calculated for.
import vizcave
# Declare constants
C0 = 0,6,0
# Front Wall: C1,C2,C5,C6
C1 = 0,6,8
# Left Wall: C0,C1,C4,C5
C2 = 8,6,8
# Right Wall: C2,C3,C6,C7
C3 = 8,6,0
# Bottom Wall: C5,C6,C4,C7
C4 = 0,0,0
C5 = 0,0,8
C6 = 8,0,8
C7 = 8,0,0
Here I defined the corners clockwise starting with the left top rear corner as position 0,6,0. Stressing this point once again, these position values need to be the values calculated by the tracker to be used.
The next step is to define each wall in vizard. The following shows how to define the Front and Right wall; the others are trivial.
#Create front wall
FrontWall = vizcave.Wall( upperLeft=C1,
upperRight=C2,
lowerLeft=C5,
lowerRight=C6,
name='Front
Wall' )
#Create right wall
RightWall = vizcave.Wall( upperLeft=C2,
upperRight=C3,
lowerLeft=C6,
lowerRight=C7,
name='Right
Wall' )
Now we need to establish the cave environment and create the walls by including the mask which indicates which computer the wall is to be drawn on.
#Create cave object
cave = vizcave.Cave()
cave.addWall(RightWall, mask=viz.CLIENT1)
cave.addWall(FrontWall, mask=viz.MASTER)
Finally we define how our position is being tracked. In this example we use a tracker object that is assumed to be previously created in the script.
cave.setTracker(pos = tracker)
NOTE: The cave.setTracker() and cave.update() commands do NOT update the active viewpoint with the tracking position. The user is responsible for applying the tracking data to the active viewpoint. The vizcave.CaveView object (see below) is useful for applying tracking data to the viewpoint in cave environments.
Updating the position data can also be done manually with the cave.update() function on a set timer. And for simplicity wall setups can be saved to files and loaded from them. See the command reference for usage of these functions.
As noted above, the cave object only updates the projection matrices, it does not modify the viewpoint. The vizcave module includes a helper class for modifying the viewpoint in a cave environment. Here is sample code for using this helper class:
view = vizcave.CaveView(tracker)
The CaveView class needs a tracker object for initialization. Once created, the CaveView object works like any standard node object. For example, if you wanted to translate the virtual viewpoint origin to (20,5,10) and rotate the view 90 degrees, you would use the following code:
view.setPosition([20,5,10])
view.setEuler([90,0,0])
Here is a sample script that creates a power wall setup (single display) using the vizcave module. The script uses the WASD keys on the keyboard to move the location of the user's viewpoint. You can also move the location of the origin of the CAVE around the virtual environment using the arrow keys and the mouse.
Here is a sample script that creates a four-sided cave using the vizcave module. Cluster support is used so that each wall is rendered by a separate machine. The script uses the WASD keys on the keyboard to move the location of the user's viewpoint. You can also move the location of the origin of the CAVE around the virtual environment using the arrow keys and the mouse.
# The same script must be run on all machines in the cluster
import viz
import vizcave
import viztracker
# Declare constants defining the CAVE dimensions
W = 3.048 # 10 feet wide
H = 2.286 # 7.5 feet tall
D = 3.048 # 10 feet deep
C0 = 0,H,0 # Front Wall: C1,C2,C5,C6
C1 = 0,H,D # Left
Wall: C0,C1,C4,C5
C2 = W,H,D
# Right Wall: C2,C3,C6,C7
C3 = W,H,0 # Bottom
Wall: C5,C6,C4,C7
C4 = 0,0,0
C5 = 0,0,D
C6 = W,0,D
C7 = W,0,0
#Create front wall
FrontWall = vizcave.Wall( upperLeft=C1, # 0, 2.286,
3.048
upperRight=C2, # 3.048, 2.286,
3.048
lowerLeft=C5, # 0,
0, 3.048
lowerRight=C6, # 3.048, 0,
3.048
name='Front Wall' )
#Create left wall
LeftWall = vizcave.Wall( upperLeft=C0,
upperRight=C1,
lowerLeft=C4,
lowerRight=C5,
name='Left Wall' )
#Create right wall
RightWall = vizcave.Wall( upperLeft=C2,
upperRight=C3,
lowerLeft=C6,
lowerRight=C7,
name='Right Wall' )
#Create bottom wall
BottomWall = vizcave.Wall( upperLeft=C5,
upperRight=C6,
lowerLeft=C4,
lowerRight=C7,
name='Bottom Wall' )
#Initialize graphics window
viz.go()
#Create cave object
cave = vizcave.Cave()
#Add each wall, make sure that they are ordered in the cluster
software correctly to match this ordering
cave.addWall(FrontWall, mask=viz.MASTER)
cave.addWall(LeftWall, mask=viz.CLIENT1)
cave.addWall(RightWall, mask=viz.CLIENT2)
cave.addWall(BottomWall, mask=viz.CLIENT3)
#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)
#Create another tracker using the keyboard and mouse (arrow
keys adjust position, mouse changes orientation)
origintracker = viztracker.KeyboardMouse6DOF()
#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
viz.add('gallery.ive')