User Guide
352 Chapter 16: Working with Models and Model Resources
or
car.child[1].rotate(0,10,0, #self)
where the fourth parameter of the rotate method is the object the rotation should be
relative to.
• Parent-relative: A model’s transform property expresses its position and rotation relative to
the model’s parent. If you want the wheels of the car to move outward regardless of how the
wheels are turned, use
car.child[1].translate(10,0,0,#parent) or
car.child[1].transform.translate(10,0,0). If you want a planet model that is a child of
the sun to orbit around the sun, use
planet.rotate(0,5,0, #parent).
• World-relative: If you want the car to move along the world’s x-axis regardless of which way it
is facing, use
model.translate(10,0,0,#world). If you want to rotate the car 20° around
the world y-axis, with the rotation taking place at the world location vector (10, 10, 10), use
model.rotate(vector(10,10,10), vector(0,1,0), 20, #world).
• Relative to another object: If you want to move an object so that it goes toward the right edge
of the screen, use
model.translate (vector(10,0,0), sprite(1).camera). If you want
to rotate the object parallel to the camera and around the center of the screen, use
model.rotate(vector(0,0,0), vector(0,0,1), 20, sprite(1).camera).
Shaders
A model resource defines a model’s shape, and shaders define the model’s surface colors and
reflectivity. You can use just one shader or more than one. Each mesh in a model resource can
have its own shader. For example, a box might have six different shaders, one for each mesh (a box
is actually composed of 6 plane meshes carefully arranged). If you do not specify a shader, the
default
#standard shader is used. If the shader’s properties are modified, the change affects all
models that use that shader.
Models that are created with script are assigned the standard shader. You can replace the default
shader of a model with any of the other types of shaders.
Properties of the standard shader
The standard shader makes the surface of a model appear in a photorealistic style. Use these
properties to work with the standard shader:
Property Name Access Description Default
name
Get The string name of this shader. None
ambient
Get and set A color object describing the surface's
reaction to ambient light.
color(63,63,
63)
diffuse
Get and set A color object describing the surface's
reaction to diffuse light. Ambient and
diffuse color objects together describe a
model resource’s base color.
color(255,
255,255)
specular
Get and set A color object describing the surface's
specular highlight color. This setting has
an effect only if there are lights in the
scene whose specular property is
TRUE
(1)
.
color(255,
255,255)