mshooter Posted July 11 Share Posted July 11 (edited) 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 July 11 by mshooter forgot to specify which languange im programming Link to comment Share on other sites More sharing options...
LeeC22 Posted July 11 Share Posted July 11 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 More sharing options...
mshooter Posted July 11 Author Share Posted July 11 Thanks for answering! LeeC22 1 Link to comment Share on other sites More sharing options...
LeeC22 Posted July 11 Share Posted July 11 (edited) 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 July 11 by LeeC22 mshooter 1 Link to comment Share on other sites More sharing options...
mshooter Posted July 13 Author Share Posted July 13 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 More sharing options...
LeeC22 Posted July 13 Share Posted July 13 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) mshooter 1 Link to comment Share on other sites More sharing options...
mshooter Posted July 13 Author Share Posted July 13 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 LeeC22 1 Link to comment Share on other sites More sharing options...
mshooter Posted July 14 Author Share Posted July 14 (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 July 14 by mshooter Link to comment Share on other sites More sharing options...
LeeC22 Posted July 14 Share Posted July 14 (edited) 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 July 14 by LeeC22 Link to comment Share on other sites More sharing options...
mshooter Posted July 14 Author Share Posted July 14 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 More sharing options...
LeeC22 Posted July 14 Share Posted July 14 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. mshooter 1 Link to comment Share on other sites More sharing options...
mshooter Posted July 14 Author Share Posted July 14 I have found something on the internet which will change the order hopefully But thank you for the other feedback! really helped me LeeC22 1 Link to comment Share on other sites More sharing options...
mshooter Posted July 19 Author Share Posted July 19 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 More sharing options...
mshooter Posted July 25 Author Share Posted July 25 (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 July 25 by mshooter Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now