COFFEE (Cinema 4D)
Encyclopedia
COFFEE is a computer
Computer
A computer is a programmable machine designed to sequentially and automatically carry out a sequence of arithmetic or logical operations. The particular sequence of operations can be changed readily, allowing the computer to solve more than one kind of problem...

 scripting language
Scripting language
A scripting language, script language, or extension language is a programming language that allows control of one or more applications. "Scripts" are distinct from the core code of the application, as they are usually written in a different language and are often created or at least modified by the...

 that forms part of CINEMA 4D
Cinema 4D
CINEMA 4D is a 3D modeling, animation and rendering application developed by MAXON Computer GmbH of Friedrichsdorf, Germany. It is capable of procedural and polygonal/subd modeling, animating, lighting, texturing, rendering, and common features found in 3d modelling applications.- Overview:The...

, a proprietary 3D graphics application. Although presented as an acronym the letters of the word COFFEE do not appear to stand for anything, but are rather a comic reference to Java
Java (Sun)
Java refers to several computer software products and specifications from Sun Microsystems, a subsidiary of Oracle Corporation, that together provide a system for developing application software and deploying it in a cross-platform environment...

, a considerably more famous computer language.

Purpose

Like most scripting languages, COFFEE is used to extend or modify the functionality of the host software. This technique is preferable to writing a so-called plug-in module using a traditional language such as C for a number of reasons, among them:
  • The scripting language implicitly handles memory management
    Memory management
    Memory management is the act of managing computer memory. The essential requirement of memory management is to provide ways to dynamically allocate portions of memory to programs at their request, and freeing it for reuse when no longer needed. This is critical to the computer system.Several...

     on the user's behalf, where C does not;
  • The language interpreter
    Interpreter (computing)
    In computer science, an interpreter normally means a computer program that executes, i.e. performs, instructions written in a programming language...

     does not require programs to be compiled
    Compiler
    A compiler is a computer program that transforms source code written in a programming language into another computer language...

     as a separate step before they can be used;
  • A purpose-built scripting language can be tailored so that it lends itself to its intended usage. For example, COFFEE has built-in mathematical functions that are necessary for 3D graphics programming.


There are several different aspects of CINEMA 4D's operation that can be customised using COFFEE scripts, notably additions to the user interface
User interface
The user interface, in the industrial design field of human–machine interaction, is the space where interaction between humans and machines occurs. The goal of interaction between a human and a machine at the user interface is effective operation and control of the machine, and feedback from the...

 and extensions for reading and writing new file formats and creating texture shaders. Almost all the main functionality of the application can be accessed from a COFFEE program, and so
customised features can look and behave much like those supplied as standard.

Syntax and language features

COFFEE is a fairly typical curly bracket language and so it would look familiar to any previous user of C/C++, Java, Perl
Perl
Perl is a high-level, general-purpose, interpreted, dynamic programming language. Perl was originally developed by Larry Wall in 1987 as a general-purpose Unix scripting language to make report processing easier. Since then, it has undergone many changes and revisions and become widely popular...

 or anything along those lines. The function and object class definitions are closely modelled after those of C++. However, COFFEE is dynamically typed, and so variables are defined with a simple var keyword without any reference to their type. Unlike similar scripting languages such as Squirrel
Squirrel programming language
Squirrel is a high level imperative, object-oriented programming language, designed to be a light-weight scripting language that fits in the size, memory bandwidth, and real-time requirements of applications like video games. MirthKit, a simple toolkit for making and distributing open source,...

 and JavaScript
JavaScript
JavaScript is a prototype-based scripting language that is dynamic, weakly typed and has first-class functions. It is a multi-paradigm language, supporting object-oriented, imperative, and functional programming styles....

, COFFEE does not use a function keyword to introduce functions, nor does it require a return type or "void" return like C/C++ - the function definition simply begins with the function name.

COFFEE's memory management is handled entirely by a garbage collection
Garbage collection (computer science)
In computer science, garbage collection is a form of automatic memory management. The garbage collector, or just collector, attempts to reclaim garbage, or memory occupied by objects that are no longer in use by the program...

 process; essentially this means that it looks after itself, and the programmer seldom needs to worry about it. However, it is possible to control the process explicitly when necessary.

3D graphics programming makes extensive use of certain mathematical techniques, notably trigonometry
Trigonometry
Trigonometry is a branch of mathematics that studies triangles and the relationships between their sides and the angles between these sides. Trigonometry defines the trigonometric functions, which describe those relationships and have applicability to cyclical phenomena, such as waves...

 and vector arithmetic
Vector space
A vector space is a mathematical structure formed by a collection of vectors: objects that may be added together and multiplied by numbers, called scalars in this context. Scalars are often taken to be real numbers, but one may also consider vector spaces with scalar multiplication by complex...

. COFFEE is well equipped in this area, with a good set of mathematical functions and a built-in vector datatype.

Interface with CINEMA 4D

Since COFFEE is used to extend CINEMA 4D, it clearly needs to make use of the host program's features to some extent. Through the application programming interface
Application programming interface
An application programming interface is a source code based specification intended to be used as an interface by software components to communicate with each other...

(API) it is possible to locate 3D objects created by the user and access their internal data structures. For example, a new object can be created or an existing one modified or distorted from a script. Since a major purpose of COFFEE is to allow new file formats to be used, the Cinema API provides features useful for the task; a file input/output class is available and this allows individual items of binary data (such as integers and floating point numbers) to be read and written.

External links

The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK