Jump to content
    1. Welcome to GTAForums!

    1. GTANet.com

    1. GTA Online

      1. The Criminal Enterprises
      2. Updates
      3. Find Lobbies & Players
      4. Guides & Strategies
      5. Vehicles
      6. Content Creator
      7. Help & Support
    2. Red Dead Online

      1. Blood Money
      2. Frontier Pursuits
      3. Find Lobbies & Outlaws
      4. Help & Support
    3. Crews

    1. Grand Theft Auto Series

      1. Bugs*
      2. St. Andrews Cathedral
    2. GTA VI

    3. GTA V

      1. Guides & Strategies
      2. Help & Support
    4. GTA IV

      1. The Lost and Damned
      2. The Ballad of Gay Tony
      3. Guides & Strategies
      4. Help & Support
    5. GTA San Andreas

      1. Classic GTA SA
      2. Guides & Strategies
      3. Help & Support
    6. GTA Vice City

      1. Classic GTA VC
      2. Guides & Strategies
      3. Help & Support
    7. GTA III

      1. Classic GTA III
      2. Guides & Strategies
      3. Help & Support
    8. Portable Games

      1. GTA Chinatown Wars
      2. GTA Vice City Stories
      3. GTA Liberty City Stories
    9. Top-Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    1. Red Dead Redemption 2

      1. PC
      2. Help & Support
    2. Red Dead Redemption

    1. GTA Mods

      1. GTA V
      2. GTA IV
      3. GTA III, VC & SA
      4. Tutorials
    2. Red Dead Mods

      1. Documentation
    3. Mod Showroom

      1. Scripts & Plugins
      2. Maps
      3. Total Conversions
      4. Vehicles
      5. Textures
      6. Characters
      7. Tools
      8. Other
      9. Workshop
    4. Featured Mods

      1. Design Your Own Mission
      2. OpenIV
      3. GTA: Underground
      4. GTA: Liberty City
      5. GTA: State of Liberty
    1. Rockstar Games

    2. Rockstar Collectors

    1. Off-Topic

      1. General Chat
      2. Gaming
      3. Technology
      4. Movies & TV
      5. Music
      6. Sports
      7. Vehicles
    2. Expression

      1. Graphics / Visual Arts
      2. GFX Requests & Tutorials
      3. Writers' Discussion
      4. Debates & Discussion
    1. Announcements

    2. Support

    3. Suggestions

*DO NOT* SHARE MEDIA OR LINKS TO LEAKED COPYRIGHTED MATERIAL. Discussion is allowed.

access hierarchy of bones


mshooter
 Share

Recommended Posts

mshooter

Hi, 

 

is there a way to access the parent or children of a certain bone? 

Edit: I am using C# 

Thanks for the help!

Edited by mshooter
forgot to specify which languange im programming
Link to comment
Share on other sites

1 hour ago, mshooter said:

Hi, 

 

is there a way to access the parent or children of a certain bone? 

Edit: I am using C# 

Thanks for the help!

 

There is a dismemberment mod that uses a C++ ASI file to disable bone drawing for limbs, so I suspect the ASI file can do it but it involves memory accessing and there is no source available for it.  There are no natives that do it as far as I know of.

 

 

 

Link to comment
Share on other sites

1 hour ago, mshooter said:

Thanks for answering!

 

If it's for Peds then you could export a ped YMT file to .skel using OpenIV and convert the information in there into your own hierarchy lookup system. The skel file will show you the bone name, its ID and the number of children it has and which bones they are.

 

All peds have the same skeleton and Bone IDs, so once you have it for one, it will work for all peds.

Edited by LeeC22
Link to comment
Share on other sites

mshooter

Im not familiar with what look up system I should use. I was maybe thinking of using a tree data structure ? (C#)
I am also currently or would like to access the information related to the the transforms (translation, rotation) of the children relative to the parent with the .skel format would that be possible ?

Link to comment
Share on other sites

1 hour ago, mshooter said:

Im not familiar with what look up system I should use. I was maybe thinking of using a tree data structure ? (C#)
I am also currently or would like to access the information related to the the transforms (translation, rotation) of the children relative to the parent with the .skel format would that be possible ?

 

A tree structure would work fine as the data is very similar to the Node data in a TreeView control. Or you could create a simple BoneStruct that contained a Parent boneIndex and a List of Child boneIndexes and then store that in a Dictionary<int, BoneStruct> where the int key is the BoneIndex. Or you could use a Dictionry<string, BoneStruct> and use the bone name. There are a few options so it's a case of choosing the one that you feel most comfortable with

 

You can get the default offsets for position and rotation from the .skel file but if you wanted that information in realtime you can get the bone position in the world, and there are two rotation natives _GET_ENTITY_BONE_ROTATION and _GET_ENTITY_BONE_ROTATION_LOCAL. There is also a _GET_ENTITY_BONE_POSITION_2 native and that might be the LOCAL version of the position. I can't confirm that as I have never used that native. If it doesn't then you can get the relative position using Ped.GetOffsetFromWorldCoords(BoneWorldPosition)

 

Link to comment
Share on other sites

mshooter

Thank you very much, I’m going to try it out by tomorrow and let you know if I figured it out! Really appreciate your help 

Link to comment
Share on other sites

mshooter
Posted (edited)
23 hours ago, LeeC22 said:

 

A tree structure would work fine as the data is very similar to the Node data in a TreeView control. Or you could create a simple BoneStruct that contained a Parent boneIndex and a List of Child boneIndexes and then store that in a Dictionary<int, BoneStruct> where the int key is the BoneIndex. Or you could use a Dictionry<string, BoneStruct> and use the bone name. There are a few options so it's a case of choosing the one that you feel most comfortable with

 

You can get the default offsets for position and rotation from the .skel file but if you wanted that information in realtime you can get the bone position in the world, and there are two rotation natives _GET_ENTITY_BONE_ROTATION and _GET_ENTITY_BONE_ROTATION_LOCAL. There is also a _GET_ENTITY_BONE_POSITION_2 native and that might be the LOCAL version of the position. I can't confirm that as I have never used that native. If it doesn't then you can get the relative position using Ped.GetOffsetFromWorldCoords(BoneWorldPosition)

 

Ok, so I have been successful with what you have suggested. 

However, I am struggling in getting the local position, are you sure you can the local position of the bones from the Ped.GetOffsetFromWorldCoords() Function? 

Meaning it will give me the local position (vector3) ?  

Edited by mshooter
Link to comment
Share on other sites

1 hour ago, mshooter said:

However, I am struggling in getting the local position, are you sure you can the local position of the bones from the Ped.GetOffsetFromWorldCoords() Function? 

Meaning it will give me the local position (vector3) ?

 

It will give you a position based on the Ped being the origin. The Ped's origin is based on the root bone, so getting a bone world position as an offset from the ped will give you a local value relative to the ped's origin. Is that not what you expected to get back? So if the ped is at 1000,1000,10 and the hand is at 1000,1001,11 you will get a value back of 0,1,1

 

Maybe my interpretation of what you meant by local is different to what you needed to get back.

 

Edit: Thinking about it... maybe you don't want the position relative to the ped's direction, which is what GetOffsetFromWorldCoords() will do. You can always subtract the ped's position from the bone world position and that will give you an offset based on world positions alone, without taking the ped's direction into account.

Edited by LeeC22
Link to comment
Share on other sites

mshooter

Great thanks! 

Last question: 

So the ultimate goal is to export a .bvh file (motion sequence)

It's giving me something when the Ped is static, however I think I am doing something wrong with the rotations, the order should be CHANNELS 3 Z Y X. 

I know I should convert the X,Y,Z rotations to Z,Y,X; but when I just change the order it doesn't work.  

Would you know if there is a formula? 

 

 

Link to comment
Share on other sites

15 minutes ago, mshooter said:

It's giving me something when the Ped is static, however I think I am doing something wrong with the rotations, the order should be CHANNELS 3 Z Y X. 

I know I should convert the X,Y,Z rotations to Z,Y,X; but when I just change the order it doesn't work.  

 

That's probably connected to Rotation Order, which isn't something I have any real experience with. For Entity rotations, sych as Peds and Vehicles, you can specify the rotation order when you get and set the rotations but there doesn't seem to be a parameter for that with bone rotations. That means you are probably going to need to find an algorithm to convert to a different rotation order and I am afraid that's something I can't help with. It's probably very simple but my maths knowledge with that kind of thing is pretty much non-existent.

Link to comment
Share on other sites

mshooter

I have found something on the internet which will change the order hopefully :)

But thank you for the other feedback! really helped me

Link to comment
Share on other sites

mshooter

does anyone know which rotation order GTA has? 

or can someone tell me what the _GET_ENTITY_BONE_ROTATION_LOCAL exactly returns? (what I know it returns a Vector3 with angels in degrees) 

Link to comment
Share on other sites

mshooter
Posted (edited)

Ok so i found out that the function does not return what I expect. 

I have tested a ped which moves it's arm around the x-axis from 0 degrees to 90. I would normally expect from the function a Vector3 where the X-axis is changing and the Y-axis and Z-axis values are not, they stay 0. 

However, when I use the native _GET_ENTITY_BONE_ROTATION_LOCAL it does not return the expected values. 

It gives float numbers for all 3 which range between:

for the x-axis: -34 to -35 (floating numbers with decimals)

for the y-axis:  98 and 98 (floating numbers with decimals)

for the z-axis: 4.something values

 

Now this is why I am asking are these values supposed to be in degrees? or am I missing something 

 

EDIT: 

I did more testing -> where I change solely the Y-axis and then solely the Z-axis too. 

no matter if i rotate the bone from 0-90 around any axis, the third value of the vector3 changes and the first value and second value doesn't. 

does anyone know what this means?

 

Edited by mshooter
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • 1 User Currently Viewing
    0 members, 0 Anonymous, 1 Guest

×
×
  • Create New...

Important Information

By using GTAForums.com, you agree to our Terms of Use and Privacy Policy.