playing with model_t Created 6 years ago2018-01-21 02:17:09 UTC by tschumann tschumann

Created 6 years ago2018-01-21 02:17:09 UTC by tschumann tschumann

Posted 6 years ago2018-01-21 02:17:09 UTC Post #338695
Anyone played much with the model_t data structure in client.dll? I'm looking at it wondering if I can access raw texture data for a model/sprite/whatever. The texture_t struct has an offets array and a paloffset attribute (not sure what they index into) but no obvious raw pixel data.
Posted 6 years ago2018-01-21 04:17:46 UTC Post #338699
Okay so I've played around a bit and it looks like the textures field in model_t is only populated for mod_brush models (nothing for mod_studio, mod_sprite or mod_alias).

Basically I was trying to access raw texture data for arbitrary model types but it doesn't look like it is exposed at all.
It's possible to get a .mdl file's studiohdr_t with engine_studio_api_t.Mod_Extradata (I assume server_studio_api_t.Mod_Extradata does the same thing) but I got garbage data when trying to access mstudiotexture_t *pTextures = (mstudiotexture_t *)((void *)pHdr) + pHdr->textureindex;
Mod_Extradata doesn't seem to work on non-mod_studio models either.
Posted 6 years ago2018-01-21 11:23:59 UTC Post #338701
If studiohdr_t::textureindex is 0 then the textures were loaded from a T.mdl, which is apparently stored in model_t::texinfo.

This is an mtexinfo_t pointer, but actually stores a model_t*, and contains the texture data. You need to call Mod_Extradata on this model to get the studiohdr_t* that contains the texture data.

Unfortunately, it seems that Mod_LoadStudioModel doesn't save the actual texture data.
It only copies the model data up to where the texture data starts (texturedataindex is a byte offset into the file, effectively the size of the file up until the texture data), so even if you do get the texture header it'll still crash if you try to use it.

You'll have to manually load the file again if you want the texture data.
Posted 6 years ago2018-01-22 10:04:48 UTC Post #338711
Yeah I thought so - too bad, I was wondering if it was possible to modify texture data from game code, but I guess it isn't.
You must be logged in to post a response.