View Single Post
  #2  
Old 03-02-2011, 01:24 PM
Renato Lima Renato Lima is offline
Member
 
Join Date: Sep 2010
Posts: 54
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?
Reply With Quote