View Single Post
  #9  
Old 02-12-2004, 12:24 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
Hi John,

I modified the previous code so that when you press the 'p' key it will print out the X and Y position of each viewpoint. When I run this script here and tilt the viewpoint 90 degrees. The X position of both viewpoints are equal and the Y positions differ by the IPD distance, which means the viewpoints lie on top of each other. Can you try running this script to make sure you are getting similar results?
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')

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

RightView = viz.add(viz.VIEWPOINT)

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)
	if key == 'p':
		print 'X Position: Left',LeftView.get(viz.HEAD_POS)[0]
		print 'X Position: Right',RightView.get(viz.HEAD_POS)[0]
		print 'Y Position: Left',LeftView.get(viz.HEAD_POS)[1]
		print 'Y Position: Right',RightView.get(viz.HEAD_POS)[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)
Reply With Quote