#1
|
|||
|
|||
window.pick function over sub-window
Hi,
I have a function that examines all the pixels of the MainWindow using the window.pick function. The problem is that when I use a sub-window instead of MainWindow, I get strange results. Specially, the window.pick command returns "no object" over the portion of the MainWindow that hasn't been occupied by the sub-window. My question is, does the window.pick function works with sub-windows? Best, Omid |
#2
|
|||
|
|||
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) |
#3
|
|||
|
|||
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) 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) Am I doing anything wrong? Best, Omid Quote:
|
#4
|
|||
|
|||
Are the coordinates you are passing to the pick function relative to the lower-left corner of the sub-window, or the lower-left corner of the graphics window? The pick function expects coordinates that are relative to the lower-left corner of the graphics window. Here is a simple script showing that picking does work with sub-windows:
Code:
import viz viz.go() viz.mouse(0) viz.clearcolor(viz.GRAY) #Add sub-windows window = viz.addWindow(view=viz.addView(scene=2),pos=(0.8,1)) window = viz.addWindow(view=viz.addView(scene=3),pos=(0,1)) window = viz.addWindow(view=viz.addView(scene=4),pos=(0,0.2)) window = viz.addWindow(view=viz.addView(scene=5),pos=(0.8,0.2)) #Add quad to each window viz.addTexQuad(pos=(0,1.8,2),color=viz.WHITE,scene=1) viz.addTexQuad(pos=(0,1.8,2),color=viz.RED,scene=2) viz.addTexQuad(pos=(0,1.8,2),color=viz.GREEN,scene=3) viz.addTexQuad(pos=(0,1.8,2),color=viz.BLUE,scene=4) viz.addTexQuad(pos=(0,1.8,2),color=viz.YELLOW,scene=5) def dopick(): win = viz.window.select() if win: node = win.pick() if node: node.runAction(vizact.sizeTo(size=[2,2,1],time=0.1)) node.addAction(vizact.sizeTo(size=[1,1,1],time=0.1)) vizact.onmousedown(viz.MOUSEBUTTON_LEFT,dopick) |
#5
|
|||
|
|||
Thanks. Yes the problem was relativity to the graphics window.
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Documentating function names | aaThomas | Vizard | 5 | 05-15-2007 09:50 AM |
Do you know how to send a value for 'pool' to the onActionEnd function? | ghazanfar | Vizard | 1 | 03-22-2007 10:25 AM |
timers and director function | Jerry | Vizard | 1 | 06-22-2006 09:47 AM |
node3d.center function | tavaksai | Vizard | 3 | 08-13-2004 11:05 AM |
The error window that couldn't | FlyingWren | Vizard | 2 | 12-02-2003 08:23 AM |