How do you create a custom helper?
I want to create a custom helper object which is a point with a direction. Can anyone help guide me along the proper path?
What I have right now is a helper tool which creates a cone on mouse click but as soon as you move the mouse, it dissapears. If you don't move the mouse it creates a cone in the scene, but also a dummy object. As far as I can tell it won't let me create just a cone because I have to extend something. There doesn't seem to be any type of helper object which has a direction of some sort which I could extend. Most of this code is cobbled together from whats in the help file:
plugin helper myConstraint
name:"myConstraint"
classID:#(0x6b4889fb, 0x5da01536)
category:"Standard"
extends:dummy
version:1
(
rollout params "Parameters" width:160 height:248
(
)
tool create
(
local p, createpoint
-- define a function to perform actual node creation. Setting coordsys to
-- ‘grid’ in order for the alignment of the node’s local Z axis to be
-- perpendicular to the construction grid
-- fn createpoint = in coordsys grid p=point pos:gridPoint
--
-- set up so that a node is created on a mouse button down, move node
-- drag, release node at mouse button up.
--
-- if clickno == 1, then we are at first mouse click, which is a mouse
-- button down. If clickno != 1, at following mouse button up.
on mousePoint clickno do (
if clickno == 1 then (
-- createPoint()
--in coordsys grid p=point pos:gridPoint
print "Click == 1"
in coordsys grid p=Cone pos:gridPoint smooth:on heightsegs:1 capsegs:1 sides:5 height:39.3701 radius1:3.93701 radius2:-50.3244 mapcoords:on transform:(matrix3 [1,0,0] [0,0,1] [0,-1,0] [-5.98291,-4.23415e-007,9.68661]) isSelected:on
-- if p == undefined, then clicked twice without mouse movement
-- (double clicked). No point object present, so just ignore this click.
) else if p != undefined do (
print "Setting p to undefined"
p.pos = worldPoint
p = undefined
#stop
)
)
-- if p != undefined, we are moving a previously created node
-- if p == undefined, and left mouse button is down, create a node
on mouseMove clickno do (
if p != undefined then (
print "MouseMove p != undefined"
p.pos=worldPoint
) -- else if lbutton then (
-- print "MouseMove p == undefined"
-- -- createPoint()
-- in coordsys grid p=Cone pos:gridPoint smooth:on heightsegs:1 capsegs:1 sides:5 height:39.3701 radius1:3.93701 radius2:-50.3244 mapcoords:on transform:(matrix3 [1,0,0] [0,0,1] [0,-1,0] [-5.98291,-4.23415e-007,9.68661]) isSelected:on
-- )
)
)
)