User Guide
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