View Single Post
  #13  
Old 02-18-2004, 05:52 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
Hi John,

Sorry for the late reply, I took the last few days off. Anyway, I believe I understand your problem now. I've attached the new code. When we release the next version of Vizard, the overlap will be a built-in command, so you won't have to do any of this manual calculation. Let me know if this is correct:
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)

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

	X.makeEuler(yaw, pitch, roll)
	X.invertOrthoNorm()
	X.preTrans(IPD, 0, 0)
	X.postTrans(0, 1.8, 0)
	X.preRot(0,1,0, HORZ_FOV*(1-OVERLAP)/2)
	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