WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 01-07-2005, 11:55 AM
Johannes Johannes is offline
Member
 
Join Date: Jan 2005
Posts: 143
Draw Line between Points selected by mouse

Hi,
the following program should draw a line between two in the "world" selected by mouse.

As viz.screentoworld(viz.mousepos()) returns a vector - is there an easier way to figure out the point the mouse was pressed at (e.g. return value [3,4,5]?

I guess I really don't understand viz.screentoworld(viz.mousepos()) that much - where does this vector start - at the viewpoint?

Thank you,
Johannes



import viz

viz.go()

SPIsSet,EPIsSet=0,0
startPoint=[0,0,0]
endPoint=[0,0,0]


def mousedown(button):
#
if button == viz.MOUSEBUTTON_LEFT:
global startPoint,SPIsSet
global endPoint,EPIsSet
if SPIsSet==0:
startPoint=viz.screentoworld(viz.mousepos())
print 'startPoint:',startPoint
SPIsSet=1
elif (SPIsSet!=0 & EPIsSet==0):
endPoint=viz.screentoworld(viz.mousepos())
print 'ePoint:',endPoint
EPIsSet=1
drawLine(startPoint, endPoint)
EPIsSet=0
SPIsSet=0
else:
print 'forgot option 3'

def drawLine(begin, end):
viz.clearcolor(0.0,0.0,0.0)
viz.vertexcolor(2, 4, 4)
viz.startlayer(viz.LINE_LOOP)
viz.vertex(begin)
viz.vertex(end)
line = viz.endlayer()
#posBox=viz.add('../resources/models/box.wrl')
#posBox.scale(0.01,0.01,0.01)
#posBox.translate(begin)

#Create callbacks for timer events and mouse click events
viz.callback(viz.MOUSEDOWN_EVENT,mousedown)
Reply With Quote
 

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 07:51 AM.


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