![]() |
|
#1
|
|||
|
|||
|
Drawing trajectory of an object
It is possible to attach the pencil tool to an object and draw its trajectory?
Or there is a better way to do that?? I'm doing a robot kinematic simulator and I want to display the end effector trajectory |
|
#2
|
|||
|
|||
|
Yes, you can link the pencil tool to any object. You could either activate the pencil draw command with an input signal (mouse button, keypress, etc.) or have it draw continuously.
|
|
#3
|
|||
|
|||
|
Hi Jeff, thank you for your answer
Could you please show me an example of a pencil attached to an object and drawing continuosly? Because I can't make it work properly |
|
#4
|
|||
|
|||
|
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)
|
|
#5
|
|||
|
|||
|
Thank you Jeff, but what I can't do is to attach the pencil to an osgb object (in this case the robot end effector), how can I do that?
Thank you in advance |
|
#6
|
|||
|
|||
|
Could you please help me to attach the pencil tool to an osgb object?
|
|
#7
|
|||
|
|||
|
Have you tried to modify the pencil example code like this:
Code:
robot=viz.add('your_robot_name.osgb')
...
arrowLink = viz.link(mouseTracker,robot)
|
|
#8
|
|||
|
|||
|
I've tried it , but if you add mousetracker , I end up drawing with the mouse.
What I want is to attach the pencil to the end of the robot and the pencil draw the trajectory of the robot end effector |
|
#9
|
|||
|
|||
|
You can parent or link the pencil tool to any node in Vizard.
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Rotate object around mainView? | performlabrit | Vizard | 3 | 12-19-2013 06:31 AM |
| How to render a texture of the transparent object and then blur it | whj | Vizard | 1 | 09-25-2012 03:15 PM |
| AMD graphics hardware seems not to preload object | sleiN13 | Vizard | 2 | 03-20-2012 06:08 AM |
| retrieve Object names | Geoffrey | Vizard | 11 | 12-11-2009 04:26 AM |
| rotate to object | jargon | Vizard | 1 | 08-08-2005 12:20 PM |