• How/where to get a list of all available bones for Player/NPC?
    4 replies, posted
Hello. I can't figure this out, so, how or where can I find a list of all available bones for entity such as player or non-playable-character (NPC)? I have searched google and wikis, and I found nothing about this; just copy/pastes of several without explanation. I think I have bones for player already, there are 23 of them. I really want to know where they come from, where are they defined exactly? If they are somewhere in Source SDK (a guess), please tell me the full path to the file(s) containing them (but for NPCs). Thanks in advance.
[QUOTE=OmegaExtern;46195277]Hello. I can't figure this out, so, how or where can I find a list of all available bones for entity such as player or non-playable-character (NPC)? I have searched google and wikis, and I found nothing about this; just copy/pastes of several without explanation. I think I have bones for player already, there are 23 of them. I really want to know where they come from, where are they defined exactly? If they are somewhere in Source SDK (a guess), please tell me the full path to the file(s) containing them (but for NPCs). Thanks in advance.[/QUOTE] They are defined within the model, not every model has the same number of bones or even the same names for bones (some stupid models have their hands named as feet, and worse). You should be fine using default models though, it's mainly custom models that I've seen with stupid bone layouts. You could use the hlmv.exe (should in garrysmod/bin) to view the models. In game you can check all the bones using :LookupBone() and :GetBoneCount(). This example prints all the bones of the local player. [lua]local ply = LocalPlayer() local BoneCount = ply:GetBoneCount() for i=0,BoneCount-1 do local BoneName = ply:LookupBone(i) local BonePos,BoneAngle = ply:GetBonePosition() print("Bone",i,BoneName,BonePos,BoneAngle) end[/lua]
[QUOTE=wh1t3rabbit;46195397]They are defined within the model, not every model has the same number of bones or even the same names for bones (some stupid models have their hands named as feet, and worse). You should be fine using default models though, it's mainly custom models that I've seen with stupid bone layouts. You could use the hlmv.exe (should in garrysmod/bin) to view the models. In game you can check all the bones using :LookupBone() and :GetBoneCount(). This example prints all the bones of the local player. local ply = LocalPlayer()local BoneCount = ply:GetBoneCount()for i=0,BoneCount-1 do local BoneName = ply:LookupBone(i) local BonePos,BoneAngle = ply:GetBonePosition() print("Bone",i,BoneName,BonePos,BoneAngle)end [/QUOTE] Thank you for your quick reply. I am wondering, why does bone count start from zero instead 1?
[QUOTE=OmegaExtern;46195449]Thank you for your quick reply. I am wondering, why does bone count start from zero instead 1?[/QUOTE] Because it just does :downs: This is just a guess, but I'd say its because it makes calls to the C code and arrays starts at 0 in C but 1 in Lua.
[QUOTE=wh1t3rabbit;46195504]Because it just does :downs: This is just a guess, but I'd say its because it makes calls to the C code and arrays starts at 0 in C but 1 in Lua.[/QUOTE] Perhaps, that only makes sense to me, okay. But, your code resulted in errors... I have searched wikis better this time and figured it, here is my code: [LUA] local ply = LocalPlayer() print('List of bones (i, name, index, position, angle):') for i = 0, ply:GetBoneCount() - 1 do local boneName = ply:GetBoneName(i) local boneIndex = ply:LookupBone(boneName) local bonePos, boneAng = ply:GetBonePosition(boneIndex) print(i, boneName, boneIndex, bonePos, boneAng) end [/LUA] Thanks for your time :)
Sorry, you need to Log In to post a reply to this thread.