GetElementMatrix: Difference between revisions
Jump to navigation
Jump to search
(int CLuaFunctionDefinitions::GetElementMatrix) |
(nnnnp) |
||
Line 1: | Line 1: | ||
{{Client function}} | {{Client function}} | ||
__NOTOC__ | __NOTOC__ | ||
This function gets an element's matrix. This contains various components such as position and rotation. It is most useful for matrix calculations such as calculating offsets. | |||
==Syntax== | ==Syntax== | ||
Line 9: | Line 9: | ||
===Required Arguments=== | ===Required Arguments=== | ||
*'''theElement:''' | *'''theElement:''' The element which you wish to retrieve the matrix for | ||
===Returns=== | ===Returns=== | ||
Returns a multi-dimensional array in the format of: | |||
<syntaxhighlight lang="lua"> | |||
{ | |||
{ rollX, rollY, rollZ, 1 }, | |||
{ directionX, directionY, directionZ, 1 }, | |||
{ wasX, wasY, wasZ, 1 }, | |||
{ posX, posY, posZ, 1 }, | |||
} | |||
</syntaxhighlight> | |||
==Example== | ==Example== | ||
This example creates a utility function that gets the position that is in front of a specified player. Note that it assumes you have the [http://lua-users.org/wiki/LuaMatrix Lua Matrix] library installed. | |||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
-- | function getPositionInFrontOfElement(element) | ||
local posX,posY,posZ = getElementPosition(element) | |||
--Get the position 5 units in front | |||
local transformed = matrix{0,5,0} * matrix(getElementMatrix(element)} | |||
--Get our offset components | |||
local offX,offY,offZ = transformed[1][1],transformed[2][1],transformed[3][1] | |||
--Return absolute coordinates by adding the original position | |||
return posX + offX, posY + offY, posZ + offZ | |||
end | |||
</syntaxhighlight> | </syntaxhighlight> | ||
==See Also== | ==See Also== | ||
{{Client_element_functions}} | {{Client_element_functions}} |
Revision as of 19:40, 26 April 2009
This function gets an element's matrix. This contains various components such as position and rotation. It is most useful for matrix calculations such as calculating offsets.
Syntax
int getElementMatrix ( element theElement )
Required Arguments
- theElement: The element which you wish to retrieve the matrix for
Returns
Returns a multi-dimensional array in the format of:
{ { rollX, rollY, rollZ, 1 }, { directionX, directionY, directionZ, 1 }, { wasX, wasY, wasZ, 1 }, { posX, posY, posZ, 1 }, }
Example
This example creates a utility function that gets the position that is in front of a specified player. Note that it assumes you have the Lua Matrix library installed.
function getPositionInFrontOfElement(element) local posX,posY,posZ = getElementPosition(element) --Get the position 5 units in front local transformed = matrix{0,5,0} * matrix(getElementMatrix(element)} --Get our offset components local offX,offY,offZ = transformed[1][1],transformed[2][1],transformed[3][1] --Return absolute coordinates by adding the original position return posX + offX, posY + offY, posZ + offZ end
See Also
- getElementBoneMatrix
- getElementBonePosition
- getElementBoneRotation
- getElementBoundingBox
- getElementDistanceFromCentreOfMassToBaseOfModel
- getElementLighting
- getElementRadius
- isElementCollidableWith
- isElementLocal
- isElementOnScreen
- isElementStreamable
- isElementStreamedIn
- isElementSyncer
- isElementWaitingForGroundToLoad
- setElementBoneMatrix
- setElementBonePosition
- setElementBoneRotation
- setElementCollidableWith
- setElementStreamable
- updateElementRpHAnim
- Shared
- attachElements
- createElement
- destroyElement
- detachElements
- getAttachedElements
- getElementAlpha
- getElementAttachedOffsets
- getElementAttachedTo
- getElementByIndex
- getElementByID
- getElementChild
- getElementChildren
- getElementChildrenCount
- getElementCollisionsEnabled
- getElementColShape
- getElementData
- getAllElementData
- hasElementData
- getElementDimension
- getElementHealth
- getElementID
- getElementInterior
- getElementMatrix
- getElementModel
- getElementParent
- getElementPosition
- getElementRotation
- getElementsByType
- getElementsWithinColShape
- getElementsWithinRange
- getElementType
- getElementVelocity
- getLowLODElement
- getRootElement
- isElement
- isElementAttached
- isElementCallPropagationEnabled
- isElementDoubleSided
- isElementFrozen
- isElementInWater
- isElementLowLOD
- isElementWithinColShape
- isElementWithinMarker
- setElementAlpha
- setElementAngularVelocity
- getElementAngularVelocity
- setElementAttachedOffsets
- setElementCallPropagationEnabled
- setElementCollisionsEnabled
- setElementData
- setElementDimension
- setElementDoubleSided
- setElementFrozen
- setElementHealth
- setElementID
- setElementInterior
- setElementModel
- setElementParent
- setElementPosition
- setElementRotation
- setElementVelocity
- setLowLODElement
- getPedContactElement
- getResourceDynamicElementRoot
- getResourceRootElement