View Single Post
  #3  
Old 09-23-2009, 06:38 AM
omidbrb omidbrb is offline
Member
 
Join Date: Dec 2008
Posts: 27
I think I didn't describe the problem clearly. Imagine I created a window:

Code:
	UpperRightWindow = viz.addWindow()
	UpperRightWindow.position (0.6, 1.0)
	UpperRightWindow.size(0.4, 0.4)
	UpperRightWindow.visible(0,viz.SCREEN)

	RightEye = viz.add(viz.VIEWPOINT)
	RightEye.eyeheight(0)
	rightLink = viz.link(avatar.getBone('Bip01 Head'),RightEye)

	UpperRightWindow.viewpoint(RightEye)
	UpperRightWindow.clip(0.00001, 50000)
Then I want to determine what object lies at any pixel:

Code:
	xres = 200
	yres = 200
	size = (xres, yres)

	for x in xrange(xres):
		for y in xrange(yres):
			xNorm = x/(xres*1.0)
			yNorm = 1-y/(yres*1.0)
			intersect = UpperRightWindow.pick(True, viz.WORLD, pos = [xNorm, yNorm])
			if intersect.valid == True:
				print "pixel " + str(x) + "," + str(y) + "," + intersect.name + "," + str(intersect.point)
			else:
				print "no object at " + str(x) + "," + str(y)
This function works correctly with viz.MainWindow but not with the new UpperRightWindow.

Am I doing anything wrong?

Best,
Omid

Quote:
Originally Posted by farshizzo View Post
The window.pick function only works for that window. You will have to call the pick function for the specific window you are interested in. You can use the viz.window.select command to get the current sub-window located at the specified screen position. I just noticed that this command is currently undocumented, so here is some example code showing how to use it:
Code:
# Get the sub-window located at the current mouse position
window = viz.window.select()

# Get the window located at the center of the screen
window = viz.window.select([0.5,0.5])

# Get the window located at pixel location (100,100)
window = viz.window.select([100,100],mode=viz.WINDOW_PIXELS)
Reply With Quote