PSHomeCacheDepot / DEV /1.86 Docs /lua_api_chatgpt_friendly.txt
pebxcvi's picture
small commit 6
e118a4c
Entity
Entity. ApplyAngularlmpulse
Brief
Applies an angular impulse to the entity.
Definition
Entity.ApplyAngularlmpulse( Entity entity, Vector4 impulse )
Arguments
entity - The entity to update.impulse - World space vector specifying angular impulse to be applied to the entity.
Return Values
None.
Description
Applies an angular impulse to the entity around the center of mass, creating angular velocity.
Examples
! � Apply angular impulse around Y axis
! Entity.ApplyAngularlmpulse( entity, Vector4.Create( 0, 0.1, 0.0) )
See Also
None
Entity. Applylmpulse
Brief
Applies an impulse around a point.
Definition
Entity.Applylmpulse( Entity entity, Vector4 impulse )
Entity.Applylmpulse( Entity entity, Vector4 impulse, Vector4 point )
Arguments
entity - The entity to update.impulse - World space vector specifying impulse (or force) to be applied to the entity.point - World space vector
specifying the point around which the impulse acts.
Return Values
None.
Description
Applies an impulse around a point. If no point is specified, the center of mass of the entity's rigid body is used.
Examples
! � Apply an impulse around the entity's center of mass
i Entity.Applylmpulse( entity, Vector4.Create( 5, 10, 5 ) )
! � Apply an impulse around the origin of world space
? Entity.Applylmpulse( entity, Vector4.Create( 0, 10, 0 ), Vector4.Create( 0, 0, 0 ) )
See Also
None
Entity. AttachPersonLabel
Brief
Attach a person label to the entity.
Definition
! Entity.AttachPersonLabel(Entity entity. Person person, Vector4 offset)
Arguments
person - The person to take the label from.offset - The offset of the label from the entity's position. (Optional. Defaults to 0, 0, 0).
Return Values
Description
This function will detach the person label from the given person, and attach it to the entity instead. Any number of person labels can be attached
to the entity.
Examples
j Entity.AttachPersonLabel(entity, person, labelOffset)
See Also
� Entity.DetachPersonLabel
Entity. AttachToBone
Brief
Attach the entity to the specified bone of its parent.
Definition
Entity.AttachToBone( Entity entity, string boneName )
Arguments
entity - The entity to update.boneName - The name of the bone to attach to or nil to clear it. Can be one of the following:
"pelvis�
"hips"
"leftleg"
"leftfoot"
"rightleg"
"rightfoot"
"spine"
"neck"
"head"
"leftshoulder�
"leftarm"
"leftforearm"
"lefthand"
"rightshoulder"
"rightarm"
"rightforearm"
"righthand"
Return Values
None.
Description
Attach the entity to the specified bone of its parent. In addition to specifying the bone to which the entity is to be attached, it is also necessary to
specify the person to which the bone belongs. This is done by calling Entity.AttachToParent and supplying the desired person.
Examples
entity = Entity.Create()
Entity.AttachToParent( entity, LocalPlayer.GetPerson() )
Entity.AttachToBone( entity, "head" )
See Also
� Entity.Create
� Entity.AttachToParent
� Entity.SetAttachType
Entity. AttachToParent
Brief
Attaches the entity to the specified parent.
Definition
Entity.AttachToParent( Entity child. Entity parent, string boneName = nil )
Entity.AttachToParent( Entity child. Person parent, string boneName = nil )
Arguments
entity - The entity to update.parent - The parent to attach the entity to or nil to remove it.boneName - The name of the bone to attach to, if any.
For a person, it must be from the following list:
"pelvis�
"hips"
"leftleg"
"leftfoot"
"rightleg"
"rightfoot"
"spine"
"neck"
"head"
"leftshoulder�
"leftarm"
"leftforearm"
"lefthand"
"rightshoulder"
"rightarm"
"rightforearm"
"righthand"
Return Values
None.
Description
Attaches the entity to the specified parent. The parent�s world matrix will be applied to the entity so the entity's position, rotation and scale are
relative to the parent. If a bone is specified, the entity will be attached to the specified bone in the parent's skeleton.
Examples
� Parent an entity to an entity
entityl = Entity.Create()
parent = Entity.Create()
Entity.AttachToParent( entityl, parent );
� Parent an entity to a person's right hand
entity2 = Entity.Create()
person = Person.Findlnlnstance( personld )
Entity.AttachToParent( entity2, person, "righthand" )
See Also
� Entity.Create
� Person.Findlnlnstance
� Entity.SetAttachType
Entity. BlendAnimln
Brief
Blends an animation into, and alongside the currently playing animations.
Definition
Entity.BlendAnimln( Entity entity, string resourceName, boolean isLooping = true, number time = 0,
number easeType = AnimBlendType.Linear, number blendDuration = 0.25, number priority = 0, Animation
anim = nil)
Entity.BlendAnimln( Entity entity, Resource animResource, boolean isLooping = true, number time = 0,
number easeType = AnimBlendType.Linear, number blendDuration = 0.25, number priority = 0, Animation
anim = nil)
Arguments
entity - entity to blend animation ontoresourceName - the name of the animation resource to blend inanimResource - the animation resource to
blend inisLooping - flag indicating if the animation played should loop, (default is true)time - point in at which the animation should start playing
from (default is 0.0)easeType - the easing method to be used. The values used are in the enumerated type AnimBlendType (default value is
AnimBlendType.Linear )blendDuration - the period in seconds, over which the blend factor will increase from 0.0 to 1.0 (default is 0.25)priority -
The priority affects where in the animation list an animation will be played. The higher the number, the later it will be played.
If a prior animation is being played at the same priority, then the new animation will be placed after the old animation in the list, (default is 0)anim
if supplied, the animation handle is set to the newly created active animation
Return Values
None.
Description
Values for the ease type are provided by the enumeration AnimBlendType:
AnimBlendType.None
AnimBlendType. Linear
AnimBlendType.SCurve
AnimBlendType. Accelerate
AnimBlendType. Decelerate
Examples
Entity.BlendAnimln( entity, "myAnim" )
Entity.BlendAnimln( entity, "myWalk", true, 0.0, AnimBlendType.Linear, 0.25, 0, animHandleToSave)
See Also
� Entity. GetlndexOfAnim
� Entity. GetActiveAnim
Entity. BlendAnimOut
Brief
Blends the specified active animation out.
Definition
Entity.BlendAnimOut(Entity entity. Animation anim, number easeType = AnimBlendType.Linear, number
blendDuration = 0.25)
Arguments
entity - entity to blend anim out fromanim - animation to blend outeaseType - the blend curve to use when blending out, default is
AnimBlendType.LinearblendDuration - the duration over which the animation is blended out, default is 0.25
Return Values
None.
Description
Begins to blend out a currently active animation. To check the progress of the blend, use Animation.GetBlendState and/or
Animation.GetBlendTime. An invalid animation handle will have no effect.
Examples
local animlndex = Entity.GetlndexOfAnim( entity, "idleAnim" )
local hAnim = Entity.GetActiveAnim( entity, animlndex )
Entity.BlendAnimOut( entity, hAnim, AnimBlendType.Linear, 0.25 )
See Also
� Entity. BlendAnimln
� Entity.GetlndexOfAnim
� Entity.GetActiveAnim
� Entity. PlayAnim
� Animation.GetBlendWeight
Entity.Copy
Brief
Clone an entity's state to another entity.
Definition
! Entity.Copy(Entity dest, Entity source)
Arguments
dest - Destination entity to modify.source - Source entity to copy.
Return Values
None.
Description
Copies all state from the source entity to the destination entity, leaving the source entity unchanged. The only state that will not be copied is
transform state (position and orientation), as having two identical entities in the same place may cause issues with collision and other systems.
The destination entity is still a different entity (it will not compare equal and will have a different unique ID) but will have the same state as the
source entity. Similarly to Reset, the hierarchy state of the destination entity will not be modified; if the script wishes to detach the entity and its
children this must be done explicitly.
Examples
! myDestEntity:Copy(mySourceEntity)
See Also
� Entity. Reset
Entity.Create
Brief
Creates a new entity.
Definition
j Entity Entity.Create()
Arguments
None
Return Values
A new Entity instance.
Description
Creates a new entity.
Examples
! entity = Entity.Create()
See Also
None
Entity.CreateForceAction
Brief
Creates a new 'force' action for an entity.
Definition
number Entity.CreateForceAction( Entity entity, boolean autoEnable = false )
Arguments
entity - The entity to which the action will belong.autoEnable - true to automatically enable the action, false otherwise.
Return Values
A numerical action ID.
Description
Creates a new 'force' action for an entity. If autoEnable is false, the action can be enabled with Entity.EnableAction. This action applies a force to
an entity every physics update. This function is only available if the entity has a collision item.
Examples
entity = Entity.Create()
e:SetCollision("kCollisionResource")
e:EnableDynamics()
actionld = Entity.CreateForceAction( e, false )
f = Vector4.Create( 10.0, 0.0, 0.0 )
Entity.EnableAction( e, actionld )
Entity.SetActionForce( e, actionld, f )
See Also
� Entity.CreateTorqueAction
� Entity. CreatePointForceAction
� Entity.EnableAction
� Entity.SetActionForce
Entity.CreatePointForceAction
Brief
Creates a new 'point-force' action for an entity.
Definition
number Entity.CreatePointForceAction( Entity entity, boolean localSpace = true, boolean autoEnable =
i false )
Arguments
entity - The entity to which the action will belonglocalSpace - true to use a local-space point, false to use a world-space point.autoEnable - true to
automatically enable the action, false otherwise.
Return Values
A numerical action ID.
Description
Creates a new 'point-force' action for an entity. If autoEnable is false, the action can be enabled with Entity.EnableAction. This action applies a
force at a given position to an entity. The position can a local-space point or a world-space point. This function is only available if the entity has a
collision item.
Examples
entity = Entity.Create()
e:SetCollision("kCollisionResource" )
e:EnableDynamics()
actionld = Entity.CreatePointForceAction( e, true, false )
f = Vector4.Create( 10.0, 0.0, 0.0 )
p = Vector4.Create( 0.0, 1.0, 0.0 )
Entity.EnableAction( e, actionld )
Entity.SetActionForce( e, actionld, f )
Entity.SetActionPosition( e, actionld, p )
See Also
� Entity.CreateTorqueAction
� Entity.CreateForceAction
� Entity.SetActionPosition
Entity.CreateTorqueAction
Brief
Creates a new 'torque' action for an entity.
Definition
number Entity.CreateTorqueAction( Entity entity, boolean autoEnable = false )
Arguments
entity - The entity to which the action will belong.autoEnable - true to automatically enable the action, false otherwise.
Return Values
A numerical action ID.
Description
Creates a new 'torque' action for an entity. If autoEnable is false, the action can be enabled with Entity.EnableAction. This action applies a torque
to an entity every physics update. This function is only available if the entity has a collision item.
Examples
entity = Entity.Create()
e : SetCollision ( ,, kCollisionResource ,, )
e:EnableDynamics()
actionld = Entity.CreateTorqueAction( e, false )
t = Vector4.Create( 10.0, 0.0, 0.0 )
Entity.EnableAction( e, actionld )
Entity.SetActionTorque( e, actionld, t )
See Also
� Entity.CreateForceAction
� Entity.CreatePointForceAction
� Entity.EnableAction
� Entity.SetActionTorque
Entity.DebugSetAxesVisible
Brief
Sets the entity to show its axis or not.
Definition
Entity.DebugSetAxesVisible( Entity entity, boolean value, boolean recursive, number size = 1)
Arguments
entity - The entity to update.value - If true the entity shows its axis and if false it hides it.recursive - If true the entity also sets the values of all the
children below it.size - The size of the line drawn to represent the axis (in meters).
Return Values
None.
Description
Sets the entity to show its axis or not. Entities default to not show their axis when created. Note that this function is provided for debugging
purposes and should not be used in a finalized script.
Examples
entity = Entity.Create()
Entity.DebugSetAxesVisible( entity, true, true, 1.0 )
See Also
� Entity.DebugSetHierarchyVisible
� Entity.DebugSetCollisionVisible
Entity.DebugSetCollisionVisible
Brief
Sets the entity to show its collision or not.
Definition
! Entity.DebugSetCollisionVisible( Entity entity, boolean value, boolean recursive )
Arguments
entity - The entity to update.value - If true the entity shows its collision shape.recursive - If true the entity also sets the values of all the children
below it.
Return Values
None.
Description
Sets the entity to show its collision or not. Entities default to not show their collision when created. Note that this function is provided for
debugging purposes and should not be used in a finalized script.
Examples
j entity = Entity.Create()
1 Entity.DebugSetCollisionVisible( entity, true, true )
See Also
� Entity.DebugSetAxesVisible
� Entity.DebugSetHierarchyVisible
Entity.DebugSetHierarchyVisible
Brief
Sets the entity to show its hierarchy or not.
Definition
Entity.DebugSetHierarchyVisible( Entity entity, boolean value, boolean recursive )
Arguments
entity - The entity to update.value - If true the entity shows its hierarchy with its immediate children and if false it hides it.recursive - If true the
entity also sets the values of all the children below it.
Return Values
None.
Description
Sets the entity to show its hierarchy or not. Entities default to not show their hierarchy when created. Note that this function is provided for
debugging purposes and should not be used in a finalized script.
Examples
entity = Entity.Create()
Entity.DebugSetHierarchyVisible( entity, true, true )
See Also
� Entity.DebugSetAxesVisible
� Entity.DebugSetCollisionVisible
Entity.DestroyAction
Brief
Destroy an entity action.
Definition
Entity.DestroyAction( Entity entity, number actionld )
Arguments
entity - The entity to which the action belongsactionld - The numerical action ID, obtained at action creation time
Return Values
None.
Description
Destroy an entity action. It is good practice to destroy ail actions when no longer required, however the system will also automatically destroy
them if the target entity is destroyed. This function is only available if the entity has a collision item.
Examples
entity = Entity.Create()
e:SetCollision("kCollisionResource")
e:EnableDynamics()
actionld = Entity.CreatePointForceAction( e, false )
f = Vector4.Create( 10.0, 0.0, 0.0 )
p = Vector4.Create( 0.0, 1.0, 0.0 )
Entity.EnableAction( e, actionld )
Entity.SetActionForce( e, actionld, f )
Entity.SetActionPosition( e, actionld, p )
Entity.DestroyAction( e, actionld )
See Also
� Entity.CreateForceAction
� Entity.CreateTorqueAction
Entity.DetachPersonLabel
Brief
Detaches a previously attached person label from the entity.
Definition
Entity.DetachPersonLabel(Entity entity. Person person)
Arguments
person - The person the label was taken from.
Return Values
Description
This function will detach the person label previously attached to the entity, and will re-attach it to the person it was taken from.
Examples
1 Entity.DetachPersonLabel(entity, person)
See Also
� Entity.AttachPersonLabel
Entity.EnableAction
Brief
Make entity action take effect.
Definition
1 Entity.EnableAction( Entity entity, number actionld, boolean enable = true )
Arguments
entity - The entity to which the action belongsactionld - The numerical action IDenable - true to enable the action, false otherwise
Return Values
None.
Description
Make entity action take effect. A disabled action will not be applied to the entity. This function is only available if the entity has a collision item.
Examples
entity = Entity.Create()
e:SetCollision("kCollisionResource" )
e:EnableDynamics()
actionld = Entity.CreatePointForceAction( e, false )
f = Vector4.Create( 10.0, 0.0, 0.0 )
p = Vector4.Create( 0.0, 1.0, 0.0 )
Entity.EnableAction( e, actionld, true )
Entity.SetActionForce( e, actionld, f )
Entity.SetActionPosition( e, actionld, p )
Entity.DestroyAction( e, actionld )
See Also
� Entity. IsActionEnabled
Entity.EnableCollision
Brief
Enables/disables collision on the specified entity.
Definition
Entity.EnableCollision( Entity entity, boolean enable = true, Phys3dWorld world = nil )
Arguments
entity - The entity to update.enable - true to enable collision, false otherwise (defaults to true if not specified).world - The Phys3dWorld to add to
the entity to, or nil to add to the default world.
Return Values
None.
Description
If collision is enabled for the specified entity, the local player's avatar and other physical entities can collide with it, thereby preventing
penetrations. If collision is disabled, the local player's avatar and other physical entities will be able to pass through this entity. Note that the
collision world specified in this call will override the collision world specified to SetCollision, if any; specifying nil here will cause the item to be
removed from the world specified in SetCollision and added to the default Phys3dWorld. Limitation: Although collision can be enabled for
translated and/or rotated entities, scaling is not supported.
Examples
� Turn off collisions
Entity.EnableCollision( entity, false )
� Turn on collisions
Entity.EnableCollision( entity )
See Also
� Entity.EnableDynamics
� Phys3dWorld.Create
Entity.EnableCollisionCallbacks
Brief
Enable or disable collision callbacks for the specified entity.
Definition
Entity.EnableCollisionCallbacks(Entity entity, boolean enable)
Arguments
entity - the entity to enable/disable collision callbacks forenable - enable or disable
Return Values
None.
Description
Enable or disable collision callbacks for the specified entity. Note that in order to receive callbacks, you must register your interest in the particular
type(s) of collision event you want to receive, using Entity.RegisterCollisionCallbackQ. You must also set the maximum contacts using
Entity.SetMaxContacts(). Finally, the entity must have collision set and enabled for the callback(s) to occur. The entity need not have dynamics
enabled as static entities will also report collisions.
Examples
� set up a collision data buffer
Entity.SetMaxContacts( 64 )
foo = Entity.Create()
foo:SetModel("model")
foo:SetCollision("collision" )
foo:SetPosition(Vector4.Create(0, 5, 0))
foo:SetVisible(true)
foo:EnableCollision(true)
foo:EnableDynamics(true)
foo:EnableCollisionCallbacks(true)
foo:RegisterCollisionCallback(EntityCollision.ContactAdded, ContactAddedCallback, foo)
See Also
� Entity. RegisterCollisionCallback
� Entity.SetMaxContacts
� Entity.SetCollision
� Entity.EnableCollision
Entity.EnableDynamics
Brief
Enables/disables dynamics on the specified entity.
Definition
! Entity.EnableDynamics( Entity entity, boolean enable = true )
Arguments
entity - The entity to update.enable - true to enable dynamics, false otherwise (defaults to true if not specified).
Return Values
None.
Description
If dynamics is enabled, the rigid body attached to the entity will be activated in PS Home's physics simulation. If dynamics is disabled, the entity
will become fixed in its current position and will no longer be affected by the simulation. Note that collision must be enabled on the entity if
dynamics is to be enabled. Attempts to set absolute translations or rotations on an entity that has dynamics enabled will be ignored. For this to
succeed, dynamics must be temporarily disabled while the transformation is explicitly applied to the entity. Limitation: This function must not be
called for entities that have been scaled in any way.
Examples
� Turn off dynamics
Entity.EnableDynamics( entity, false )
� Turn on dynamics (collision must be enabled as well)
Entity.EnableCollision ( entity )
Entity.EnableDynamics( entity )
See Also
� Entity.EnableCollision
Entity.EnableDynamicsAutoDeactivation
Brief
Enable/disable auto-deactivation of dynamics on the specified entity.
Definition
Entity.EnableDynamicsAutoDeactivation( Entity entity, boolean enable = true )
Arguments
entity - The entity to update.enable - true to enable auto-deactivation, false otherwise (defaults to true if not specified).
Return Values
None.
Description
Dynamics must be enabled with Entity.EnableDynamicsf) for the activated/deactivated state to take effect. An Entity with activated dynamics is
one that is having it's motion updated. If dynamics are deactivated, Home's physics engine will stop updating the Entity's motion, until it is
activated again. Entities can be activated by another call to Entity.SetDynamicsActive or by the application of forces/torques/impulses or by
coming into contact with other activated Entities. Entities can be deactivated with Entity.SetDynamicsActive or by allowing auto-deactivation which
will deactivate the Entity if it has not been moving for a while. Auto-deactivation can be enabled/disabled with this function.
Examples
� Disable auto-deactivation
Entity.EnableDynamicsAutoDeactivation( entity, false )
� Enable auto-deactivation
Entity.EnableCollision( entity )
Entity.EnableDynamics( entity )
Entity.SetDynamicsActive( entity )
Entity.EnableDynamicsAutoDeactivation( entity )
See Also
� Entity.EnableDynamics
� Entity.SetDynamicsActive
� Entity. IsDynamicsAutoDeactivationEnabled
Entity.EnablelnterpolatedMode
Brief
Enable/disable interpolated mode.
Definition
| Entity.EnablelnterpolatedMode( Entity entity, boolean enable )
Arguments
entity - The entity.enable - true to enable interpolated mode, false otherwise.
Return Values
None
Description
Enable/disable interpolated mode. Interpolated mode can help smooth the motion of dynamic entities, however there is an extra processing
overhead.
Examples
j Entity.EnablelnterpolatedMode( entity, true )
See Also
� Entity. IsinterpolatedModeEnabled
Entity.EnableKeepUpright
Brief
Set whether or not to keep the entity upright.
Definition
! Entity.EnableKeepUpright( Entity entity, boolean keepUpright = true, number softness =0.0 )
Arguments
entity - entity to be affected.keepUpright - true to keep the entity upright, false otherwisesoftness - the softness of the constraint: 0 is strongest, 1
is weakest.
Return Values
None.
Description
Adds a dynamic constraint to try to keep the entity upright. The softness value is only necessary when enabling the keep upright constraint.
Examples
e = Entity.Create()
e:SetCollision("kCollisionResource")
e:EnableCollision()
e:EnableDynamics()
e:EnableKeepUpright( true, 0.1 )
See Also
� Entity.IsKeepUprightEnabled
Entity. EnableLayerCollision
Brief
Set whether or not an entity can collide with collision of the specified layer.
Definition
Entity.EnableLayerCollision( Entity entity, enum layer, boolean enable )
Arguments
entity - The entity.layer - The collision layer (a CollisionLayer enum).enable - true to enabled collision, false otherwise.
Return Values
None.
Description
Set whether or not an entity can collide with collision of the specified layer. Changes will only take effect for new collisions/overlaps. If two objects
are already colliding (or very close), disabling their collisions via this function will not take effect until they separate. Also, if two objects are
overlapping but do not currently collide with each other (due to disabled layer collisions), then enabling their collision via this function will not take
effect until they separate.
Examples
Entity.EnableLayerCollision( entityl. Entity.GetCollisionLayer ( entity2 ), false )
See Also
� Entity.IsLayerCollisionEnabled
Entity. EvaluateAnims
Brief
Evaluates all current animation(s) active on the entity, and updates the skeleton.
Definition
Entity.EvaluateAnims( Entity entity )
Arguments
entity - The entity to update.
Return Values
None.
Description
In the general case, changes made to the animation state on an entity will be reflected in the next frame. In certain situations, a script may wish to
modify the animation list and have it immediately reflected in the current frame. In this event, the script can call this function, and PS Home will
re-evaluate the entire animation blend list on the entity, and apply the results to the entity's skeleton. Use this function sparingly, as this evaluation
is synchronous and significantly slower than the core animation update. Generally the single-frame delay in the normal case can be hidden with
appropriate blending, rather than relying on this function.
Examples
entity = Entity.Create()
Entity.SetModel( entity, "mymodel" )
Entity.SetSkeleton( entity, "myskel" )
Entity.PlayAnim( entity, "myanim" )
function OnUpdateO
if (playlnstantDeathAnim) then
local animlndex = Entity.GetIndexOfAnim( entity, "myanim" )
local anim = Entity.GetActiveAnim( entity, animlndex )
Entity.BlendAnimOut( entity, anim, AnimBlendType.Linear, 0.1 )
Entity.BlendAnimln( entity, "instantDeath", false, 0.0, AnimBlendType.Linear, 0.1, 0)
Entity.EvaluateAnims( entity )
end
end
See Also
None
Entity.FindMaterials
Brief
Get an array of materials on an entity's model.
Definition
Material[] Entity.FindMaterials( Entity entity, string materialld=nil)
Arguments
entity - The entity to search on.materialld - The material's scriptld as set in max/maya, or nil to get all materials on the entity
Return Values
An array of Materials that matches the given materialld, or all materials on the entity if no id is given.
Description
Gets an array of Materials that matches the given materialld, or all materials on the entity if no id is given.
Examples
entity = Entity.Create()
Entity.SetModel( entity, "mymodel" )
allMaterials = Entity.FindMaterials(entity)
print( "Found " .. #allMaterials .. " materials." );
for i, v in ipairs(array) do
print( tostring( v ) )
end
See Also
� Material. GetParam
� Material.SetAlphaRef
� Material.SetBlendMode
� Material.SetMatrix
� Material.SetTexture
� Material.SetVector
Entity.GetActiveAnim
Brief
Returns a handle to a currently active animation
Definition
Animation Entity.GetActiveAnim( Entity entity, number index )
Entity.GetActiveAnim( Entity entity, number index. Animation anim )
Arguments
entity - the entity to accessindex - the index of the animation handle (within the entity's animation list) to retrieve.anim - the animation object to set,
instead of returning a new one
Return Values
If animation is not specified as a parameter, either a handle to the animation, or nil if no current anim.
If an animation is specified as a parameter, there is no return value.
Description
Get a handle to the current active animation. Note that if there is no current active animation and the user has specified an animation object to set,
the animation object will be marked as invalid. To check this, use Animation.IsValid.
Examples
local animlndex = entity:GetlndexOfAnim("myAnim")
local anim = entity:GetActiveAnim( animlndex )
See Also
� Animation.IsValid
� Animation.Create
Entity. GetAngularDamping
Brief
Gets the angular damping of the collision resource attached to the entity.
Definition
! number Entity.GetAngularDamping( Entity entity )
Arguments
entity - The entity to query.
Return Values
The angular damping for the entity.
Description
Gets the angular damping of the collision resource attached to the entity. This function is only valid if the entity has a collision item.
Examples
! local damping = Entity.GetAngularDamping( entity )
See Also
� Entity.EnableCollision
� Entity. EnableDynamics
� Entity. SetCollision
� Entity. SetAngularDamping
Entity.GetAngularVelocity
Brief
Returns the angular velocity around the center of mass of the entity.
Definition
! Vector4 Entity.GetAngularVelocity( Entity entity )
i Entity.GetAngularVelocity( Entity entity, Vector4 outVec )
Arguments
entity - The entity to query.outVec - The Vector4 to store the result to.
Return Values
The entity's current angular velocity.
Description
Returns the angular velocity around the center of mass of the entity's rigid body in world space. The W component of the returned vector is zero.
If outVec is specified it stores the result in there instead of returning a new Vector4.
Examples
� Add the entity to the physics simulation
Entity.EnableCollision ( entity, true )
Entity.EnableDynamics( entity, true )
� Query the angular velocity
angularVel = Entity.GetAngularVelocity( entity )
See Also
� Entity.GetLinearVelocity
Entity.GetBoneCount
Brief
Get the number of bones in the entity's skeleton.
Definition
number Entity.GetBoneCount(Entity entity)
Arguments
entity - Entity to query.
Return Values
Number of bones in the skeleton, or 0 if the entity has no skeleton attached.
Description
Retrieves the number of bones/joints in the entity's skeleton. If no skeleton is present, 0 is returned.
Examples
! local boneCount = myEntity:GetBoneCount()
See Also
� Entity.GetBonelndex
Entity. GetBonelndex
Brief
Find the index of a bone in the entity's skeleton.
Definition
number Entity.GetBonelndex(Entity entity, string boneName)
Arguments
entity - Entity to query.boneName - Name of bone to locate.
Return Values
The index of the bone in the skeleton (in range 1 - GetBoneCount()), or 0 if not found.
Description
Retrieves the index of the specified bone/joint in the entity's skeleton. The index is 1 -based. If the bone cannot be found, or there is no skeleton
attached, 0 is returned.
Examples
! local leftHandlndex = myEntity:GetBonelndex("lefthand")
See Also
� Entity.GetBoneCount
� Entity.GetBoneLocalMatrix
� Entity.GetBoneWorldMatrix
Entity.GetBoneLocalMatrix
Brief
Get the local transform matrix for a bone in the skeleton.
Definition
! Entity.GetBoneLocalMatrix(Entity entity, string|number bone, Matrix44 result)
Arguments
entity - Entity to query.bone - Bone name or index.result (out) - Matrix44 value to store result into.
Return Values
None.
Description
Retrieve the local-space transform matrix for a specified bone in the skeleton. If the bone is not found an error will result. Retrieving the matrix by
index will be more efficient if done more than once.
Examples
local mat = Matrix44.Create()
myEntity:GetBoneLocalMatrix("lefthand", mat)
� or
local leftHandlndex = myEntity:GetBonelndex("lefthand")
myEntity:GetBoneLocalMatrix(leftHandlndex, mat)
See Also
� Entity.GetBoneWorldMatrix
� Entity.GetBonelndex
Entity.GetBoneWorldMatrix
Brief
Get the world transform matrix for a bone in the skeleton.
Definition
Entity.GetBoneWorldMatrix(Entity entity, string|number bone, Matrix44 result)
Arguments
entity - Entity to query.bone - Bone name or index.result (out) - Matrix44 value to store result into.
Return Values
None.
Description
Retrieve the world-space transform matrix for a specified bone in the skeleton. If the bone is not found an error will result. Retrieving the matrix by
index will be more efficient if done more than once.
Examples
local mat = Matrix44.Create()
myEntity:GetBoneWorldMatrix("lefthand", mat)
� or
local leftHandlndex = myEntity:GetBonelndex("lefthand")
myEntity:GetBoneWorldMatrix(leftHandlndex, mat)
See Also
� Entity.GetBoneLocalMatrix
� Entity.GetBonelndex
Entity.GetCenterOfMassLocal
Brief
Returns the position of the entity's center of mass in local space.
Definition
Vector4 Entity.GetCenterOfMassLocal( Entity entity )
Entity.GetCenterOfMassLocal( Entity entity, Vector4 outVec )
Arguments
entity - The entity to query.outVec - The Vector4 to store the result to.
Return Values
The position of the entity's center of mass in local space.
Description
Returns the position of the entity's center of mass in local space. This may be offset from the coordinate origin of the entity depending on its
physics configuration. If outVec is specified it is used to store the result instead of returning a new Vector4. This function is only available if the
entity has a collision item.
Examples
print( "Entity COM = " .. Entity.GetCenterOfMassLocal( entity ) )
See Also
� Entity. EnableDynamics
� Entity.GetCenterOfMassLocal
Entity.GetCenterOfMassWorld
Brief
Returns the position of the entity's center of mass in world space.
Definition
Vector4 Entity.GetCenterOfMassWorld( Entity entity )
Entity.GetCenterOfMassWorld( Entity entity, Vector4 outVec )
Arguments
entity - The entity to query.outVec - The Vector4 to store the result to.
Return Values
The position of the entity's center of mass in world space.
Description
Returns the position of the entity's center of mass in world space. This may differ from the position of the entity depending on its physics
configuration. If outVec is specified it stores the result in there instead of returning a new Vector4.
Examples
! print( "Entity COM = " .. Entity.GetCenterOfMassWorld( entity ) )
See Also
� Entity.EnableDynamics
Entity.GetChildren
Brief
Get an array of the child entities of a specified entity.
Definition
table Entity.GetChildren(Entity entity)
Arguments
entity - entity to obtain children from.
Return Values
An array of the child entities of the specified entity.
Description
If an entity has had children attached using Entity.AttachToParent, this function will return an array of all the child entities, in the order in which
they were attached. If there are no children, an empty table will be returned.
Examples
parent = Entity.Create()
childl = Entity.Create()
child2 = Entity.Create()
childl:AttachToParent(parent)
child2:AttachToParent(parent)
children = parent:GetChildren()
print(#children) � prints 2 , children[1] == childl and children[2] == child2
print(#childl:GetChildren()) � prints 0, childl has no children
See Also
� Entity.AttachToParent
� Entity.GetParent
� Entity.GetSiblings
Entity.GetCloth
Brief
Retrieve a handle to the entity's cloth meshes, if any.
Definition
Cloth Entity.GetCloth(Entity entity)
Arguments
entity - Entity to query.
Return Values
A Cloth object, or nil if the entity has no model or model contains no cloth elements.
Description
If the entity's model contains cloth elements, this function can be used to obtain a handle to the cloth elements to alter their parameters. All cloth
elements in the model are modified when using the cloth handle.
Examples
myEntity:SetModel("ModelWithCloth")
local cloth = myEntity:GetCloth()
if (cloth) then
cloth:SetWindAngle(135)
end
See Also
� Cloth.SetWindAngle
Entity.GetCollisionLayer
Brief
Query the collision layer of an entity.
Definition
! enum Entity.GetCollisionLayer( Entity entity )
Arguments
entity - The entity.
Return Values
The collision layer (a CollisionLayer enum).
Description
Query the collision layer of an entity.
Examples
i print( "collisionLayer="..Entity.GetCollisionLayer( entity )
See Also
� Entity.SetCollisionLayer
Entity.GetContactCount
Brief
Retrieve the number of contacts passed to a collision callback.
Definition
! number Entity.GetContactCount()
Arguments
None
Return Values
Number of contacts passed to collision callback.
Description
Retrieve the number of contacts available in a collision callback. This function is only valid inside a collision callback.
Examples
function ContactAddedCallback(entity)
local numContacts = Entity.GetContactCount()
print(numContacts .. ' contacts added')
end
See Also
� Entity.GetContactPoint
� Entity.GetContactEntity
� Entity.GetContactRelVelocity
� Entity.GetContactld
Entity.GetContactEntity
Brief
Retrieve the other entity that has been contacted in a collision.
Definition
! Entity Entity.GetContactEntity(number index)
Arguments
index - index of the contact point
Return Values
The contacted entity, or nil in a collision with the world.
Description
Retrieve the other entity contacted in a collision, that is, the entity that is not reporting the collision. In a collision with world geometry or another
physics object not owned by an Entity, nil is returned. It is important to realise that the entity returned is not the exact same entity instance from
Lua's perspective. It will compare equal using == or ~=, and all API functions are available, but if used as a table key it will not match the "original''
entity. If you wish to match the entities using a table, it is recommended to insert them using a unique key based on the entity itself. Note that this
function is only valid from within a collision callback, and will not be available for ContactRemoved callbacks.
Examples
function ContactAddedCallback(entity)
local numContacts = Entity.GetContactCount ()
for i = 1, numContacts do
local entity = Entity.GetContactEntity(i)
if (entity == nil) then
print("I've hit the world!\n")
end
end
end
See Also
� Entity.GetContactCount
� Entity.GetContactPoint
� Entity.GetContactRelVelocity
Entity. GetContactld
Entity.GetContactld
Brief
Retrieve the unique contact ID.
Definition
number Entity.GetContactld(number index)
Arguments
index - index of the contact point
Return Values
The contact ID.
Description
Retrieve the unique ID number assigned the contact. This number will be preserved across multiple frames and so can be used to track individual
contacts over the duration of the collision. Do not make any assumptions about the ID numbers returned. Note that this function is only valid from
within a collision callback.
Examples
function ContactProcessCallback(entity)
local numContacts = Entity.GetContactCount ()
for i = 1, numContacts do
local id = Entity.GetContactld(i)
UpdateContactTracker(id) � do something with contacts being tracked
end
end
See Also
Entity.GetContactPoint
Brief
Retrieve the position and/or normal of the specified contact.
Definition
Entity.GetContactPoint(number index, Vector4 position = nil, Vector4 normal = nil)
Arguments
index - index of the contact pointposition - Vector4 to store the position into, or nil if unwantednormal - Vector4 to store the normal into, or nil if
unwanted
Return Values
None.
Description
Retrieve the position and/or normal of a contact, specified by an index which must be between 1 and the contact count. Passing nil to position
and/or normal will skip retrieval of that value. Both values will be given in world space. Note that this function is only valid from within a collision
callback, and will not be available for ContactRemoved callbacks.
Examples
function ContactAddedCallback(entity)
local numContacts = Entity.GetContactCount ()
local pos = Vector4.Create ()
local norm = Vector4.Create()
for i = l r numContacts do
Entity.GetContactPoint(i, pos, norm)
SpawnlmpactEffeet(pos, norm) � user function to spawn an impact particle effect
end
end
See Also
� Entity.GetContactCount
� Entity.GetContactEntity
� Entity.GetContactRelVelocity
� Entity.GetContactld
Entity.GetContactRelVelocity
Brief
Retrieve the relative velocity of the colliding objects.
Definition
number Entity.GetContactRelVelocity(number index)
Arguments
index - index of the contact point
Return Values
The relative velocity, projected onto the contact normal.
Description
Retrieve the relative velocity of the colliding objects, projected onto the contact normal. Note that the value may be negative or positive. Note also
that this function is only valid from within a collision callback, and only in reponse to the ContactAdded event.
Examples
function ContactAddedCallback(entity)
local numContacts = Entity.GetContactCount()
local pos = Vector4.Create()
local norm = Vector4.Create()
for i = 1, numContacts do
local relVel = math.abs(Entity.GetContactRelVelocity(i))
Entity.GetContactPoint(i, pos, norm)
if (relVel > 10) then
SpawnBigParticle(pos, norm)
else
SpawnSmallParticle(pos, norm)
end
end
end
See Also
Entity.GetContactUserld
Brief
Retrieve the user ID of the part of a party (entity or collision geometry) involved in a contact.
Definition
number, number Entity.GetContactUserld(number contactIndex)
number Entity.GetContactUserld(number contactlndex, number partylndex)
Arguments
contactlndex - index of the contact pointpartylndex - index of the party; 1 or 2
Return Values
In the first usage, both user IDs in order, or the single user ID requested in the second usage. If a value is
nil, no user ID is available.
Description
Retrieve the user ID(s) of the part of a party (entity or collision geometry) involved in a contact. Note that this function is only valid from within a
collision callback. Note that there are two collision items involved in a contact, so there are two corresponding user IDs. The user IDs are ordered
such that party 1 is the entity registered for collision callbacks, and party 2 is the other collision item.
Examples
function ContactProcessCallback(entity)
local numContacts = Entity.GetContactCount()
for i = 1, numContacts do
local idA = Entity.GetContactUserld(i, 1)
local idB = Entity.GetContactUserld(i, 2)
� or local idA, idB = Entity.GetContactUserld(i)
if idA == 100 then
print("UserlD 100 has been hit!")
end
end
end
See Also
Entity.GetCullDistance
Brief
Get the cull distance for an entity.
Definition
! number Entity.GetCullDistance(Entity entity)
Arguments
entity - The entity to modify.
Return Values
The cull distance of the entity, or 0 if disabled.
Description
Get the cull distance of an entity set with SetCullDistance.
Examples
! if (myEntity:GetCullDistance() > 500) then
print("This entity has a very large cull distance!")
| end
See Also
� Entity.SetCullDistance
Entity.GetGravity
Brief
Query the gravity vector of the entity.
Definition
Vector4 Entity.GetGravity( Entity entity )
Entity.GetGravity( Entity entity, Vector4 gravityVectorOut )
Arguments
entity - entity to be queried.gravityVectorOut - gravity vector storage.
Return Values
The gravity vector
Description
Query the gravity vector of the entity. This function is only valid if the entity has a collision item.
Examples
� first form
print( Entity.GetGravity( entity ) )
� second form
local grav = Vector4.Create()
Entity.GetGravity( entity, grav )
print( grav )
See Also
� Entity.SetGravity
Entity. GetlndexOfAnim
Brief
Find the index of the active animation that is using the specified animation resource.
Definition
number Entity.GetIndexOfAnim( Entity entity, string resourceName, number startlndex = 1 )
Arguments
entity - the entity to queryresourceName - the name of the animation we are looking forstartlndex - index to begin search at
Return Values
The index of the animation being queried, or nil if not found.
Description
The start index is provided so that multiple searches can be made if the same resorce is being played multiple times.
Examples
; local animlndex = Entity.GetlndexOfAnim( myEntity, "myAnim" )
See Also
� Entity. GetActiveAnim
� Entity. BlendAnimln
� Entity. BlendAnimOut
� Entity. StopAnim
Entity. GetLinearDamping
Brief
Gets the linear damping of the collision resource attached to the entity.
Definition
number Entity.GetLinearDamping( Entity entity )
Arguments
entity - The entity to query.
Return Values
The linear damping for the entity.
Description
Gets the linear damping of the collision resource attached to the entity. This function is only valid if the entity has a collision item.
Examples
I local damping = Entity.GetLinearDamping( entity )
See Also
� Entity.EnableCollision
� Entity. EnableDynamics
� Entity.SetCollision
� Entity. SetLinearDamping
Entity.GetLinearVelocity
Brief
Returns the linear velocity of the entity.
Definition
! Vector4 Entity.GetLinearVelocity( Entity entity )
! Entity.GetLinearVelocity( Entity entity, Vector4 outVec )
Arguments
entity - The entity to query.outVec - The vector to write the result to.
Return Values
The entity's current linear velocity.
Description
Returns the linear velocity of the center of mass of the entity's rigid body in world space. The W component of the returned vector is zero. If
outVec is specified it stores the result in there instead of returning a new Vector4.
Examples
� Add the entity to the physics simulation
Entity.EnableCollision ( entity, true )
Entity.EnableDynamics( entity, true )
� Query the linear velocity
linearVel = Entity.GetLinearVelocity( entity )
See Also
� Entity. GetAngularVelocity
Entity. GetLocalBounds
Brief
Retrieve the local-space bounds of an entity's model.
Definition
Entity.GetLocalBounds(Entity entity, Vector4 min, Vector4 max)
Arguments
entity - The entity to query.min (out) - Vector4 to receive the minimum extents.max (out) - Vector4 to receive the maximum extents.
Return Values
None.
Description
This function will retrieve the local-space bounds of the entity's model. If no model is set then an error will be raised. The returned vectors indicate
the minimum and maximum extents on each axis in local space, and define an axis-aligned bounding box. The W components will be 1.
Examples
Vector4 min = Vector4.Create()
Vector4 max = Vector4.Create()
myEntity:GetLocalBounds(min, max)
local center = (min + max) * 0.5
local extents = max - center
See Also
� Entity.GetWorldBounds
Entity.GetLocalMatrix
Brief
Returns the current local transformation matrix of the entity.
Definition
Matrix44 Entity.GetLocalMatrix( Entity entity )
Entity.GetLocalMatrix( Entity entity, Matrix44 outMat )
Arguments
entity - The entity to query.outMat - The Matrix44 to store the result to.
Return Values
The current local matrix of the entity.
Description
Returns the current local transformation matrix of the entity. This matrix is relative to the coordinate system of the entity's parent, if one exists. If
the entity has no parent, the matrix is relative to the world space coordinate system. If outMat is specified it stores the result in there instead of
returning a new Matrix44.
Examples
entity = Entity.Create()
mat = Entity.GetLocalMatrix( entity )
print( mat )
See Also
� Entity.Create
Entity.GetMass
Brief
Returns the mass of the collision resource attached to the entity.
Definition
number Entity.GetMass( Entity entity )
Arguments
entity - The entity to query.
Return Values
The mass of the collision resource attached to the entity.
Description
Gets the mass of the rigid body that is attached to the entity. This function can only be called if the entity has a collision resource.
Examples
! local mass = Entity.GetMass( entity )
See Also
� Entity.EnableCollision
� Entity. EnableDynamics
� Entity.SetColiision
� Entity.SetMass
Entity.GetNumActiveAnims
Brief
Returns the number of active animations currently being played on the specified entity.
Definition
! number Entity.GetNumActiveAnims( Entity entity )
Arguments
entity - the entity to query
Return Values
The number of active anims running.
Description
Returns the number of active animations currently being played on the specified entity.
Examples
! local numAnims = Entity.GetNumActiveAnims( myEntity )
See Also
None
Entity.GetParent
Brief
Get the parent entity for the specified entity, if any.
Definition
Entity Entity.GetParent(Entity entity)
Arguments
entity - entity to obtain parent from.
Return Values
The parent entity, or nil if no parent.
Description
If an entity has been attached to another entity using Entity.AttachToParent, the parent entity can be retrieved with this function.
Examples
! parent = Entity.Create()
i entity = Entity.Create()
| entity:AttachToParent(parent)
if (entity:GetParent () == parent) then
print("Attached!") � prints Attached!
| end
L_I
See Also
Entity.AttachToParent
� Entity.GetChildren
� Entity.GetSiblings
Entity.GetPointVelocity
Brief
Returns the velocity of a point on a physics collision item.
Definition
Vector4 Entity.GetPointVelocity( Entity entity, Vector4 point )
Entity.GetPointVelocity( Entity entity, Vector4 point, Vector4 outVec )
Arguments
entity - The entity to query.point - The point of which you wish to know the velocity.outVec - The Vector4 to store the result to.
Return Values
The velocity of the point on the rigid body.
Description
Returns the velocity of a point on a physics collision item in world space. If outVec is specified it stores the result it is used to store the result
instead of returning a new Vector4. This function is only available if the entity has a collision item.
Examples
j print( "Point velocity lm up = " .. Entity.GetPointVelocity( entity, Vector4.Create( 0, 1, 0 ) )
See Also
� Entity. EnableDynamics
Entity.GetPosition
Brief
Returns the entity's position.
Definition
Vector4 Entity.GetPosition( Entity entity )
Entity.GetPosition( Entity entity, Vector4 outVec )
Arguments
entity - The entity to query.outVec - The Vector4 to store the result to.
Return Values
The entity's position.
Description
Returns the entity's position. If the entity has a parent, the returned position is relative to the parent's coordinate system. If outVec is specified it
stores the result in there instead of returning a new Vector4.
Examples
print( "Entity position = " .. Entity.GetPosition( entity ) )
See Also
None
Entity.GetRotationQuat
Brief
Gets the rotation as a quaternion.
Definition
Quaternion Entity.GetRotationQuat( Entity entity )
Entity.GetRotationQuat( Entity entity, Quaternion outQuat )
Arguments
entity - The entity to query.outQuat - The Quaternion to store the result to.
Return Values
The rotation of the entity in quaternion form, or none using the second syntax.
Description
Gets the rotation of the entity in quaternion form. If outQuat is specified it is used for storing the result instead of returning a new Quaternion.
Examples
j entity = Entity.Create()
i rotation = entity:GetRotationQuat()
See Also
� Entity.SetRotationQuat
Entity.GetRotationXyz
Brief
Gets the rotation about the x, y, and z-axis in degrees.
Definition
Vector4 Entity.GetRotationXyz( Entity entity )
Entity.GetRotationXyz( Entity entity, Vector4 outVec )
Arguments
entity - The entity to query.outVec - The Vector4 to store the result to.
Return Values
The XYZ-ordered axis rotation of the entity.
Description
Gets the rotation about the x, y, and z-axis of the entity's local coordinate system in degrees. The rotation order is x, y, z. The W component of the
returned vector is set to 0.0. If outVec is specified it stores the result in there instead of returning a new Vector4.
Examples
j entity = Entity.Create()
i rotation = Entity.GetRotationXyz( entity )
See Also
� Entity.SetRotationXyz
Entity.GetScale
Brief
Returns the entity's scale.
Definition
Vector4 Entity.GetScale( Entity entity )
Entity.GetScale( Entity entity, Vector4 outVec )
Arguments
entity - The entity to query.outVec - The Vector4 to store the result to.
Return Values
The entity's scale.
Description
Returns the entity's scale. If the entity has a parent, the returned scale is relative to the parent's coordinate system. If outVec is specified it stores
the result in there instead of returning a new Vector4.
Examples
! print( "Entity scale = " .. Entity.GetScale( entity ) )
See Also
� Entity.AttachToParent
� Entity.SetScale
Entity.GetSiblings
Brief
Get an array of the sibling entities of a specified entity.
Definition
table Entity.GetSiblings(Entity entity)
Arguments
entity - entity to obtain siblings from.
Return Values
An array of the sibling entities of the specified entity.
Description
If an entity has been attached to a parent entity using Entity.AttachToParent, this function will return an array of all other entities attached to the
same parent, excluding this entity. If this entity is the only child, the table will be empty.
Examples
parent = Entity.Create()
childl = Entity.Create()
child2 = Entity.Create()
childl:AttachToParent(parent)
child2:AttachToParent(parent)
childlSiblings = childl:GetSiblings()
child2Siblings = child2:GetSiblings()
if (childlSublings[1] ~= child2 or child2Siblings[1] ~= childl) then
error("This will never happen")
end
See Also
� Entity.AttachToParent
� Entity.GetParent
� Entity.GetChildren
Entity.GetUniqueld
Brief
Returns a unique integer ID that identifies the entity.
Definition
number Entity.GetUniqueld(Entity entity)
Arguments
entity - The entity to query.
Return Values
A unique integer ID value.
Description
The integer ID returned is guaranteed to be unique for all currently active entities on the local client, and it is guaranteed that if entityl == entity2
is true, then entityl :GetUniqueld() == entity2:GetUniqueld() is also true, and vice versa. No assumptions should be made about the nature of the
ID value, and it is not guaranteed to be persistent or reproducible across instances or PS Home versions. Note that the ID value isn't replicated in
any way, it only applies to local entities.
Examples
local hitEntity = raycast:GetHitEntity()
if (myEntityTable[ hitEntity:GetUniqueld() ] == nil) then
print("New entity hit!")
myEntityTable[ hitEntity:GetUniqueld() ] = hitEntity
end
See Also
None
Entity.GetWorldBounds
Brief
Retrieve the world-space bounds of an entity's model.
Definition
Entity.GetWorldBounds(Entity entity, Vector4 min, Vector4 max)
Arguments
entity - The entity to query.min (out) - Vector4 to receive the minimum extents.max (out) - Vector4 to receive the maximum extents.
Return Values
None.
Description
This function will retrieve the world-space bounds of the entity's model. If no model is set then an error will be raised. The returned vectors
indicate the minimum and maximum extents on each axis in world space, and define a world-space axis-aligned bounding box. The W
components will be 1. NOTE: the world bounds are only updated when the model renders. Thus if you move the object in current frame, the world
bounds will be out of date until the following frame. If you wish to compute up to date world bounds in this specific case, transform the local
bounds and take the AABB of the OBB thus formed.
Examples
Vector4 min = Vector4.Create()
Vector4 max = Vector4.Create()
myEntity:GetWorldBounds(min, max)
local center = (min + max) * 0.5
local extents = max - center
See Also
� Entity.GetLocalBounds
Entity. GetWorldMatrix
Brief
Returns the current world matrix of the entity.
Definition
Matrix44 Entity.GetWorldMatrix( Entity entity )
Entity.GetWorldMatrix( Entity entity, Matrix44 outMat )
Arguments
entity - The entity to query.outMat - The Matrix44 to store the result to.
Return Values
The current world matrix of the entity.
Description
Returns the current world matrix of the entity. If outMat is specified it stores the result in there instead of returning a new Matrix44.
Examples
j entity = Entity.Create()
; mat = Entity.GetWorldMatrix( entity )
j print( mat )
See Also
� Entity.Create
Entity.HasActiveAnims
Brief
Indicates if there are any active animations on the entity.
Definition
boolean Entity.HasActiveAnims( Entity entity )
Arguments
entity - the entity to query
Return Values
True if there are any active animations being played on the entity, or false if not.
Description
This function is more efficient than checking if Entity.GetNumActiveAnims() is 0.
Examples
! if ( Entity.HasActiveAnims( myEntity ) ) then
Entity.StopAnim( myEntity )
| end
See Also
Entity. BlendAnimln
� Entity. BlendAnimOut
� Entity.GetlndexOfAnim
� Entity.GetActiveAnim
Entity. IsActionEnabled
Brief
Query whether entity action is enabled.
Definition
! boolean Entity.IsActionEnabled( Entity entity, number actionld )
Arguments
entity - The entity to which the action belongsactionld - The numerical action ID
Return Values
true if enabled, false otherwise
Description
Query whether an entity action is currently enabled.
Examples
entity = Entity.Create()
e:SetCollision("kCollisionResource" )
e:EnableDynamics()
actionld = Entity.CreatePointForceAction( e, false )
f = Vector4.Create( 10.0, 0.0, 0.0 )
p = Vector4.Create( 0.0, 1.0, 0.0 )
Entity.EnableAction( e, actionld, true )
print( Entity.IsActionEnabled( e, actionld ) )
Entity.SetActionForce( e, actionld, f )
Entity.SetActionPosition( e, actionld, p )
Entity.DestroyAction( e, actionld )
See Also
� Entity.EnableAction
Entity.lsDynamicsActive
Brief
Query whether dynamics is active on the specified entity.
Definition
boolean Entity.IsDynamicsActive( Entity entity )
Arguments
entity - The entity to update.
Return Values
true if dynamics is active, false otherwise.
Description
Query whether dynamics is active on the specified entity. See Entity.SetDynamicsActive documentation for more information. This function is only
valid if the entity has a collision item.
Examples
� Activate dynamics (collision must be enabled as well)
Entity.EnableCollision( entity )
Entity.EnableDynamics( entity )
Entity.SetDynamicsActive( entity )
print( Entity.IsDynamicsActive( entity ) )
See Also
� Entity.EnableDynamics
� Entity.SetDynamicsActive
Entity.lsDynamicsAutoDeactivationEnabled
Brief
Query whether auto-deactivation of dynamics is enabled on the specified entity.
Definition
boolean Entity.IsDynamicsAutoDeactivationEnabled( Entity entity )
Arguments
entity - The entity to update.
Return Values
true if enabled, false otherwise.
Description
Query whether auto-deactivation of dynamics is enabled on the specified entity. See Entity.EnableDynamicsAutoDeactivation for more
information.
Examples
� Enable auto-deactivation
Entity.EnableCollision ( entity )
Entity.EnableDynamics( entity )
Entity.SetDynamicsActive( entity )
Entity.EnableDynamicsAutoDeactivation( entity )
print( ( Entity.IsDynamicsAutoDeactivationEnabled( entity ) ) )
See Also
Entity. EnableDynamics
� Entity.SetDynamicsActive
� Entity. EnableDynamicsAutoDeactivation
Entity.IsInterpolatedModeEnabled
Brief
Query whether or not interpolated mode is enabled.
Definition
! boolean Entity.IsInterpolatedModeEnabled( Entity entity )
Arguments
entity - The entity.
Return Values
true if interpolated mode is enabled, false otherwise.
Description
Query whether or not interpolated mode is enabled. Interpolated mode can help smooth the motion of dynamic entities, particularly those that are
directly controlled by the user; however, there is an extra processing overhead.
Examples
! print( Entity.IsInterpolatedModeEnabled( entity ) )
See Also
� Entity.EnablelnterpolatedMode
Entity. IsKeepUprightEnabled
Brief
Query whether or not the entity is being kept upright.
Definition
! boolean Entity.IsKeepUprightEnabled( Entity entity )
Arguments
entity - entity to be queried.
Return Values
true if the entity is being kept upright, false otherwise.
Description
Query whether or not the entity is being kept upright, e = Entity.Create() e:SetCollision("kCollisionResource") e:EnableCollision()
e:EnableDynamics() e:EnableKeepUpright( true, 0.1 ) print( e:lsKeepUprightEnabled())
Examples
! Entity.EnableKeepUpright
See Also
None
Entity.IsLayerCollisionEnabled
Brief
Query whether or not an entity can collide with collision of the specified layer.
Definition
! boolean Entity.IsLayerCollisionEnabled( Entity entity, enum layer )
Arguments
entity - The entity.layer - The collision layer (a CollisionLayer enum).
Return Values
true if collision is enabled, false otherwise.
Description
Query whether or not an entity can collide with collision of the specified layer.
Examples
: print( Entity.IsLayerCollisionEnabled( entityl, Entity.GetCollisionLayer( entity2 ) ) )
See Also
� Entity.EnableLayerCollision
Entity.IsVisible
Brief
Indicates if the entity is currently marked as visible.
Definition
! Entity.IsVisible(Entity entity)
Arguments
entity - the entity to query.
Return Values
true if the object is marked as visible, false otherwise.
Description
An entity can be marked as invisible for several reasons: the script can do so using SetVisible, entities attached to a person that is invisible or too
close to the camera, and entities that represent scene objects hidden by the client (for example, active furniture during removal). This function will
indicate whether an entity has been marked invisible for any reason. It is not possible to tell from the return value why the entity is invisible, but it
may be helpful to a script if it is desired to hide other entities/effects when one entity is invisible. It is not required to check this for all entities, as
only entities attached to scene objects as indicated above can be affected outside the script's control. Visibility is also inherited, so children of an
invisible entity are automatically made invisible also, and this functionality should be leveraged if it is desired to hide groups of entities when a
parent entity is made invisible for any reason.
Examples
if (not Active.GetEntity():IsVisible()) then
� active has been hidden, pause our special unattached particle effects
PauseParticles()
end
See Also
� Active.GetEntity
� Entity.SetVisible
Entity. LookAt
Brief
Rotate an entity to look at a specified point.
Definition
Entity.LookAt( Entity entity, Vector4 targetPoint, Vector up=[0,l,0,0] )
Arguments
entity - The entity to update.targetPoint - The point to look at, in the entity's parent space.up - The up vector of the entity, in the entity's parent
space.
Return Values
None.
Description
Rotate the entity to look at the specified point. The entity looks down its forward/front vector, the z-axis. Note that this is a one-off reorientation of
the entity, it will not track the look-at point if the entity (or its parent) moves.
Examples
! entity = Entity.Create()
Entity.LookAt( entity, Vector4.Create( 0.5, 0.5, 0 ) )
See Also
� Entity.Create
� Vector4. Create
Entity. LookAtWorld
Entity.LookAtWorld
Brief
Rotate an entity to look at a specified point in world space.
Definition
! Entity.LookAtWorld( Entity entity, Vector4 targetPoint, Vector up=[0,l,0,0] )
Arguments
entity - The entity to update.targetPoint - The point to look at in world space.up - The up vector of the entity in world space.
Return Values
None.
Description
Rotate the entity to look at the specified point in world space. The entity looks down its forward/front vector, the z-axis. Note that this is a one-off
reorientation of the entity, it will not track the look-at point if the entity (or its parent) moves.
Examples
1 entity = Entity.Create()
j Entity.LookAtWorld( entity, Vector4.Create( 0.5, 0.5, 0 ) )
See Also
� Entity.Create
� Vector4.Create
� Entity.LookAt
Entity.ParticlelsAlive
Brief
Returns true if particle effect is still alive.
Definition
! boolean Entity.ParticlelsAlive( Entity entity )
Arguments
entity - The entity to query.
Return Values
true if any particles are still active, false otherwise.
Description
Returns true if particle effect is still alive.
Examples
entity = Entity.Create()
Entity.ParticleSetEffeet( entity, "myparticle" )
if Entity.ParticlelsAlive( entity ) then
print( "Particle system still active!" )
end
See Also
� Entity.Create
� Entity. ParticleSetEffect
Entity.ParticleReset
Brief
Resets the particle effect.
Definition
Entity.ParticleReset( Entity entity )
Arguments
entity - The entity to update.
Return Values
None.
Description
Resets the particle effect by clearing the particle buffer and resetting time to 0.0.
Examples
! entity = Entity.Create()
| Entity.ParticleSetEffeet( entity, "myparticle" )
j Entity.ParticleReset( entity )
See Also
� Entity.Create
� Entity. ParticleSetEffect
Entity.ParticleSetAttachType
Brief
Sets how the particle is attached to the entity's world matrix.
Definition
Entity.ParticleSetAttachType( Entity entity, string type )
Arguments
entity - The entity to update.type - The type of attachment the entity has over the particle effect. Can be one of the following:
"render"
"emitter"
Return Values
None.
Description
Sets how the particle is attached to the entity's world matrix. Can be one of the following: "render" - The entity's world matrix is used as the render
matrix of the particle effect. This is the default, "emitter� - The entity's world matrix is used as the emitter matrix of the particle effect.
Examples
e = Entity.Create()
Entity.ParticleSetEffeet( e, "flaming_torch" )
Entity.ParticleSetAttachType( e, "emitter" )
See Also
� Entity. ParticleSetEffect
Entity.ParticleSetEffect
Brief
Sets the entity's particle effect.
Definition
Entity.ParticleSetEffeet( Entity entity, string resourceName )
Entity.ParticleSetEffeet( Entity entity. Resource particleResource )
Arguments
entity - The entity to update.resourceName - The resource name of the particle effect or nil to remove it.particleResource - The particle effect
resource or nil to remove it.
Return Values
None.
Description
Sets the entity's particle effect to the named resource as specified in the HDK's Object Editor application.
Examples
! entity = Entity.Create()
i Entity.ParticleSetEffeet( entity, "myparticle" )
See Also
None
Entity.ParticleSetEmitting
Brief
Starts/Stops particle emission.
Definition
Entity.ParticleSetEmitting( Entity entity, boolean value )
Arguments
entity - The entity to update.value - true to enable emission and false to stop emission.
Return Values
None.
Description
Starts/Stops particle emission.
Examples
| entity = Entity.Create()
Entity.ParticleSetEffeet( entity, "myparticle" )
j Entity.ParticleSetEmitting( entity, false )
See Also
� Entity.Create
Entity.ParticleSetUpdate
Brief
Starts/stops particle updating.
Definition
Entity.ParticleSetUpdate( Entity entity, boolean value )
Arguments
entity - The entity to update.value - true to enable particle updates and false to disable them.
Return Values
None.
Description
Starts/stops particle updating. This effectively starts/stops time.
Examples
! entity = Entity.Create()
Entity.ParticleSetEffeet( entity, "myparticle" )
| Entity.ParticleSetUpdate( entity, false )
See Also
� Entity.Create
� Entity. ParticleSetEffect
Entity.ParticleSetUserParam
Brief
Sets a user parameter in the particle system
Definition
boolean Entity.ParticleSetUserParam( Entity entity, string paramName, number paramValue )
boolean Entity.ParticleSetUserParam( Entity entity, string paramName, Vector4 paramValue )
Arguments
entity - The entity to update.paramName - The name of the parameter to set in the particle graph.paramValue - The value to set.
Return Values
true if the assignment was made, false if parameter not present in particle system.
Description
The particle editor tool allows for input of user parameters from runtime code. Access this via the "HomeLua..." nodes in the particle editor. There
are many supported types. 1->4 float components. (Scalar, Scale, Vector, Colour, etc...) The Scalar types can use the number or Vector4
interface. All other types need to use the Vector4 interface.
Examples
entity = Entity.Create()
Entity.ParticleSetEffeet( entity, "myparticle" )
Entity.ParticleSetUserParam( entity, "homelua_scalarl"
Entity.ParticleSetUserParam( entity, "homelua_scalar2"
Entity.ParticleSetUserParam( entity, "homelua_colourl"
Entity.ParticleSetUserParam( entity, "homelua_vector5"
5.0 )
Vector4(5.0) )
Vector4(0.3,0.4,0.5,1.0) )
Vector4(1.0,0.0,1.0) )
See Also
None
Entity.PauseAnim
Brief
Pauses all current animation(s) if any are playing.
Definition
Entity.PauseAnim( Entity entity )
Arguments
entity - The entity to update.
Return Values
None.
Description
Pauses all current animation(s) if any are playing. Use ResumeAnim to continue to play the animation(s).
Examples
entity = Entity.Create()
Entity.SetModel( entity, "mymodel" )
Entity.SetSkeleton( entity, "myskel" )
Entity.PlayAnim( entity, "myanim" )
Entity.PauseAnim( entity )
See Also
� Entity.ResumeAnim
Entity.PlayAnim
Brief
Plays the specified animation resource.
Definition
Entity.PlayAnim( Entity entity,
priority = 0 )
Entity.PlayAnim( Entity entity,
priority = 0 )
string resourceName, boolean looping = true, number time = 0, number
Resource animResource, boolean looping = true, number time = 0, number
Arguments
entity - The entity to update.resourceName - The resource name of the animation.animResource - The animation resource.looping - flag indicating
if animation should loop, or only play once. Default is true.time - the time at which the animation is played from. If the time is greater than the
duration, is taken as 0. Default is 0.priority - The priority affects where in the animation list an animation will be played. The higher the number, the
later it will be played.
If a prior animation is being played at the same priority, then the new animation will be placed after the old animation in the list, (default is 0).
*NB Internally, priority is treated as an integer.
Return Values
None.
Description
Plays the specified animation resource as specified in the HDK's Object Editor application. Stops all other animations that are currently playing.
Examples
entity = Entity.Create()
Entity.SetModel( entity, "mymodel" )
Entity.SetSkeleton( entity, "myskel" )
Entity.PlayAnim( entity, "myanim" )
See Also
Entity.Create
� Entity. SetModel
� Entity.SetSkeleton
Entity.RegisterCollisionCallback
Brief
Register a function to be called in response to a collision event involving the specified entity.
Definition
Entity.RegisterCollisionCallback( Entity entity, EntityCollision eventType, function callback,
userData = nil )
Arguments
entity - the entity to register for the collision callbackeventType - an EntityCollision enum value:
EntityCollision.ContactAdded - a new contact point has been added
EntityCollision.ContactProcess - called for all active contact points each frame while they exist
EntityCollision.ContactRemoved - a contact point has been removedcallback - the Lua function to be calleduserData - arbitrary user data of the
user's choice
Return Values
None.
Description
Register a function to be called in response to a collision event involving the specified entity. You must enable collision callbacks for the specified
entity using EnableCollisionCallbacksQ in order to begin receiving callbacks to your registered function(s). You must also set the maximum
contacts buffer using Entity.SetMaxContacts(). Finally, the entity must have collision set and enabled for the callbacks to occur.
Examples
� set up a collision data buffer
Entity.SetMaxContacts( 128 )
foo = Entity.Create ()
foo:SetModel("model")
foo:SetCollision("collision")
foo:SetPosition(Vector4.Create(0, 5, 0))
foo:SetVisible(true)
foo:EnableCollision(true)
foo:EnableDynamics(true)
foo:EnableCollisionCallbacks(true)
foo:RegisterCollisionCallback(EntityCollision.ContactAdded, ContactAddedCallback, foo)
foo:RegisterCollisionCallback(EntityCollision.ContactRemoved, ContactRemovedCallback, foo)
See Also
� Entity. RegisterCollisionCallback
� Entity.SetMaxContacts
� Entity.SetCollision
� Entity.EnableCollision
Entity. Reset
Brief
Reset an entity to a newly-created state.
Definition
Entity.Reset(Entity entity)
Arguments
entity - Entity to reset.
Return Values
None.
Description
Resets all non-hierarchy entity state, including model, animation, collision, particles, attached cameras, lights and other state. The entity's
hierarchy state (parent and children) and transform state (position and rotation) will not be reset, if this is desired it must be done explicitly. Of
particular use if using a pool of entities, as entities can be reset upon being released back into the pool (or when allocated from the pool).
Examples
myEntity:Reset()
See Also
� Entity.Copy
Entity.ResumeAnim
Brief
Resumes all current animation(s) if they are paused.
Definition
Entity.ResumeAnim( Entity entity )
Arguments
entity - The entity to update.
Return Values
None.
Description
Resumes all current animation(s) if they are paused. Use PauseAnim to pause the animation(s).
Examples
entity = Entity.Create()
Entity.SetModel( entity, "mymodel" )
Entity.SetSkeleton( entity, "myskel" )
Entity.PlayAnim( entity, "myanim" )
Entity.PauseAnim( entity )
Entity.ResumeAnim( entity )
See Also
� Entity.PauseAnim
Entity.SetActionForce
Brief
Set the force of an entity action.
Definition
Entity.SetActionForce( Entity entity, number actionld, Vector4 force )
Arguments
entity - The entity to which the action belongsactionld - The numerical action IDforce - The force in world-space
Return Values
None.
Description
Set the force of an entity action. Only applicable to force-based actions. This function is only available if the entity has a collision item.
Examples
entity = Entity.Create()
e:SetCollision("kCollisionResource" )
e:EnableDynamics()
actionld = Entity.CreatePointForceAction( e, false )
f = Vector4.Create( 10.0, 0.0, 0.0 )
p = Vector4.Create( 0.0, 1.0, 0.0 )
Entity.EnableAction( e, actionld )
Entity.SetActionForce( e, actionld, f )
Entity.SetActionPosition( e, actionld, p )
Entity.DestroyAction( e, actionld )
See Also
� Entity. SetActionTorque
� Entity.SetActionPosition
Entity.SetActionPosition
Brief
Set the position of an entity action.
Definition
Entity.SetActionPosition( Entity entity, number actionld, Vector4 position )
Arguments
entity - The entity to which the action belongsactionld - The numerical action IDposition - The position in world-space.
Return Values
None.
Description
Set the position of an entity action. Only applicable to position-based actions. This function is only available if the entity has a collision item.
Examples
entity = Entity.Create()
e:SetCollision("kCollisionResource" )
e:EnableDynamics()
actionld = Entity.CreatePointForceAction( e, false )
f = Vector4.Create( 10.0, 0.0, 0.0 )
p = Vector4.Create( 0.0, 1.0, 0.0 )
Entity.EnableAction( e, actionld )
Entity.SetActionForce( e, actionld, f )
Entity.SetActionPosition( e, actionld, p )
Entity.DestroyAction( e, actionld )
See Also
� Entity.SetActionTorque
� Entity.SetActionForce
Entity.SetActionTorque
Brief
Set the torque of an entity action.
Definition
Entity.SetActionTorque( Entity entity, number actionld, Vector4 torque )
Arguments
entity - The entity to which the action belongsactionld - The numerical action IDtorque - The torque in world-space.
Return Values
None.
Description
Set the torque of an entity action. Only applicable to torque-based actions. This function is only available if the entity has a collision item.
Examples
entity = Entity.Create()
e:SetCollision("kCollisionResource" )
e:EnableDynamics()
actionld = Entity.CreateTorqueAction( e, false )
t = Vector4.Create( 10.0, 0.0, 0.0 )
p = Vector4.Create( 0.0, 1.0, 0.0 )
Entity.EnableAction( e, actionld )
Entity.SetActionTorque( e, actionld, t )
Entity.DestroyAction( e, actionld )
See Also
� Entity.SetActionForce
� Entity.SetActionPosition
Entity. SetAngularDamping
Brief
Sets the angular damping of the collision resource attached to the entity.
Definition
! Entity.SetAngularDamping( Entity entity, number damping )
Arguments
entity - The entity to update.damping - The angular damping to apply to the entity.
Return Values
None.
Description
Sets the angular damping of the collision resource attached to the entity. Angular damping reduces the rotational velocity of the entity over time.
For example, if you set the angular damping to 0.2, then every second about 20% of the object's angular velocity will be removed. This function is
only valid if the entity has a collision item.
Examples
! Entity.SetAngularDamping( entity, 0.2 )
See Also
� Entity.EnableCollision
� Entity.EnableDynamics
� Entity.SetCollision
� Entity.GetAngularDamping
Entity.SetAngularVelocity
Brief
Sets the angular velocity around the center of mass of the entity.
Definition
Entity.SetAngularVelocity( Entity entity, Vector4 velocity )
Arguments
entity - The entity to update.velocity - vector specifying angular velocity.
Return Values
None.
Description
Sets the angular velocity around the center of mass of the entity's rigid body in world space. The W component of the specified vector is ignored.
Examples
! � Add the entity to the physics simulation
i Entity.EnableCollision( entity, true )
| Entity.EnableDynamics( entity, true )
| Entity.SetAngularVelocity( entity, Vector4.Create( 0, 10, 0 ) )
See Also
� Entity. SetLinearVelocity
� Vector4.Create
Entity .Set AttachT ype
Brief
Set the type of attachment used by the entity.
Definition
Entity.SetAttachType( Entity entity, AttachType type )
Arguments
entity - The entity to affect (must be attached to another entity or person).type - The type of attachment to use:
AttachType.T ranslation
AttachType. Rotation
AttachType.Scale
AttachType.Transform (default)
Return Values
None.
Description
The default behaviour for attached entities is to inherit all of their parent's transform, including translation, rotation and scaling. A script can use
this function to only inherit some of the parent's transform, to only translate an object with its parent and not alter its rotation for example. Scale is
handled so that if translation and scale are both inherited, then the local translation of the child entity will be scaled also, as per normal
attachment. If translation is not inherited, the local translation will not be scaled.
Examples
child:AttachToParent(parent)
child:SetAttachType(AttachType.Translation) � only inherit parent translation
child:SetAttachType(AttachType.Translation + AttachType.Rotation) � ignore parent scale
child:SetAttachType(AttachType.Transform) � same as default
See Also
� Entity.AttachToParent
� Entity.AttachToBone
Entity.SetCenterOfMassLocal
Brief
Sets the position of the entity's center of mass in local space.
Definition
Entity.SetCenterOfMassLocal( Entity entity, Vector4 com )
Arguments
entity - The entity to update.com - The position of the entity's center of mass in local space.
Return Values
None.
Description
Sets the position of the entity's center of mass in local space. This may be offset from the coordinate origin of the entity depending on its physics
configuration. This function is only available if the entity has a collision item.
Examples
: Entity.SetCenterOfMassLocal( entity, Vector4.Create( 0.5, 0.5, 0.5 ) )
See Also
� Entity. EnableDynamics
Entity.SetCollision
Brief
Sets the entity's collision.
Definition
Entity.SetCollision( Entity entity, string resourceName, Phys3dWorld world = nil )
Entity.SetCollision( Entity entity, Resource collisionResource, Phys3dWorld world = nil )
Arguments
entity - The entity to update.resourceName - The collision's resource name or nil to remove it.collisionResource - The collision resource or nil to
remove it.world - Phys3dWorld to add the entity to, or nil for the default.
Return Values
None.
Description
Sets the entity's collision to the named resource as specified in the HDK�s Object Editor application. Note that an entity with collision will no longer
respect attachments specified prior to calling SetCollision. The current world transform of the entity is preserved across this function call. This
function will automatically enable collision on the entity.
Examples
entity = Entity.Create()
Entity.SetCollision( entity, "mycollision" )
� Remove the collision from the entity
Entity.SetCollision( entity, nil )
See Also
� Entity.Create
� Phys3dWorld.Create
Entity.SetCollision Layer
Brief
Set the collision layer of an entity.
Definition
Entity.SetCollisionLayer( Entity entity, enum layer, boolean preserveCurrentLayerCollisions = true )
Arguments
entity - The entity.layer - The collision layer; can be either CollisionLayer.Entity or a "User Layer".preserveCurrentLayerCollisions - true to
preserve which layers the entity collides with, false otherwise.
Return Values
None.
Description
Set the collision layer of an entity. If preserveCurrentLayerCollisions is false, the layers with which the entity collides are reset to the default for the
specified layer. The defaults can be changed using Scene.SetLayerCollisionDefault.
Examples
Entity.SetCollisionLayer( entity, CollisionLayer.Userl, false )
See Also
� Entity.GetCollisionLayer
� Scene.SetLayerCollisionDefault
Entity.SetCullDistance
Brief
Set a distance at which the entity will be automatically made invisible.
Definition
! Entity.SetCullDistance(Entity entity, number distance)
Arguments
entity - The entity to modify.distance - The distance from camera at which to visibility cull the entity, or 0 to disable.
Return Values
None.
Description
For situations involving a large scene, it may be beneficial for efficiency reasons to set objects to invisible when they are located far away. Setting
a cull distance will automatically compute the entity's distance from camera every frame and hide it and any child entities if the distance is greater
than the specified cull distance. Note that internally squared distances are compared, so the cull distance should not overflow a floating point
number when squared.
Examples
! myEntity:SetCullDistance(80) � set cull distance to 80m
See Also
� Entity.GetCullDistance
Entity.SetDynamicsActive
Brief
Activate/deactivate dynamics on the specified entity.
Definition
! Entity.SetDynamicsActive( Entity entity, boolean activate = true )
Arguments
entity - The entity to update.activate - true to activate dynamics, false otherwise (defaults to true if not specified).
Return Values
None.
Description
Dynamics must be enabled with Entity.EnableDynamicsf) for the activated/deactivated state to take effect. An Entity with activated dynamics is
one that is having it�s motion updated. If dynamics are deactivated with this function, Flome's physics engine will stop updating the Entity's motion,
until it is activated again. Entities can be activated by another call to this function or by the application of forces/torques/impulses or by coming
into contact with other activated Entities. Entities can be deactivated with this function or by allowing auto-deactivation which will deactivate the
Entity if it has not been moving for a while. Auto-deactivation can be enabled/disabled with Entity.EnableDynamicsAutoDeactivation. This function
is only valid if the entity has a collision item.
Examples
� Deactivate dynamics
Entity.SetDynamicsActive( entity, false )
� Activate dynamics (collision must be enabled as well)
Entity.EnableCollision( entity )
Entity.EnableDynamics( entity )
Entity.SetDynamicsActive( entity )
See Also
� Entity.EnableDynamics
� Entity. EnableDynamicsAutoDeactivation
Entity.SetFrictionCoeff
Brief
Set the friction coefficient of the collision resource attached to the entity.
Definition
Entity.SetFrictionCoeff( Entity entity, number f )
Arguments
entity - The entity to updated - the coefficient of friction.
Return Values
None.
Description
Set the coefficient of friction for the surface of the rigid body that is attached to the entity. This affects the entity's motion relative to surfaces it
comes into contact with. Although this is actually a pair-wise coefficient, friction is specified on a per rigid body basis. When affecting the relative
motion of two surfaces, the surfaces' friction coefficients are combined to produce a coefficient for the interaction. Usual values for friction are
between 0 and 1. Values greater than 1, although physically invalid, are allowed. However, values must be less than or equal to 255.
Examples
Entity.SetFrictionCoeff( entity, 0.0 )
See Also
� Entity.EnableCollision
� Entity.EnableDynamics
� Entity. SetCollision
Entity.SetGravity
Brief
Set the gravity vector to apply to the entity.
Definition
Entity.SetGravity( Entity entity, Vector4 gravityVector )
Arguments
entity - entity to be affected.gravityVector - new gravity vector.
Return Values
None.
Description
Only the specified entity is affected by the new gravity force.
Examples
! � set gravity to half strength
j local g = Scene.GetGravity() * 0.5
j entity:SetGravity( g )
See Also
� Entity.GetGravity
Entity.SetLight
Brief
Set the entity's light.
Definition
Entity.SetLight( Entity entity, Light light = nil )
Arguments
entity - The entity to update.light - The Light to attach to the entity or nil to detach the existing light.
Return Values
None.
Description
Set the entity's light.
Examples
i entity = Entity.Create()
! Entity.SetLight( entity, light )
See Also
Entity.Create
Entity. SetLinearDamping
Brief
Sets the linear damping of the collision resource attached to the entity.
Definition
! Entity.SetLinearDamping( Entity entity, number damping )
Arguments
entity - The entity to update.damping - The linear damping to apply to the entity.
Return Values
None.
Description
Sets the linear damping of the collision resource attached to the entity. Linear damping reduces the linear velocity of the entity over time. For
example, if you set the linear damping to 0.2, then every second about 20% of the object's linear velocity will be removed. This function is only
valid if the entity has a collision item.
Examples
! Entity.SetLinearDamping( entity, 0.2 )
See Also
� Entity.EnableCollision
� Entity. EnableDynamics
� Entity.SetCollision
� Entity.GetLinearDamping
Entity.SetLinearVelocity
Brief
Sets the linear velocity of this object.
Definition
! Entity.SetLinearVelocity( Entity entity, Vector4 velocity )
Arguments
entity - The entity to update.velocity - Vector specifying linear velocity.
Return Values
None.
Description
Sets the linear velocity of the center of mass of the entity's rigid body in world space. The W component of the specified vector is ignored.
Examples
� Add the entity to the physics simulation
Entity.EnableCollision( entity, true )
Entity.EnableDynamics( entity, true )
Entity.SetLinearVelocity( entity, Vector4.Create( 0, 10, 0 ) )
See Also
� Entity.SetAngularVelocity
� Vector4.Create
Entity.SetLocalMatrix
Brief
Sets the entity's local transformation matrix.
Definition
Entity.SetLocalMatrix( Entity entity, Matrix44 matrix )
Arguments
entity - The entity to update.matrix - The matrix to set the entity's transform to.
Return Values
None.
Description
Sets the entity's local transformation matrix. The specified matrix is relative to the coordinate system of the entity's parent, if one exists. If the
entity has no parent, the matrix is relative to the world space coordinate system.
Examples
entity = Entity.Create()
matrix = Matrix44.Create()
� Set up a uniform scale matrix
Matrix44.SetScale( matrix, 2, 2, 2, 1, MATRIX_REPLACE )
Entity.SetLocalMatrix( entity, matrix )
print( mat )
See Also
� Entity.Create
� Matrix44.Create
� Matrix44.SetScale
Entity.SetMass
Brief
Sets the mass of the collision resource attached to the entity.
Definition
! Entity.SetMass( Entity entity, number mass )
Arguments
entity - The entity to update.mass - The mass of the entity's collision resource in kilograms.
Return Values
None.
Description
Sets the mass of the collision resource that is attached to the specified entity. Very large or very small masses should be avoided, as these can
create instability in the simulation. This function can only be called if the entity has a collision resource.
Examples
! Entity.SetMass( entity, 5 )
See Also
� Entity.EnableCollision
� Entity. EnableDynamics
� Entity.SetCollision
� Entity.GetMass
Entity.SetMaxContacts
Brief
Specify the maximum number of contacts to buffer for collision callbacks.
Definition
boolean Entity.SetMaxContacts(number maxContacts)
Arguments
maxContacts - maximum number of contact events to buffer
Return Values
true if sufficient memory could be allocated or false otherwise.
Description
Allocates an internal buffer to record contact events for provision via collision callbacks. Each contact event generated by PS Home for the types
for which the script has registered callbacks will be buffered in this internal buffer, until the contacts are passed to the script via the callbacks. All
entities registered for callbacks in the current script environment will share this buffer. If more contacts are generated than the buffer can store,
subsequent contacts will not be buffered and will not be available to the script, and a message indicating this will be displayed in the console.
Note that each contact currently requires 64 bytes of memory. If this function fails, there was insufficient memory available to the script to allocate
the buffer. In this case, collision callbacks will be disabled until a subsequent call to this function (with a lower maximum) succeeds. This function
is not available from within a collision callback and will generate an error.
Examples
! Entity.SetMaxContacts(128) � enough memory for 128 contact events (added/processed/removed) per
; frame
See Also
� Entity. RegisterCollisionCallback
� Entity. EnableCollisionCallbacks
� Entity.SetColiision
� Entity. EnableCollision
Entity.SetModel
Brief
Set the entity's model.
Definition
Entity.SetModel( Entity entity, string resourceName )
Entity.SetModel( Entity entity, Resource modelResource )
Arguments
entity - The entity to update.resourceName - The model's resource name or nil to remove the model.modelResource - The model resource or nil
to remove the model.
Return Values
None.
Description
Set the entity's model to the named resource as specified in the HDK's Object Editor application.
Examples
! entity = Entity.Create()
i Entity.SetModel( entity, "mymodel" )
! � Remove the model from the entity
; Entity.SetModel( entity, nil )
See Also
� Entity.Create
Entity.SetPosition
Brief
Sets the entity's position.
Definition
Entity.SetPosition( Entity entity, Vector4 position )
Arguments
entity - The entity to update.position - The new position for the entity.
Return Values
None.
Description
Sets the entity's position. If the entity has a parent, the specified position is relative to local coordinate system of the parent.
Examples
! entity = Entity.Create()
Entity.SetPosition( entity, Vector4.Create( 10, 10, 0 ) )
See Also
� Entity.Create
Entity.SetRestitutionCoeff
Brief
Sets the restitution coefficient of the collision resource attached to the entity.
Definition
! Entity.SetRestitutionCoeff( Entity entity, number r )
Arguments
entity - The entity to update.r - the coefficient of restitution.
Return Values
None.
Description
Sets the restitution (or elasticity) coefficient for the rigid body attached to the entity. This governs the effect that collisions have on the velocities of
colliding entities. Like friction, this is a pair-wise coefficient - when two physical entities collide, their restitution values are combined to produce a
coefficient for the interaction. Usual values for restitution are between 0 and 1. Values greater than 1, although physically invalid, are allowed.
However, values must be less than 1.99.
Examples
� Prevent entity from bouncing
Entity.SetRestitutionCoeff( entity, 0.0 )
See Also
Entity. EnableCollision
� Entity.EnableDynamics
� Entity.SetCollision
Entity.SetRotationQuat
Brief
Sets the rotation using the supplied quaternion.
Definition
| Entity.SetRotationQuat( Entity entity, Quaternion quat )
Arguments
entity - The entity to update.quat - The quaternion.
Return Values
None.
Description
Sets the rotation of the specified entity using the supplied quaternion.
Examples
! entity = Entity.Create()
j quat = Quaternion.Create()
| entity:SetRotationQuat(quat)
See Also
� Entity.GetRotationQuat
Entity.SetRotationX
Brief
Sets the rotation about the x-axis in degrees.
Definition
! Entity.SetRotationX( Entity entity, number rotation )
Arguments
entity - The entity to update.rotation - The specified angle of rotation about the x-axis in degrees.
Return Values
None.
Description
Sets the rotation about the x-axis of the entity's local coordinate system in degrees. The rotation order is x, y, z.
Examples
entity = Entity.Create()
Entity.SetRotationX( entity, 90.0 )
See Also
� Entity.Create
Entity.SetRotationXyz
Brief
Sets the rotation about the x, y, and z-axis in degrees.
Definition
Entity.SetRotationXyz( Entity entity, Vector4 rotation )
Arguments
entity - The entity to update.rotation - The specified x, y, and z angles of rotation in degrees.
Return Values
None.
Description
Sets the rotation about the x, y, and z-axis of the entity's local coordinate system in degrees. The rotation order is x, y, z.
Examples
! entity = Entity.Create()
i Entity.SetRotationXyz( entity, Vector4.Create( 45, 30, 90 ) )
See Also
� Entity.Create
Entity.SetRotationY
Brief
Sets the rotation about the y-axis in degrees.
Definition
! Entity.SetRotationY( Entity entity, number rotation )
Arguments
entity - The entity to update.rotation - The specified angle of rotation about the y-axis in degrees.
Return Values
None.
Description
Sets the rotation about the y-axis of the entity's local coordinate system in degrees. The rotation order is x, y, z.
Examples
: entity = Entity.Create()
i Entity.SetRotationY( entity, 90.0 )
See Also
� Entity.Create
Entity.SetRotationZ
Brief
Sets the rotation about the z-axis in degrees.
Definition
Entity.SetRotationZ( Entity entity, number rotation )
Arguments
entity - The entity to update.rotation - The specified angle of rotation about the z-axis in degrees.
Return Values
None.
Description
Sets the rotation about the z-axis of the entity's local coordinate system in degrees. The rotation order is x, y, z.
Examples
! entity = Entity.Create()
i Entity.SetRotationZ( entity, 90.0 )
See Also
� Entity.Create
Entity.SetScale
Brief
Sets the entity's scale.
Definition
Entity.SetScale( Entity entity, Vector4 scale )
Arguments
entity - The entity to update.scale - The new scale of the entity.
Return Values
None.
Description
Sets the entity's scale. The specified scale is applied to the local transformation matrix of the entity. On creation, an entity has a scale of (1,1,1)
or no scaling, in other words. Note that the W component of the specified vector is ignored. Note that scale should not be applied to entities with
collision enabled.
Examples
entity = Entity.Create()
Entity.SetScale( entity, Vector4.Create( 45, 30, 90 ) )
See Also
� Entity.Create
� Vector4. Create
Entity.SetScreen
Brief
Set the entity's screen.
Definition
Entity.SetScreen( Entity entity, Screen screen )
Arguments
entity - The entity to update.screen - The screen to attach to the entity or nil to remove it.
Return Values
None.
Description
Set the entity's screen. The screen's corner coordinates will be transformed by the entity's world transformation matrix.
Examples
j entity = Entity.Create()
i Entity.SetScreen( entity, screen )
! � Remove the screen from the entity
Entity.SetScreen( entity, nil )
See Also
Entity.Create
Entity.SetSkeleton
Brief
Set the entity's skeleton.
Definition
Entity.SetSkeleton( Entity entity, string resourceName )
Entity.SetSkeleton( Entity entity. Resource skeletonResource )
Arguments
entity - The entity to update.resourceName - The skeleton's resource name or nil to remove it.skeletonResource - Pre-loaded skeleton resource
object.
Return Values
None.
Description
Set the entity's skeleton to the named resource as specified in the HDK's Object Editor application.
Examples
! entity = Entity.Create()
i Entity.SetSkeleton( entity, "myskel" )
! � Remove the skeleton from the entity
i Entity.SetSkeleton( entity, nil )
See Also
� Entity.Create
Entity.SetVisible
Brief
Sets the entity to visible or invisible.
Definition
Entity.SetVisible( Entity entity, boolean value )
Arguments
entity - The entity to update.value - If true the entity is visible and it false it is invisible.
Return Values
None.
Description
Sets the entity to visible or invisible. Entities default to visible when created.
Examples
entity = Entity.Create()
Entity.SetVisible( entity, false )
See Also
� Entity.Create
Entity.StopAnim
Brief
Stops the current animation if it is playing.
Definition
Entity.StopAnim( Entity entity )
Entity.StopAnim( Entity entity, Animation anim )
Arguments
entity - The entity to update.anim - The animation to stop.
Return Values
None.
Description
If the Animation anim passed in is nil, or invalid, nothing is done. If an animation is specified, it will be stopped immediately with no blend out. If no
animation is specified, all animations on the entity will be stopped immediately, with no blend out.
Examples
entity = Entity.Create()
local animHandle = Animation.Create()
Entity.SetModel( entity, "mymodel" )
Entity.SetSkeleton( entity, "myskel" )
Entity.PlayAnim( entity, "mylstAnim" )
Entity. BlendAnim ( entity, "my2ndAnim ,, , true, 0, 0, animHandle )
Entity.StopAnim( entity, animHandle ) � stops specific animation
Entity.StopAnim( entity ) � stops all other animations
See Also
� Entity.Create
� Entity.PlayAnim
� Entity.SetModel
� Entity.SetSkeleton
Camera
Camera.Activate
Brief
Activates the specified camera.
Definition
! Camera.Activate( Camera camera, number transitionTime =0.0 )
Arguments
camera - The camera to activate.transitionTime - The time taken to smoothly move from the previously active camera's position, to the
specified camera's position.
Return Values
None.
Description
Activates the specified camera.
Examples
! Camera.Activate( gameCamera, 1.0 )
See Also
� Camera. Deactivate
� Camera. IsActivated
Camera. AttachToParent
Brief
Links the camera to the given entity so that the camera inherits the entity's transform.
Definition
Camera.AttachToParent( Camera camera, Entity parent )
Arguments
camera - The camera to update.parent - The entity to attach this camera to, or nil to detach the camera.
Return Values
None.
Description
Links the camera to the given entity so that the camera inherits the entity's transform. This will override any values set via Camera.SetPosition, or
Camera.SetLookAtPosition until the connection is cleared by passing in nil as the parent. If the entity is destroyed then the camera will be
unparented. It is not possible at present to specify a local transform offset from the entity.
Examples
! Camera.AttachToParent( gameCamera, myEntity ) � connect the camera to myEntity
; Camera.AttachToParent( gameCamera, nil ) � detach the camera from any connected entity
See Also
None
Camera.Create
Brief
Creates a new 3D camera.
Definition
Camera Camera.Create( string constructionMethod = nil )
Arguments
constructionMethod - How to construct the camera, either nil or "current".
Return Values
Returns a Camera instance.
Description
Creates a new 3D camera. This camera is, by default, positioned at the origin (0, 0, 0). If constructionMethod is "current" it creates a new camera
with the properties of the currently active camera.
Examples
gameCamera = Camera.Create( "current" )
Camera.SetPosition( gameCamera, Camera.GetPosition() + Vector4.Create( 0, 1, 0 ) )
See Also
� Camera.Activate
Camera. Deactivate
Brief
Deactivates the specified camera.
Definition
Camera.Deactivate( Camera camera, number transitionTime =0.0 )
Arguments
camera - The camera to deactivate.transitionTime - The time taken to smoothly move from the specified camera's position back to the
previously active camera's position.
Return Values
None.
Description
Deactivates the specified camera.
Examples
! if Camera.IsActivated( gameCamera ) then
Camera.Deactivate( gameCamera, 1.0 )
| end
See Also
� Camera.Activate
� Camera. IsActivated
Camera.EnableAvatarCameraSync
Brief
Tell the normal Avatar camera to face the same direction as a deactivating custom camera, minimizing the camera transition.
Definition
i Camera.EnableAvatarCameraSync()
Arguments
None
Return Values
Description
When enabled, the normal Avatar Camera will sync with any active custom camera to face the same direction. This simply means that when the
custom camera is deactivated, the normal Avatar Camera will be facing the same direction, and the magnitude of the transition between the two
will be minimized. This defaults to on. It�s rare, and generally not advised to disable this.
Examples
Camera.EnableAvatarCameraSync(false)
See Also
None
Camera.GetlnverseViewMatrix
Brief
Get the view to world transform for the currently active camera.
Definition
Camera.GetInverseViewMatrix(Matrix44 matrix)
Arguments
matrix - The matrix to set.
Return Values
None.
Description
Retrieves the view to world transform for the currently active camera. This can be considered as the world transform of the camera object itself.
Examples
! local invViewMat = Matrix44.Create ()
; Camera.GetlnverseViewMatrix(invViewMat)
See Also
� Camera.GetViewMatrix
� Camera.GetProjectionMatrix
Camera.GetLookAtPosition
Brief
Retrieves the camera's world space target position.
Definition
Vector4 Camera.GetLookAtPosition( Camera camera )
Camera.GetLookAtPosition( Camera camera, Vector4 outPos )
Vector4 Camera.GetLookAtPosition ()
Camera.GetLookAtPosition( Vector4 outPos )
Arguments
camera - The camera to query.outPos - (out) The vector to receive the target position.
Return Values
Returns a Vector4 specifying the world space target position of the camera.
Description
Retrieves the camera's world space target position. Only the X, Y and Z components of the Vector4 are valid. If no camera is specified it uses the
currently active camera.
Examples
! camtarget = Camera.GetLookAtPosition( gameCamera )
See Also
� Camera.SetLookAtPosition
Camera.GetPosition
Brief
Retrieves the camera's world space position.
Definition
Vector4 Camera.GetPosition( Camera camera )
Camera.GetPosition( Camera camera, Vector4 outPos )
Vector4 Camera.GetPosition()
Camera.GetPosition( Vector4 outPos )
Arguments
camera - The camera to query.outPos - (out) The vector to receive the camera position.
Return Values
A Vector4 specifying the world space position of the camera.
Description
Retrieves the camera's world space position. Only the X, Y and Z components of the Vector4 are valid. If no camera is specified it uses the
currently active camera. Note that inactive cameras are not updated, and therefore if a position is requested for an inactive camera the most
recent position available will be returned. For the currently active camera the position will match the translation of the inverse view matrix.
Examples
campos = Camera.GetPosition( gameCamera )
See Also
� Camera.SetPosition
� Camera.GetlnverseViewMatrix
Camera.GetProjectionMatrix
Brief
Get the projection matrix for the currently active camera.
Definition
Camera.GetProjectionMatrix(Matrix44 matrix)
Arguments
matrix - The matrix to set.
Return Values
None.
Description
Retrieves the projection transform for the currently active camera. A script should not assume a particular projection transform format. The
projection matrix is used to transform a point from view to clip space.
Examples
j local projMat = Matrix44.Create()
; Camera.GetProjectionMatrix(projMat)
See Also
� Camera.GetViewMatrix
� Camera.GetlnverseViewMatrix
Camera.GetViewMatrix
Brief
Get the world to view transform for the currently active camera.
Definition
Camera.GetViewMatrix(Matrix44 matrix)
Arguments
matrix - The matrix to set.
Return Values
None.
Description
This matrix will transform from world space to view space.
Examples
j local worldToViewMat = Matrix44.Create()
| Camera.GetViewMatrix(worldToViewMat)
See Also
Camera.GetlnverseViewMatrix
� Camera. GetProjectionMatrix
Camera.GetViewPortFOV
Brief
Retrieves the vertical field of view for the specified camera.
Definition
! number Camera.GetViewPortFOV( Camera camera )
i number Camera.GetViewPortFOV()
Arguments
camera - The camera to query.
Return Values
The vertical field of view for the camera, specified in degrees.
Description
Retrieves the vertical field of view (FOV) for the specified camera. If no camera is specified it uses the currently active camera.
Examples
I fov = Camera.GetViewPortFOV( gameCamera )
See Also
� Camera.SetViewPortFOV
Camera.GetViewPortZFar
Brief
Retrieves the camera's far clip plane.
Definition
number Camera.GetViewPortZFar( Camera camera )
number Camera.GetViewPortZFar()
Arguments
camera - The camera to query.
Return Values
The far clip plane of the camera in units of meters.
Description
Retrieves the camera's far clip plane. Units are specified in meters. The default far clip plane for a newly created camera is 4000.0. If no camera
is specified it uses the currently active camera.
Examples
! farz = Camera.GetViewPortZFar( gameCamera )
See Also
� Camera.SetViewPortZFar
Camera.GetViewPortZNear
Brief
Retrieves the camera's near clip plane.
Definition
! number Camera.GetViewPortZNear( Camera camera )
i number Camera.GetViewPortZNear()
Arguments
camera - The camera to query.
Return Values
The near clip plane of the camera in units of meters.
Description
Retrieves the camera's near clip plane. Units are specified in metres. The default near clip plane for a newly created camera is 0.1. If no camera
is specified it uses the currently active camera.
Examples
! nearz = Camera.GetViewPortZNear( gameCamera )
See Also
� Camera.SetViewPortZNear
Camera.IsActivated
Brief
Determines whether the specified camera is currently active.
Definition
! boolean Camera.IsActivated( Camera camera )
Arguments
camera - The camera to query.
Return Values
true if the specified camera is activated, false otherwise.
Description
Determines whether the specified camera is currently active.
Examples
1 if Camera.IsActivated( gameCamera ) then
Camera.Dectivate( gameCamera, 1.0 )
| end
See Also
� Camera.Activate
� Camera. Deactivate
Camera.SetLookAtPosition
Brief
Sets the camera's world space target position.
Definition
! Camera.SetLookAtPosition( Camera camera, Vector4 target )
Arguments
camera - The camera to update.target - Vector4 specifying the world space target position for the camera.
Return Values
None.
Description
Sets the camera's world space target position. Only the X, Y and Z components of the Vector4 are used to position the camera. The W
component is ignored.
Examples
1 Camera.SetLookAtPosition( gameCamera, Vector4.Create( 0, 10, 0, 0 ) )
See Also
� Camera.GetLookAtPosition
Camera.SetPosition
Brief
Sets the camera's world space position.
Definition
! Camera.SetPosition( Camera camera, Vector4 position )
Arguments
camera - The camera to update.position - Vector4 specifying the world space position of the camera.
Return Values
None.
Description
Sets the camera's world space position. Only the X, Y and Z components of the Vector4 are used to position the camera. The W component is
ignored.
Examples
! Camera.SetPosition( gameCamera, Vector4.Create( 0, 10, 0, 0 ) )
See Also
� Camera.GetPosition
Camera.SetViewPortAspect
Brief
Sets the aspect ratio for the specified camera's viewport.
Definition
! Camera.SetViewPortAspect( Camera camera, number aspect )
Arguments
camera - The camera to update.aspect - aspect ratio for the camera's viewport (width / height).
Return Values
None.
Description
Sets the aspect ratio for the specified camera's viewport.
Examples
! Camera.SetViewPortAspect( gameCamera, 16.0 / 9.0 )
See Also
Camera.SetViewPortFOV
Brief
Sets the vertical field of view of the specified camera.
Definition
! Camera.SetViewPortFOV( Camera camera, number fov )
Arguments
camera - The camera to update.fov - Vertical field of view for the camera, specified in degrees.
Return Values
None.
Description
Sets the vertical field of view of the specified camera in degrees.
Examples
! Camera.SetViewPortFOV( gameCamera, 60.0 )
See Also
� Camera.GetViewPortFOV
Camera.SetViewPortZFar
Brief
Sets the camera's far clip plane.
Definition
! Camera.SetViewPortZFar( Camera camera, number zfar )
Arguments
camera - The camera to update.znear - The far clip plane of the camera in units of metres.
Return Values
None.
Description
Sets the camera's far clip plane. Units are specified in metres. The default far clip plane for a newly created camera is 4000.0.
Examples
! Camera.SetViewPortZFar( gameCamera, 5000.0 )
See Also
� Camera.GetViewPortZFar
Camera.SetViewPortZNear
Brief
Sets the camera's near clip plane.
Definition
! Camera.SetViewPortZNear( Camera camera, number znear )
Arguments
camera - The camera to update.znear - The near clip plane of the camera in units of meters.
Return Values
None.
Description
Sets the camera's near clip plane. Units are specified in metres. The default near clip plane for a newly created camera is 0.1. The minimum
value that the function will accept is 0.001.
Examples
! Camera.SetViewPortZNear( gameCamera, 0.2 )
See Also
� Camera.GetViewPortZNear
Person
Person. AttachToEntity
Brief
Attaches the person to specified entity so when the entity moves around the person moves with it.
Definition
Person.AttachToEntity( Person person, Entity entity = nil, Matrix44 localTransform = nil )
Arguments
entity - the entity to attach to or nil to detach player from current entity.
Return Values
None.
Description
When attached to an entity, setting position and rotation will affect the local transform only. The transform must be locked by the calling lua
environment otherwise a lua error is generated. If the person is unlocked it automatically detaches from the entity.
Examples
person = LocalPlayer.GetPerson ()
car = Entity.Create ()
Person.AttachToEntity( person, car )
See Also
None
Person. DoAction
Brief
Plays an action on a Person
Definition
Person.DoAction( Person person, string actionName, boolean autoUnlock = false )
Person.DoAction( Person person, string actionName, boolean autoUnlock, number unlockFeatures )
Arguments
person - the person to play an action on.actionName - Name of the action to be performed. It can be a custom animation loaded remotely through
LocalPlayer.AddRepertoire as well as one of the following standard actions:
"agree�
"beckon"
"bow"
"cheer"
"clap"
"disagree"
"frustration"
"laugh"
"point"
"wave"
"stand_up_from_seat"autoUnlock - if true, then the animation lock on the person is automatically released after the action has completed.
Defaults to false.unlockFeatures - only used if the autoUnlock parameter is true. If omitted then defaults to releasing the locks that were set when
Person.DoAction was called, otherwise will only release the locks specified,
features specified.
Return Values
Returns true if the action succeeds.
Description
The animation must be locked by the calling lua environment otherwise a lua error is generated. If the action isn't recognized a lua error is
generated. If it fails and autollnlock is true it unlocks immediately.
Examples
if Person.HasLock ( person ) then
Person.DoAction( person, "clap" )
end
See Also
� Person.Lock
� Person.Unlock
� Person.IsLocked
� Person.HasLock
� Person.SetBehavior
� Person.DoActionBroadcast
Person.DoActionBroadcast
Brief
Piays an action on a Person
Definition
Person.DoActionBroadcast( Person person, string actionName, boolean autoUnlock = false )
Person.DoActionBroadcast( Person person, string actionName, boolean autoUnlock, number unlockFeatures
)
Arguments
person - the person to play an action on.actionName - Name of the action to be performed. It can be a custom animation loaded remotely through
LocalPlayer.AddRepertoire as well as one of the following standard actions:
"agree�
"beckon"
"bow�
"cheer"
"clap"
"disagree"
"frustration"
"laugh"
"point"
"wave"
"stand_up_from_seat"autoUnlock - if true, then the animation lock on the person is automatically released after the action has completed.
Defaults to false.unlockFeatures - only used if the autoUnlock parameter is true. If omitted then defaults to releasing the locks that were set when
Person.DoActionBroadcast was called, otherwise will only release the locks specified,
features specified.
Return Values
Returns true if the action succeeds.
Description
The animation must be locked by the calling lua environment otherwise a lua error is generated. If the action isn't recognized a lua error is
generated. If it fails and autoUnlock is true it unlocks immediately. If calling DoActionBroadcast on the LocalPlayer, this function will broadcast the
action to other clients in the scene. Using DoActionBroadcast impacts on the amount of network traffic, so avoid calling this function frequently.
Examples
if Person.HasLock( person ) then
Person.DoActionBroadcast( person, "clap" )
end
See Also
� Person.Lock
� Person.Unlock
� Person. IsLocked
� Person.HasLock
� Person.SetBehavior
� Person.DoAction
Person.EnableChatBubbles
Brief
Sets chat bubbles on or off.
Definition
! Person.EnableChatBubbles( Person person, boolean enabled )
Arguments
enabled - True to enable chat bubbles or false to disable.
Return Values
None.
Description
With this function, a script can allow chat bubbles to be switched on or off at will. Chat will still appear in the chat log as normal. Please note: In
order to use this function, the is_allowed_chat_bubble_change property in the object's mini_game component must be set to true.
Examples
local person = LocalPlayer.GetPerson( );
if ( Person.Lock( person, PersonLockType.ChatBubbles ) == true ) then
Person.EnableChatBubbles( person, false );
end
See Also
� Person.Lock
� Person.Unlock
Person.EnableCollision
Brief
Toggles collision detection for the person's avatar.
Definition
! Person.EnableCollision( Person person, boolean value )
Arguments
person - the person to modify.value - Whether collision should be on or off.
Return Values
None.
Description
Toggles collision detection for the person's avatar. The collision must be locked by the calling lua environment otherwise a lua error is generated.
Examples
! if Person.IsCollision ( person ) then
Person.EnableCollision( person, false )
| end
See Also
� Person.IsCollision
Person.Findlnlnstance
Brief
Finds a person in the instance from the person ID.
Definition
! Person Person.Findlnlnstance( string personld )
Arguments
personld - The person to find.
Return Values
A Person if found and nil otherwise.
Description
Finds a person in the instance from the specified person ID.
Examples
me = Person.Findlnlnstance( LocalPlayer.GetPersonld() )
See Also
Local Player.GetPersonld
Person. GetAnimReg
Brief
Returns the value of the specified animation register.
Definition
number|boolean|string Person.GetAnimReg(Person person, string registerName)
Arguments
person - person to query.registerName - the name of the animation register to get.
Return Values
The value of the register, with the type based on the register type.
Description
If the register doesn't exist or the animation register doesn't have Lua read access an error will be thrown.
Examples
! fatness = person:GetAnimReg("Fatness")
See Also
� Person. SetAnimReg
Person.GetAvatarStatusType
Brief
Returns the current avatar status type of the person specified
Definition
number Person.GetAvatarStatusId( Person person )
Arguments
person - The person to query.
Return Values
The enumerated value of the current status type.
Description
The user can change the status of their avatar from the emotes menu. This method returns the current user status type. Changing the status type
affects the facial animation (mood) used, and the status text above the avatar that remote users see. The possible status types are:
AvatarStatusType.Neutral
AvatarStatusT ype. Happy
AvatarStatusType.Sad
AvatarStatusType. Angry
AvatarStatusType.Confused
AvatarStatusType. Unwell
AvatarStatusType.Busy
AvatarStatusType. IsLookingForHelp
AvatarStatusT ype. WantT oChat
AvatarStatusType. WantToPlayGame
Examples
me = LocalPlayer.GetPerson()
if Person.GetAvatarStatusType( me ) == AvatarStatusType.Happy then
DoSomethingHappy()
end
See Also
� Person.GetMood
Person.GetBehavior
Brief
Returns the name of the current behavior playing on the person.
Definition
string Person.GetBehavior( Person person )
Arguments
person - The person to query.
Return Values
The name of the current behavior playing on the person.
Description
Returns the name of the current behavior playing on the person or nil if the behavior is a Plome internal behavior. For a list of Home's public
behaviors see Person.SetBehavior. For post 1.40 behaviour, if the behaviour belongs to the calling script environment, will only specify the name.
If the behaviour belongs to another object, that has allowed its behaviours to be public, then will specify the object id, as well as the name. For
pre-1.40 behaviour. For the local player, will only return the name of the behaviour, but for remote persons, will return the fully qualified name
(objectld:name) - this is for backwards compatibility. If the behaviour is a system public behaviour, will return the name only.
Examples
behaviorName = Person.GetBehavior( person )
See Also
� Person.SetBehavior
Person. GetBehaviorCategory
Brief
Returns the specified person's behavior state.
Definition
string|nil Person.GetBehaviorCategory( Person person )
Arguments
person - The person to update.
Return Values
Returns the specified person's behavior state.
Description
Returns nil if in an internal behavior or be one of the following: "dancing'' "posing" �sitting_on_floor" "sitting_on_seat" "standing" "moving"
Behaviors should be catagorized into one of the above states. This function can be used to check if a person is dancing etc. without checking the
animation behavior name.
Examples
! if Person.GetBehaviorCategory( LocalPlayer.GetPerson() ) == 'dancing* then
StartTheParty()
| end
See Also
� Person.GetBehavior
� Person.SetBehavior
Person. GetBoneCount
Brief
Get the number of bones in the person's skeleton.
Definition
! number Person.GetBoneCount(Person person)
Arguments
person - Person to query.
Return Values
Number of bones in the skeleton, or 0 if the skeleton is not available.
Description
Retrieves the number of bones/joints in the person's skeleton. If no skeleton is present or loaded, 0 is returned.
Examples
! local boneCount = LocalPlayer.GetPerson():GetBoneCount()
See Also
Person.GetBonelndex
Person.GetBonelndex
Brief
Find the index of a bone in the person's skeleton.
Definition
! number Person.GetBonelndex(Person person, string boneName)
Arguments
person - Person to query.boneName - Name of bone to locate.
Return Values
The index of the bone in the skeleton (in range 1 - GetBoneCount()), or 0 if not found.
Description
Retrieves the index of the specified bone/joint in the person's skeleton. The index is 1 -based. If the bone cannot be found, or there is no skeleton
attached or loaded, 0 is returned.
Examples
1 local leftHandlndex = LocalPlayer.GetPerson():GetBonelndex("lefthand")
See Also
� Person.GetBoneCount
� Person.GetBoneLocalMatrix
� Person.GetBoneWorldMatrix
Person.GetBoneLocalMatrix
Brief
Get the local transform matrix for a bone in the skeleton.
Definition
! Person.GetBoneLocalMatrix(Person person, string|number bone, Matrix44 result)
Arguments
person - Person to query.bone - Bone name or index.result (out) - Matrix44 value to store result into.
Return Values
None.
Description
Retrieve the local-space transform matrix for a specified bone in the skeleton. If the bone is not found an error will result. Retrieving the matrix by
index will be more efficient if done more than once.
Examples
local mat = Matrix44.Create ()
LocalPlayer.GetPerson():GetBoneLocalMatrix("lefthand", mat)
� or
local leftHandlndex = LocalPlayer.GetPerson():GetBonelndex("lefthand")
LocalPlayer.GetPerson():GetBoneLocalMatrix(leftHandlndex, mat)
See Also
� Person. GetBoneWorldMatrix
� Person.GetBonelndex
Person.GetBoneWorldMatrix
Brief
Get the world transform matrix for a bone in the skeleton.
Definition
Person.GetBoneWorldMatrix(Person person, string|number bone, Matrix44 result)
Arguments
person - Person to query.bone - Bone name or index.result (out) - Matrix44 value to store result into.
Return Values
None.
Description
Retrieve the world-space transform matrix for a specified bone in the skeleton. If the bone is not found an error will result. Retrieving the matrix by
index will be more efficient if done more than once.
Examples
local mat = Matrix44.Create ()
LocalPlayer.GetPerson():GetBoneWorldMatrix("lefthand", mat)
� or
local leftHandlndex = LocalPlayer.GetPerson():GetBonelndex("lefthand")
LocalPlayer.GetPerson():GetBoneWorldMatrix(leftHandlndex, mat)
See Also
� Person.GetBoneLocalMatrix
� Person.GetBonelndex
Person.GetCurrentAction
Brief
Returns the name of the current action the person is in, if any.
Definition
! string Person.GetCurrentAction( Person person )
Arguments
person - The person to query.
Return Values
Returns the name of the current action.
Description
If the person is not in an action nil is returned. Home internal actions will also return nil. For a list of Home public actions see Person.DoAction.
Examples
I actionName = Person.GetCurrentAction( LocalPlayer.GetPerson() )
See Also
� Local Player. DoAction
� LocalPlayer.IsDoingAction
Person. GetGroundllserld
Brief
Return the userlD of the collision on which the person is standing.
Definition
! number Person.GetGroundUserld( Person person )
Arguments
person - The person to query
Return Values
The userlD.
Description
Return the userlD of the collision on which the person is standing. Check Person.IsOnGround before calling this function; if the person is not on
the ground an error will occur.
Examples
! if ( person:IsOnGround() ) then
print( Person.GetGroundUserld( person ) )
| end
See Also
� Person.IsOnGround
Person.GetHeight
Brief
Retrieve the avatar's height in meters.
Definition
! number Person.GetHeight(Person person)
Arguments
person - the person to query.
Return Values
The height of the person's avatar in meters, or nil if the avatar is not yet loaded.
Description
The value returned is the height of the avatar when in the bind pose, given the current height settings, in meters. This will return nil if the avatar is
currently a fallback.
Examples
! if ( person:GetHeight() <1.0 ) then print ("Hello shorty") end
See Also
None
Person.Getld
Brief
Returns the person's ID.
Definition
j string Person.GetId( Person person )
Arguments
person - The person to query.
Return Values
The person's ID.
Description
Returns the person's ID. A person's ID value is unique per instance, but not across instances and is not persistent. That is, a person ID can be
used within an instance to uniquely identify any person in that instance, but it should be assumed to be assigned at random to players entering
the instance, and only valid while that player is in the instance. Players in another instance of the same scene will not be accessible by person ID.
Players exiting and re-entering the instance will almost certainly be assigned a different person ID, but a person's ID will not change while they
remain in the same instance.
Examples
me = LocalPlayer.GetPerson()
if Person.GetId( me ) ~= LocalPlayer.GetPersonld() then
print( "Oh no!" )
end
See Also
� LocalPlayer.GetPerson
� LocalPlayer.GetPersonld
Person.GetldsOfFriendsInlnstance
Brief
Returns a table of people IDs in the current instance that are friends.
Definition
string[] Person.GetldsOfFriendsInlnstance()
Arguments
None
Return Values
A table of person ID strings.
Description
Returns a table of person IDs in the current instance that are friends.
Examples
! ids = Person.GetIdsOfFriendsInlnstance()
; numFriends = #ids
j print( "There are " .. numFriends .. " friends in the instance." )
See Also
None
Person. GetldsOfRemotePeoplelnlnstance
Brief
Returns a table of all remote person IDs in the current instance.
Definition
string[] Person.GetldsOfRemotePeoplelnlnstance()
Arguments
None
Return Values
A table of person ID strings.
Description
Returns a table of person IDs for all remote avatars in the current instance.
Examples
! ids = Person.GetIdsOfRemotePeoplelnlnstance()
i numAvatars = #ids + 1
I print( "There are " .. numAvatars .. " avatars in the instance." )
See Also
None
Person.GetlnstanceSessionMasterld
Brief
Returns the current instance's session master Person ID.
Definition
string Person.GetlnstanceSessionMasterld()
Arguments
None
Return Values
A person ID of the session master or nil if not ready yet.
Description
Returns the current instance's session master Person ID. Each instance has a session master automatically assigned to it. When a new instance
is created the first person in that instance will be the session master and if they leave then a new session master is chosen if other users are in
the instance.
Examples
local sessionMasterld = Person.GetInstanceSessionMasterld()
local sessionMaster = nil
if sessionMasterld ~= nil then
sessionMaster = Person.Findlnlnstance( sessionMasterld )
SendNetworkMessageToRequestlnstanceState( sessionMaster )
end
See Also
� User.GetSceneOwner
Person. GetlnventoryltemObjectld
Brief
Obtain the object id of the currently deployed companion object.
Definition
! string Person.GetInventoryltemObjectId(Person person)
Arguments
person - The person to query.
Return Values
The object ID of the deployed inventory item if present, and nil otherwise.
Description
Obtains the object id of the currently deployed companion object, or returns nil if one is not currently active.
Examples
if (Person.GetlnventoryltemObjectld(person) == "12345678-12345678-12345678-12345678") then
isAllowedlntoMiniGame = true
| end
See Also
None
Person.GetLocalBounds
Brief
Retrieve the local-space bounds of a person.
Definition
! boolean Person.GetLocalBounds(Person person, Vector4 min, Vector4 max)
Arguments
person - The person to query.min (out) - Vector4 value to receive the minimum extent.max (out) - Vector4 value to receive the maximum extent.
Return Values
True if the bounds were retrieved successfully, false if the person is not yet loaded.
Description
Get the local-space bounds of a person's model. This will reflect the user's clothing choices and height selection. If the person's avatar is not
loaded, this function will return false.
Examples
local min = Vector4.Create ()
local max = Vector4.Create()
if (LocalPlayer.GetPerson():GetLocalBounds(min, max)) then
print("Local player avatar is", max:Y() - min:Y(), "metres tall")
end
See Also
� Person.GetWorldBounds
Person. GetMood
Brief
Returns the mood of the specified person.
Definition
MoodType Person.GetMood(Person person)
Arguments
person - the person to interrogate the mood value for.
Return Values
The enumerated value of the mood.
Description
The mood type is the facial animation that is used on the idling person. This is controlled by the user through the status option in the emotes
menu. Different statuses can share the same mood, ie Confused and IsLookingForHelp statuses both use the same mood Confused. The
enumerated type of MoodType is:
MoodType.Neutral
MoodType.Happy
MoodType.Sad
MoodType.Angry
MoodType.Confused
Examples
if (person:GetMood() == MoodType.Sad) then
print("Why the long face?")
end
See Also
� Person. GetAvatarStatusType
Person. GetName
Brief
Returns the person's Online ID.
Definition
string Person.GetName( Person person )
Arguments
person - The person to query.
Return Values
The person's Online ID.
Description
Returns the person's Online ID, but only if you launch HomeDeveloper.self in online mode. If launching in offline mode, only the local player's
Person will be accessible, and the function will return the string "Me".
Examples
! me = LocalPlayer.GetPerson()
i print( "My name is " .. Person.GetName( me ) )
See Also
� LocalPlayer.GetPerson
Person.GetPosition
Brief
Returns the position of the person.
Definition
Vector4 Person.GetPosition( Person person )
Person.GetPosition( Person person, Vector4 outVec )
Arguments
person - The person to query.outVec - The Vector4 to store the result to.
Return Values
The position of the person.
Description
Returns a vector containing the position of the specified person.
Examples
! me = LocalPlayer.GetPerson()
print( "I am at: ", Person.GetPosition( me ) )
See Also
Local Player.GetPerson
Person.GetRigComponentObjectld
Brief
Returns the specified component type's object ID.
Definition
! string Person.GetRigComponentObjectId( Person person, string componentType )
Arguments
person - The person to query.componentType - The component type to search for. It is case sensitive.
Return Values
The component's object ID or nil if not found.
Description
Returns the specified component type's object ID. The component must be loaded to identity its type.
Examples
! me = LocalPlayer.GetPerson()
i types = Person.GetRigComponentTypes( person )
| print( 'type=* .. types[ 1 ] ' object id=' .. Person.GetRigComponentObjectId( person, types[ 1 ] )
)
See Also
� Person.GetRigComponentTypes
Person.GetRigComponentTypes
Brief
Returns a table of strings for the current rig's component types.
Definition
! string[] Person.GetRigComponentTypes( Person person )
Arguments
person - The person to query.
Return Values
Table of strings for the rig component types.
Description
Returns a table of strings for the current rig's component types. The rig must be loaded to obtain the information.
Examples
me = LocalPlayer.GetPerson()
rigCompTypes = Person.GetRigComponentTypes( me )
if rigCompTypes ~= nil then
for index, item in ipairs( rigCompTypes ) do
print( 'type = ' .. item )
end
end
See Also
� Person.GetRigComponentObjectld
Person.GetRigField
Brief
Returns the value of the field and nil if not found
Definition
string|number|boolean Person.GetRigField( Person person, string field )
Arguments
person - The person to query.field - The field to retrieve. Can be one of the following:
"sex" (returns the string "male" or "female")
Return Values
The value of the field and nil if not found. Supported types are boolean, string and number.
Description
Returns the value of the field and nil if not found. The rig must be loaded to get the correct result.
Examples
me = LocalPlayer.GetPerson()
| print( "My gender is " .. Person.GetRigField( me, "sex" ) )
See Also
� LocalPlayer.GetPerson
Person. GetRotationY
Brief
Returns the y-axis rotation of the person.
Definition
number Person.GetRotationY( Person person )
Arguments
person - The person to query.
Return Values
The rotation in the y-axis of the person in degrees.
Description
Returns the rotation in the y-axis of the specified person in degrees.
Examples
i me = LocalPlayer.GetPerson()
! print( "My rotation is: " .. Person.GetRotationY( me ) )
See Also
� LocalPlayer.GetPerson
Person.GetUser
Brief
Returns the User object for this person.
Definition
User Person.GetUser( Person person )
Arguments
person - The person to query.
Return Values
The User object for the specified person.
Description
Returns the User object attached to the specified person.
Examples
local user = person:GetUser()
print(person:GetName() .. (user:IsFriend() and " is " or " is not ") .. "your friend!")
See Also
Person.GetVelocity
Brief
Returns the current velocity of the person.
Definition
Vector4 GetVelocity( Person person )
locity( Person person, Vector4 outVec )
Arguments
person - the person to queryoutVec - The Vector4 to store the result in
Return Values
Returns the current velocity of the person specified if no outVec is supplied.
Description
Returns a vector containing the velocity of the person specified.
Examples
1 local me = LocalPlayer.GetPerson()
i elocity is: ", Person.GetVelocity( me ) )
See Also
None
Person.GetWidth
Brief
Retrieves the width factor of an avatar.
Definition
! number Person.GetWidth(Person person)
Arguments
person - the person to query.
Return Values
The width factor of the person in the range [ -1, 1 ], or nil if the avatar isn't yet loaded and available.
Description
Return the width factor of the avatar, which is in the range -1 to 1, with -1 being thin, 0 being average, and 1 being fat.
Examples
1 if ( Person.GetWidth() == 1) then BreakChair() end
See Also
None
Person.GetWorldBounds
Brief
Retrieve the world-space bounds of a person.
Definition
boolean Person.GetWorldBounds(Person person, Vector4 min, Vector4 max)
Arguments
person - The person to query.min (out) - Vector4 value to receive the minimum extent.max (out) - Vector4 value to receive the maximum extent.
Return Values
True if the bounds were retrieved successfully, false if the person is not yet loaded.
Description
Get the world-space bounds of a person's model. This will reflect the user's clothing choices and height selection. If the person's avatar is not
loaded, this function will return false.
Examples
local min = Vector4.Create ()
local max = Vector4.Create ()
if (LocalPlayer.GetPerson():GetWorldBounds(min, max)) then
print("Local player avatar is", max:Y() - min:Y(), "metres tall")
end
See Also
� Person.GetLocalBounds
Person.HasLock
Brief
true if the person is locked by the calling Lua environment and false otherwise.
Definition
boolean Person.HasLock( Person person )
boolean Person.HasLock( Person person , number lockFeatures, boolean any = false )
Arguments
person - the person to query.lockFeatures - specific lock features to test to see if they are locked by this lua environmentany - if lockFeatures is
specified, then this parameter is used to indicate that if any of the features specified are locked, then return true
otherwise will only return true if all the features specified are locked.
Return Values
true if the person is locked by the calling Lua environment and false otherwise.
Description
true if the person is locked by the calling Lua environment and false otherwise.
Examples
if Person.HasLock( person ) == true then
Person.DoAction( person, "Clap" )
end
See Also
� Person.Lock
� Person.Unlock
� Person.IsLocked
� Person.DoAction
� Person.SetBehavior
Person.InterpolatePosition
Brief
Allows the client to interpolate the position of the person in the frames between successive calls to InterpolatePosition.
Definition
! Person.InterpolatePosition( Person person, Vector4 position, Vector4 velocity, number facingAngle,
i number timeOffset = 0)
Arguments
person - the person to interpolate the position onposition - the position to use for the interpolationvelocity - the velocity to use for the
interpolationfacinqAnqle - the anqle the person is facinqtimeOffset - the difference in time between the session clocks (in seconds) - if omitted
then defaults to 0.0
Return Values
None.
Description
The calling lua environment must have atleast a Transform lock on the person for the call to succeed This call will only work on NPC persons (will
throw a Lua error for the the local player person).
Examples
person:InterpolatePosition( recvdPos, recvdVel, recvdAngle, timeOffset )
See Also
� Person.Lock
� Person.GetPosition
� Person.GetVelocity
Person.IsCollision
Brief
Reports whether the person's collision is enabled.
Definition
boolean Person.IsCollision( Person person )
Arguments
person - the person to query.
Return Values
true if collision for the player is on and false otherwise.
Description
Reports whether the person's collision is enabled.
Examples
! if Person.IsCollision( person ) then
Person.EnableCollision( person, false )
| end
See Also
� Person.EnableCollision
Person.IsLoaded
Brief
Indicates when a person's avatar is fully loaded and visible.
Definition
boolean Person.IsLoaded(Person person)
Arguments
person - The person to query.
Return Values
True if the person's avatar is fully loaded and ready, or false if still loading or invalid.
Description
When a person initially enters the scene, their avatar and associated components may still be loading in the background. Some functionality such
as locking is not available until the avatar is ready, so this function can be used to query the loading state of the person. If the person object is
invalid, this function will return false.
Examples
if (person:IsValid() and person:IsLoaded()) then
if (not person:Lock(PersonLockType.All)) then
print("Unable to get lock!")
end
end
See Also
� Person.IsValid
Person.IsLocked
Brief
true if the person is locked by any lua environment and false otherwise.
Definition
! boolean Person.IsLocked(Person person)
Arguments
person - the person to query.
Return Values
true if the person is locked by any lua environment and false otherwise.
Description
true if the person is locked by any lua environment and false otherwise.
Examples
if Person.IsLocked( person ) == true and Person.HasLock( person ) == false then
print( �Waiting to get the lock' )
| end
See Also
� Person.Lock
� Person.Unlock
� Person.HasLock
� Person.DoAction
� Person.SetBehavior
Person. IsOnGround
Brief
Return whether the person is on the ground or not.
Definition
! boolean Person.IsOnGround( Person person )
Arguments
person - The person to query
Return Values
true if on the ground, false otherwise.
Description
Return whether the person is on the ground or not.
Examples
! print( Person.IsOnGround( person ) );
See Also
� Person.GetGroundllserld
Person.IsRigUsingComponent
Brief
Returns true if the specified object is being used and false otherwise.
Definition
boolean Person.IsRigUsingComponent( Person person, string objectld )
Arguments
person - The person to query.objectld - The object ID to test for its usage.
Return Values
true if the specified object is being used and false otherwise.
Description
Returns true if the specified object is being used and false otherwise. Does not require the specified object have have completed its loading for
the function to succeed.
Examples
me = LocalPlayer.GetPerson()
smartJacketId = "853B950D-ACF84EE7-920D819B-5A9A6C16"
if Person.IsRigUsingComponent( me, smartJacketld ) then
accessGranted = true
end
See Also
� LocalPlayer.GetPerson
Person.IsValid
Brief
Returns whether the handle to the person is valid or not.
Definition
boolean Person.IsValid( Person person )
Arguments
person - The person to query.
Return Values
Returns whether the handle to the person is valid or not.
Description
Returns whether the handle to the person is valid or not. Invalid persons can be caused if the person leaves the scene while you still have a
handle to that person.
Examples
if Person.IsValid( randomPerson ) == false then
person = GetAnotherPerson()
| end
See Also
� Person.Findlnlnstance
� Person. IsLoaded
Person.IsVisible
Brief
Return whether the person is visible or not to the user.
Definition
boolean Person.IsVisible( Person person )
Arguments
None
Return Values
Return whether the person is visible or not
Description
If a user can see a Person in game this will return true, otherwise false. No lock is required since you are only querying the value.
Examples
Person.SetVisibile( person, true );
print( Person.IsVisible( person ) );
See Also
� Person.Lock
� Person.Unlock
Person.Lock
Brief
Locks a combination of the person's animation, collision state, transform, label or chatbubbles so it can be controlled by script rather than network
messages or pad input.
Definition
boolean Person.Lock( Person person, number lockType = nil )
Arguments
person - the person to query.lockType - Can be one of the following or nil:
PersonLockType. Animation
PersonLockType.Transform
PersonLockType.Collision
PersonLockType. Visibility
PersonLockType. Label
PersonLockType.ChatBubbles
PersonLockType. EmoteMenu
PersonLockType. Wardrobe
PersonLockType.Default = PersonLockType.Animation + PersonLockType.Transform + PersonLockType.Collision + PersonLockType.Visibility
PersonLockType.All - all the lock types together
If lockType is nil then PersonLockType.Default is used.
Return Values
True if the Lua environment was able to obtain the lock (or already has the lock) on the person, otherwise false.
Description
A Lua error is generated if the lockType passed in aren't one of the possible values above. Lua errors are also generated if
PersonLockType.Label or PersonLockType.ChatBubbles is used when not in a minigame which supports it. A lock can only be obtained for
people currently joined to the active game, and will be released automatically for all people when the local player quits the game. A script should
not rely on this automatic behaviour however, and locks should be explicitly released as soon as they are no longer required. *NB To prevent a
delay in character loading causing scripts to fail, always ensure that calls to Person.Lock() return true before using any functions which require a
locked character. If the function returns false, wait for a short period and then attempt to lock the character again. This can be performed in a
co-routine if necessary. 1.55 Added PersonLockType.Wardrobe. This lock type can only be used on the Local Player person, otherwise a Lua
error is thrown.
Examples
� Example 1, locking specific types.
Person.Lock( person, PersonLockType.Transform ) � Locked the transform
Person.Lock( person, PersonLockType.Collision ) � Unlocked the transform and now locked the collision
Person.Lock( person, PersonLockType.Collision + PersonLockType.Visibility ) � Now additionally locked
the visibility
� Example 2, locking transform, collision, animation and visibility,
if Person.Lock ( person ) then
Person.DoAction( person, "clap" )
end
See Also
� Person.Unlock
� Person.IsLocked
� Person.HasLock
� Person.DoAction
� Person.SetBehavior
Person.ResetCurrentStatusText
Brief
Reset the status text to show in the over-head person label.
Definition
| Person.ResetCurrentStatusText( Person person )
Arguments
person - The person to update.
Return Values
None.
Description
Reset the status text to show in the over-head person label.
Examples
me = LocalPlayer.GetPerson()
j Person.ResetCurrentStatusText( me )
See Also
� LocalPlayer.GetPerson
Person.SetAnimReg
Brief
Sets the value of the specified animation register for the specified person.
Definition
! Person.SetAnimReg(Person person, string registerName, number|boolean|string value)
Arguments
person - person to set the animation register for.registerName - the name of the animation register to set.value - the value to set the register (the
type should agree with the register type).
Return Values
None.
Description
If the register doesn't exist or does not have Lua write access, or the value type and the register type don't match, then an error will be thrown.
Examples
person:SetAnimReg("myReg", 0.3)
See Also
� Person. GetAnimReg
Person.SetBehavior
Brief
Sets the current behavior of the person
Definition
Person.SetBehavior( Person person, string behaviorName, number unlockPeriodSeconds = 0, boolean
snapAnimation = false )
Person.SetBehavior( Person person, string behaviorName, number unlockPeriodSeconds, boolean
snapAnimation, number unlockFeatures )
Arguments
person - The Person to set the behavior onbehaviorName - The name of the behavior.unlockPeriodSeconds - if great than 0 then the animation
lock on the person is automatically released after
the period specified has elapsed. Defaults to 0.snapAnimation - if true, then removes blend from previous action/behavior (defaults
false)unlockFeatures - only used if the unlockPeriodSeconds parameter is greater than 0. If omitted then defaults to releasing the locks that were
set when
Person.SetBehavior was called, otherwise will only release the locks specified.
Return Values
Error code. BehaviorError.None if everything was fine, BehaviorError.Invalid if the behavior cannot be set, BehaviorError.NotReady if the person
is not ready for setting the behavior
Description
The following behaviors Home behaviors are available for use:
sitjow
sit_mid
sit_high
sit_low_recline
sit_mid_recline
standing
Additionally, any behaviors defined by the developer within an objects repertoire are available for use by the developer. The animation must be
locked by the calling lua environment otherwise a lua error is generated. If the behavior specified isn't recognised, then a lua error is thrown.
Examples
if Person.HasLock ( person ) == true then
Person.SetBehavior( person, "sit_mid" )
end
See Also
� Person.Lock
� Person.Unlock
� Person. IsLocked
Person.HasLock
� Person.DoAction
Person.SetCurrentStatusText
Brief
Set the status text to show in the over-head person label.
Definition
Person.SetCurrentStatusText( Person person, string text, bool persist = false )
Arguments
person - The person to update.text - The status text to show in the over-head person label.persist - boolean which determines whether the text is
displayed in picture captures.
Return Values
None.
Description
Set the status text to show in the over-head person label. The status text is used to indicate an activity that the user is currently partaking in. This
function must not be used without first obtaining permission from your RHQ.
Examples
! me = LocalPlayer.GetPerson()
i Person.SetCurrentStatusText( me,
"Racing!" )
See Also
None
Person.SetLabelText
Brief
Change the current text label displayed atop the avatar.
Definition
Person.SetLabelText( Person person, enumeration setting )
Arguments
setting - the current setting to use for player labels.
PersonLabelText.On
PersonLabelText.Off
PersonLabelText.Name
Return Values
None.
Description
With this function, a script can set the labels above a person to show full labels, just the name, or even switch them off. Please note: In order to
use this function, the is_allowed_label_change property in the object's mini_game component must be set to true.
Examples
local person = LocalPlayer.GetPerson( );
if ( Person.Lock( person, PersonLockType.Label ) == true ) then
Person.SetLabelText( person, PersonLabelText.Off );
end
See Also
� Person.Lock
� Person.Unlock
Person.SetPosition
Brief
Sets the position of the the person, assuming the calling Lua environment owns the lock (with transformation attribute)
Definition
SetPosition( Person person, Vector4 position )
Arguments
position - the desired world position of the person
Return Values
None.
Description
The transform must be locked by the calling lua environment otherwise a lua error is generated.
Examples
! Person.SetPosition( person, pos )
See Also
� Person.Lock
� Person.Unlock
Person.SetRotationY
Brief
Sets the rotation in the (world) Y axis of the person.
Definition
Person.SetRotationY( Person person, number angle)
Arguments
person - The Person to set.angle - The world angle in degrees.
Return Values
None.
Description
The transform must be locked by the calling lua environment otherwise a lua error is generated.
Examples
I Person.SetRotationY( person, 180 )
See Also
� Person.Lock
� Person.Unlock
Person.SetVisible
Brief
Sets the visibility of the the person.
Definition
! Person.SetVisible( Person person, boolean enable )
Arguments
enable - whether to switch visibility on or off for that person
Return Values
None.
Description
Sets the visibility of the the person. The visibility must be locked with visibility attribute PersonLockType.Visibility by the calling lua environment
otherwise a lua error is generated. If the person is not valid the call is ignored.
Examples
I Person.SetVisible( person, false )
See Also
� Person.Lock
� Person.Unlock
� Person.IsLocked
� Person.HasLock
Person.Unlock
Brief
Unlocks the features specified on the person. If all features are unlocked, then lock is released, allowing other Lua environments to get a lock.
Definition
Arguments
person - the Person to unlock.unlockFlags - the features to unlock. If 0 is passed in will return false.
Return Values
A true return value only indicates that the features requested to be unlocked were unlocked, which may mean that other features are still locked
and that the person is not yet free to be locked by another calling environment - Use if (Person.HasLock(person, PersonLockType.AII )==false)
to verify if lock has been released on the person. 'Return value behaviour has changed for 1.45 - see history for previous behaviour.
Description
If all features are unlocked, it then allows other lua environments to lock the person. The features are:
PersonLockType. Animation
PersonLockType.Transform
PersonLockType.Collision
PersonLockType. Visibility
PersonLockType. Label
PersonLockType.ChatBubbles
PersonLockType. EmoteMenu
PersonLockType.Default = PersonLockType.Animation + PersonLockType.Transform + PersonLockType.Collision + PersonLockType.Visibility
PersonLockType.AII - all the lock types together
Examples
Person.Unlock( person , PersonLockType.Animation + PersonLockType.Transform )
See Also
� Person.Lock
� Person.IsLocked
� Person.HasLock
� Person.DoAction
� Person.SetBehavior
Vector4
Vector4.Abs
Brief
Compute the component-wise absolute value of a vector.
Definition
! Vector4.Abs(Vector4 dest, Vector4 v)
Arguments
dest - destination vector to store result.v - vector to negate.
Return Values
None.
Description
Sets dest to [math.abs(v:XQ), math.abs(v:Y()), math.abs(v:Z()), math.abs(v:W())].
Examples
� local v = Vector4.Create(-1, 2 , -3)
i v:Abs(v)
; print (v) � [1, 2 , 3]
See Also
None
Vector4.Add
Brief
Adds one vector or number to another and stores the result in the destination.
Definition
! Vector4.Add( Vector4 destination, Vector4|number sourcel, Vector4|number source2 )
Arguments
destination - Vector to store the result of the addition.sourcel - Vector or number to be added to source2.source2 - Vector or number to be added
to sourcel.
Return Values
None.
Description
Adds one vector or number to another and stores the result in the destination.
Descriptive notation:
destination.x = sourcel .x[source1 + source2.x|source2
destination.y = sourcel ,y|source1 + source2.y|source2
destination.z = sourcel .z|source1 + source2.z|source2
destination, w = sourcel .w|source1 + source2.w|source2
Examples
result = Vector4.Create()
vl = Vector4.Create(
1, 2, 3, 4 )
v2 = Vector4.Create(
4 , 3, 2, 1 )
Vector4.Add( result,
vl, v2 )
Vector4.Add( result.
3, v2 )
See Also
� Vector4.Create
Vector4.Calculate2dLinelntersection
Brief
Calculates a 2-dimensional line intersection.
Definition
boolean Vector4.Calculate2dLineIntersection( Vector4 intersectionPoint, Vector4 pO, Vector4 pi,
Vector4 qO, Vector4 ql, boolean infinitelntersection = false )
Arguments
intersectionPoint - The result of the line intersection.pO - First endpoint of first line.pi - Second endpoint of first line.qO - First endpoint of second
line.ql - Second endpoint of second line.infinitelntersection - true if the supplied lines are to be treated as infinite rays, false otherwise
Return Values
Returns true if lines intersect, false otherwise.
Description
Calculates a 2-dimensional line intersection with the line p, defined by points pO and pi, with the line q, defined by points qO and ql. If the
infinitelntersection is true it returns false if p and q are parallel. If infinitelntersection is false it returns false if the lines are parallel or the
intersection does not lie on both p and q.
Examples
pO = Vector4.Create( 1, 0 )
pi = Vector4.Create( 0, 0 )
qO = Vector4.Create( 0, 0.5 )
ql = Vector4.Create( 1, 0.5 )
ip = Vector4.Create()
if Vector4.Calculate2dLineIntersection( ip, pO, pi, qO, ql ) then
print ( "The lines intersect!" )
end
See Also
� Vector4.Create
Vector4.Copy
Brief
Copies the values of one vector into another.
Definition
Vector4.Copy( Vector4 destination, Vector4 source )
Arguments
destination - The vector to copy to.source - The vector to be copied.
Return Values
None.
Description
Copies the values of the source vector and stores them in the destination. This is used to copy the values as opposed to pointing to the same
vector as an assignment would do. Use copy as vec2 = vecl does not copy values but instead makes vec2 point to vecl.
Examples
vecl = Vector4.Create( 4, 3, 2, 1 )
vec2 = Vector4.Create()
Vector4.Copy( vec2, vecl )
See Also
� Vector4.Create
Vector4.Create
Brief
Creates a new Vector4 object using the specified values.
Definition
Vector4 Vector4.Create( Vector4 source )
Vector4 Vector4.Create( number x = 0.0, number y = 0.0, number z = 0.0, number w = 0.0 )
Arguments
source - Vector whose values are used to initialize newly created vector.x - Number to be written into the first element of the vector (defaults to
0).y - Number to be written into the second element of the vector (defaults to 0).z - Number to be written into the third element of the vector
(defaults to 0).w - Number to be written into the fourth element of the vector (defaults to 0).
Return Values
A new Vector4 instance.
Description
Creates a new Vector4 object using the specified values.
Examples
� Create a default zero (0, 0, 0, 0) vector
vecl = Vector4.Create ()
� Create a vector with supplied values
vec2 = Vector4.Create ( 1, 2, 3, 4 )
� Create a vector using the values of another
vec3 = Vector4.Create( vec2 )
See Also
� Vector4.CreateBroadcast
Vector4.CreateBroadcast
Brief
Creates a new Vector4 and sets all its elements to the specified value.
Definition
Vector4 Vector4.CreateBroadcast( number value )
Arguments
value - The value to broadcast to all the elements of the new vector.
Return Values
A new Vector4 instance.
Description
Creates a new Vector4 and sets all its elements to the specified value.
Examples
vecHalf = Vector4.CreateBroadcast( 0.5 )
vec = Vector4.Create( 1, 2 , 3 )
Vector4.Multiply( vec, vec, vecHalf )
See Also
� Vector4. Create
Vector4.Cross
Brief
Performs a cross product between two 3-dimensional vectors.
Definition
Vector4.Cross( Vector4 destination, Vector4 srcl, Vector4 src2 )
Arguments
destination - Vector to store the result of the cross product.srcl - First vector to take part in the cross product.src2 - Second vector to take part in
the cross product.
Return Values
None.
Description
Performs a 3-dimensional cross product between srcl and src2 storing the result in destination. The vector generated will be perpendicular to
both srcl and src2.
Vector algebra notation:
srcl X src2
Descriptive notation:
destination.x = ( srcl .y * src2.z ) - ( srcl .z * src2.y )
destination.y = ( srcl .z * src2.x ) - ( srcl .x * src2.z )
destination.z = ( srcl .x * src2.y ) - ( srcl .y * src2.x )
Examples
xAxis = Vector4.Create( 1, 0, 0 )
yAxis = Vector4.Create( 0, 1, 0 )
result = Vector4.Create()
Vector4.Cross( result, xAxis, yAxis )
See Also
� Vector4.Create
Vector4.Dist2Sqr
Brief
Computes the squared Euclidean distance between two points in 2D space.
Definition
number Vector4.Dist2Sqr( Vector4 pi, Vector4 p2 )
Arguments
pi - A point in 2D space.p2 - A second point in 2D space.
Return Values
The squared Euclidean distance between the two points.
Description
Computes the squared Euclidean distance between two points in 2D space.
Vector algebra notation:
((p2-p1) dot (p2-p1))
Examples
vl = Vector4.Create (1, 2)
v2 = Vector4.Create (2, 3)
print("Distance between", vl, "and", v2, "is:", math.sqrt(Vector4.Dist2Sqr(vl, v2)))
See Also
� Vector4.Dist3Sqr
� Vector4.Dist4Sqr
Vector4.Dist3Sqr
Brief
Computes the squared Euclidean distance between two points in 3D space.
Definition
number Vector4.Dist3Sqr( Vector4 pi, Vector4 p2 )
Arguments
pi - A point in 3D space.p2 - A second point in 3D space.
Return Values
The squared Euclidean distance between the two points.
Description
Computes the squared Euclidean distance between two points in 3D space.
Vector algebra notation:
(( P 2-p1) dot ( P 2-p1))
Examples
j vl = Vector4.Create(1, 2, 3)
I v2 = Vector4.Create(2, 3, 4)
j print("Distance between", vl, "and", v2, "is:", math.sqrt(Vector4.Dist3Sqr(vl, v2)))
See Also
� Vector4.Dist2Sqr
� Vector4.Dist4Sqr
Vector4.Dist4Sqr
Brief
Computes the squared Euclidean distance between two points in 4D space.
Definition
number Vector4.Dist4Sqr( Vector4 pi, Vector4 p2 )
Arguments
pi - A point in 4D space.p2 - A second point in 4D space.
Return Values
The squared Euclidean distance between the two points.
Description
Computes the squared Euclidean distance between two points in 4D space.
Vector algebra notation:
((p2-p1) dot (p2-p1))
Examples
vl = Vector4.Create ( 1, 2, 3, 4 )
v2 = Vector4.Create ( 2 , 3, 4, 5 )
print("Distance between", vl, "and", v2, "is:", math.sqrt(Vector4.Dist4Sqr(vl, v2)))
See Also
� Vector4.Dist2Sqr
� Vector4.Dist3Sqr
Vector4. Divide
Brief
Divides one vector or scalar by the other vector or scalar.
Definition
Vector4.Divide( Vector4 destination, Vector4|number sourcel, Vector4|number source2 )
Arguments
destination - Vector to store the result of the division.sourcel - The dividend of the vector division.source2 - The divisor of the vector division.
Return Values
None.
Description
Divides sourcel by source2 storing the result in destination.
Descriptive notation:
destination.x = sourcel .x|source1 / source2.x]source2
destination.y = sourcel .y|source1 / source2.y|source2
destination, z = sourcel ,z|source1 / source2.z|source2
destination.w = sourcel .w|source1 / source2.w|source2
Examples
result = Vector4.Create()
vl = Vector4.Create( 1, 2, 3, 4 )
v2 = Vector4.Create( 4, 3 , 2 , 1 )
Vector4.Divide( result, vl, v2 )
Vector4.Divide( result, 1.0, v2 )
See Also
� Vector4.Create
Vector4.Dot2
Brief
Performs a dot product between two 2-dimensional vectors.
Definition
number Vector4.Dot2( Vector4 srcl, Vector4 src2 )
Arguments
srcl - First vector to take part in the dot product.src2 - Second vector to take part in the dot product.
Return Values
The number representing the dot product of the two supplied 2-dimensional vectors.
Description
Performs a 2-dimensional dot product with srcl and src2 returning the result.
Vector algebra notation:
srcl . src2
Descriptive notation:
returnvalue = ( srcl .x * src2.x ) + ( srcl .y * src2.y )
Examples
vl = Vector4.Create ( 1, 2 )
v2 = Vector4.Create ( 4, 3 )
result = Vector4.Dot2( vl, v2 )
See Also
� Vector4.Create
� Vector4.Dot3
� Vector4.Dot4
Vector4.Dot3
Brief
Performs a dot product between two 3-dimensional vectors.
Definition
number Vector4.Dot3( Vector4 srcl, Vector4 src2 )
Arguments
srcl - First vector to take part in the dot product.src2 - Second vector to take part in the dot product.
Return Values
The number representing the dot product of the two supplied 3-dimensional vectors.
Description
Performs a 3-dimensional dot product with srcl and src2 returning the result.
Vector algebra notation:
srcl . src2
Descriptive notation:
returnvalue = ( srcl .x * src2.x ) + ( srcl .y * src2.y ) + ( srcl .z * src2.z )
Examples
j vl = Vector4.Create( 1, 2, 3 )
! v2 = Vector4.Create( 4, 3, 2 )
j result = Vector4.Dot3( vl, v2 )
See Also
� Vector4.Create
� Vector4.Dot2
� Vector4.Dot4
Vector4.Dot4
Brief
Performs a dot product between two 4-dimensional vectors.
Definition
1 number Vector4.Dot4( Vector4 srcl, Vector4 src2 )
Arguments
srcl - First vector to take part in the dot product.src2 - Second vector to take part in the dot product.
Return Values
The number representing the dot product of the two supplied 4-dimensional vectors.
Description
Performs a 4-dimensional dot product with srcl and src2 returning the result.
Vector algebra notation:
srcl . src2
Descriptive notation:
returnvalue = ( srcl .x * src2.x ) + ( srcl .y * src2.y ) + ( srcl .z * src2.z ) + ( srcl .w * src2.w )
Examples
vl = Vector4.Create ( 1, 2, 3, 4 )
v2 = Vector4.Create ( 4, 3, 2, 1 )
result = Vector4.Dot4( vl, v2 )
See Also
� Vector4.Create
� Vector4.Dot2
� Vector4.Dot3
Vector4.HorizAdd3
Brief
Compute the horizontal sum of a 3D vector.
Definition
number Vector4.HorizAdd3(Vector4 v)
Arguments
v - input vector.
Return Values
The sum of the X, Y and Z components of the input vector.
Description
Returns v:X() + v:Y() + v:Z(). W is ignored.
Examples
! local v = Vector4.Create(1, 2, 3)
I print(v:HorizAdd3()) � 6
See Also
� Vector4.HorizAdd4
Vector4.HorizAdd4
Brief
Compute the horizontal sum of a 4D vector.
Definition
number Vector4.HorizAdd4(Vector4 v)
Arguments
v - input vector.
Return Values
The sum of the X, Y, Z and W components of the input vector.
Description
Returns v:X() + v:Y() + v:Z() + v:W().
Examples
local v = Vector4.Create (1, 2, 3 , 4)
print(v:HorizAdd4()) � 10
See Also
� Vector4.HorizAdd3
Vector4.Length2
Brief
Calculates the length of a 2-dimensional vector.
Definition
number Vector4.Length2( Vector4 vector )
Arguments
vector - Source vector for the calculation.
Return Values
A number holding the magnitude of the specified 2-dimensional vector.
Description
Calculates the length of the specified 2-dimensional vector.
Vector algebra notation:
vector
or sqrt( vector dot vector)
Descriptive notation:
returnvalue = sqrt( ( vector.x * vector.x ) + ( vector.y * vector.y ))
Examples
vl = Vector4.Create( 1, 2 )
print( "Vector magnitude is: " .. Vector4.Length2( vl ) )
See Also
� Vector4.Create
� Vector4.Length3
� Vector4.Length4
Vector4.Length2Sqr
Brief
Calculates the squared length of a 2-dimensional vector.
Definition
! number Vector4.Length2Sqr( Vector4 vector )
Arguments
vector - Source vector for the calculation.
Return Values
A number holding the squared magnitude of the specified 2-dimensional vector.
Description
Calculates the squared length of the specified 2-dimensional vector.
Vector algebra notation:
( vector dot vector)
Descriptive notation:
returnvalue = ( vector.x * vector.x ) + ( vector.y * vector.y )
Examples
! vl = Vector4.Create( 1, 2 )
j print( "Vector squared magnitude is: " .. Vector4.Length2Sqr( vl ) )
See Also
� Vector4. Create
� Vector4.Length3Sqr
� Vector4.Length4Sqr
� Vector4.Length2
Vector4.Length3
Brief
Calculates the length of a 3-dimensional vector.
Definition
number Vector4.Length3( Vector4 vector )
Arguments
vector - Source vector for the calculation.
Return Values
A number holding the magnitude of the specified 3-dimensional vector.
Description
Calculates the length of the specified 3-dimensional vector.
Vector algebra notation:
vector
or sqrt( vector dot vector)
Descriptive notation:
returnvalue = sqrt( ( vector.x * vector.x ) + ( vector.y * vector.y ) + ( vector.z * vector.z ))
Examples
vl = Vector4.Create ( 1, 2, 3 )
print( "Vector magnitude is: " .. Vector4.Length3( vl ) )
See Also
� Vector4.Create
� Vector4.Length2
� Vector4.Length4
Vector4.Length3Sqr
Brief
Calculates the squared length of a 3-dimensional vector.
Definition
! number Vector4.Length3Sqr( Vector4 vector )
Arguments
vector - Source vector for the calculation.
Return Values
A number holding the squared magnitude of the specified 3-dimensional vector.
Description
Calculates the squared length of the specified 3-dimensional vector.
Vector algebra notation:
( vector dot vector)
Descriptive notation:
retumvalue = ( vector.x * vector.x ) + ( vector.y * vector.y ) + ( vector.z * vector.z )
Examples
vl = Vector4.Create( 1 , 2, 3 )
print( "Vector squared magnitude is: " .. Vector4.Length34Sqr( vl ) )
See Also
� Vector4.Create
� Vector4.Length2Sqr
� Vector4.Length4Sqr
� Vector4.Length3
Vector4.Length4
Brief
Calculates the length of a 4-dimensional vector.
Definition
! number Vector4.Length4( Vector4 vector )
Arguments
vector - Source vector for the calculation.
Return Values
A number holding the magnitude of the specified 4-dimensional vector.
Description
Calculates the length of the specified 4-dimensional vector.
Vector algebra notation:
vector
or sqrt( vector dot vector)
Descriptive notation:
returnvalue = sqrt( ( vector.x * vector.x ) + ( vector.y * vector.y ) + ( vector.z * vector.z ) + ( vector.w * vector.w ))
Examples
vl = Vector4.Create( 1, 2, 3, 4 )
print( "Vector magnitude is: " .. Vector4.Length4( vl ) )
See Also
� Vector4.Create
� Vector4.Length2
� Vector4.Length3
Vector4.Length4Sqr
Brief
Calculates the squared length of a 4-dimensional vector.
Definition
! number Vector4.Length4Sqr( Vector4 vector )
Arguments
vector - Source vector for the calculation.
Return Values
A number holding the squared magnitude of the specified 4-dimensional vector.
Description
Calculates the squared length of the specified 4-dimensional vector.
Vector algebra notation:
( vector dot vector)
Descriptive notation:
returnvalue = ( vector.x * vector.x ) + ( vector.y * vector.y ) + ( vector.z * vector.z ) + ( vector.w * vector.w )
Examples
j vl = Vector4.Create( 1, 2 , 3 , 4 )
I print( "Vector squared magnitude is: " .. Vector4.Length4Sqr( vl ) )
See Also
� Vector4. Create
� Vector4.Length2Sqr
� Vector4.Length3Sqr
� Vector4.Length4
Vector4.Max
Brief
Compute the maximum element values of two vectors.
Definition
! Vector4.Max(Vector4 dest, Vector4 sourcel, Vector4 source2)
Arguments
dest - Vector to hold result. May be the same vector as either of source vectors if desired.sourcel - First source vector.source2 - Second source
vector.
Return Values
None.
Description
Compares each element in sourcel with equivalent element in source2 and stores the greater value in the equivalent element of dest. That is:
dest =
Unknown macro: { max(source1 .x, source2.x), max(source1 .y, source2.y), max(source1 .z, source2.z), max(source1 .w, source2.w)}
Examples
� assuming verts is an array of Vector4 values
local min = Vector4.Create(Const.MaxNum, Const.MaxNum, Const.MaxNum)
local max = Vector4.Create(-Const.MaxNum, -Const.MaxNum, -Const.MaxNum)
for i = 1, numVerts do
Vector4.Min(min, min, verts[i])
Vector4.Max(max, max, verts[i])
end
� min and max now store bounds of vert list
See Also
� Vector4.Min
� StreamOps.BoundsVec4
Vector4.Min
Brief
Compute the minimum element values of two vectors.
Definition
Vector4.Min(Vector4 dest, Vector4 sourcel, Vector4 source2)
Arguments
dest - Vector to hold result. May be the same vector as either of source vectors if desired.sourcel - First source vector.source2 - Second source
vector.
Return Values
None.
Description
Compares each element in sourcel with equivalent element in source2 and stores the lower value in the equivalent element of dest. That is:
dest =
Unknown macro: { min(source1.x, source2.x), min(source1 .y, source2.y), min(source1 .z, source2.z), minfsourcel .w, source2.w)}
Examples
� assuming verts is an array of Vector4 values
local min = Vector4.Create(Const.MaxNum, Const.MaxNum, Const.MaxNum)
local max = Vector4.Create(-Const.MaxNum, -Const.MaxNum, -Const.MaxNum)
for i = 1, numVerts do
Vector4.Min(min, min, verts[i])
Vector4.Max(max, max, verts[i])
end
� min and max now store bounds of vert list
See Also
� Vector4.Max
� StreamOps.BoundsVec4
Vector4.Multiply
Brief
Multiplies two vectors or scalars together storing the result as a vector.
Definition
Vector4.Multiply( Vector4 destination, Vector4|number sourcel, Vector4|number source2 )
Arguments
destination - Vector to store the result of the multiplication.sourcel - The first argument for the multiplication, can be a Vector4 or a scalar.source2
- The second argument for the multiplication, can be a Vector4 or a scalar.
Return Values
None.
Description
Multiplies sourcel and source2 together storing the result in the destination vector.
Descriptive notation:
destination.x = sourcel .x|source1 * source2.x|source2
destination.y = sourcel ,y|source1 * source2.y|source2
destination.z = sourcel ,z|source1 * source2.z|source2
destination.w = sourcel.w|source1 * source2.w|source2
Examples
result = Vector4.Create()
vl = Vector4.Create( 1, 2, 3, 4 )
v2 = Vector4.Create( 4, 3, 2, 1 )
Vector4.Multiply( result, vl, v2 )
Vector4.Multiply( result, vl, 4.0 )
Vector4.Multiply( result, -3.0, v2 )
Vector4.Multiply( result, -3.0, 4 )
See Also
Vector4. Create
Vector4.MultiplyAdd
Brief
Multiplies two vectors together and then adds the third vector.
Definition
Vector4.MultiplyAdd( Vector4 destination, Vector4|number sourcel, Vector4|number source2,
Vector4|number source3 )
Arguments
destination - Vector to store the result of the multiplication.sourcel - The first vector argument for the multiplication.source2 - The second vector
argument for the multiplication.source3 - The third vector argument for the addition.
Return Values
None.
Description
Multiplies sourcel and source2 together and then adds the third vector, storing the result in destination.
Descriptive notation:
destination.x = ( sourcel.x|source1 * source2.x|source2 ) + source3.x|source3
destination.y = ( sourcel.y|source1 * source2.y|source2 ) + source3.y|source3
destination.z = ( sourcel.z|source1 * source2.z|source2 ) + source3.z|source3
destination.w = ( sourcel .w]source1 * source2.w|source2 ) + source3.w|source3
Examples
result = Vector4.Create()
vl = Vector4.Create( 1, 2, 3, 4 )
v2 = Vector4.Create( 4, 3, 2, 1 )
v3 = Vector4.Create( 1, 0, 0, 1 )
Vector4.MultiplyAdd( result, vl, v2, v3 )
Vector4.MultiplyAdd( result, 1, 2, 6 )
See Also
� Vector4.Create
Vector4.Negate
Brief
Negate a vector in-place.
Definition
Vector4.Negate(Vector4 v)
Arguments
v - vector to negate.
Return Values
None.
Description
Sets v to -v.
Examples
! local v = Vector4.Create(1, 2, 3)
! v:Negate()
| print(v) � [-1, - 2 , -3]
See Also
None
Vector4.Normal2
Brief
Returns the normalization of a 2-dimensional vector.
Definition
Vector4 Vector4.Normal2( Vector4 vector )
Arguments
vector - The vector to normalize.
Return Values
A new Vector4 instance containing a normalized copy of the source vector.
Description
Returns the normalization of the specified 2-dimensional vector (i.e. a new vector of unit length). The source vector is not modified.
Descriptive notation:
length = sqrt( src.x * src.x + src.y * src.y )
returnvec.x = src.x / length
returnvec.y = src.y / length
retumvec.z = 0
returnvec.w = 0
Examples
| vec = Vector4.Create( 1, 2 )
; result = Vector4.Normal2( vec )
j print( result )
See Also
Vector4.Create
� Vector4.Normal3
� Vector4.Normal4
Vector4.Normal3
Brief
Returns the normalization of a 3-dimensional vector.
Definition
! Vector4 Vector4.Normal3( Vector4 src )
Arguments
src - The vector to use as a source to normalize.
Return Values
A new Vector4 instance containing a normalized copy of the source vector.
Description
Returns the normalization of the specified 3-dimensional vector (i.e. a new vector of unit length). The source vector is not modified.
Descriptive notation:
length = sqrt( src.x*src.x + src.y*src.y + src.z*src.z )
returnvec.x = src.x / length
returnvec.y = src.y / length
retumvec.z = src.z / length
retumvec.w = 0
Examples
j vec = Vector4.Create( 1, 2, 3 )
; result = Vector4.Normal3( vec )
j print( result )
See Also
� Vector4.Create
� Vector4.Normal2
� Vector4.Normal4
Vector4.Normal4
Brief
Returns the normalization of a 4-dimensional vector.
Definition
Vector4 Vector4.Normal4( Vector4 src )
Arguments
src - The vector to use as a source to normalize.
Return Values
A new Vector4 instance containing a normalized copy of the source vector.
Description
Returns the normalization of the specified 4-dimensional vector (i.e. a new vector of unit length). The source vector is not modified.
Descriptive notation:
length = sqrt( src.x*src.x + src.y*src.y + src.z*src.z + src.w*src.w )
returnvec.x = src.x / length
returnvec.y = src.y / length
returnvec.z = src.z / length
returnvec.w = src.z / length
Examples
j vec = Vector4.Create( 1, 2 , 3, 4 )
; result = Vector4.Normal4( vec )
| print( result )
See Also
� Vector4. Create
� Vector4.Normal2
� Vector4.Normal3
Vector4.Normalize2
Brief
Normalizes a vector using Length2 of that vector.
Definition
! Vector4.Normalize2( Vector4 vector )
Arguments
vector - The vector to normalize.
Return Values
None.
Description
Normalizes the specified vector using Length2 of the vector.
Descriptive notation:
length = sqrt( vector.x*vector.x + vector.y'vector.y )
vector.x = vector.x / length
vector.y = vector.y / length
vector.z = 0
vector.w = 0
Examples
! vector = Vector4.Create( 1, 3 , 2 , 4 )
! Vector4.Normalize2( vector )
| print( vector )
See Also
� Vector4.Create
� Vector4.Normalize3
� Vector4.Normalize4
Vector4.Normalizes
Brief
Normalizes a vector using Length3 of that vector.
Definition
! Vector4.Normalize3( Vector4 vector )
Arguments
vector - The vector to normalize.
Return Values
None.
Description
Normalizes the specified vector using Length3 of the vector.
Descriptive notation:
length = sqrt( vector.x*vector.x + vector.y'vector.y + vector.z*vector.z )
vector.x = vector.x / length
vector.y = vector.y / length
vector.z = vector.z / length
vector.w = 0
Examples
vector = Vector4.Create ( 1 , 3 , 2 , 4 )
Vector4.Normalize3( vector )
print ( vector )
See Also
� Vector4.Create
� Vector4.Normalize2
� Vector4.Normalize4
Vector4.Normalize4
Brief
Normalizes a vector using Length4 of that vector.
Definition
Vector4.Normalize4( Vector4 vector )
Arguments
vector - The vector to normalize.
Return Values
None.
Description
Normalizes the specified vector using Length4 of the vector.
Descriptive notation:
length = sqrt( vector.x*vector.x + vector.y'vector.y + vector.z*vector.z + vector.w'vector.w )
vector.x = vector.x / length
vector.y = vector.y / length
vector.z = vector.z / length
vector.w = vector.w / length
Examples
j vector = Vector4.Create( 1 , 3 , 2 , 4 )
I Vector4.Normalize4( vector )
| print( vector )
See Also
� Vector4. Create
� Vector4.Normalize2
� Vector4. Normalizes
Vector4.Recip
Brief
Compute the component-wise reciprocal of a vector.
Definition
Vector4.Recip(Vector4 dest, Vector4 v)
Arguments
dest - destination vector to store result.v - input vector.
Return Values
None.
Description
Sets dest to [1 / v:X(), 1 / v:Y(), 1 / v:Z(), 1 / v:W()]. If any elements of v are 0 the result is undefined. Note that due to floating point arithmetic
precision, Recip(Recip^) is not necessarily x.
Examples
j local v = Vector4.Create (-1, 2, -3)
I v:Recip(v)
| print(v) � [-1, 0.5, -0.333333]
See Also
� Vector4.RecipSqrt
Vector4.RecipSqrt
Brief
Compute the component-wise reciprocal square root of a vector.
Definition
Vector4.RecipSqrt(Vector4 dest, Vector4 v)
Arguments
dest - destination vector to store result.v - input vector.
Return Values
None.
Description
Sets dest to [1 / math.sqrt(v:X()), 1 / math.sqrt(v:Y()), 1 / math.sqrt(v:Z()), 1 / math.sqrt(v:W()]. If any elements of v are <= 0 the result is
undefined. This operation is faster than the equivalent combination of Sqrt and Recip.
Examples
local v = Vector4.Create(1, 4, 9)
v:RecipSqrt(v)
print(v) � [1, 0.5, 0.333333]
See Also
� Vector4.Recip
� Vector4.Sqrt
Vector4. Rotate
Brief
Rotate a vector about and axis.
Definition
Vector4.Rotate( Vector4 destination, Vector4 source, Vector4 axis, number angle )
Arguments
destination - Vector to store the result of the rotation.source - Vector to be rotated.axis - Axis to rotate about.angle - Angle (in degrees) to rotate
by.
Return Values
Description
Rotate a vector about and axis.
Examples
src = Vector4.Create( 12, 2, -3 )
axis = Vector4.Create( 0, 0.707, -0.707 )
dst = Vector4.Create()
Vector4.Rotate( dst, src, axis, 45 )
See Also
� Vector4. Create
Vector4.SetBroadcast
Brief
Sets the all of the vector's elements to the specified value.
Definition
Vector4 Vector4.SetBroadcast( Vector4 vector, number value )
Arguments
vector - Vector to be set.value - The value to broadcast to all the elements of the vector.
Return Values
None.
Description
Sets the all of the vector's elements to the specified value.
Examples
vecHalf = Vector4.Create()
Vector4.SetBroadcast( vecHalf, 0.5 )
vec = Vector4.Create( 1, 2, 3 )
Vector4.Multiply( vec, vec, vecHalf )
See Also
� Vector4.Create
� Vector4.CreateBroadcast
Vector4.SetW
Brief
Sets the w value of the vector.
Definition
Vector4.SetW( Vector4 vector, number value )
Arguments
vector - Vector to be set.value - A numerical value that is copied into the w component of the vector.
Return Values
None.
Description
Sets the w value of the vector.
Examples
j vec = Vector4.Create( 1, 2, 3, 4 )
! Vector4.SetW( vec, 6 )
See Also
� Vector4. Create
� Vector4.SetX
� Vector4.SetY
Vector4.SetZ
Vector4.SetX
Brief
Sets the x value of the vector.
Definition
Vector4.SetX( Vector4 vector, number value )
Arguments
vector - Vector to be set.value - A numerical value that is copied into the x component of the vector.
Return Values
None.
Description
Sets the x value of the vector.
Examples
j vec = Vector4.Create( 1, 2, 3, 4 )
i Vector4.SetX( vec, 6 )
See Also
� Vector4.Create
� Vector4.SetY
� Vector4.SetZ
� Vector4.SetW
Vector4.SetXyzw
Brief
Sets a Vector4 object with the specified values.
Definition
! Vector4.SetXyzw( Vector4 vector, number x = 0, number y = 0, number z = 0, number w = 0 )
Arguments
vector - Vector to be set.x - Number to be written into the first element of the vector (defaults to 0).y - Number to be written into the second
element of the vector (defaults to 0).z - Number to be written into the third element of the vector (defaults to 0).w - Number to be written into the
fourth element of the vector (defaults to 0).
Return Values
None.
Description
Sets a Vector4 object with the specified values.
Examples
vec = Vector4.Create()
Vector4.SetXyzw( vec, 1, 2, 3, 4 )
See Also
� Vector4.Create
Vector4.SetY
Brief
Sets the y value of the vector.
Definition
1 Vector4.SetY( Vector4 vector, number value )
Arguments
vector - Vector to be set.value - A numerical value that is copied into the y component of the vector.
Return Values
None.
Description
Sets the y value of the vector.
Examples
vec = Vector4.Create( 1, 2, 3, 4 )
Vector4.SetY( vec, 6 )
See Also
� Vector4.Create
� Vector4.SetX
� Vector4.SetZ
� Vector4.SetW
Vector4.SetZ
Brief
Sets the z value of the vector.
Definition
Vector4.SetZ( Vector4 vector, number value )
Arguments
vector - Vector to be set.value - A numerical value that is copied into the z component of the vector.
Return Values
None.
Description
Sets the z value of the vector.
Examples
j vec = Vector4.Create( 1, 2, 3, 4 )
: Vector4.SetZ( vec, 6 )
See Also
� Vector4.Create
� Vector4.SetX
� Vector4.SetY
� Vector4.SetW
Vector4.Sign
Brief
Compute the sign (-1 or 1) of all elements in a vector.
Definition
! Vector4.Sign(Vector4 dest, Vector4 v)
Arguments
dest - destination vector to store result.v - input vector.
Return Values
None.
Description
Each element of dest is set to the sign (-1 or 1) of the equivalent element of v. 0 is considered positive and thus becomes 1, if a separate 0 value
is required use the Signum function.
Examples
j local v = Vector4.Create (-3.1, 0, -0.4, 1.2)
i v:Sign(v)
j print (v) � [-1, 1, -1, 1]
See Also
Vector4.Signum
Vector4.Signum
Brief
Compute the sign (-1,0 or 1) of all elements in a vector.
Definition
! Vector4.Signum(Vector4 dest, Vector4 v)
Arguments
dest - destination vector to store result.v - input vector.
Return Values
None.
Description
Each element of dest is set to the sign (-1,0 or 1) of the equivalent element of v. If a separate 0 value is not required, use the Sign function.
Examples
! local v = Vector4.Create(-3.1, 0, -0.4, 1.2)
i v:Signum(v)
| print (v) � [-1, 0, -1, 1]
See Also
� Vector4.Sign
Vector4.Sqrt
Brief
Compute the component-wise square root of a vector.
Definition
j Vector4.Sqrt(Vector4 dest, Vector4 v)
Arguments
dest - destination vector to store result.v - input vector.
Return Values
None.
Description
Sets dest to [math.sqrt(v:XQ), math.sqrt(v:Y()), math.sqrt(v:Z()), math.sqrt(v:W())]. If any elements of v are < 0 the result is undefined.
Examples
local v = Vector4.Create(1, 4, 9)
v: Sqrt (v)
print (v) � [1, 2, 3]
See Also
� Vector4.RecipSqrt
Vector4.Subtract
Brief
Subtracts one vector from another.
Definition
Vector4.Subtract( Vector4 destination, Vector4|number sourcel, Vector4|number source2 )
Arguments
destination - Vector to store the result of the subtraction.sourcel - The minuend for the subtraction.source2 - The subtrahend for the subtraction.
Return Values
None.
Description
Subtracts source2 from sourcel storing the result in destination.
Descriptive notation:
destination.x = sourcel .x|source1 - source2.x|source2
destination.y = sourcel ,y|source1 - source2.y|source2
destination.z = sourcel .z|source1 - source2.z|source2
destination.w = sourcel.w|source1 - source2.w|source2
Examples
result = Vector4.Create()
vl = Vector4.Create( 1, 2 , 3, 4 )
v2 = Vector4.Create( 4 , 3, 2 , 1 )
Vector4.Subtract( result, vl, v2 )
Vector4.Subtract( result, vl, 3 )
See Also
� Vector4.Create
Vector4.T ransform
Brief
Transforms a vector by a matrix.
Definition
Vector4.Transform( Vector4 destination, Matrix44 matrix, Vector4 source )
Vector4.Transform( table destination, Matrix44 matrix, table source )
Arguments
destination - Vector or table of vectors to store the result of the multiplication.matrix - Matrix to transform the source vector or table of
vectors.source - Vector or table of vectors to be transformed.
Return Values
Description
Transforms the specified source vector by a matrix and stores the resultant vector in the destination. It is equivalent to:
destination = matrix * source
It is also possible to transform a table of vectors by the specified matrix. The result is stored in a destination table with the same number of
vectors as the source table. This can be considerably faster than transforming vectors individually.
Examples
� Create the matrix for the example code below
matrix = Matrix44.Create()
Matrix44.SetRotationXyz( matrix, 45, 12, 7 )
� Example 1: Transform a single vector by a matrix
src = Vector4.Create ( 12, 2, -3, 1 )
dst = Vector4.Create ()
Vector4.Transform( dst, matrix, src )
� Example 2: Transform a table of vectors by a matrix
source = {}
destination = {}
for v = 1, 10 do
source[v] = Vector4.Create(v, v, v, v)
destination[v] = Vector4.Create ()
end
Vector4.Transform( destination, matrix, source )
See Also
� Matrix44. Create
� Vector4. Create
Vector4.TransformPoint
Brief
Transforms a point by a matrix.
Definition
Vector4.TransformPoint( Vector4 destination, Matrix44 matrix, Vector4 source )
Vector4.TransformPoint( table destination, Matrix44 matrix, table source )
Arguments
destination - Point or table of points to store the result of the multiplication.matrix - Matrix to transform the source vector or table of vectors.source
- Point or table of points to be transformed.
Return Values
Description
Transforms the specified source point by a matrix and stores the resultant point in the destination. It is equivalent to:
destination = matrix * source (where source.w is substituted with 1.0)
It is also possible to transform a table of points by the specified matrix. The result is stored in a destination table with the same number of points
as the source table. This can be considerably faster than transforming points individually.
Examples
� Create the matrix for the example code below
matrix = Matrix44.Create()
Matrix44.SetRotationXyz( matrix, 45, 12, 7 )
� Example 1: Transform a single point by a matrix
src = Vector4.Create ( 12, 2, -3 )
dst = Vector4.Create ()
Vector4.TransformPoint( dst, matrix, src )
� Example 2: Transform a table of points by a matrix
source = {}
destination = {}
for v = 1, 10 do
source[v] = Vector4.Create(v, v, v)
destination[v] = Vector4.Create ()
end
Vector4.TransformPoint( destination, matrix, source )
See Also
� Matrix44.Create
� Vector4.Create
Vector4.T ransform Vector
Brief
Transforms a vector by a matrix.
Definition
Vector4.TransformVector( Vector4 destination, Matrix44 matrix, Vector4 source )
Vector4.TransformVector( table destination, Matrix44 matrix, table source )
Arguments
destination - Vector or table of vectors to store the result of the multiplication.matrix - Matrix to transform the source vector or table of
vectors.source - Vector or table of vectors to be transformed.
Return Values
Description
Transforms the specified source vector by a matrix and stores the resultant vector in the destination. It is equivalent to:
destination = matrix * source (where source.w is substituted with 0.0)
It is also possible to transform a table of vectors by the specified matrix. The result is stored in a destination table with the same number of
vectors as the source table. This can be considerably faster than transforming vectors individually.
Examples
� Create the matrix for the example code below
matrix = Matrix44.Create()
Matrix44.SetRotationXyz( matrix, 45, 12, 7 )
� Example 1: Transform a single vector by a matrix
src = Vector4.Create ( 12, 2, -3 )
dst = Vector4.Create ()
Vector4.TransformVector( dst, matrix, src )
� Example 2: Transform a table of vectors by a matrix
source = {}
destination = {}
for v = 1, 10 do
source[v] = Vector4.Create(v, v, v)
destination[v] = Vector4.Create ()
end
Vector4.TransformVector( destination, matrix, source )
See Also
� Matrix44.Create
� Vector4.Create
Vector4.W
Brief
Returns the w value of the vector.
Definition
! number Vector4.W( Vector4 vector )
Arguments
vector - Vector to be queried.
Return Values
Returns the fourth element of the vector, the w component.
Description
Returns the w value of the vector.
Examples
j vec = Vector4.Create( 1, 2, 3, 4 )
j print( "Value of W is: " .. Vector4.W( vec ) )
See Also
� Vector4.Create
� Vector4.X
� Vector4.Y
� Vector4.Z
Vector4.X
Brief
Returns the x value of the vector.
Definition
! number Vector4.X( Vector4 vector )
Arguments
vector - Vector to be queried.
Return Values
The first element of the vector, the x component.
Description
Returns the x value of the vector.
Examples
j vec = Vector4.Create( 10 )
i print( "Value of X is: " .. Vector4.X( vec ) )
See Also
� Vector4.Create
� Vector4.Y
� Vector4.Z
� Vector4.W
Vector4.Y
Brief
Returns the y value of the vector.
Definition
! number Vector4.Y( Vector4 vector )
Arguments
vector - Vector to be queried.
Return Values
Returns the second element of the vector, the y component.
Description
Returns the y value of the vector.
Examples
vec = Vector4.Create( 1, 2 )
print( "Value of Y is: " .. Vector4.Y( vec ) )
See Also
� Vector4.Create
� Vector4.X
� Vector4.Z
� Vector4.W
Vector4.Z
Brief
Returns the z value of the vector.
Definition
! number Vector4.Z( Vector4 vector )
Arguments
vector - Vector to be queried.
Return Values
Returns the third element of the vector, the z component.
Description
Returns the z value of the vector.
Examples
vec = Vector4.Create( 1, 2, 3 )
print( "Value of Z is: " .. Vector4.Z( vec ) )
See Also
� Vector4.Create
� Vector4.X
� Vector4.Y
� Vector4.W