Announcements

Between mid-October and November, the content on AREA will be relocated to the Autodesk Community M&E Hub and the Autodesk Community Gallery. Learn more HERE.

Simple Manipulators

Simple Manipulators

Anonymous
Not applicable
449 Views
3 Replies
Message 1 of 4

Simple Manipulators

Anonymous
Not applicable
Hi,
I've been having this wierd problem. I am making a new helper that creates a guide (a line)
from 2 click you make. I am using the line (thus the vector) as the x axis. As you would understand , I am using the line as a new transformation matrix. Applying the Matrix3 from the tool is easy:

nodetm = newTM -- where nodeTM is a direct access to the newly created transform matrix.


The problem is that I really need to create this node by another UI or functions. So the Script won't get through the "tool" part. This will result in not applying the new Matrix3 I created.

Question:
Is there a way to access to the node or its transform from the updategizmos?


The help files says:



Methods:
<void><MixinInterface:gizmoShape>.startNewLine()
Starts a new line in the gizmo.

<void><MixinInterface:gizmoShape>addPoint <point3 by value>point
Adds a new point to the last line created.

<void><MixinInterface:gizmoShape>transform <matrix3 by value>point
Transforms the gizmo by the given matrix3 value



I've been trying everything from "this" "target" "node" "nodeTM" or using the node i created.transform and nothing worked... Here is my example code since i can't show my real actual code from my job:
plugin simplemanipulator HelperTest
name:"MyTest"
category:"Test"
classID:#(0x6d92d655, 0x4db1aac6)

(
parameters main
(
Startpos type:#point3 default:
Endpos type:#point3 default:
)

on updategizmos do
(
this.clearGizmos()
local MyGizmo = manip.makeGizmoShape()
local newmatrix = matrix3
local color1 =

--Part of code that I wish would work
MyGizmo.transform = newmatrix -- says Unknown property: "transform" in <MixinInterface:gizmoShape> <<
print this -- This will only point to my manipulator , not the helper / gizmo / node
print target -- undefined
print node -- undefined
print nodeTM -- undefined
-----------------------------------------

-- Draw Gizmo
MyGizmo.startNewLine()
MyGizmo.addPoint startpos
MyGizmo.addPoint endpos
this.addGizmoShape MyGizmo 0 color1 color1
)

tool create
(
on mousePoint click do
(
case click of
(
1:
(
startpos = worldpoint
)
3:
(
endpos = worldpoint
#stop
)
)
)
)
)
0 Likes
450 Views
3 Replies
Replies (3)
Message 2 of 4

Anonymous
Not applicable
Within the updateGizmos the node is referred to as "node" 😄

 
on updateGizmos do
(
local giz
local yourNode = node
print yourNode.transform
giz = manip.makeGizmoShape()
...
)


Also important to note: You cannot directly set the transform of a gizmo via giz.transform = (matrix3).

With gizmos it is instead a method: giz.transform() which applies a matrix3 transformation to the gizmo.

giz.transform (inverse yourNode.transform)
0 Likes
Message 3 of 4

Anonymous
Not applicable
I've been trying everything and i can't get to the node. I am ultimately trying to change position of this node at least if i could change it's transform matrix.

Here is my code , try it if you want. As you can see i am trying to assign a new matrix with a big offset in its position and nothing changes.

and the print node.transform does a Unknown property: "transform" in undefined <<
plugin simplemanipulator TH4Test
name:"MyTest"
category:"Test"
classID:#(0x6d92d655, 0x4db1aac6)

(
parameters main rollout:paramRollout
(
myLength type:#float ui:spn1 default:20
)

rollout paramRollout "Parameters" width:160 height:120
(
spinner spn1 "" pos: width:69 height:16 range:

on spn1 changed value do
(
myLength = value
)
)


on updategizmos do
(
local color1 =

this.clearGizmos()
local MyGizmo = manip.makeGizmoShape()

local yourNode = node
print yourNode.transform
MyGizmo.transform (matrix3 )

MyGizmo.startNewLine()
MyGizmo.addPoint
MyGizmo.addPoint
this.addGizmoShape MyGizmo 0 color1 color1

)

tool create
(
on mousePoint click do
(
case click of
(
1:
(
nodetm.position = worldpoint
#stop
)
)
)
)
)




0 Likes
Message 4 of 4

Anonymous
Not applicable
Yours likely isn't working because you need "on canManipulateNode(...)"

Here is an example for you (a snippet from my stereoscopic camera rig):

plugin simpleManipulator Eye_Gizmo
name:"Eye Gizmo"
invisible:true
classID:#(0x47294766, 0x7c49a8b6)
(
--******************************************************************************************
--Events
--******************************************************************************************
on canManipulateNode n do
(
--If node is geometry or helper...
if (Superclassof n == GeometryClass) or (Superclassof n == helper) then (true)
)

on updateGizmos do
(
local giz
local thisNode = node
(
this.clearGizmos()

nodeTM = matrix3 1
--Reverse any scewing caused by scale (if any)
preScale nodeTM (inverse (scaleMatrix thisNode.scale)).scalepart
--Rotate eyes to look up
rotateX nodeTM 90

giz = manip.makeGizmoShape()

this.addGizmoShape giz 0

------------------------------------------------------------------------------------------------------------------
--/////////////////////////////////////////////////////////////////////////////////////////////
--EYES--------------------------------------------------------------------------------------------------------
fn makeEye eye2 eClr obj m =
(
radius = 10
eyeDistance = 30
eyeMatrix =
( -- Separate transform offsets for left/right eyes
if (eye2 == true) then
(
(matrix3 )
)
else
(
(matrix3 )
)
)

fn drawCircle thePoint axis em g =
( --Function for building gizmo lines circles with a given radius
divs = 30
g.addPoint (thePoint * em)
for i=1 to divs do
(
thePoint = thePoint * ((angleaxis (360/divs) axis) as quat)
g.addPoint (thePoint * em)
)
g.startNewLine()
)

gizTmp = manip.makeGizmoShape()

drawCircle eyeMatrix gizTmp
drawCircle eyeMatrix gizTmp
drawCircle eyeMatrix gizTmp
drawCircle eyeMatrix gizTmp --iris
drawCircle eyeMatrix gizTmp --pupil

--Apply transform to the given eye shape
gizTmp.transform m
--Add new eye shape to gizmo
this.addGizmoShape gizTmp 2 eClr eClr
)
eyeCol = #(,) --Red/Cyan
makeEye false eyeCol thisNode nodeTM --Left eye
makeEye true eyeCol thisNode nodeTM --Right eye
)
)
)
0 Likes