pointAt
Usage
member( whichCastmember ).model( whichModel ).pointAt ( vectorPosition {, vectorUp })
member( whichCastmember ).camera( whichCamera ).pointAt ( vectorPosition {, vectorUp })
member( whichCastmember ).light( whichLight ).pointAt ( vectorPosition {, vectorUp })
member( whichCastmember ).group( whichGroup ).pointAt ( vectorPosition {, vectorUp })
Description
3D command; rotates the referenced object so that its forward direction
vector points at a specified world relative position, then it rotates the
referenced object to point it’s up direction vector in the direction hinted at
by a specified relative vector.
The object’s front and up direction vectors are defined by the object’s
pointAtOrientation property.
Parameters
vectorPosition Required. Specifies the world relative
position. This value can also be a node reference.
vectorUp Optional. Specfies a world relative vector that
hints at where the object’s up vector should point. If this parameter isn’t
specified, then pointAt defaults to using the world’s y axis as the
up hinting vector. If you attempt to point the object at a position such that
the object’s forward vector is parallel to the world’s y axis, then the world’s
x axis is used as the up hinting vector. The direction at which you wish to
point the object’s forward direction and the direction specified by
vectorUp do not need to be perpendicular to each other being
as this command only uses the vectorUp parameter as a
hinting vector.
Example
This example points three objects at the model named Mars: the camera named
MarsCam, the light named BrightSpot, and the model named BigGun:
thisWorldPosn = member("Scene").model("Mars").worldPosition
member("Scene").camera("MarsCam").pointAt(thisWorldPosn)
member("Scene").light("BrightSpot").pointAt(thisWorldPosn)
member("Scene").model("BigGun").pointAt(thisWorldPosn, vector(0,0,45))
If you use non-uniform scaling and a custom pointAtOrientation
on the same node, e.g., a model, using pointAt will likely cause
unexpected non-uniform scaling. This is due to the order in which the
non-uniform scaling and the rotation to properly orient the node are applied. To
workaround this issue, do one of the following:
- Avoid using non-uniform scaling and non-default
pointAtOrientation together on the same node.
- Remove your scale prior to using
pointAt , and then reapply it
afterwards.
For example:
scale = node.transform.scale
node.scale = vector( 1, 1, 1 )
node.pointAt(vector(0, 0, 0)) -- non-default pointAtOrientation
node.transform.scale = scale
pointAtOrientation
Usage
member(whichCastmember ).model(whichModel ).pointAtOrientation
member(whichCastmember ).group(whichGroup ).pointAtOrientation
member(whichCastmember ).light(whichLight ).pointAtOrientation
member(whichCastmember ).camera(whichCamera ).pointAtOrientation
Description
3D model, light, group and camera property; allows you to get or set how the
referenced object responds to the pointAt command. This property is
a linear list of two object-relative vectors, the first vector in the list
defines which direction is considered the object’s front direction, the second
defines which direction is considered the object’s up direction.
The object’s front and up directions do not need to be perpendicular to each
other, but they should not be parallel to each other.
Example
This statement displays the object-relative front direction and up direction
vectors of the model named bip01:
put member("scene").model("bip01").pointAtOrientation
-- [vector(0.0000, 0.0000, 1.0000), vector(0.0000, 1.0000, 0.0000)]
See also
pointOfContact
Usage
collisionData.pointOfContact
Description
3D collisionData property; returns a vector describing the point
of contact in a collision between two models.
The collisionData object is sent as an argument with the
#collideWith and #collideAny events to the handler
specified in the registerForEvent, registerScript, and
setCollisionCallback commands.
The #collideWith and #collideAny events are sent
when a collision occurs between models to which collision modifiers have been
added. The resolve property of the models’ modifiers must be set to
TRUE .
This property can be tested but not set.
Example
This example has two parts. The first part is the first line of code, which
registers the #explode handler for the #collideAny
event. The second part is the #explode handler. When two models in
the cast member MyScene collide, the #explode handler is called and
the collisionData argument is sent to it. The first nine lines of
the #explode handler create the model resource named SparkSource
and set its properties. This model resource is a single burst of particles. The
tenth line of the handler creates a model named SparksModel using the model
resource named SparkSource. The last line of the handler sets the position of
SparksModel to the position where the collision occurred. The overall effect is
a burst of sparks caused by a collision.
member("MyScene").registerForEvent(#collideAny, #explode, 0)
on explode me, collisionData
nmr = member("MyScene").newModelResource("SparkSource", #particle)
nmr.emitter.mode = #burst
nmr.emitter.loop = 0
nmr.emitter.minSpeed = 30
nmr.emitter.maxSpeed = 50
nmr.emitter.direction = vector(0, 0, 1)
nmr.colorRange.start = rgb(0, 0, 255)
nmr.colorRange.end = rgb(255, 0, 0)
nmr.lifetime = 5000
nm = member("MyScene").newModel("SparksModel", nmr)
nm.transform.position = collisionData.pointOfContact
end
See also
modelA , modelB
|