GetElementBoneMatrix: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
Fernando187 (talk | contribs) (Remove obsolete Requirements section) |
||
(6 intermediate revisions by 2 users not shown) | |||
Line 18: | Line 18: | ||
==Example== | ==Example== | ||
this example will output bone position and rotation for id 5. | |||
<syntaxhighlight lang="lua"> | |||
local boneMatrix = getElementBoneMatrix(localPlayer, 5) -- get the bone matrix for localPlayer, id: 5 | |||
if boneMatrix then | |||
-- extract position and rotation from the matrix | |||
local posX, posY, posZ = boneMatrix[4][1], boneMatrix[4][2], boneMatrix[4][3] | |||
local rotX, rotY, rotZ = math.deg(math.asin(-boneMatrix[3][2])), math.deg(math.atan2(boneMatrix[3][1], boneMatrix[3][3])), math.deg(math.atan2(boneMatrix[1][2], boneMatrix[2][2])) | |||
outputChatBox("Bone position: (" .. posX .. ", " .. posY .. ", " .. posZ .. ")") | |||
outputChatBox("Bone rotation: (" .. rotX .. ", " .. rotY .. ", " .. rotZ .. ")") | |||
else | |||
outputChatBox("Invalid element or bone ID.") | |||
end | |||
</syntaxhighlight> | |||
==See Also== | ==See Also== | ||
{{Client_element_functions}} | {{Client_element_functions}} |
Latest revision as of 17:23, 7 November 2024
This function returns the transformation matrix of a specific bone. Currently the Player and Ped element types are accepted.
Tip: If you want to attach an element to a bone, see attachElementToBone. |
Tip: For matrix manipulation which goes beyond the basic examples given on this page, see the Lua matrix library. Using the built-in matrix class is also recommended. |
Syntax
table getElementBoneMatrix ( element theElement, int boneId )
Required Arguments
- theElement: the element to get the bone matrix on.
- boneId: the ID of the bone to get the matrix of. See Bone IDs.
Returns
Returns a multi-dimensional array (which can be transformed into a proper matrix class using Matrix.create method) containing a 4x4 matrix. Returns false if invalid arguments were passed.
Example
this example will output bone position and rotation for id 5.
local boneMatrix = getElementBoneMatrix(localPlayer, 5) -- get the bone matrix for localPlayer, id: 5 if boneMatrix then -- extract position and rotation from the matrix local posX, posY, posZ = boneMatrix[4][1], boneMatrix[4][2], boneMatrix[4][3] local rotX, rotY, rotZ = math.deg(math.asin(-boneMatrix[3][2])), math.deg(math.atan2(boneMatrix[3][1], boneMatrix[3][3])), math.deg(math.atan2(boneMatrix[1][2], boneMatrix[2][2])) outputChatBox("Bone position: (" .. posX .. ", " .. posY .. ", " .. posZ .. ")") outputChatBox("Bone rotation: (" .. rotX .. ", " .. rotY .. ", " .. rotZ .. ")") else outputChatBox("Invalid element or bone ID.") 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