model_header values ?

General discussion for off-topic subjects.
Speed0x
Member
Posts: 84
Joined: Sun Feb 05, 2017 4:55 pm

model_header values ?

Postby Speed0x » Fri Oct 30, 2020 9:49 pm

hey i've checked the bone structure for playermodels, but when i receive the bones it gives me the same values on position and euler values for all models ? ( as if this function only reads the data for one specific type of model ? )

this is how i received the data:

Code: Select all

header = player.model_header
bone = header.get_bone(x)
Speed0x
Member
Posts: 84
Joined: Sun Feb 05, 2017 4:55 pm

Re: model_header values ?

Postby Speed0x » Fri Oct 30, 2020 11:04 pm

Code: Select all

print(model_cache.find_model("player/custom_player/legacy/ctm_idf_variante.mdl"))
print(model_cache.find_model("models/player/custom_player/legacy/tm_leet_variantC.mdl"))
print(model_cache.find_model("player/custom_player/legacy/tm_leet_variantC.mdl"))

681
1125
680

print(model_cache.get_model_header(model_cache.find_model("models/player/custom_player/legacy/ctm_idf_variantE.mdl")))
print(model_cache.get_model_header(model_cache.find_model("player/custom_player/legacy/ctm_idf_variante.mdl")))
print(model_cache.get_model_header(model_cache.find_model("models/player/custom_player/legacy/tm_leet_variantC.mdl")))


<_studio.ModelHeader object at 0x48269A98>
<_studio.ModelHeader object at 0x48269A98>
<_studio.ModelHeader object at 0x48269A98>

https://github.com/Source-Python-Dev-Te ... ap.cpp#L73
Speed0x
Member
Posts: 84
Joined: Sun Feb 05, 2017 4:55 pm

Re: model_header values ?

Postby Speed0x » Fri Oct 30, 2020 11:25 pm

Code: Select all

print(model_cache.get_model_header(model_cache.find_model("models/player/custom_player/legacy/ctm_idf_variantE.mdl")).id)
print(model_cache.get_model_header(model_cache.find_model("models/player/custom_player/legacy/tm_leet_variantC.mdl")).id)
print(model_cache.get_model_header(model_cache.find_model("models/player/custom_player/legacy/ctm_idf_variantE.mdl")).name)
print(model_cache.get_model_header(model_cache.find_model("models/player/custom_player/legacy/tm_leet_variantC.mdl")).name)

1414743113
1414743113
player/custom_player/legacy/ctm_idf_variante.mdl
player/custom_player/legacy/tm_leet_variantC.mdl


https://github.com/Source-Python-Dev-Te ... ap.cpp#L79
Speed0x
Member
Posts: 84
Joined: Sun Feb 05, 2017 4:55 pm

Re: model_header values ?

Postby Speed0x » Fri Oct 30, 2020 11:54 pm

maybe this has to do with unexposed methods for modelcache? perhaps each model_header needs to be "loaded" into the shared header separately ? does anyone know what "mode_cachel.add_reference" does ? or what "mode_cachel.release" does ? it seems a bit like each modelheader has to be initiated ? but maybe i am just going off track here because i am desparate to find a solution ... lol
Speed0x
Member
Posts: 84
Joined: Sun Feb 05, 2017 4:55 pm

Re: model_header values ?

Postby Speed0x » Sat Oct 31, 2020 12:30 am

looking at this :
https://github.com/VSES/SourceEngine200 ... .cpp#L2001

it seems that the header i get from sourcepython should be a correct cached studiohdr object. but why are then all the bone values the same for each header?

maybe i am receiving only the "last" cached player object of that studioobject type from within the cache as it looks like it only returns a single variable ? ...

https://github.com/VSES/SourceEngine200 ... e.cpp#L363
User avatar
L'In20Cible
Project Leader
Posts: 1533
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Re: model_header values ?

Postby L'In20Cible » Sat Oct 31, 2020 2:49 am

Speed0x wrote:hey i've checked the bone structure for playermodels, but when i receive the bones it gives me the same values on position and euler values for all models ? ( as if this function only reads the data for one specific type of model ? )

Why do you expect them to be different? The skeletal structure is usually the same for all player models, what is likely to change are the poses and/or animations.
Speed0x
Member
Posts: 84
Joined: Sun Feb 05, 2017 4:55 pm

Re: model_header values ?

Postby Speed0x » Sat Oct 31, 2020 3:09 am

Why do you expect them to be different?

that's what i was wondering... when i calculated them ingame they were only aligning for some models... when i check in studiomdl the idle animation of both models ( modelviewer csgo:sdk ) bones LOOK different. but perhaps that derives from the animation.
bones.jpg
bones.jpg (37.56 KiB) Viewed 14344 times


i am trying to calculate the current boneposition of a player. but i don't want to go through reading the animation sequence data, keep track of it and then recalculate the current bone position for each tick from that....

isn't there some function exposed for this from within the game ? ( getting current bone positions )
User avatar
L'In20Cible
Project Leader
Posts: 1533
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Re: model_header values ?

