View Single Post
  #4  
Old 02-11-2004, 04:08 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
Hi,

Here is a sample script that performs overlapped stereo. Adjust the variable OVERLAP to 0.5 for 50% overlap. Also, keep in mind that this script uses an intersense for head movement:
Code:
import viz
import vizmat

VERT_FOV		= 50
HORZ_FOV		= 50 * 1.3
HORZ_2_VERT_ASPECT	= 1.0
OVERLAP			= 0.5
IPD			= 0.1

viz.go()

ori = viz.add('intersense.dls')
ori.reset()

X = vizmat.Transform()

#Add the room
room = viz.add('../vrmls/gallery.wrl', viz.WORLD, 2)

# Create a new window in the upper left corner
UpperLeftWindow = viz.add(viz.WINDOW)
UpperLeftWindow.position(0, 1.0)
UpperLeftWindow.size(0.5, 1.0)
UpperLeftWindow.fov(50, HORZ_2_VERT_ASPECT)

#Create a new window in the upper right corner
UpperRightWindow = viz.add(viz.WINDOW)
UpperRightWindow.position(0.5, 1.0)
UpperRightWindow.size(0.5, 1.0)
UpperRightWindow.fov(50, HORZ_2_VERT_ASPECT)

LeftView = viz.add(viz.VIEWPOINT)
LeftView.scene(2)

RightView = viz.add(viz.VIEWPOINT)
RightView.scene(2)

UpperLeftWindow.viewpoint(LeftView)
UpperRightWindow.viewpoint(RightView)

angle = 0.0
def mytimer(num):
	global angle
	
	data = ori.get()
	yaw = data[3]
	pitch = data[4]
	roll = data[5]
	
	angle += .1
	X.makeEuler(yaw + HORZ_FOV*(1-OVERLAP)/2, pitch, roll)
	X.invertOrthoNorm()
	X.preTrans(-IPD, 0, 0)  # pretrans correct for stereo
	X.postTrans(0, 1.8, 0)
	LeftView.update(X)

	X.makeEuler(yaw - HORZ_FOV*(1-OVERLAP)/2, pitch, roll)
	X.invertOrthoNorm()
	X.preTrans(IPD, 0, 0)
	X.postTrans(0, 1.8, 0)
	RightView.update(X)
	
def mykeyboard(key):
	if key == '1':
		UpperRightWindow.visible(0)
	if key == '2':
		UpperRightWindow.visible(1)
		
viz.callback(viz.KEYBOARD_EVENT, mykeyboard)	
	
# Create callback to a timer and start it
viz.callback(viz.TIMER_EVENT,mytimer)
viz.starttimer(0,0.001,-1)

# Turn on collision detection so we can't go through walls
viz.collision(viz.ON)
Also, to fix the duckcourt demo, go to the duckcourt directory and delete the file duckcourt.viz. This was a mistake in the last version and will be fixed in the next version.
Reply With Quote