Mouse Selection Area Question
Is there any way that I can create a selection box with a mouse click (just like selecting icons on the desktop with the mouse) in vizard? Is there any builtin function for doing this? Ideally, the selection are would return the objects that were selected.
Does anyone have any suggestions for doing this? Thank you. |
This is what I managed to do so far:
import viz import viztask viz.go() def DrawLineTask(): while True: viz.startlayer(viz.QUADS) viz.vertexcolor(viz.RED) yield viztask.waitMouseDown(viz.MOUSEBUTTON_LEFT) pos = viz.mouse.getPosition() viz.vertex(pos[0],pos[1],0) #0 viz.vertex(pos[0],pos[1],0) #1 viz.vertex(pos[0],pos[1],0) #2 viz.vertex(pos[0],pos[1],0) #3 line = viz.endlayer(parent=viz.SCREEN) VertexLink = vizact.ontimer(.01, copyTransform, viz.Mouse, line.Vertex(0), line.Vertex(1), line.Vertex(2), line.Vertex(3)) yield viztask.waitMouseUp(viz.MOUSEBUTTON_LEFT) VertexLink.remove() line.remove() viztask.schedule( DrawLineTask() ) def copyTransform(mouse, vertex_a, vertex_b, vertex_c, vertex_d): M = mouse.getMatrix() A = vertex_a.getMatrix() A[12] = M[12] A[13] = M[13] vertex_c.setMatrix(A) A = vertex_a.getMatrix() A[12] = M[12] vertex_b.setMatrix(A) A = vertex_a.getMatrix() A[13] = M[13] vertex_d.setMatrix(A) How can I make it now do the selection under the square? |
For each object in the scene you could get the 2D screen coordinate corresponding to the object's position using the
This world require your selection box includes the objects center to register as a selection: Code:
import viz |
Thank you. It did the trick!
|
All times are GMT -7. The time now is 11:34 PM. |
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC