Chapter 20
524
Camera commands
These camera functions allow you to determine which models have been clicked when a user
clicks the mouse within a 3D sprite. You can also translate coordinates in 3D space to coordinates
in 2D sprite space and vice versa.
Vector math
A 3D vector describes both direction and location in 3D space. Vector objects include floating-
point values for position along each of the x-, y-, and z-axes. Vectors can be node-relative or
world-relative. If they are node-relative, their x, y, and z values are relative to the position of the
node. If they are world-relative, their x, y, and z directions are relative to the world.
Vector math operations perform calculations using each of the x, y, and
z
values. These
calculations are useful for performing intelligent movement and rotation of models.
Function
Description
Returns
worldSpaceTo
SpriteSpace
(
vector
)
Returns the 2D sprite-space coordinates of a point from a 3D
world vector.
A point.
spriteSpaceTo
WorldSpace
(
point
)
The opposite of the
worldSpaceToSpriteSpace
(
vector
)
, this function returns a world-space vector on the
camera’s projection plane from a sprite-space point.
Multiple world-space positions can map to the same sprite-
space point. A round-trip
y=worldSpaceToSpriteSpace(x)
z=worldSpaceToSpriteSpace(y)
won’t necessarily result in
x=z
.
A vector.
modelUnder
Loc(point)
Returns the first model intersected by a ray from a location
point
within the
rect
of the sprite using this camera. The
location
point
is relative to the upper left corner of the sprite, in
pixels. The ray is cast forward in the direction the camera is
looking.
This function is useful for picking in conjunction with an
onMouseDown
handler. For accuracy, be sure to subtract the
upper left corner of the sprite’s
loc
from the
mouseLoc
.
The first model
intersected by the ray.
A value of
void
means
there is no model under
the ray.
modelsUnder
Loc(point,
optionalMax
NumberOf
Models)
Returns a list of all models intersected by a ray from a location
point
within the
rect
of the sprite using this camera. The
location
point
is relative to the upper left corner of the sprite,
in pixels. The ray is cast forward in the direction the camera
is looking.
This function is useful for picking in conjunction with an
onMouseDown
handler. For accuracy, be sure to subtract the
upper left corner of the sprite’s
loc
from the
mouseLoc
.
The first model
intersected by the ray or
a list of up to the
specified maximum.
If no maximum is
specified, the command
returns all models under
the ray.
A value of void
means there is no model
under the ray.
modelsUnder
Ray(
location
Vector
,
direction
Vector
,
optionalMax
NumberOf
Models
)
Returns a list of models under the ray starting at the vector
locationVector
and pointing down the vector
directionVector
,
with both vectors specified in world-
relative coordinates.
The first model
intersected by the ray
plus a list of up to the
specified maximum
number of models.
If the maximum number
of models isn’t specified,
all models the ray
intersects are returned.
Содержание 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 ...