# Generators

These nodes are used to generate sequences, ramps, bounce effects, maths functions based upon current frame, etc. Their principle use is in setting when things happen with animation nodes, they were made to avoid me having to remember complex maths when building node trees! Here are the six nodes in the set: The “Multi-Channel Sequencer” Node is designed to repeat a sequence of numbers over a set frame period. The size of the steps and the number of steps can all be set. The node has the following input:

• Start Frame
• End Frame
• Number of Steps
• Step Value

Start Frame expects and Integer and can be either entered as entered text or fed from another node, End Frame also expects an integer and should be at least 10 greater than Start Frame, or an error is given and your sperm/egg count seriously reduced. Number of Steps is exactly what it says – how many steps are there in the sequence. Step value is how many frames each step will last and is a float number.

The node has the following outputs:

• Output as Integer List (Integer List)
• Current Pulse Index (Integer)

So when it is running it will output, for example 1,0,0,0,0 – then – 0,1,0,0,0 as an Integer List (if the Number of Steps is 5) with the values changing from 0 to 1 at 5 frame intervals (if the Step Value is 5), and so on, into the Output as Integer List socket. It will also output the current index, so 0 if the list is 1,0,0,0,0 1 if the list is 0,1,0,0,0 – 5 if the list is 0,0,0,0,1 – and so on, into the Current Pulse Index socket. This will only happen between the Start and End Frame settings, otherwise it will output only a list of zeros and zero as the pulse index.

The “Frame Range/Switch” Node is designed to limit when an action in the node tree can take place, so either inside, or outside of the stated frame range. It also gives a “local” frame number, so they count from when the start frame in the node rather than the start frame in the project. The node has the following inputs:

• Inside Frame Range (Checkbox)
• Input Value (Float)
• Start Frame (Integer)
• End Frame (Integer)

End Frame must be greater than Start Frame, or an error will be returned. It has the following outputs:

• Frame (In Rangle) (Integer)
• Output Value (Float)
• In/Out of Range (Boolean)
• Combined Output (Float)

The first output gives the “local” frame, starting from 0 at the Start Frame value. The second output gives 0, or the value of Input depending on whether the current frame is in or out of range, so if Inside Frame Range is on, Start Frame is 100 and End Frame is 200, it will give 0 at frame 100 in the time line, 50 at frame 150, etc.

The Combined Output multiplies the “local” frame number by the Input Value. So if the Input Value is 4 and all other settings are as above, it will give 0 before frame 100 in the timeline, 80 at frame 120, and 0 after frame 200.

The In/Out Range simply lets the user know if the current frame in the timeline is in, or out of the specified range set by Start and End Frame values. If you have not checked the Inside Frame Range checkbox, it gives False in between Start and End and True outside of those values of course, since the working range is now outside of the given values.

It is not difficult to see that these nodes can be nested together, feeding output from each into an Expression Node to achieve a series of activations of a node sub-tree in various different frame ranges as below: The “Frame Ramp” Node is designed to give a gradually increasing value from 0 to 1, or decreasing value from 1 to 0 between the Start and End Frame values. It has the following inputs:

• Expo Function (Checkbox)
• Exp Factor (Integer)
• Input Value (Integer – 0 or 1 only)
• Start Frame (Integer)
• End Frame (Integer)

End Frame must be greater than Start Frame, or an error will be returned. It has the following output:

• Output Value (Float)

The node will output values between 0 and 1 over the given frame range if the Input is 0 and between 1 and 0 if the Input is 1. If Expo Function is not checked it will be a linear decay/growth. If Expo Function is checked it will give an exponential decay/growth depending on the value in Exp Factor – a value of 2 gives a quadratic decay/growth, a value of 3 gives a cubic decay/growth and so on. This function is designed to give a gradual then increasing rate of acceleration/deceleration of a movement over the specified frame range for example. In this example the Empty is gradually accelerated to 180 degrees of rotation between frames 21 and 101. Thereafter you would need to add more nodes to keep it rotating at a set rate. So, in the image above, it would rotate 0.5 degrees between frames 21 and 22 accelerating to 9 degrees between frames 100 and 101 – finishing at 180 degrees total rotation. You would then need a node setup that kept it rotating at 9 degrees per frame after frame 101 using say a Frame Range/Switch node and adding the two outputs together and feeding this into the Combine Euler node.

Or like this: Expression node formula is: ((x > 101) * (9 * (x – 101))) + y

Where x is current frame and y is value from Frame Ramp node. So if the frame is greater than 101, it adds 9 times the current frame minus 101 to keep it spinning at 9 degrees per frame – Simples!

The “Bounce” Node gives a “bouncing” motion in terms of a height decaying over time. Here is a typical usage: The cube will drop from the start height down to the base height and then bounce with a decaying bounced height.

The node has the following inputs:

• Start Frame (Integer)
• End Frame (Integer)
• Cycle Speed (Float)
• Speed Decay Factor (Float 0.8 to 1)
• Compute Factor (Used by the System – no user input accepted)
• Start height (Float)
• Base Height (Float)

The Start Frame is the frame you want the motion to begin, it must be at least 1 greater than the project start frame, or an error is returned. The End Frame is the frame number you want the motion to end on. The Cycle Speed is the time in frames for one cycle – object drops and bounces back. The Compute Factor is a variable stored by the system, anything you enter here will be over-written. The Start Height is the Z value for the object before it falls, the Base Height is the height from which it bounces and must be less than the Start Height (you can always reverse the output with a subsequent Math node).

The Speed Decay Factor is a speed by which you want the cycles to decrease in time as the bounce height decreases and the system will accept values between 0.8 and 1. If the value is 1, the cycle times remain unaltered from the Cycle Speed value. Incidentally, the Compute Factor will show the revised Cycle Speeds as the animation progresses, if the Speed Decay Factor is less than 1.

You can, of course feed this into any axis, it is not restricted to Z only, nor is its use restricted to linear motion, you can also feed rotations & scales, whatever you want really.

The “Maths Functions” Node produces a series of outputs based upon mathematical expressions. Here is a typical usage: The Cylinder is spinning at 100 revs per minute, taken from the frame rate in the blend file.

The node has the following inputs:

• Tick Speed (sec) (Float)
• Revs Per Min (Float)
• Produce Trig Waves (Checkbox)
• Speed (fpc) (Float)
• Amplitude (Float)
• Pulse Trigger (Float)
• Tangent Max (Float)

It has the following outputs:

• Seconds Tick (Integer)
• RPM (Revolutions) (Float)
• Sine Wave (Float)
• Cosine Wave (Float)
• Tangent Wave (Float)
• Sine Pulse (Float)
• Cosine Pulse (Float)

The Seconds Tick counts whole seconds, if Tick Speed is 1, from the start of the project Timeline, using the Frames Per Second setting of the blend file. If Tick Speed is greater than 1, it counts multiple seconds, so a setting of 2 outputs a value of 1 after 48 frames at 24fps and 2 after 96 frames, i.e counting multiple-seconds.

The RPM (Revolutions) uses the Revs Per Min setting to compute the number of revolutions achieved at the current frame position in the Timeline. So with the setting of 100, at 24fps after 144 frames from the project start frame = 10 revolutions. Multiply the value by 2 * pi to get the angular rotation in Radians to spin an object as I have done in the image above.

If the Produce Trig Waves checkbox is set, the remainder of the outputs will be computed. These are all based upon the Speed (fpc) and Amplitude, so if the Speed (fpc) is 20, a cyclic wave is produced every 20 frames, either Sine, Cosine or Tangent with the maximum value being the Amplitude setting. The Tangent Max value is used to set the maximum returned tangent value, since tangents go from infinity to minus-infinity, this limits the max value given, this value is held in the cycle until the output is once again lower than this value. I use this to “fly in” object at reducing speeds from outside camera visibility range, as one example.

The two Pulse outputs produce either 0 or the value for Amplitude, if the current values produced by a Sine or Cosine wave is greater than the Pulse Trigger value. Since the decay/growth from a sine wave is exponential, the trigger value will produce longer pulses per cycle as it’s value decreases from 1 (1 will normally give a pulse of less than 1 frame, so may not even be noticed). However, a value of 0.9 does not produce a pulse twice as long as a value of 0.95, it will be more than twice as long. Just look at the shape of a sine wave to see how this works.

Here is an image of Sine and Cosine Waves: The “Angle/Chord/Radius” Node produces a set of geometric constants from a series of three object, the output and usage can be seen below: The node has the following inputs:

• Fulcrum Object (Object)
• First Object (Object)
• Second Object (Object)

It has the following enumerator:

• Active Plane (Selector)

This is used to set which plane the system is working on and should be selected before readings are taken. So if you are working in the Top View you would use XY plane since those are the axes you would see in the Top View.

It has the following outputs:

• Acute/Obtuse Angle (Float)
• Reflex Angle (Float)
• Length F-2nd (Float)
• Chord Length (Float)

The Acute/Obtuse Angle is the smaller angle produced between the three points. The Reflex Angle is the larger, so add the two together to get 360. The Radius is the radius of a circle drawn through all three points. The Length F-2nd is the straight line distance between the fulcrum and point 2. The Chord Length is the distance along the circle drawn through all three points, between fulcrum and point 2. These are often used to calculate turning points on hinged mechanisms, such as semi-trailers, etc. This saves you having to remember the formulae, or do the maths!

Acute angles are less than 90, Obtuse angles are 90-180, Reflex angles are 180-360, in case you had omitted to listen during maths lessons at school.

Here’s a sh***y little video showing what happens to objects affected by nodes in these pages, just Blender Internal Render, so don’t expect a lot!

Notice the little Torus start to rotate, then speed up, this is done with a Ramp node. The Cone is operated by a series of Switch Nodes, the Cube by a Bounce Node and the Cylinder by a Maths Node as previously described, which you would know if you had been paying any attention at all!

NOT FINISHED YET 😛