View Single Post
  #8  
Old 08-13-2009, 10:39 AM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
Here is a sample script that draws arbitrary arrows on the screen. Hope this helps:
Code:
import viz
import vizmat
viz.go()

def addArrow(begin,end):
	
	ARROW_SIZE = 0.015
	
	#Find distance between points
	d = vizmat.Distance(begin,end)
	
	#Draw arrow line
	viz.startlayer(viz.LINES)
	viz.linewidth(5)
	viz.vertex(0,0,0)
	viz.vertex(0,d,0)
	
	#Draw arrow tip
	viz.startlayer(viz.TRIANGLES)
	viz.vertex(-ARROW_SIZE,d,0)
	viz.vertex(0,d+(2*ARROW_SIZE),0)
	viz.vertex(ARROW_SIZE,d,0)
	
	#Finish drawing arrow
	arrow = viz.endlayer(parent=viz.SCREEN)
	
	#Place/rotate arrow to match begin end points
	arrow.setPosition(begin)
	arrow.setEuler(0,0,-vizmat.AngleToPoint(begin,end))
	
	return arrow

arrow1 = addArrow([0.2,0.2,0],[0.4,0.4,0])
arrow1.color(viz.GREEN)

arrow2 = addArrow([0.6,0.2,0],[0.8,0.9,0])
arrow2.color(viz.RED)
Reply With Quote