WorldViz User Forum

WorldViz User Forum (https://forum.worldviz.com/index.php)
-   Vizard (https://forum.worldviz.com/forumdisplay.php?f=17)
-   -   Picking in multiple windows (https://forum.worldviz.com/showthread.php?t=1131)

FalconNL 07-02-2007 05:05 AM

Picking in multiple windows
 
Hello everyone,

I'm currently in the process of comparing Vizard and the TrueVision3D engine. Therefor I'm writing a simple test program in both environments. There are a few things that I haven't been able to accomplish in Vizard yet.

The program has two viewports, one top-down and one 3D viewport. The scene consists of a floor and a cube, both of which can be dragged. I've managed to add two windows and got the dragging working (via viz.pick), but it only works in the main viewport. it completely ignores the two windows. I found that window objects have a pick method as well, so I could use that.

My question is then how to determine which viewport to use for picking. In C# I set the active viewport on the mouse move event, but window objects don't seem to have the callback function. What is the correct way of doing this?

Thanks in advance.

farshizzo 07-02-2007 09:45 AM

Hi,

There is currently no built-in feature that returns the selected window, but you can compute it manually. Here is sample script that creates a couple windows and will determine which one is selected when the left mouse button is pressed:
Code:

import viz
viz.go()

#Create some windows
window1 = viz.addWindow()
window1.clearcolor(viz.RED)

window2 = viz.addWindow(pos=(0,1))
window2.clearcolor(viz.BLUE)

#Create list of windows to select
windowSelection = [window1,window2,viz.MainWindow]

def SelectWindow():
        """Returns the window that is underneath the mouse"""
        for w in windowSelection:
                c = w.displayToWindow(viz.mousepos())
                if 0.0 <= c[0] <= 1.0 and 0.0 <= c[1] <= 1.0:
                        return w
        return None

#Perform picking on selected window when left mouse button pressed
def PickWindow():
        window = SelectWindow()
        if window:
                print 'Window',window.id,'selected'
vizact.onmousedown(viz.MOUSEBUTTON_LEFT,PickWindow)



All times are GMT -7. The time now is 08:10 PM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC