PDA

View Full Version : float_script cues not rendering


bhnh
04-14-2008, 11:32 PM
Here's a brief script wherein a custom att of one object controls the color of a second object...
(
ca = attributes predecessor
(
parameters main rollout:params
(
pred type:#Node
clutch type:#float ui:btn_clutch default:1.0
)
rollout params "Predecessor Test"
(
button btn_clutch "Clutch Button"

on btn_clutch pressed do
(
if clutch == 1.0 then clutch = 0.0 else clutch = 1.0
)

)
)
rollout predtest "Test Pred attribute"
(
button btn_init "First Box"
button btn_next "Next Box"
local p, i=50, holder, fs

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

)

on btn_next pressed do
(
b = box pos:[i,0,0]
custAttributes.add b ca
b.pred = p
holder = point()
holder.parent = b
fs = float_script()
holder.position.x_position.controller = fs
fs.addNode "cube" b
fs.script = "try (with animate off (if cube.clutch == 1.0
then cube.pred.wirecolor = blue else cube.pred.wirecolor = red \n 0))catch(0) "
i += 50
p = b
)
)

createDialog predtest 200 60
)
When I scrub the animation in Max the color changes happen as planned (animation in max (http://www.e-nimation.com/colorFloat_Script/colorFloat_Script.htm). But when published, either as a .mov (animation as .mov (http://www.e-nimation.com/colorFloat_Script/colorFloat_Script.mov) or an .avi (animation as .avi (http://www.e-nimation.com/colorFloat_Script/colorFloat_Script.avi), the color changes don't appear. Am I missing something fundamental here? Any input greatly appreciated.

Bobo
04-15-2008, 12:47 AM
VERY fundamental.

First of all, keep in mind that .wirecolor is considered Non-Animatable by Max. Thus, the wirecolor will be evaluated on the first frame of a range and never updated again. Max does this with everything - geometry, modifiers and so on - when a property is animated via, say, keyframes, the corresponding object's validity interval is set to just the current frame, causing it to update on each frame. But if nothing is animated (say, a simple Box with no animated parameters), its validity interval is set to "forever" and Max will update it just once before starting rendering. Some properties that cannot be animated natively will be skipped in general because when Max 1.0 was designed, Scripting was not part of the design ;)

I would suggest to assign a standard material and manipulate its diffuse color instead. Materials are considered animatable and will work better in your case.

Since Helpers do not render, storing data in helpers to control render properties is also a bad idea. Max will evaluate the PRS of the helper ONLY if something else depends on it, but in your case it has no scene dependency and is being skipped completely. Max cannot know that the Helper will affect renderable properties since the color change happens as a side effect of a position controller evaluation.

For example, if you would link the box that has to change the color to the Point helper holding the script, Max will see that the position of the Box depends on the position of the Helper and will update both, causing the Float_Script to actually do something. If the script manipulates the diffuse color of a material, that material will be updated on each frame and you will see the color changing...

In your code though, the helpers were linked to the boxes and they would not update at all because Max would think that nothing really depends on the helpers...

(
ca = attributes predecessor
(
parameters main rollout: params
(
pred type:#Node
clutch type:#float ui:btn_clutch default:1.0
)
rollout params "Predecessor Test"
(
button btn_clutch "Clutch Button"

on btn_clutch pressed do
(
if clutch == 1.0 then clutch = 0.0 else clutch = 1.0
)

)
)
rollout predtest "Test Pred attribute"
(
button btn_init "First Box"
button btn_next "Next Box"
local p, i=50, holder, fs

on btn_init pressed do
(
b = box()
b.material = standard() --assign a material
custAttributes.add b ca
print b.clutch
p = b

)

on btn_next pressed do
(
b = box pos:[i,0,0]
custAttributes.add b ca
b.material = standard() --assign a material
b.pred = p
holder = point()
holder.parent = b
fs = float_script()
holder.position.x_position.controller = fs
fs.addNode "cube" b
fs.script = "try (with animate off (if cube.clutch == 1.0 then cube.pred.material.diffuse = blue else cube.pred.material.diffuse = red \n 0))catch(0) "
p.parent = holder --parent the previous box to the current holder to cause dependency
i += 50
p = b
)
)

createDialog predtest 200 60
)

bhnh
04-15-2008, 01:27 AM
Ah. Thanks, Bobo. So many nuances to this.

CGTalk Moderation
04-15-2008, 01:27 AM
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.