Director 3D > Creating Simple 3D

Creating 3D Primitives

“Primitives” are considered to be the building blocks of 3D environments. They are (apart from ‘particles’) simple shapes that require a small number of parameters. The five “primitive” types are #plane, #sphere, #box, #cylinder and #particle.

Although simple, primitives can be used for very powerful results. Broad, sweeping objects that satisfy large goals of an environment, such as the sky or ground are examples of this. Lighting and texture techniques can also be used to simulate complex shapes.

Here is an example of the Lingo used to create a primitive shape (in this case, a sphere.

  1. Before creating the model, you need to create a model resource – referenced in this example by a variable we call “sphereResource”.
  2. sphereResource = pScene.newModelResource("SphereResource", #sphere, #facing)

    newModelResource creates a new model resource of a particular “#type” (one of the following primitives #plane, #box, #sphere, #cylinder, #particle).

    #facing defines if the mesh is generated for front (the outside of the sphere – it would appear invisible from inside) or back only (the inside of the sphere – it would appear invisible from outside), or both. If you have mesh for front and back, you can have separate shaders for each.

  3. A model resource has its own unique properties depending on the type of resource it is. A sphere has a radius property.

    sphereResource.radius = 40

  4. The following Lingo then creates the model:
    pSphere = pScene.newmodel("Sphere", sphereResource)

    newModel is a 3D command that creates a new model with a unique name, based on a model resource.

    This is the result:

This could then be textured and/or modified further with such effects as transparency, scaling, etc.

Here is an example:

You can download the source file here.

A good tutorial on the creation of 3D models, through the control of primitives with Lingo can be found at this location:

Another good starting point is “Director’s Third Dimension: Fundamentals of 3D Programming in Director 8.5” by Paul Catanese (Que, 2002) – Chapter 2 is particularly recommended for a good understanding of this subject.

< Previous | Next >

July 2003