Changing prop models dynamically: Difference between revisions
HenryDorsett (talk | contribs) (Created page with "PLACEHOLDER!! (Intro goes here) == Modifying the Source Code == Our knowledgebase of technical information about using the engine and all of the related tools is posted on a co...") |
HenryDorsett (talk | contribs) No edit summary |
||
Line 1: | Line 1: | ||
PLACEHOLDER!! | PLACEHOLDER!! | ||
( | One of the major issues I've seen with the Source engine (and with most engines) is the inability to change the model of a prop on-the-fly. Why is this a problem? Well, presently, the issue, for me, has to do with lights, as most of my issues tend to be. In this case, I have a light fixture that's red at one point, but needs to be changed to white when the light being emitted is also changed. | ||
But wait, why not just make another skin for the model? Because that doesn't cover alternate cases, when I want a completely different model. Moving on. | |||
I was pleasantly surprised to find that this is incredibly easy, as things go. It's just small change to a few places, some copy/paste of Valve's existing code, and BAM!, it's done. So, here's the solution: | |||
== Modifying the Source Code == | == Modifying the Source Code == | ||
First, open up <code>game/server/props.h</code>. Find <code>class CBaseProp : public CBaseAnimating</code> and replace the entire class declaration with this: | |||
<source lang="cpp">class CBaseProp : public CBaseAnimating | |||
{ | |||
public: | |||
DECLARE_CLASS( CBaseProp, CBaseAnimating ); | |||
DECLARE_DATADESC(); | |||
void Spawn( void ); | |||
void Precache( void ); | |||
void Activate( void ); | |||
bool KeyValue( const char *szKeyName, const char *szValue ); | |||
void CalculateBlockLOS( void ); | |||
int ParsePropData( void ); | |||
void DrawDebugGeometryOverlays( void ); | |||
void InputSetModel( inputdata_t &inputdata ); | |||
// Don't treat as a live target | |||
virtual bool IsAlive( void ) { return false; } | |||
virtual bool OverridePropdata() { return true; } | |||
};</source> |
Revision as of 15:50, 8 October 2013
PLACEHOLDER!!
One of the major issues I've seen with the Source engine (and with most engines) is the inability to change the model of a prop on-the-fly. Why is this a problem? Well, presently, the issue, for me, has to do with lights, as most of my issues tend to be. In this case, I have a light fixture that's red at one point, but needs to be changed to white when the light being emitted is also changed.
But wait, why not just make another skin for the model? Because that doesn't cover alternate cases, when I want a completely different model. Moving on.
I was pleasantly surprised to find that this is incredibly easy, as things go. It's just small change to a few places, some copy/paste of Valve's existing code, and BAM!, it's done. So, here's the solution:
Modifying the Source Code
First, open up game/server/props.h
. Find class CBaseProp : public CBaseAnimating
and replace the entire class declaration with this:
class CBaseProp : public CBaseAnimating
{
public:
DECLARE_CLASS( CBaseProp, CBaseAnimating );
DECLARE_DATADESC();
void Spawn( void );
void Precache( void );
void Activate( void );
bool KeyValue( const char *szKeyName, const char *szValue );
void CalculateBlockLOS( void );
int ParsePropData( void );
void DrawDebugGeometryOverlays( void );
void InputSetModel( inputdata_t &inputdata );
// Don't treat as a live target
virtual bool IsAlive( void ) { return false; }
virtual bool OverridePropdata() { return true; }
};