dynamically scaling a model Created 6 years ago2018-08-25 08:31:46 UTC by tschumann tschumann

Created 6 years ago2018-08-25 08:31:46 UTC by tschumann tschumann

Posted 6 years ago2018-08-25 08:31:46 UTC Post #340654
Is it possible in GoldSource to dynamically scale a model? I tried playing with pev->scale but it looks like it's only for sprites.
There's a tutorial from the old VERC about fatboy mode which does some hacking in the client-side model rendering code to scale models but if there's a simpler solution that would be better.
Posted 6 years ago2018-08-25 11:02:44 UTC Post #340656
Check Spirit. I recall Laurie saying you could use calc_ratio to dynamically scale Barney's size according to his health.
Posted 6 years ago2018-08-26 12:31:17 UTC Post #340679
Talking about vanilla HL, I have never seen it done. I think it could be done by animating it, if it's simple enough you might even be able to control it's scale with a controller but I know little about models.
Posted 6 years ago2018-08-26 14:30:02 UTC Post #340683
The Studio model renderer that comes with the vanilla HL doesn't account for the networked scale variable (pev->scale). If I recall correctly all you have to do is multiply the bone rotation matrix in CStudioModelRenderer::StudioSetupBones() by the scale value. That's probably the easiest way to get this working. It will scale the model, but if scaled NPCs are what you are after, you will have to make more changes.

Depending on the situation, custom animation or bone controller might be a better option as Bruce suggested.
Posted 6 years ago2018-08-26 14:35:23 UTC Post #340684
gargantua dies with dynamic scaling.
i remember i tried to use this i remember when i shot barney hes getting big.
but i could not find the code now.
Posted 6 years ago2018-08-26 15:02:04 UTC Post #340685
The Garg effect (kRenderFxExplode) is hardcoded in the engine and in CStudioModelRenderer::StudioFxTransform().
Posted 6 years ago2018-08-27 11:02:46 UTC Post #340689
what about bounding box and hitboxes? can we change or are they hardcoded too?
Posted 6 years ago2018-08-28 10:53:42 UTC Post #340706
Thanks all - I want to be able to scale in-game so a QC $scale or bone controller aren't an option.
@GeckonCZ so I guess at the end of CStudioModelRenderer::StudioSetupBones I should do something like this:
(*m_pbonetransform)[i][0][1] *= scale;
(*m_pbonetransform)[i][1][1] *= scale;
(*m_pbonetransform)[i][2][1] *= scale;
where scale is available somewhere in CStudioModelRenderer?
I'm okay with just a bigger looking model but it's simple enough to scale the bounding box on the server I think (not sure about hitboxes).
Posted 6 years ago2018-08-29 01:45:31 UTC Post #340728
You want to multiply the matrix before you start concatenating the transformations, so put it before the last last for loop in that function.

The scale value is networked and you can get it from the m_pCurrentEntity->curstate structure. Something like this should do the trick:
for ( int i = 0; i < 3; i++ )
	for ( int j = 0; j < 3; j++ )
		( * m_protationmatrix )[ i ][ j ] *= m_pCurrentEntity->curstate.scale;
Posted 6 years ago2018-08-31 22:08:14 UTC Post #340755
Thanks, I'll give that a go.
Posted 6 years ago2018-09-09 05:42:59 UTC Post #340822
Many thanks - it worked.
There was one change that was required and that was to check that the value of scale was greater than 0 as it seems weapon and player models have a scale of 0 by default.
You must be logged in to post a response.