Working with Models and Model Resources
487
Moving models
Because the 3D world has no absolute frame of reference, moving and rotating is much more
complex than in 2D, where all movement is in relation to screen position.
In 3D, everything is drawn relative to the camera’s frame of reference. If the camera is behind an
object, when the object moves to the left relative to the center of the world, or world origin, it
appears to move toward the right of the screen.
Each piece of position and orientation information can be expressed relative to one or more
frames of reference. A model’s transform property, for instance, expresses its position and rotation
relative to the model’s parent. In general, there are four frames of reference to consider: relative to
the object (model, light, camera) itself, relative to the object’s parent, relative to the world, and
relative to some other object.
•
Object-relative: When you create a model in a 3D modeling program, you build it relative to
its own frame of reference. For instance, when you create a model of a car, the front of the car
may be pointed along its z-axis and the antenna may be pointed along its y-axis. To move such
a car forward (along its z-axis) regardless of which direction it is pointing relative to the camera
or the world, use
car.translate(0,0,10)
. To turn the car left, use
car.rotate(0,45,0)
.
The car model might have wheel models as children. To rotate the wheel of a car relative to
itself, rather than relative to its parent (the car), use the following Lingo:
wheel.rotate(0,10,0)
or
car.child[1].rotate(0,10,0, #self)
where the fourth parameter of the
rotate
command 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. For example, a box might have six
different shaders, one for each face. 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 Lingo are assigned the standard shader. You can replace the default
shader of a model with any of the other types of shaders.
Содержание DIRECTOR MX-USING DIRECTOR MX
Страница 1: ...Using Director MX Macromedia Director MX...
Страница 12: ...Contents 12...
Страница 156: ...Chapter 4 156...
Страница 202: ...Chapter 6 202...
Страница 244: ...Chapter 7 244...
Страница 292: ...Chapter 10 292...
Страница 330: ...Chapter 12 330...
Страница 356: ...Chapter 13 356...
Страница 372: ...Chapter 14 372...
Страница 442: ...Chapter 16 442...
Страница 472: ...Chapter 18 472...
Страница 520: ...Chapter 19 520...
Страница 536: ...Chapter 20 536...
Страница 562: ...Chapter 23 562...
Страница 566: ...Chapter 24 566...
Страница 602: ...Chapter 27 602...