
346
Chapter 16: Working with Models and Model Resources
Models
Models can be referred to by name or number. Models can be added to or removed from the
world at any time.
In the member’s parent-child hierarchy, each model can have a maximum of one parent, but it
can have an unlimited number of children. Models with no parent can exist in the 3D world but
are not rendered. A child’s position and orientation depend on its parent’s position and
orientation, and it changes when the position and orientation of the parent changes. Models can
have any other group, light, camera or model as their parent, or they can have no parent specified.
In this case, their
transform
property describes their position and rotation in the 3D world, and
is identical to their
getWorldTransform()
property. All models that have parents have a
relationship both to their immediate parent and to the world parent. You can add or remove
models from the 3D world at any time by using the
addToWorld()
or
removeFromWorld()
methods.
For example, if the first child of the model named
car1
is a wheel model, the following
transform
script would refer to the position of the wheel relative to the model named
car1
:
car1.child[1].transform.position
To refer to the position of the wheel model relative to the world itself, use
getWorldTransform()
:
car1.child[1].getWorldTransform().position
newModel
Resource(
name,
type)
Creates a new model resource and adds it to the
model resource palette. The
type
can be
#plane
,
#box
,
#sphere
,
#cylinder
, or
#particle
.
The
type
cannot be
#mesh
. To create a new mesh
model resource, use the
newMesh
method detailed
below.
New model resource
object
newMesh(
name,
numFaces,
numVertices,
numNormals
numColors,
numTexture
Coordinates
)
Creates a new mesh model resource.
numFaces
is the user-specified number of triangles.
numVertices
is the user-specified number
of vertices. A vertex can be used by more than one
face.
numNormals
is the user-specified number of normals.
Enter
0
or omit this step to use the
generateNormals()
method.
numColors
is the user-specified number of colors.
You can specify a color for each point of a triangle.
numTextureCoordinates
is the number of user-
specified texture coordinates. Enter
0
or omit this
step to get the default coordinates.
New mesh model
resource
Method
Description
Returns
Summary of Contents for DIRECTOR MX 2004-USING DIRECTOR
Page 1: ...DIRECTOR MX 2004 Using Director...
Page 16: ...16 Chapter 1 Introduction...
Page 82: ...82 Chapter 3 Sprites...
Page 98: ...98 Chapter 4 Animation...
Page 134: ...134 Chapter 5 Bitmaps...
Page 242: ...242 Chapter 10 Sound and Synchronization...
Page 274: ...274 Chapter 11 Using Digital Video...
Page 290: ...290 Chapter 12 Behaviors...
Page 302: ...302 Chapter 13 Navigation and User Interaction...
Page 334: ...334 Chapter 15 The 3D Cast Member 3D Text and 3D Behaviors...
Page 392: ...392 Chapter 16 Working with Models and Model Resources...
Page 418: ...418 Chapter 18 Movies in a Window...
Page 446: ...446 Chapter 22 Managing and Testing Director Projects...