PDA

View Full Version : local coordsys in paramWire?


bhnh
04-22-2008, 03:25 PM
Here's a simple routine that creates two boxes and wires their z_rotations via a float_script...
(
ca = attributes predecessor
(
parameters main rollout:params
(
pred type:#Node
engage type:#float ui:btn_engage default:2.0
disengage type:#float ui:btn_disengage default:0.0
ratio type:#float
invRatio type:#float
)
rollout params "Predecessor Test"
(
button btn_engage "Engage"
button btn_disengage "Disengage"

on btn_engage pressed do
(
this.engage = this.ratio
this.invRatio = 1/this.ratio
print engage
)

on btn_disengage pressed do
(
this.engage = 0.0
this.invRatio = 0.0
print engage
)

)
)
rollout predtest "FloatScript-ParamWire"
(
button btn_init "First Box"
spinner spn "Ratio" range:[0,1000,1]
button btn_next "Next Box"
local p, i=50, holder, fs

on btn_init pressed do
(
b = box()
custAttributes.add b ca
print b.engage
p = b

)
on btn_next pressed do
(
b = box pos:[i,0,0]
custAttributes.add b ca
b.pred = p
b.ratio = spn.value
b.engage = b.ratio
b.invRatio = 1/b.ratio
paramWire.disconnect2way b.pred.rotation.controller.z_rotation.controller \
b.rotation.controller.z_rotation.controller
paramWire.connect2way b.rotation.controller[#z_rotation] \
b.pred.rotation.controller[#z_rotation] ("Z_rotation*"+b.engage as string) ("Z_rotation*"+ b.invRatio as string)
holder = point()
fs = float_script()
holder.position.x_position.controller = fs
fs.addNode "cube" b
fs.script = "paramWire.connect2way cube.rotation.controller[#z_rotation] \
cube.pred.rotation.controller[#z_rotation] (\"Z_rotation*\"+cube.engage as string)\
(\"Z_rotation*\"+cube.invRatio as string)\n0"
p.parent = holder
i += 50
p = b
)
)
createDialog predtest
)
As demonstated in this vid... coordsys-paramWire question (http://www.e-nimation.com/turbosquid/coordsysWire/coordsysWire.htm)... right out of the box the two boxes are synced as planned if one box is rotated on the z_axis. However, if Box2 is rotated, say 45 degrees on the y_axis, when Box1 is rotated it's evident that the linkage is using the World coordinate system; Box2 doesn't rotate on its local z_axis but rather on the World z_axis. If Box2 is parented to a Dummy and the Dummy is rotated 45 degrees on the y_axis, Box2 will rotate on its local z_axis.

My question is, can the float script.script be written in such a way that the two boxes can be wired using their local coordinates rather than global coordinates, and avoid parenting to other objects? I've tried inserting in coordsys local in the float script every place I can think of, and I get either nothing or a variety of errors. Many thanks in advance.

PiXeL_MoNKeY
04-22-2008, 03:50 PM
Have you tried using an ExposeTransformHelper? This should allow you to get the local values between an Expose Node and a Local Reference Node. From there you can use the maxscript buttons in the helper to copy out the maxscript link to the local values you need.

-Eric

bhnh
04-22-2008, 06:29 PM
From the little that the MXS Reference says, it looks like your suggestion's the way to go, Eric, but I haven't the foggiest idea how to implement it. As usual the MXS Ref entry reads like it's missing the first two pages; no complete syntax, no examples. Any chance you might demonstrate how to set it up in the example code I posted? It's asking a lot, but would be immensely appreciated.

Kameleon
04-22-2008, 06:40 PM
Have you tried applying a Freeze Transform and them wiring those parameters?

bhnh
04-22-2008, 06:55 PM
Thanks, Artur. Can you tell me where in the MAXSCRIPT Reference I could read about freeze Transform? I can't find it anywhere.

RobertMayer
04-22-2008, 09:10 PM
Select your object, Alt+Right click. should be Freeze Transform.

Kameleon
04-23-2008, 02:59 PM
After doing what Robert told you, you can access it like this:



print $.position.controller.Frozen_Position
[0.610664,0.358727,0]
[0.610664,0.358727,0]
showproperties $.position.controller.Zero_Pos_XYZ
.X_Position : float
.Y_Position : float
.Z_Position : float



The first one is the World Position in which the object was frozen, the other one is the one I guess you want, that is [0,0,0]. Hope it helps!

bhnh
04-23-2008, 03:06 PM
Thanks, guys. I'll give it a try.

bhnh
04-23-2008, 04:12 PM
Well, I tried every permutation I could think of with the above suggestions, but didn't have any success. I was directed to another thread (http://forums.cgsociety.org/showthread.php?f=98&t=430499) which looks like it holds some promise.

bhnh
04-24-2008, 10:52 PM
OK, I'm raising the white flag on this one. :banghead:

I've searched and read the threads pertaining to anything like this, and am left with a vague understanding that it involves Node Transforms, but I'm just not getting it. Basically what I'd like to do is find a way to put
r = $box01.rotation.z_rotation
in coordsys local $box02.rotation.z_rotation = r
in a form that it'll work in a paramWire in a float_script. :scream:

CGTalk Moderation
04-24-2008, 10:52 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.