Return to Overview

GroIMP Project Gallery

XL4C4D

XL4C4D.jpg

ID: 67053a3e256715cda41c85a9

Uploader: dforys

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

Description: <b>Installation</b><br><br> XL4C4D is a plug-in to integrate the XL programming language (see <a href="http://www.grogra.de">http://www.grogra.de</a>) in CINEMA 4D (see <a href="http:://www.maxon.net">http:://www.maxon.net</a>). It is currently only available for OSX >= 10.6 and CINEMA 4D >= R13.<br><br> 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.<br><br> <b>Features</b><br> The plug-in defines three entries in the Plugins/XL4C4D menu:<br> <ul> <li>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.</li> <li>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.</li> <li>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.</li> </ul> On the Java-side, the plug-in exposes parts of the CINEMA 4D SDK to Java. See the Java source code, especially the files in the de.grogra.c4d package.

How It Works: <b>XL Object</b><br><br> 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.<br><br> The snowflake example uses the following source code:<br><br> <i>public module Main</i><br> <i>{</i><br> <i> public void init()</i><br> <i> [</i><br> <i> ==>> ^ F(1000) RU(-120) F(1000) RU(-120) F(1000);</i><br> <i> ]<i></i><br><br> <i> public void grow()</i><br> <i> [</i><br> <i> F(x) ==> F(x/3) RU(60) F(x/3) RU(-120) F(x/3) RU(60) F(x/3);</i><br> <i> ]</i><br> <i>}</i><br><br> 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.<br> For a new simulation run, you have to click on the Reset button at first before you can choose and invoke init.<br><br> 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 <i>document().searchObject("NameOfObject")</i> instead of ^.<br><br> 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<br><br> <i>public void reset()</i><br> <i>{</i><br> <i> BaseObject gol = document().searchObject("Game Of Life");</i><br> <i> if (gol != null)</i><br> <i> {</i><br> <i> gol.removeChildren();</i><br> <i> }</i><br> <i>}</i><br><br> 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:<br><br> <i>public void step()</i><br> <i>[</i><br> <i> x:Cell ::> x.newState = ((x.state == 1) && !(sum((*x -neighbor- Cell *).state) in (2:3))) ? 0</i><br> <i> : ((x.state == 0) && (sum((*x -neighbor- Cell *).state) == 3)) ? 1</i><br> <i> : x.state;</i><br> <i> x:Cell ::> x.setState(x.newState);</i><br> <i>]</i><br><br> 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.<br><br> You can add an instantiation rule after a module declaration as in<br><br> <i>public module Main</i><br> <i>{</i><br> <i> public static int n = 15;</i><br> <i>} ==> for (int i : 1 : n) (F(100) RU(10));</i><br><br> The Generator example shows a more complex instantiation rule.

Categories: 6705382e256715cda41c7e08
6705382e256715cda41c7e0a

Version: