Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

New bone functions and onClientPedsProcessed event #1673

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
9 commits merged into multitheftauto:master from codenulls:bonesmanipulation
Oct 27, 2020

Conversation

@ghost
Copy link

@ghost ghost commented Sep 24, 2020
edited by ghost
Loading

Video: https://cdn.discordapp.com/attachments/366384007535001612/758487499517198366/2020-09-24_05-36-42.mp4

This PR adds a new event and 8 new functions:

onClientPedsProcessed 

This new event also fixes the issue with bone frame delay #465

bool setElementBonePosition (element theElement, int boneId, float x, float y, float z)
bool setElementBoneRotation (element theElement, int boneId, float yaw, float pitch, float roll)
float x, float y, float z getElementBonePosition (element theElement, int boneId)
float yaw, float pitch, float roll getElementBoneRotation (element theElement, int boneId)
bool setElementBoneMatrix (element theElement, int boneId, matrix theMatrix)
matrix getElementBoneMatrix (element theElement, int boneId) 
void updateElementRpHAnim(element theElement)

setElementBonePosition allows you to set the translation values for the bone.
setElementBoneRotation allows you to set the orientation values for the bone.
setElementBoneMatrix allows you to set the bone world matrix.

updateElementRpHAnim should be called after setElementBoneRotation. This is a bit heavy function, so it should be only called after you are completely done with rotating bones.

You can rotate a ped head vertically, like this:

local pitch = 0 
addEventHandler ( "onClientPedsProcessed", root,
function ()
 pitch = pitch + 3
 if pitch > 360 then pitch = 0 end
 local BONE_HEAD = 5
 setElementBoneRotation(localPlayer, BONE_HEAD, 0, pitch, 0)
 updateElementRpHAnim(localPlayer)
end)
complete list of ped bone ids (32 bones)
BONE_NORMAL = 0 // Normal or Root both are same
BONE_PELVIS = 1
BONE_SPINE = 2
BONE_SPINE1 = 3
BONE_NECK = 4
BONE_HEAD = 5
BONE_L_BROW = 6
BONE_R_BROW = 7
BONE_JAW = 8
BONE_L_CLAVICLE = 31
BONE_L_UPPER_ARM = 32
BONE_L_FORE_ARM = 33
BONE_L_HAND = 34
BONE_L_FINGER = 35
BONE_L_FINGER_01 = 36
BONE_R_CLAVICLE = 21
BONE_R_UPPER_ARM = 22
BONE_R_FORE_ARM = 23
BONE_R_HAND = 24
BONE_R_FINGER = 25
BONE_R_FINGER_01 = 26
BONE_L_BREAST = 302
BONE_R_BREAST = 301
BONE_BELLY = 201
BONE_L_THIGH = 41
BONE_L_CALF = 42
BONE_L_FOOT = 43
BONE_L_TOE_0 = 44
BONE_R_THIGH = 51
BONE_R_CALF = 52
BONE_R_FOOT = 53
BONE_R_TOE_0 = 54

I am thinking of creating a new function to get LTMs (Local Transformation Matrix) of bones. This will make it easy for people to implement their own animation system that they use to animate their models from Lua. A shader can be used for matrix multiplication, and this will give a very good performance boost. GTA SA doesn't use a shader for skinning, and that's why multiple animating peds will cause FPS drop when they are streamed in. Adding an additional function to disable GTA SA skinning to save performance would also be nice since it's very slow as it relies on the CPU for skinning rather than the GPU. Nonetheless, it would be only useful for people who want to implement a custom skeletal animation system.

StrixG, CrosRoad95, Disinterpreter, Shuubaru, zo3n, Dutchman101, christophercampbell1, AlexTMjugador, Vadya963, xLive, and 12 more reacted with thumbs up emoji AlexTMjugador, jayceon123, CrosRoad95, Shuubaru, Einheit-101, PlatinMTA, mahlukat5, lex128, and jey-banned reacted with hooray emoji Shuubaru, Dutchman101, christophercampbell1, AlexTMjugador, jayceon123, AlexRazor1337, CrosRoad95, Einheit-101, PlatinMTA, lex128, and jey-banned reacted with heart emoji AlexTMjugador, jayceon123, CrosRoad95, Shuubaru, Einheit-101, PlatinMTA, T-MaxWiese-T, lex128, and jey-banned reacted with rocket emoji
@StrixG StrixG added the enhancement New feature or request label Sep 24, 2020
@StrixG StrixG added this to the Backlog milestone Sep 24, 2020
Copy link

My goodness, you are a LORD!

tut001, StrixG, Einheit-101, and PlatinMTA reacted with thumbs up emoji CrosRoad95 reacted with thumbs down emoji jey-banned reacted with heart emoji

Copy link
Contributor

Thanks for this PR 🥇

Einheit-101 and PlatinMTA reacted with thumbs up emoji

all functions seem to work properly now..
Copy link
Contributor

Damn this is huge, good work

Copy link
Author

ghost commented Sep 29, 2020

I did some more research and figured out a way to rotate all 32 bones. It seems to work fine. I removed setPedNodeOrientation and replaced it with setElementBoneRotation. When you rotate a bone, the child bones will also be affected. The API is much cleaner now. Check the first post for more detailed info. Now I just need to clean up the code and the PR is complete.

Copy link
Contributor

Pirulax commented Sep 29, 2020

@saml1er Lemme know if I can help with anything.

Copy link
Author

ghost commented Sep 30, 2020

@saml1er Lemme know if I can help with anything.

Sure, I'll let you know if I need help with something.

@ghost ghost marked this pull request as ready for review October 1, 2020 00:21
Copy link
Author

ghost commented Oct 1, 2020

This took a lot more work than I expected. The PR is finally complete. I modified the argument parser for the PR because I wanted to add support for CMatrix. It works, but I'm not sure if I've done it properly.

@ghost ghost linked an issue Oct 6, 2020 that may be closed by this pull request
Comment on lines 33 to 38
if (AllocConsole())
{
freopen("CONIN$", "r", stdin);
freopen("CONOUT$", "w", stdout);
freopen("CONOUT$", "w", stderr);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is really useful we really need to just have this run in master when we're in Debug mode

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, and it's also much faster than MTA's GUI console.

@ghost ghost changed the title (削除) Bone orientation and translation and update bone matrices and new event (削除ここまで) (追記) New bone functions and onClientPedsProcessed event (追記ここまで) Oct 27, 2020
@ghost ghost modified the milestones: Confirmed Issues, 1.6 Oct 27, 2020
@ghost ghost merged commit b2b7ef9 into multitheftauto:master Oct 27, 2020
@ghost ghost deleted the bonesmanipulation branch November 30, 2020 22:01
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

enhancement New feature or request

Projects

None yet

Milestone

1.5.9

AltStyle によって変換されたページ (->オリジナル) /