bhnh
04-22-2008, 02: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.
(
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.