Postby L'In20Cible » Sat Oct 31, 2020 3:17 am

Speed0x wrote:
Why do you expect them to be different?

that's what i was wondering... when i calculated them ingame they were only aligning for some models... when i check in studiomdl the idle animation of both models ( modelviewer csgo:sdk ) bones LOOK different. but perhaps that derives from the animation.
bones.jpg

i am trying to calculate the current boneposition of a player. but i don't want to go through reading the animation sequence data, keep track of it and then recalculate the current bone position for each tick from that....

isn't there some function exposed for this from within the game ? ( getting current bone positions )

I think the default bone positions are not their idling stance, but their T pose they get when they hold no weapons. There is no built-in way to achieve that, but you can do so with GetBoneTransform as discussed in the following thread: viewtopic.php?f=20&t=1638&p=10878
Speed0x
Member
Posts: 84
Joined: Sun Feb 05, 2017 4:55 pm

Re: model_header values ?

Postby Speed0x » Sat Oct 31, 2020 3:34 am

I think the default bone positions are not their idling stance, but their T pose they get when they hold no weapons


with "idle" i meant "default" in the sequence tab of SDK.

i think the problem is that in my code i am just reading default mdl file bone positions... not "in world" bones positions...

but with the link : i am not looking to get the weapon muzzle flash position. i know how to workaround that... i was wondering if the engine had a way to access all active current bones positions. i think "CBaseAnimating::GetBoneTransform" looks like the right approach. as you suggested taking into account animations... did that code work?
User avatar
L'In20Cible
Project Leader
Posts: 1533
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Re: model_header values ?

Postby L'In20Cible » Sat Oct 31, 2020 3:52 am

Speed0x wrote:
I think the default bone positions are not their idling stance, but their T pose they get when they hold no weapons


with "idle" i meant "default" in the sequence tab of SDK.

i think the problem is that in my code i am just reading default mdl file bone positions... not "in world" bones positions...

but with the link : i am not looking to get the weapon muzzle flash position. i know how to workaround that... i was wondering if the engine had a way to access all active current bones positions. i think "CBaseAnimating::GetBoneTransform" looks like the right approach. as you suggested taking into account animations... did that code work?

The first step to get the muzzle position was to offset the weapon from the hand of the player, so if you look through the following code: viewtopic.php?f=20&t=1638#p10920

The following should do what you are trying to achieve:

Syntax: Select all

header = player.model_header

for index in range(header.bones_count):
if header.get_bone(index).name == 'ValveBiped.Bip01_R_Hand':
break
else:
return

GetBoneTransform = player.make_virtual_function(
199, Convention.THISCALL, [DataType.POINTER, DataType.INT, DataType.POINTER],
DataType.VOID)

matrix = Matrix3x4()
GetBoneTransform(player, index, matrix)

matrix.position # current position of the player's hand bone
Speed0x
Member
Posts: 84
Joined: Sun Feb 05, 2017 4:55 pm

Re: model_header values ?

Postby Speed0x » Sat Oct 31, 2020 3:56 am

i just read the thread. it looks like we approached in the same way that i did here. which let to: just reading the base bone positions from a mdl file. but you are right, every animation moves the active bone positions. so reading the header file is no use unless we want to create the entire math from python and take the animation sequences in all its details into account, which makes no sense, when its already done via the engine in c. so there must be a function to read bone positions, probably not explicitly exposed to the server, but i'll try and dig in a little deeper
Speed0x
Member
Posts: 84
Joined: Sun Feb 05, 2017 4:55 pm

Re: model_header values ?

Postby Speed0x » Sat Oct 31, 2020 4:00 am

so the VFunction "GetBoneTransform" takes care of calculating the correct inworld-position by taking into account animations etc ? ( i am asking for comprehension as it would be done behind the scenes )
User avatar
L'In20Cible
Project Leader
Posts: 1533
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Re: model_header values ?

Postby L'In20Cible » Sat Oct 31, 2020 4:03 am

Speed0x wrote:so the VFunction "GetBoneTransform" takes care of calculating the correct inworld-position by taking into account animations etc ? ( i am asking for comprehension as it would be done behind the scenes )

Yes, it will returns the current position of the bone regardless if the player is moving, shooting, scaled, crouching, etc.
Speed0x
Member
Posts: 84
Joined: Sun Feb 05, 2017 4:55 pm

Re: model_header values ?

Postby Speed0x » Sat Oct 31, 2020 4:07 am

okay, great. is the v_index you used for css or csgo ? sorry : i didn't mention that i am testing this in csgo.. :(
User avatar
L'In20Cible
Project Leader
Posts: 1533
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Re: model_header values ?

Postby L'In20Cible » Sat Oct 31, 2020 4:33 am

Speed0x wrote:okay, great. is the v_index you used for css or csgo ? sorry : i didn't mention that i am testing this in csgo.. :(

Was for CS:S about 3 years ago.. for CS:GO, it would be something around 204 for windows and 205 for linux. Just test offsets around that and you should find it soon enough.

Return to “Whatever”

Who is online

Users browsing this forum: No registered users and 13 guests