XL4C4D: CINEMA 4D Plug-in

CINEMA 4D Plug-in

 

 

DOWNLOAD: XL4C4D.zip

 

DATE: 16.11.2012

 

AUTHOR: Ole Kniemeyer

 

DESCRIPTION: A plug-in to integrate the XL programming language in CINEMA 4D.

INSTALLATION:  XL4C4D is a plug-in to integrate the XL programming language) in CINEMA 4D (see maxon.net). It is currently only available for OSX >= 10.6 and CINEMA 4D >= R13.To install the plug-in, copy the file XL4C4D.zip to the plugins-folder of CINEMA 4D and unpack it there such that a folder XL4C4D is created which contains xl4c4d.dylib. In the folder named “source” you can find the Java source files (just as a reference, you don’t need them), the folder “examples” contains some examples.

FEATURES:

The plug-in defines three entries in the Plugins/XL4C4D menu:

    • There is an XL console where output from the XL execution is shown, and where you can also directly type in XL code. Typed in code will be executed immediately, and the result will be shown in the console.
    • The XL Instance is similar to a normal Instance object, but it scales and translates the instanced object according to several parameters which are useful for XL models.
    • The XL Object allows to enter XL code to describe an XL model. It can also be used as a generator if you use instantiation rules.

On the Java-side, the plug-in exposes parts of the CINEMA 4D SDK to Java.

HOW IT WORKS:  The XL Object shows a Code tab in the Attribute Manager. In the Code attribute, you can enter XL code which is immediately compiled when you leave the editor. Compiler messages are shown in the XL console.The snowflake example uses the following source code:

//#########################################public module Main
{
public void init()
[
==>> ^ F(1000) RU(-120) F(1000) RU(-120) F(1000);
]

public void grow()
[
F(x) ==> F(x/3) RU(60) F(x/3) RU(-120) F(x/3) RU(60) F(x/3);
]
}

//#########################################

If you type this into the Code attribute, you’ll see two methods in the drop-down list of the Method attribute. By clicking on the Invoke button, the selected method will be invoked. So for the example you have to choose init as first and invoke it once, afterwards you have to choose grow and invoke it several times. But be aware that CINEMA 4D isn’t able to handle large graph depths, so you’ll experience a crash after four iterations or so for the snowflake example.

For a new simulation run, you have to click on the Reset button at first before you can choose and invoke init.

The ^ in a rule corresponds to the XL Object in which the XL code is defined. I.e., the snowflake example adds the new nodes under the XL Object. But you can add nodes wherever you want, e.g., using document().searchObject(“NameOfObject”) instead of ^.

With the Reset button, all descendants of the XL Object are removed from the graph. If you added nodes somewhere else, you have to make sure to remove them, too. This can be done by overriding the reset() method in the XL code as in

public void reset()
{
BaseObject gol = document().searchObject(“Game Of Life”);
if (gol != null)
{
gol.removeChildren();
}
}

You can override the step()-method of the XLObject. This method is invoked whenever the document time changes, so typically during an animation playback in the editor. The Game-Of-Life example makes use of this:

public void step()
[
x:Cell ::> x.newState = ((x.state == 1) && !(sum((*x -neighbor- Cell *).state) in (2:3))) ? 0
: ((x.state == 0) && (sum((*x -neighbor- Cell *).state) == 3)) ? 1
: x.state;
x:Cell ::> x.setState(x.newState);
]

If you declare public member fields in the main class, an “XL Data” tab is added to the Attribute Manager where you can edit (or even animate) the values. Only fields of type boolean, int, float, double, Vector3d and BaseObject are supported. See the Generator example for a usage.

You can add an instantiation rule after a module declaration as in

public module Main
{
public static int n = 15;
} ==> for (int i : 1 : n) (F(100) RU(10));

The Generator example shows a more complex instantiation rule.

Welcome to the website grogra.de. This site is the web centre of growth grammars of the Department Ecoinformatics, Biometrics and Forest Growth at the Georg-August University of Göttingen and its cooperation partners.