|
Tell us what you think of the site.
|
Autodesk Media & Entertainment User Community
|
Autodesk® 3ds Max®
|
|
Autodesk® Maya®
|
|
Autodesk® Softimage®
|
|
Autodesk® MotionBuilder®
|
|
Autodesk® Mudbox™
|
|
Autodesk® ImageModeler™
|
|
Autodesk® Sketchbook® Pro
|
|
Autodesk® Smoke on Mac®
|
|
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 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:[0,0,0]
Endpos type:#point3 default:[0,0,0]
)
on updategizmos do
(
this.clearGizmos()
local MyGizmo = manip.makeGizmoShape()
local newmatrix = matrix3 [1,0,0] [0,1,0] [0,0,1] [10,10,10]
local color1 = [0, 1, 0]
--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
)
)
)
)
)
|
|
|
|
Within the updateGizmos the node is referred to as “node” :D
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)
thedour.net
Render 3D @ ScriptSpot.com
|
|
|
|
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:[8,8] width:69 height:16 range:[0,9999,myLength]
on spn1 changed value do
(
myLength = value
)
)
on updategizmos do
(
local color1 = [0, 1, 0]
this.clearGizmos()
local MyGizmo = manip.makeGizmoShape()
local yourNode = node
print yourNode.transform
MyGizmo.transform (matrix3 [1,0,0] [0,1,0] [0,0,1] [100,100,100])
MyGizmo.startNewLine()
MyGizmo.addPoint [0,0,0]
MyGizmo.addPoint [myLength,0,0]
this.addGizmoShape MyGizmo 0 color1 color1
)
tool create
(
on mousePoint click do
(
case click of
(
1:
(
nodetm.position = worldpoint
#stop
)
)
)
)
)
|
|
|
|
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 [0,1,1] [1,1,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 [1,0,0] [0,1,0] [0,0,1] [(eyeDistance/2),0,0])
)
else
(
(matrix3 [1,0,0] [0,1,0] [0,0,1] [-(eyeDistance/2),0,0])
)
)
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 [0, radius, 0] [0, 0, 1] eyeMatrix gizTmp
drawCircle [radius, 0, 0] [0, 1, 0] eyeMatrix gizTmp
drawCircle [0, radius, 0] [1, 0, 0] eyeMatrix gizTmp
drawCircle [0, (radius/1.50), -(radius/1.35)] [0, 0, 1] eyeMatrix gizTmp --iris
drawCircle [0, (radius/2.5), -(radius/1.1)] [0, 0, 1] 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 = #([1,0,0],[0,1,1]) --Red/Cyan
makeEye false eyeCol[1] thisNode nodeTM --Left eye
makeEye true eyeCol[2] thisNode nodeTM --Right eye
)
)
)
thedour.net
Render 3D @ ScriptSpot.com
|
|
|
|