WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 05-12-2009, 01:33 AM
Chrissy2009 Chrissy2009 is offline
Member
 
Join Date: May 2009
Posts: 33
Draw Line between Points

Hi,

I want to create a line between two points. The first point at the mouseDown Position and the second point at the mouseUp Position. Between these two points I want to draw a line.

This works very fine.

But now I want to show the line, before the mouseUp Event. So that I push down the mousebutton, move it at another position and can already see the line, although the mousebutton is pushed.

The line would change as long as I push the mousebutton.

Is this possible?

Thanks in advance...
Reply With Quote
  #2  
Old 05-12-2009, 09:12 AM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
Yes, this is definitely possible. Here is a sample script that uses the viztask module to draw lines with the mouse:
Code:
import viz
import viztask
viz.go()

def DrawLineTask():
	
	while True:
		
		#Wait for left mouse butten to be pressed
		yield viztask.waitMouseDown(viz.MOUSEBUTTON_LEFT)
		
		#Get mouse position
		pos = viz.mouse.getPosition()
		
		#Create line
		viz.startlayer(viz.LINES)
		viz.vertexcolor(viz.RED)
		viz.vertex(pos[0],pos[1],0)
		viz.vertex(pos[0],pos[1],0)
		line = viz.endlayer(parent=viz.SCREEN)
		
		#Create link between mouse position and vertex
		VertexLink = viz.link(viz.Mouse,line.Vertex(1))
		
		#Wait for mouse button to be released
		yield viztask.waitMouseUp(viz.MOUSEBUTTON_LEFT)
		
		#Destroy link
		VertexLink.remove()
		
viztask.schedule( DrawLineTask() )
Reply With Quote
  #3  
Old 05-13-2009, 04:42 AM
Chrissy2009 Chrissy2009 is offline
Member
 
Join Date: May 2009
Posts: 33
Hi,

thanks a lot!

And how can I stop the schedule, so I'm able to draw only two lines and no more??

Is there a possibility to save the separate positions of all these four vertex?
Reply With Quote
Reply

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Pivot points for child objects in Vizard with 3ds Max Gladsomebeast Vizard 0 09-19-2006 11:21 AM
problem with collision detection paulpars Vizard 6 06-09-2006 06:03 PM
Draw Line between Points selected by mouse Johannes Vizard 7 01-07-2005 02:50 PM


All times are GMT -7. The time now is 11:19 AM.


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