GetElementBoneRotation: Difference between revisions
Jump to navigation
Jump to search
Zangomangu (talk | contribs) (Created page with "__NOTOC__ {{Client function}} {{New feature/item|3.0160|1.5.8|20704|Returns the 3D world orientation of a specific bone of a given element. Currently the following element...") |
Fernando187 (talk | contribs) (Remove obsolete Requirements section) |
||
(15 intermediate revisions by 4 users not shown) | |||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
{{Client function}} | {{Client function}} | ||
{{ | {{Added feature/item|1.5.9|1.5.8|20704|Returns the orientation of a specific bone relative to the [[element]]. Currently the [[Element/Player|Player]] and [[Element/Ped|Ped]] element types are accepted.}} | ||
{{Tip|If you want to attach an element to a bone, see [[attachElementToBone]].}} | |||
}} | |||
{{Tip|If you want to attach an element to a bone, see [[attachElementToBone]]}} | |||
==Syntax== | ==Syntax== | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
float, float, float getElementBoneRotation ( element theElement, int | float, float, float getElementBoneRotation ( element theElement, int boneId ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
[[Image:The-yaw-pitch-and-roll-angles-in-the-human-head-motion-11.png|thumb|Rotation axes]] | |||
===Required Arguments=== | ===Required Arguments=== | ||
*'''theElement:''' the element to get the bone rotation on. | *'''theElement:''' the [[element]] to get the bone rotation on. | ||
*''' | *'''boneId:''' the ID of the bone to get the rotation of. See [[Bone IDs]]. | ||
===Returns=== | ===Returns=== | ||
Returns the yaw, pitch, roll rotation values. | Returns 3 [[Float|floats]], representing the yaw, pitch, roll rotation values. | ||
==Example== | ==Example== | ||
{{ | This example outputs the yaw, pitch and roll orientation of a specific bone relative to the local player bone specified through a command: | ||
<syntaxhighlight lang="lua"> | |||
function getBoneRotation (commandName, boneId) | |||
if not tonumber (boneId) then | |||
outputChatBox ("You didn't insert an bone ID!", 255, 0, 0) | |||
return false | |||
end | |||
local x, y, z = getElementBoneRotation (localPlayer, boneId) | |||
outputChatBox ("The bone rotation is: "..x..", "..y..", "..z) | |||
end | |||
addCommandHandler ("getbonerotation", getBoneRotation) | |||
</syntaxhighlight> | |||
==Example 2== | |||
This example takes the current rotation of all player bones. by ThigasDEV | |||
<syntaxhighlight lang="lua"> | |||
local settings = { | |||
copyDiscord = false; -- true = "yes" // false = "no" - Copy to paste table in discord format. | |||
tableName = "bonesPos"; -- Table name to be copied. | |||
} | |||
local boneIDs = {0, 1, 2, 3, 4, 5, 6, 7, 8, 21, 22, 23, 24, 25, 26, 31, 32, 33, 34, 35, 36, 41, 42, 43, 44, 51, 52, 53, 54, 201, 301, 302} | |||
addCommandHandler ("getbonerotation", function () | |||
local bonesPositions = { } | |||
local bonesConverted = "" | |||
for _, v in ipairs (boneIDs) do | |||
local x, y, z = getElementBoneRotation (localPlayer, v) | |||
table.insert (bonesPositions, "["..v.."] = {"..x..", "..y..", "..z.."};") | |||
end | |||
for i, v in ipairs (bonesPositions) do | |||
bonesConverted = " "..bonesConverted.."\n".." "..v | |||
end | |||
setClipboard ((settings["copyDiscord"] and "```lua\nlocal "..string.gsub(settings["tableName"], " ", "_").." = {"..bonesConverted.."\n}\n```" or "local "..string.gsub(settings["tableName"], " ", "_").." = {"..bonesConverted.."\n}")) | |||
outputChatBox ("Copy to clipboard.") | |||
end) | |||
</syntaxhighlight> | |||
==See Also== | ==See Also== | ||
{{Client_element_functions}} | {{Client_element_functions}} |
Latest revision as of 17:23, 7 November 2024
Returns the orientation of a specific bone relative to the element. Currently the Player and Ped element types are accepted.
Tip: If you want to attach an element to a bone, see attachElementToBone. |
Syntax
float, float, float getElementBoneRotation ( element theElement, int boneId )
Required Arguments
- theElement: the element to get the bone rotation on.
- boneId: the ID of the bone to get the rotation of. See Bone IDs.
Returns
Returns 3 floats, representing the yaw, pitch, roll rotation values.
Example
This example outputs the yaw, pitch and roll orientation of a specific bone relative to the local player bone specified through a command:
function getBoneRotation (commandName, boneId) if not tonumber (boneId) then outputChatBox ("You didn't insert an bone ID!", 255, 0, 0) return false end local x, y, z = getElementBoneRotation (localPlayer, boneId) outputChatBox ("The bone rotation is: "..x..", "..y..", "..z) end addCommandHandler ("getbonerotation", getBoneRotation)
Example 2
This example takes the current rotation of all player bones. by ThigasDEV
local settings = { copyDiscord = false; -- true = "yes" // false = "no" - Copy to paste table in discord format. tableName = "bonesPos"; -- Table name to be copied. } local boneIDs = {0, 1, 2, 3, 4, 5, 6, 7, 8, 21, 22, 23, 24, 25, 26, 31, 32, 33, 34, 35, 36, 41, 42, 43, 44, 51, 52, 53, 54, 201, 301, 302} addCommandHandler ("getbonerotation", function () local bonesPositions = { } local bonesConverted = "" for _, v in ipairs (boneIDs) do local x, y, z = getElementBoneRotation (localPlayer, v) table.insert (bonesPositions, "["..v.."] = {"..x..", "..y..", "..z.."};") end for i, v in ipairs (bonesPositions) do bonesConverted = " "..bonesConverted.."\n".." "..v end setClipboard ((settings["copyDiscord"] and "```lua\nlocal "..string.gsub(settings["tableName"], " ", "_").." = {"..bonesConverted.."\n}\n```" or "local "..string.gsub(settings["tableName"], " ", "_").." = {"..bonesConverted.."\n}")) outputChatBox ("Copy to clipboard.") 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