C4Dforbeginners

Compare Node

Now consider the Compare Node. A Compare Node compares the values of the two data items arriving at its two Input Ports. If you select the Compare Node and look at its Attributes (in the Attribute Manager : Node button) you will see that its Data Type has been set to Integer and its Function to "==" (equals). This means that the Compare Node will output a Boolean True value (1) whenever the value of the data arriving at its Input 1 is equal to the value of the data arriving at its Input 2, otherwise it will output a False (0) value.

The Compare Node's Input 1 has delivered to it the current Frame Number by the Time Node: 1, 2, 3, etc. as the animation progresses. The Compare Node's Input 2 is fed by a constant value of 15 from the Constant Node "A". This constant value is set by the user in the node's Attribute Manager : Parameter button.

Therefore, the Compare Node will output a Boolean True momentarily when the animation has reached the Frame no. set at its Input 2 (Frame no. 15), and then returns to False for the remainder of the animation.

To see this, set the animation running to the last frame and round to the beginning and stop it before Frame 15. Note that the two Result Nodes show a new value (Result and Spy Nodes do not show correct values while the animation is running.) Now advance the animation frame-by-frame until Frame 15. The Result (Current Frame No.) shows 15 and the Output of the Compare Node will change to True (1). Now advance to Frame 16 and note that the Output of the Compare Node returns to False.

Monoflop Node

Now for Monoflop Node itself. One of its Input Ports is called On. This is a common Xpresso (and Thinking Particles (TP) ) Input Port. The arrival of a Boolean True data item causes the node in question to start doing whatever it is designed to do. For example, a PStorm Node in Thinking Particles would start emitting particles. Therefore, a True value arriving at its On Input Port will cause Monoflop to do what it is designed to do: change its Output Port from False to True, and, in this Expression, to do that when the current Frame equals 15 (as described above).

Monoflop's other Input Port is named Time. With no other node Linked to it, it will be set to whatever the value is in it's Attributes - 12 Frames at present, revealed in the Attribute Manager : Parameter button. This will determine the extent of the On Period.

Finally, Monoflop's Output data are delivered to the Input Port of the Light Node. This node was created by simply dragging the name of the Light in the Object Manager on to the Xpresso Editor window, and that is the way to introduce any Object whose interaction is to be affected by the Xpresso Expression. The data arriving at the Input Port of the Light Node Input Port "Brightness" controls the brightness of the light - a Boolean False causes it to be off (zero brightness) and a True to be on (100% brightness).

Now let's see the whole Expression working. As before, set the animation running to the last frame and stop it before Frame 15. Now move the animation frame-by-frame until Frame 15 and note that Monoflop's Output changes to True. Now move to Frame 16 and you will see that Monoflop's Output remains at True despite the fact that the Compare Node's Output Port has returned to False. Move the animation again frame-by-frame to Frame 27 and note that Monoflop's Output changes to False, having come to the end of the On Period of 12 Frames.

Finally, position things so that you can see the Viewport (preferably in Perspective) with its cube and light and run the animation. You will see the light coming on at Frame 15 and off at Frame 27.

So that's it.

One more thing. If the Time Node of Monoflop is connected to another node producing data, that data will be interpreted by Monoflop as the desired On Period in seconds. This can be an integer or real data type. To do that, click and drag between the Output Port of Constant B Node (inactive until now) to the Time Input Port of Monoflop, so creating a Link there. This will set the On Period to 0.5 seconds (15 frames at the animation speed of 30 frames/sec).

Dragging boxes around and linking them with string is better than programming in C.O.F.F.E.E. any day!

page1
page1