Director 3D > Creating Simple 3D

Easy Creation of Primitives Using Custom Handlers

Custom handlers can streamline the process of creating 3D with Lingo. If you are familiar with the idea of functions, a “custom handler” works in the same way to create a kind of “toolkit” of code, which can be called at any time - so you don’t need to repeat it. For example, the creation of a primitive from scratch involves several steps that can become repetitive. A custom handler stores these steps and allows you to call them via a simple, one-line piece of code:


You can view a sample here.

 

Here is an example of a custom handler Lingo script (it can be found in the sample file, in the movie script called "Basic Primitive Creation Custom Handlers") - the comments (lines beginning with --) explain what the code is doing:

In the "INITIALIZE" movie script we then call this handler with the following code:

This is the resulting 3D in the Director stage:

Effectively, every time you need to create a cube you can then use the one line of code (e.g. createbox("box1", 50, 50, 50, rgb(#255,255,10)) ) to create one easily (this saves a LOT of typing and repeated code).

This idea is explored in depth in Paul Catanese’s book: “Director’s Third Dimension: Fundamentals of 3D Programming in Director 8.5” – Chapter 3.

More generic information on custom handlers in Lingo can be found at: http://www.fbe.unsw.edu.au/Learning/Director/Lingo/generic.htm

< Previous | Next >

July 2003