Cinema 4D / BodyPaint 3D Program Documentation Tutorials XPresso Tutorial
Function available in CINEMA 4D Prime, Visualize, Broadcast, Studio & BodyPaint 3D

Automatic Rotation

Rotating objects are a part of many animations - Wheels, propellers, radar antennae. These objects can be rotated by setting keyframes but we will show you how it’s done using XPresso.

Object and XPresso tag

First, open the following scene:


The scene contains a simple model of a fan, including materials, lighting and background. All individual parts of the fan are grouped in a Null Object.

In the Object Manager, right-click the "Fan" object and create an XPresso tag. The XPresso Editor window will open automatically.

Creating an Expression

In order to be able to influence the rotation of the fan blades we will require an Object Node, which will be linked to the fan blades. In the Object Manager, open the "Fan" object group. In this group you will see the "Head" group and the "Propeller" group. Drag these groups into the XPresso Editor window. An Object Node will be created automatically that is linked to the "Propeller" Null Object.

Since we want to rotate this object around a single object we will create an input Port on the Object Node that will receive the rotation data. Left-click on the Object Node’s blue corner and select Coordinates/Rotation/Rotation.B. This Port can be used to influence the object’s orientation (the rotation coordinates that are also displayed at the far right of the Coordinates Manager).

What we now need is a temporal influence on the rotation of the propeller. The more time that passes the farther the propeller should rotate. Right-click on the empty background of the XPresso Editor to call up the context menu. Create a Time Node from the New Node/XPresso/General menu. This Node supplies us with the temporal information about the scene. Delete the Time output Port that was automatically created (this Port outputs a special temporal format that we don’t need). Right-click on the Time Port and select Delete Port. We will replace this Port with a Real Port, which will supply us with the current scene time in seconds as a float point value.

We now need to add another Node: Math (XPresso/Calculate menu). With this mode we can perform simple mathematical operations. In the Attribute Manager, set the Node’s Function option to Multiply, then connect one of the Node’s input Ports with the Time Node’s output Port.

In the next step we will define how fast the fan blades will rotate. For this we will use a Constant Node (XPresso/General menu). In the Attribute Manager, set the Constant Node’s Value option to 360. This will tell the "Propeller" object to rotate with a speed of 360° per second.

Note that the constant’s numeric value within the XPresso node will only be displayed correctly after the Expression has been connected and implemented. The value shown in the Attribute Manager is the relevant value.

It’s important to know that Cinema 4D expects all rotation values to be defined as radians (circular measure). However, we want to define the speed of rotation in degrees per second, which means that the rotational value must be converted to radians before they are passed on to the "Propeller" object.

Fortunately there is a Node that can do this for us - the Degree Node (XPresso/Calculate). Set this Node’s Function value to Degree to Radians in its Attribute Manager settings. Now connect the Constant Node with the Degree Node’s input Port. Next, connect the Degree Port’s output Node with the Math Node’s available input Port. Finally, connect the Math Node’s output port with the "Propeller" object’s Rotation.B input Port.

We can now close the XPresso Editor and play the animation. As you can see the fan blades rotate with a constant speed. If you look closely you will see that the fan blades are rotating in the wrong direction. This can be easily corrected by opening the XPresso Editor and setting the Constant Node’s Value to -360.

Save the scene so we can continue working on it later. The next example will be based on this rotation setup.