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

Xpresso Basics

Range of use

From the previous chapter you now know for which purposes Expressions can be used. They influence the properties and behavior of objects. Some of Cinema 4D’s pre-defined Expressions you already know as tags that are assigned to objects. For example, the Vibrate tag will modify the position of the object to which it is assigned. All of these pre-defined tags serve their own useful purpose. Nevertheless, not all imaginable functions can be performed by these pre-defined tags and this is where XPresso comes in. XPresso lets you create a custom tag step-by-step that performs exactly the task you want. Cinema 4D offers an integrated programming language, C.O.F.F.E.E., but not everyone has a knack for programming. XPresso offers an easier-to-use alternative by letting you create tags via its own graphic interface. Even after working through this tutorial you will surely have to invest more time in practicing using XPresso to better understand its ways.

The Node system

An XPresso Expression is made up of Nodes, which are the basis of any Expression. XPresso is a node-based system in which various Nodes are connected to perform one or more functions. A node-based system bears the advantage that Expressions can be created faster and that those new to the system can relate better to a graphic interface than line after line of programming code.

If you have never worked with XPresso it may at first seem a little confusing. After working through this tutorial and a little practice you will be able to easily create an Expression like the one pictured above.

XPresso tag

The XPresso tag can be viewed as a container in which our Expressions are housed. We will first create a Null. Right-click on the newly created object in the Object Manager and select XPresso from the Cinema 4D Tagsmenu. The XPresso Editor window will automatically open. This is where we will create our Expressions. This window can be scaled, if necessary, and re-opened anytime by simply double-clicking on the XPresso tag in the Object Manager. In most cases it doesn’t matter which object has the XPresso tag assigned to it.

XPresso Editor

A set of connected Nodes is called an XPresso Expression. All Nodes are created and linked in the XPresso Editor. At the left of the XPresso Editor window are two tabs, the X-Manager and X-Pool tabs. The X-Pool tab contains all Nodes that are available for use. We can also right-click on the XPresso Editor’s XGroup field to display this list of available Nodes; the X-Manager tab displays a list of all Nodes contained in our Expression.

Nodes

A Node represents an object or a function. A Nodes parameters are displayed in the Attribute Manager. Let’s take a closer look at the following Expression:

The scene contains a Cube and a Sphere object, respectively. The XPresso tag has been assigned to the Cube object. It makes no difference which object has been assigned the XPresso tag. The corresponding Expression is open and shows two Nodes that are connected by a black line. Each Node represents an object in the scene and are referred to as Object Nodes. Nodes have Ports through which data is input or output. Depending on the type of Node, it can have one or more Ports. If a Port is located on the left side of a Node it will accept input from other Ports; if a Port is located on the right side of a Node it puts data out (output) to other Ports. An Object Node can input or output any of an object’s properties. These properties are the same that are displayed in the Attribute Manager as well as several additional attributes belonging to that particular object. Ports are connected in the XPresso Editor. An input Port can be connected with multiple output Ports, even if the output Ports are located on different Nodes. However, an input Port can only have a single connection from an output Port.

Now let’s apply this to the example above. The sphere’s Object Node has an output Port named Global Position, which outputs the position of the sphere to the input Port of the other Node. This means that the Cube object is assigned the position of the Sphere object. If you now move the sphere the cube will follow accordingly.

The Attribute Manager also shows whether or not a value is taken into consideration in an Expression. In the image below you can see how the dots that are used to show existing tracks or keyframes are replaced by squares with arrows.

If an Input port is used, the arrow will point to the left, if an Output port is used it will point to the right. In the example above, the Radius is affected by an Input port, which means that data is passed from another Node to this Node; the Height is affected by an Output port, which means that this value is passed on to another Node; the Segment Height value is affected by both an Input and an Output port, which means that it receives data from another Node and subsequently passes this data on to yet another Node. If you hover the cursor over one of the arrows, an info field will appear that shows which Nodes affect this port.

Data types

So far we have talked about how a Node can assume data (input Port) or assign data (output Port). As with the Object Node we know that an object’s properties are included. If we take a look at the Attribute Manager we can see the object’s various parameters, among them its name and position coordinates. If we were to output the data from these two parameters via an Object Node we would have to ask ourselves in which format will this data be output. After all, a coordinate is a vector consisting of three floating point numbers and the name is a string of characters. Two vectors can be multiplied and two strings of characters can be connected but an operation between a vector and a string of characters does not really make any sense. This prevents the data that have nothing in common from being included in an operation. Only Ports of related data types can be connected with one another. If the data types have common characteristics an automatic conversion will take place.

In the following we will explain several XPresso data types that are available in Cinema 4D:

Boolean

There are two types of boolean states: true or false. These states are expressed as numbers: 1=true; 0=false.

This operation is explained in more detail in the Boolean Algebra section.

Integers

An integer (or "whole number") has no decimal place and is, for example, used to display the number of subdivisions an object has. In integer can have either a positive or a negative value.

Real

A real number (also called a "floating point number") is a number that continues after the decimal place. A real number can have either a positive or a negative value and has an accuracy of up to six decimal places behind the comma. Note however that the Cinema 4D GUI only displays the first three numbers behind the decimal. When a real number is converted to a vector the value will be transferred to the components of the vector. If a number is converted from real to integer all places behind the comma will be removed and no rounding will take place.

Vector

Cinema 4D uses vectors everywhere where a value cannot be displayed by a single number. This includes position (X,Y,Z), color (red, green, blue) and rotation (heading (H), pitch (P), bank (B)). A vector consists of three components, which themselves are real numbers. Normally these components are labled X, Y or Z. If a vector is converted to a real number the result is the length of the vector.

Matrix

A matrix is a group of four vectors that are used by Cinema 4D to describe a coordinate system. These components are labled v1, v2, and v3 for each axis, respectively. This data type will be explained in more detail in the course of this tutorial.

String

A string can consist of an infinite number of characters (letters, numbers, special characters). A string can be used to save individual words or blocks of text.

Link

A link is a connection to an object within the scene. This can be a tag, object or even a material. Many Nodes types have the ability to modify the properties of a linked object or extract values for further processing. Use a link to reference an element in the scene.