WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 07-18-2009, 05:49 AM
Chrissy2009 Chrissy2009 is offline
Member
 
Join Date: May 2009
Posts: 33
Exclamation Create line and vertex

Hello,

I want to draw a line with my mouse. So I made:

Code:
def drawLine():	
	global tmpnumber
	
	while tmpnumber == 0:
		yield viztask.waitMouseDown(viz.MOUSEBUTTON_LEFT)
		
		tmpMousePOS = viz.screentoworld(viz.Mouse.getPosition())
		tmpMousePOS.length = 0
		pos = tmpMousePOS.end
		
		viz.startlayer(viz.LINES)
		viz.linewidth(10)
		viz.vertexcolor(viz.BLACK)
		viz.vertex(pos[0],pos[1],0)
		viz.vertex(pos[0],pos[1],0)
		line = viz.endlayer()
		
		VertexLink = viz.link(viz.Mouse,line.Vertex(1))
		
		yield viztask.waitMouseUp(viz.MOUSEBUTTON_LEFT)
		VertexLink.remove()
		
		tmpnumber += 1

task = viztask.schedule( drawLine() )
But the line is not at the mouse position. It looks like the proportion is wrong.
Can somebody help me?

I want to draw a line with my mouse. Not at the screen, but in the world.

If I made this:

Code:
def drawLine():	
	global tmpnumber
	while tmpnumber <= 1:
		yield viztask.waitMouseDown(viz.MOUSEBUTTON_LEFT)
		
		pos = viz.mouse.getPosition()
		
		viz.startlayer(viz.LINES)
		viz.linewidth(3)
		viz.vertexcolor(viz.BLACK)
		viz.vertex(pos[0],pos[1],0)
		viz.vertex(pos[0],pos[1],0)
		line = viz.endlayer(parent=viz.SCREEN)
		
		VertexLink = viz.link(viz.Mouse,line.Vertex(1))
		
		yield viztask.waitMouseUp(viz.MOUSEBUTTON_LEFT)
		VertexLink.remove()
		
		tmpnumber += 1
than it works. The line is exactly at the mouseposition. But I want to draw the line in the world with an given z-value; for example at z = 10.


And how can I create at the begin and end of the line an vertex point?

Thanks an lot!!
Reply With Quote
  #2  
Old 07-20-2009, 10:22 AM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
You can find a post here that describes how to convert a 2D mouse coordinate into a 3D world coordinate.
Reply With Quote
  #3  
Old 07-20-2009, 10:53 AM
Chrissy2009 Chrissy2009 is offline
Member
 
Join Date: May 2009
Posts: 33
Hi,

I still tested this, but it doesn't work!
Code:
while tmpnumber == 0:
		yield viztask.waitMouseDown(viz.MOUSEBUTTON_LEFT)
		
		tmpMousePOS = viz.screentoworld(viz.Mouse.getPosition())
		tmpMousePOS.length = 0
		pos = tmpMousePOS.end
		
		viz.startlayer(viz.LINES)
		viz.linewidth(10)
		viz.vertexcolor(viz.BLACK)
		viz.vertex(pos[0],pos[1],0)
		viz.vertex(pos[0],pos[1],0)
		line1 = viz.endlayer()
		
		VertexLink = viz.link(viz.Mouse,line1.Vertex(1))
		
		yield viztask.waitMouseUp(viz.MOUSEBUTTON_LEFT)
		VertexLink.remove()
		
		tmpnumber += 1
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
How to get the position of a vertex Jerry Vizard 1 10-04-2006 11:28 AM
get vertex with on the fly object enkeli Vizard 9 05-25-2006 08:27 PM


All times are GMT -7. The time now is 12:20 AM.


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