PDA

View Full Version : Resetting the Color and Alpha of Nodes


The SundanceKid
07-16-2014, 11:12 AM
Hi,

I'm trying to make nodes 'blink' in Vizard 5. I wrote the following code to make a given node blink:

fadeColor = vizact.fadeTo(node.getColor(), time=0.333)
fadeWhite = vizact.fadeTo([1,1,1], time=0.333)
fadeSequence = vizact.sequence(fadeWhite,fadeColor,viz.FOREVER)
node.addAction(fadeSequence)

This code works. My problem arises when I want a given node to stop blinking. If I have its node.getColor() values, I can just fade the node back to those values. But this works only for one-color nodes; some nodes, for example those composed of one green node and one black node, will return values that represent a diffusion of green and black when I call node.getColor(). This means I can only reset nodes to a mix of their original colors — I can't set all of their children back to each of their respective original colors.

Of course, I could recurse through each child and each child of each child for all of the nodes, save all the color values to a list, and then access those values when resetting their colors and alphas. Surely, there's an easier way to do this, right? Isn't there some built-in function that I can call to reset a node to its original state/color/alpha?

Jeff
07-17-2014, 04:40 PM
Saving the values to a list is probably the way to do this. Is this a model with sub-parts or is the parent/child hierarchy defined through the script? The fadeTo action takes an optional 'node' argument which applies the action to a sub-part.