View Single Post
  #4  
Old 07-28-2015, 05:06 PM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,471
Take a look at the pencil documentation for commands available. The following example script executes the draw command continuously:

Code:
"""  
Right mouse button clears the drawing.  
Middle mouse button changes color.  
Mouse movements control viewpoint orientation.  
Arrow Keys control viewpoint position.  
""" 

import viz
import vizshape
import vizinfo
vizinfo.InfoPanel(align=viz.ALIGN_LEFT_BOTTOM)

viz.setMultiSample(4)
viz.fov(60)
viz.go()

piazza = viz.add('piazza.osgb')
arrow = vizshape.addArrow(length=0.2, color = viz.RED)

from tools import pencil
tool = pencil.Pencil()

# update code for pencil
def update(tool):

	state = viz.mouse.getState()
	if state & viz.MOUSEBUTTON_RIGHT:
		tool.clear()
	elif state & viz.MOUSEBUTTON_MIDDLE:
		tool.cycleColor()
	else:
		tool.draw()

tool.setUpdateFunction(update)

#Link the pencil tool to an arrow  
#Then move the arrow in the reference frame of the viewpoint
from vizconnect.util import virtual_trackers
mouseTracker = virtual_trackers.ScrollWheel(followMouse = True)
mouseTracker.distance = 1
arrowLink = viz.link(mouseTracker,arrow)
arrowLink.postMultLinkable(viz.MainView)
viz.link(arrowLink,tool)

import vizcam
vizcam.FlyNavigate()

#Hide the mouse cursor
viz.mouse.setVisible(viz.OFF)
Reply With Quote