mirror of
https://github.com/Gigaslav/HL2Overcharged.git
synced 2026-01-04 02:10:18 +03:00
Init commit
This commit is contained in:
53
game/client/AnimateSpecificTextureProxy.cpp
Normal file
53
game/client/AnimateSpecificTextureProxy.cpp
Normal file
@@ -0,0 +1,53 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: Acts exactly like "AnimatedTexture", but ONLY if the texture
|
||||
// it's working on matches the desired texture to work on.
|
||||
//
|
||||
// This assumes that some other proxy will be switching out the textures.
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
#include "cbase.h"
|
||||
#include "materialsystem/imaterialproxy.h"
|
||||
#include "materialsystem/imaterialvar.h"
|
||||
#include "materialsystem/imaterial.h"
|
||||
#include "materialsystem/itexture.h"
|
||||
#include "baseanimatedtextureproxy.h"
|
||||
#include "utlstring.h"
|
||||
#include <KeyValues.h>
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
class CAnimateSpecificTexture : public CBaseAnimatedTextureProxy
|
||||
{
|
||||
private:
|
||||
CUtlString m_OnlyAnimateOnTexture;
|
||||
public:
|
||||
virtual float GetAnimationStartTime( void* pBaseEntity ) { return 0; }
|
||||
virtual bool Init( IMaterial *pMaterial, KeyValues *pKeyValues );
|
||||
virtual void OnBind( void *pC_BaseEntity );
|
||||
virtual void Release( void ) { delete this; }
|
||||
};
|
||||
|
||||
bool CAnimateSpecificTexture::Init( IMaterial *pMaterial, KeyValues *pKeyValues )
|
||||
{
|
||||
char const* pszAnimateOnTexture = pKeyValues->GetString( "onlyAnimateOnTexture" );
|
||||
if( !pszAnimateOnTexture )
|
||||
return false;
|
||||
|
||||
m_OnlyAnimateOnTexture.Set( pszAnimateOnTexture );
|
||||
|
||||
return CBaseAnimatedTextureProxy::Init( pMaterial, pKeyValues );
|
||||
}
|
||||
|
||||
void CAnimateSpecificTexture::OnBind( void *pC_BaseEntity )
|
||||
{
|
||||
if( FStrEq( m_AnimatedTextureVar->GetTextureValue()->GetName(), m_OnlyAnimateOnTexture ) )
|
||||
{
|
||||
CBaseAnimatedTextureProxy::OnBind( pC_BaseEntity );
|
||||
}
|
||||
//else do nothing
|
||||
}
|
||||
|
||||
EXPOSE_INTERFACE( CAnimateSpecificTexture, IMaterialProxy, "AnimateSpecificTexture" IMATERIAL_PROXY_INTERFACE_VERSION );
|
||||
165
game/client/C_Env_Projected_Texture.h
Normal file
165
game/client/C_Env_Projected_Texture.h
Normal file
@@ -0,0 +1,165 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef C_ENVPROJECTEDTEXTURE_H
|
||||
#define C_ENVPROJECTEDTEXTURE_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "c_baseentity.h"
|
||||
#include "basetypes.h"
|
||||
|
||||
#ifdef ASW_PROJECTED_TEXTURES
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
class C_EnvProjectedTexture : public C_BaseEntity
|
||||
{
|
||||
DECLARE_CLASS( C_EnvProjectedTexture, C_BaseEntity );
|
||||
public:
|
||||
DECLARE_CLIENTCLASS();
|
||||
|
||||
void SetMaterial( IMaterial *pMaterial );
|
||||
void SetLightColor( byte r, byte g, byte b, byte a );
|
||||
void SetSize( float flSize );
|
||||
void SetRotation( float flRotation );
|
||||
|
||||
virtual void OnDataChanged( DataUpdateType_t updateType );
|
||||
void ShutDownLightHandle( void );
|
||||
|
||||
#ifdef MAPBASE
|
||||
virtual void Simulate();
|
||||
#else
|
||||
virtual bool Simulate();
|
||||
#endif
|
||||
|
||||
void UpdateLight( void );
|
||||
|
||||
C_EnvProjectedTexture();
|
||||
~C_EnvProjectedTexture();
|
||||
|
||||
static void SetVisibleBBoxMinHeight( float flVisibleBBoxMinHeight ) { m_flVisibleBBoxMinHeight = flVisibleBBoxMinHeight; }
|
||||
static float GetVisibleBBoxMinHeight( void ) { return m_flVisibleBBoxMinHeight; }
|
||||
static C_EnvProjectedTexture *Create( );
|
||||
|
||||
private:
|
||||
|
||||
inline bool IsBBoxVisible( void );
|
||||
bool IsBBoxVisible( Vector vecExtentsMin,
|
||||
Vector vecExtentsMax );
|
||||
|
||||
ClientShadowHandle_t m_LightHandle;
|
||||
bool m_bForceUpdate;
|
||||
|
||||
EHANDLE m_hTargetEntity;
|
||||
#ifdef MAPBASE
|
||||
bool m_bDontFollowTarget;
|
||||
#endif
|
||||
|
||||
bool m_bState;
|
||||
bool m_bAlwaysUpdate;
|
||||
float m_flLightFOV;
|
||||
#ifdef MAPBASE
|
||||
float m_flLightHorFOV;
|
||||
#endif
|
||||
bool m_bEnableShadows;
|
||||
bool m_bLightOnlyTarget;
|
||||
bool m_bLightWorld;
|
||||
bool m_bCameraSpace;
|
||||
float m_flBrightnessScale;
|
||||
color32 m_LightColor;
|
||||
Vector m_CurrentLinearFloatLightColor;
|
||||
float m_flCurrentLinearFloatLightAlpha;
|
||||
#ifdef MAPBASE
|
||||
float m_flCurrentBrightnessScale;
|
||||
#endif
|
||||
float m_flColorTransitionTime;
|
||||
float m_flAmbient;
|
||||
float m_flNearZ;
|
||||
float m_flFarZ;
|
||||
char m_SpotlightTextureName[ MAX_PATH ];
|
||||
CTextureReference m_SpotlightTexture;
|
||||
int m_nSpotlightTextureFrame;
|
||||
int m_nShadowQuality;
|
||||
#ifdef MAPBASE
|
||||
float m_flConstantAtten;
|
||||
float m_flLinearAtten;
|
||||
float m_flQuadraticAtten;
|
||||
float m_flShadowAtten;
|
||||
|
||||
bool m_bAlwaysDraw;
|
||||
//bool m_bProjectedTextureVersion;
|
||||
#endif
|
||||
|
||||
Vector m_vecExtentsMin;
|
||||
Vector m_vecExtentsMax;
|
||||
|
||||
static float m_flVisibleBBoxMinHeight;
|
||||
};
|
||||
|
||||
|
||||
|
||||
bool C_EnvProjectedTexture::IsBBoxVisible( void )
|
||||
{
|
||||
return IsBBoxVisible( GetAbsOrigin() + m_vecExtentsMin, GetAbsOrigin() + m_vecExtentsMax );
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
class C_EnvProjectedTexture : public C_BaseEntity
|
||||
{
|
||||
DECLARE_CLASS( C_EnvProjectedTexture, C_BaseEntity );
|
||||
public:
|
||||
DECLARE_CLIENTCLASS();
|
||||
|
||||
C_EnvProjectedTexture();
|
||||
~C_EnvProjectedTexture();
|
||||
|
||||
virtual void OnDataChanged( DataUpdateType_t updateType );
|
||||
void ShutDownLightHandle( void );
|
||||
|
||||
virtual void Simulate();
|
||||
|
||||
void UpdateLight( bool bForceUpdate );
|
||||
|
||||
bool ShadowsEnabled();
|
||||
|
||||
float GetFOV();
|
||||
|
||||
private:
|
||||
|
||||
ClientShadowHandle_t m_LightHandle;
|
||||
|
||||
EHANDLE m_hTargetEntity;
|
||||
|
||||
bool m_bState;
|
||||
float m_flLightFOV;
|
||||
bool m_bEnableShadows;
|
||||
bool m_bLightOnlyTarget;
|
||||
bool m_bLightWorld;
|
||||
bool m_bCameraSpace;
|
||||
color32 m_cLightColor;
|
||||
float m_flAmbient;
|
||||
char m_SpotlightTextureName[ MAX_PATH ];
|
||||
int m_nSpotlightTextureFrame;
|
||||
int m_nShadowQuality;
|
||||
bool m_bCurrentShadow;
|
||||
|
||||
public:
|
||||
C_EnvProjectedTexture *m_pNext;
|
||||
};
|
||||
|
||||
C_EnvProjectedTexture* GetEnvProjectedTextureList();
|
||||
|
||||
#endif
|
||||
|
||||
#endif // C_ENVPROJECTEDTEXTURE_H
|
||||
798
game/client/C_MaterialModifyControl.cpp
Normal file
798
game/client/C_MaterialModifyControl.cpp
Normal file
@@ -0,0 +1,798 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: Material Modify control entity.
|
||||
//
|
||||
//=============================================================================//
|
||||
|
||||
#include "cbase.h"
|
||||
#include "proxyentity.h"
|
||||
#include "materialsystem/imaterial.h"
|
||||
#include "materialsystem/imaterialvar.h"
|
||||
#include "materialsystem/itexture.h"
|
||||
#include "iviewrender.h"
|
||||
#include "texture_group_names.h"
|
||||
#include "baseanimatedtextureproxy.h"
|
||||
#include "toolframework_client.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
#define MATERIAL_MODIFY_STRING_SIZE 255
|
||||
#define MATERIAL_MODIFY_ANIMATION_UNSET -1
|
||||
|
||||
// Must match MaterialModifyControl.cpp
|
||||
enum MaterialModifyMode_t
|
||||
{
|
||||
MATERIAL_MODIFY_MODE_NONE = 0,
|
||||
MATERIAL_MODIFY_MODE_SETVAR = 1,
|
||||
MATERIAL_MODIFY_MODE_ANIM_SEQUENCE = 2,
|
||||
MATERIAL_MODIFY_MODE_FLOAT_LERP = 3,
|
||||
};
|
||||
|
||||
// forward declarations
|
||||
void ToolFramework_RecordMaterialParams( IMaterial *pMaterial );
|
||||
|
||||
ConVar debug_materialmodifycontrol_client( "debug_materialmodifycontrol_client", "0" );
|
||||
|
||||
struct materialanimcommands_t
|
||||
{
|
||||
int iFrameStart;
|
||||
int iFrameEnd;
|
||||
bool bWrap;
|
||||
float flFrameRate;
|
||||
};
|
||||
|
||||
struct materialfloatlerpcommands_t
|
||||
{
|
||||
int flStartValue;
|
||||
int flEndValue;
|
||||
float flTransitionTime;
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// FIXME: This really should inherit from something more lightweight
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
class C_MaterialModifyControl : public C_BaseEntity
|
||||
{
|
||||
public:
|
||||
|
||||
DECLARE_CLASS( C_MaterialModifyControl, C_BaseEntity );
|
||||
|
||||
C_MaterialModifyControl();
|
||||
|
||||
void OnPreDataChanged( DataUpdateType_t updateType );
|
||||
void OnDataChanged( DataUpdateType_t updateType );
|
||||
bool ShouldDraw();
|
||||
|
||||
IMaterial *GetMaterial( void ) { return m_pMaterial; }
|
||||
const char *GetMaterialVariableName( void ) { return m_szMaterialVar; }
|
||||
const char *GetMaterialVariableValue( void ) { return m_szMaterialVarValue; }
|
||||
|
||||
DECLARE_CLIENTCLASS();
|
||||
|
||||
// Animated texture and Float Lerp usage
|
||||
bool HasNewAnimationCommands( void ) { return m_bHasNewAnimationCommands; }
|
||||
void ClearAnimationCommands( void ) { m_bHasNewAnimationCommands = false; }
|
||||
|
||||
// Animated texture usage
|
||||
void GetAnimationCommands( materialanimcommands_t *pCommands );
|
||||
|
||||
// FloatLerp usage
|
||||
void GetFloatLerpCommands( materialfloatlerpcommands_t *pCommands );
|
||||
|
||||
void SetAnimationStartTime( float flTime )
|
||||
{
|
||||
m_flAnimationStartTime = flTime;
|
||||
}
|
||||
float GetAnimationStartTime( void ) const
|
||||
{
|
||||
return m_flAnimationStartTime;
|
||||
}
|
||||
|
||||
MaterialModifyMode_t GetModifyMode( void ) const
|
||||
{
|
||||
return ( MaterialModifyMode_t)m_nModifyMode;
|
||||
}
|
||||
private:
|
||||
|
||||
char m_szMaterialName[MATERIAL_MODIFY_STRING_SIZE];
|
||||
char m_szMaterialVar[MATERIAL_MODIFY_STRING_SIZE];
|
||||
char m_szMaterialVarValue[MATERIAL_MODIFY_STRING_SIZE];
|
||||
IMaterial *m_pMaterial;
|
||||
|
||||
bool m_bHasNewAnimationCommands;
|
||||
|
||||
// Animation commands from the server
|
||||
int m_iFrameStart;
|
||||
int m_iFrameEnd;
|
||||
bool m_bWrap;
|
||||
float m_flFramerate;
|
||||
bool m_bNewAnimCommandsSemaphore;
|
||||
bool m_bOldAnimCommandsSemaphore;
|
||||
|
||||
// Float lerp commands from the server
|
||||
float m_flFloatLerpStartValue;
|
||||
float m_flFloatLerpEndValue;
|
||||
float m_flFloatLerpTransitionTime;
|
||||
bool m_bFloatLerpWrap;
|
||||
float m_flAnimationStartTime;
|
||||
|
||||
int m_nModifyMode;
|
||||
};
|
||||
|
||||
IMPLEMENT_CLIENTCLASS_DT(C_MaterialModifyControl, DT_MaterialModifyControl, CMaterialModifyControl)
|
||||
RecvPropString( RECVINFO( m_szMaterialName ) ),
|
||||
RecvPropString( RECVINFO( m_szMaterialVar ) ),
|
||||
RecvPropString( RECVINFO( m_szMaterialVarValue ) ),
|
||||
RecvPropInt( RECVINFO(m_iFrameStart) ),
|
||||
RecvPropInt( RECVINFO(m_iFrameEnd) ),
|
||||
RecvPropInt( RECVINFO(m_bWrap) ),
|
||||
RecvPropFloat( RECVINFO(m_flFramerate) ),
|
||||
RecvPropInt( RECVINFO(m_bNewAnimCommandsSemaphore) ),
|
||||
RecvPropFloat( RECVINFO(m_flFloatLerpStartValue) ),
|
||||
RecvPropFloat( RECVINFO(m_flFloatLerpEndValue) ),
|
||||
RecvPropFloat( RECVINFO(m_flFloatLerpTransitionTime) ),
|
||||
RecvPropInt( RECVINFO(m_bFloatLerpWrap) ),
|
||||
RecvPropInt( RECVINFO(m_nModifyMode) ),
|
||||
END_RECV_TABLE()
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//------------------------------------------------------------------------------
|
||||
C_MaterialModifyControl::C_MaterialModifyControl()
|
||||
{
|
||||
m_pMaterial = NULL;
|
||||
m_bOldAnimCommandsSemaphore = false;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void C_MaterialModifyControl::OnPreDataChanged( DataUpdateType_t updateType )
|
||||
{
|
||||
BaseClass::OnPreDataChanged( updateType );
|
||||
|
||||
m_bOldAnimCommandsSemaphore = m_bNewAnimCommandsSemaphore;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//------------------------------------------------------------------------------
|
||||
void C_MaterialModifyControl::OnDataChanged( DataUpdateType_t updateType )
|
||||
{
|
||||
if( updateType == DATA_UPDATE_CREATED )
|
||||
{
|
||||
m_pMaterial = materials->FindMaterial( m_szMaterialName, TEXTURE_GROUP_OTHER );
|
||||
|
||||
// Clear out our variables
|
||||
m_bHasNewAnimationCommands = true;
|
||||
}
|
||||
|
||||
// Detect changes in the anim commands
|
||||
if ( m_bNewAnimCommandsSemaphore != m_bOldAnimCommandsSemaphore )
|
||||
{
|
||||
m_bHasNewAnimationCommands = true;
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void C_MaterialModifyControl::GetAnimationCommands( materialanimcommands_t *pCommands )
|
||||
{
|
||||
pCommands->iFrameStart = m_iFrameStart;
|
||||
pCommands->iFrameEnd = m_iFrameEnd;
|
||||
pCommands->bWrap = m_bWrap;
|
||||
pCommands->flFrameRate = m_flFramerate;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void C_MaterialModifyControl::GetFloatLerpCommands( materialfloatlerpcommands_t *pCommands )
|
||||
{
|
||||
pCommands->flStartValue = m_flFloatLerpStartValue;
|
||||
pCommands->flEndValue = m_flFloatLerpEndValue;
|
||||
pCommands->flTransitionTime = m_flFloatLerpTransitionTime;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Purpose: We don't draw.
|
||||
//------------------------------------------------------------------------------
|
||||
bool C_MaterialModifyControl::ShouldDraw()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
// THE MATERIALMODIFYPROXY ITSELF
|
||||
//
|
||||
class CMaterialModifyProxy : public CBaseAnimatedTextureProxy
|
||||
{
|
||||
public:
|
||||
CMaterialModifyProxy();
|
||||
virtual ~CMaterialModifyProxy();
|
||||
virtual bool Init( IMaterial *pMaterial, KeyValues *pKeyValues );
|
||||
virtual void OnBind( void *pEntity );
|
||||
virtual IMaterial *GetMaterial();
|
||||
|
||||
private:
|
||||
void OnBindSetVar( C_MaterialModifyControl *pControl );
|
||||
void OnBindAnimatedTexture( C_MaterialModifyControl *pControl );
|
||||
void OnBindFloatLerp( C_MaterialModifyControl *pControl );
|
||||
float GetAnimationStartTime( void* pArg );
|
||||
void AnimationWrapped( void* pArg );
|
||||
|
||||
IMaterial *m_pMaterial;
|
||||
|
||||
// texture animation stuff
|
||||
int m_iFrameStart;
|
||||
int m_iFrameEnd;
|
||||
bool m_bReachedEnd;
|
||||
bool m_bCustomWrap;
|
||||
float m_flCustomFramerate;
|
||||
|
||||
// float lerp stuff
|
||||
IMaterialVar *m_pMaterialVar;
|
||||
int m_flStartValue;
|
||||
int m_flEndValue;
|
||||
float m_flStartTime;
|
||||
float m_flTransitionTime;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
CMaterialModifyProxy::CMaterialModifyProxy()
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
CMaterialModifyProxy::~CMaterialModifyProxy()
|
||||
{
|
||||
}
|
||||
|
||||
bool CMaterialModifyProxy::Init( IMaterial *pMaterial, KeyValues *pKeyValues )
|
||||
{
|
||||
// set var stuff
|
||||
m_pMaterial = pMaterial;
|
||||
|
||||
// float lerp stuff
|
||||
m_flStartValue = MATERIAL_MODIFY_ANIMATION_UNSET;
|
||||
m_flEndValue = MATERIAL_MODIFY_ANIMATION_UNSET;
|
||||
|
||||
// animated stuff
|
||||
// m_pMaterial = pMaterial;
|
||||
// m_iFrameStart = MATERIAL_MODIFY_ANIMATION_UNSET;
|
||||
// m_iFrameEnd = MATERIAL_MODIFY_ANIMATION_UNSET;
|
||||
// m_bReachedEnd = false;
|
||||
// return CBaseAnimatedTextureProxy::Init( pMaterial, pKeyValues );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CMaterialModifyProxy::OnBind( void *pEntity )
|
||||
{
|
||||
// Get the modified material vars from the entity input
|
||||
IClientRenderable *pRend = (IClientRenderable *)pEntity;
|
||||
if ( pRend )
|
||||
{
|
||||
C_BaseEntity *pBaseEntity = pRend->GetIClientUnknown()->GetBaseEntity();
|
||||
|
||||
if ( pBaseEntity )
|
||||
{
|
||||
if( debug_materialmodifycontrol_client.GetBool() )
|
||||
{
|
||||
// DevMsg( 1, "%s\n", pBaseEntity->GetDebugName() );
|
||||
}
|
||||
int numChildren = 0;
|
||||
bool gotOne = false;
|
||||
for ( C_BaseEntity *pChild = pBaseEntity->FirstMoveChild(); pChild; pChild = pChild->NextMovePeer() )
|
||||
{
|
||||
numChildren++;
|
||||
C_MaterialModifyControl *pControl = dynamic_cast<C_MaterialModifyControl*>( pChild );
|
||||
if ( !pControl )
|
||||
continue;
|
||||
|
||||
if( debug_materialmodifycontrol_client.GetBool() )
|
||||
{
|
||||
// DevMsg( 1, "pControl: 0x%p\n", pControl );
|
||||
}
|
||||
|
||||
switch( pControl->GetModifyMode() )
|
||||
{
|
||||
case MATERIAL_MODIFY_MODE_NONE:
|
||||
break;
|
||||
case MATERIAL_MODIFY_MODE_SETVAR:
|
||||
gotOne = true;
|
||||
OnBindSetVar( pControl );
|
||||
break;
|
||||
case MATERIAL_MODIFY_MODE_ANIM_SEQUENCE:
|
||||
OnBindAnimatedTexture( pControl );
|
||||
break;
|
||||
case MATERIAL_MODIFY_MODE_FLOAT_LERP:
|
||||
OnBindFloatLerp( pControl );
|
||||
break;
|
||||
default:
|
||||
Assert( 0 );
|
||||
break;
|
||||
}
|
||||
}
|
||||
if( gotOne )
|
||||
{
|
||||
// DevMsg( 1, "numChildren: %d\n", numChildren );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( ToolsEnabled() )
|
||||
{
|
||||
ToolFramework_RecordMaterialParams( GetMaterial() );
|
||||
}
|
||||
}
|
||||
|
||||
IMaterial *CMaterialModifyProxy::GetMaterial()
|
||||
{
|
||||
return m_pMaterial;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CMaterialModifyProxy::OnBindSetVar( C_MaterialModifyControl *pControl )
|
||||
{
|
||||
IMaterial *pMaterial = pControl->GetMaterial();
|
||||
if( !pMaterial )
|
||||
{
|
||||
Assert( 0 );
|
||||
return;
|
||||
}
|
||||
|
||||
if ( pMaterial != m_pMaterial )
|
||||
{
|
||||
// Warning( "\t%s!=%s\n", pMaterial->GetName(), m_pMaterial->GetName() );
|
||||
return;
|
||||
}
|
||||
|
||||
bool bFound;
|
||||
IMaterialVar *pMaterialVar = pMaterial->FindVar( pControl->GetMaterialVariableName(), &bFound, false );
|
||||
if ( !bFound )
|
||||
return;
|
||||
|
||||
if( Q_strcmp( pControl->GetMaterialVariableValue(), "" ) )
|
||||
{
|
||||
// const char *pMaterialName = m_pMaterial->GetName();
|
||||
// const char *pMaterialVarName = pMaterialVar->GetName();
|
||||
// const char *pMaterialVarValue = pControl->GetMaterialVariableValue();
|
||||
// if( debug_materialmodifycontrol_client.GetBool()
|
||||
// && Q_stristr( m_pMaterial->GetName(), "faceandhair" )
|
||||
// && Q_stristr( pMaterialVar->GetName(), "self" )
|
||||
// )
|
||||
// {
|
||||
// static int count = 0;
|
||||
// DevMsg( 1, "CMaterialModifyProxy::OnBindSetVar \"%s\" %s=%s %d pControl=0x%p\n",
|
||||
// m_pMaterial->GetName(), pMaterialVar->GetName(), pControl->GetMaterialVariableValue(), count++, pControl );
|
||||
// }
|
||||
pMaterialVar->SetValueAutodetectType( pControl->GetMaterialVariableValue() );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Does the dirty deed
|
||||
//-----------------------------------------------------------------------------
|
||||
void CMaterialModifyProxy::OnBindAnimatedTexture( C_MaterialModifyControl *pControl )
|
||||
{
|
||||
assert ( m_AnimatedTextureVar );
|
||||
if( m_AnimatedTextureVar->GetType() != MATERIAL_VAR_TYPE_TEXTURE )
|
||||
return;
|
||||
|
||||
ITexture *pTexture;
|
||||
pTexture = m_AnimatedTextureVar->GetTextureValue();
|
||||
|
||||
if ( !pControl )
|
||||
return;
|
||||
|
||||
if ( pControl->HasNewAnimationCommands() )
|
||||
{
|
||||
// Read the data from the modify entity
|
||||
materialanimcommands_t sCommands;
|
||||
pControl->GetAnimationCommands( &sCommands );
|
||||
|
||||
m_iFrameStart = sCommands.iFrameStart;
|
||||
m_iFrameEnd = sCommands.iFrameEnd;
|
||||
m_bCustomWrap = sCommands.bWrap;
|
||||
m_flCustomFramerate = sCommands.flFrameRate;
|
||||
m_bReachedEnd = false;
|
||||
|
||||
m_flStartTime = gpGlobals->curtime;
|
||||
|
||||
pControl->ClearAnimationCommands();
|
||||
}
|
||||
|
||||
// Init all the vars based on whether we're using the base material settings,
|
||||
// or the custom ones from the entity input.
|
||||
int numFrames;
|
||||
bool bWrapAnimation;
|
||||
float flFrameRate;
|
||||
int iLastFrame;
|
||||
|
||||
// Do we have a custom frame section from the server?
|
||||
if ( m_iFrameStart != MATERIAL_MODIFY_ANIMATION_UNSET )
|
||||
{
|
||||
if ( m_iFrameEnd == MATERIAL_MODIFY_ANIMATION_UNSET )
|
||||
{
|
||||
m_iFrameEnd = pTexture->GetNumAnimationFrames();
|
||||
}
|
||||
|
||||
numFrames = (m_iFrameEnd - m_iFrameStart) + 1;
|
||||
bWrapAnimation = m_bCustomWrap;
|
||||
flFrameRate = m_flCustomFramerate;
|
||||
iLastFrame = (m_iFrameEnd - 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
numFrames = pTexture->GetNumAnimationFrames();
|
||||
bWrapAnimation = m_WrapAnimation;
|
||||
flFrameRate = m_FrameRate;
|
||||
iLastFrame = (numFrames - 1);
|
||||
}
|
||||
|
||||
// Have we already reached the end? If so, stay there.
|
||||
if ( m_bReachedEnd && !bWrapAnimation )
|
||||
{
|
||||
m_AnimatedTextureFrameNumVar->SetIntValue( iLastFrame );
|
||||
return;
|
||||
}
|
||||
|
||||
// NOTE: Must not use relative time based methods here
|
||||
// because the bind proxy can be called many times per frame.
|
||||
// Prevent multiple Wrap callbacks to be sent for no wrap mode
|
||||
float startTime;
|
||||
if ( m_iFrameStart != MATERIAL_MODIFY_ANIMATION_UNSET )
|
||||
{
|
||||
startTime = m_flStartTime;
|
||||
}
|
||||
else
|
||||
{
|
||||
startTime = GetAnimationStartTime(pControl);
|
||||
}
|
||||
float deltaTime = gpGlobals->curtime - startTime;
|
||||
float prevTime = deltaTime - gpGlobals->frametime;
|
||||
|
||||
// Clamp..
|
||||
if (deltaTime < 0.0f)
|
||||
deltaTime = 0.0f;
|
||||
if (prevTime < 0.0f)
|
||||
prevTime = 0.0f;
|
||||
|
||||
float frame = flFrameRate * deltaTime;
|
||||
float prevFrame = flFrameRate * prevTime;
|
||||
|
||||
int intFrame = ((int)frame) % numFrames;
|
||||
int intPrevFrame = ((int)prevFrame) % numFrames;
|
||||
|
||||
if ( m_iFrameStart != MATERIAL_MODIFY_ANIMATION_UNSET )
|
||||
{
|
||||
intFrame += m_iFrameStart;
|
||||
intPrevFrame += m_iFrameStart;
|
||||
}
|
||||
|
||||
// Report wrap situation...
|
||||
if (intPrevFrame > intFrame)
|
||||
{
|
||||
m_bReachedEnd = true;
|
||||
|
||||
if (bWrapAnimation)
|
||||
{
|
||||
AnimationWrapped( pControl );
|
||||
}
|
||||
else
|
||||
{
|
||||
// Only sent the wrapped message once.
|
||||
// when we're in non-wrapping mode
|
||||
if (prevFrame < numFrames)
|
||||
AnimationWrapped( pControl );
|
||||
intFrame = numFrames - 1;
|
||||
}
|
||||
}
|
||||
|
||||
m_AnimatedTextureFrameNumVar->SetIntValue( intFrame );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
float CMaterialModifyProxy::GetAnimationStartTime( void* pArg )
|
||||
{
|
||||
IClientRenderable *pRend = (IClientRenderable *)pArg;
|
||||
if (!pRend)
|
||||
return 0.0f;
|
||||
|
||||
C_BaseEntity* pEntity = pRend->GetIClientUnknown()->GetBaseEntity();
|
||||
if (pEntity)
|
||||
{
|
||||
return pEntity->GetTextureAnimationStartTime();
|
||||
}
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CMaterialModifyProxy::AnimationWrapped( void* pArg )
|
||||
{
|
||||
IClientRenderable *pRend = (IClientRenderable *)pArg;
|
||||
if (!pRend)
|
||||
return;
|
||||
|
||||
C_BaseEntity* pEntity = pRend->GetIClientUnknown()->GetBaseEntity();
|
||||
if (pEntity)
|
||||
{
|
||||
pEntity->TextureAnimationWrapped();
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Does the dirty deed
|
||||
//-----------------------------------------------------------------------------
|
||||
void CMaterialModifyProxy::OnBindFloatLerp( C_MaterialModifyControl *pControl )
|
||||
{
|
||||
if ( !pControl )
|
||||
return;
|
||||
|
||||
if ( pControl->HasNewAnimationCommands() )
|
||||
{
|
||||
pControl->SetAnimationStartTime( gpGlobals->curtime );
|
||||
pControl->ClearAnimationCommands();
|
||||
}
|
||||
|
||||
// Read the data from the modify entity
|
||||
materialfloatlerpcommands_t sCommands;
|
||||
pControl->GetFloatLerpCommands( &sCommands );
|
||||
|
||||
m_flStartValue = sCommands.flStartValue;
|
||||
m_flEndValue = sCommands.flEndValue;
|
||||
m_flTransitionTime = sCommands.flTransitionTime;
|
||||
m_flStartTime = pControl->GetAnimationStartTime();
|
||||
bool bFound;
|
||||
m_pMaterialVar = m_pMaterial->FindVar( pControl->GetMaterialVariableName(), &bFound, false );
|
||||
|
||||
if( bFound )
|
||||
{
|
||||
float currentValue;
|
||||
if( m_flTransitionTime > 0.0f )
|
||||
{
|
||||
currentValue = m_flStartValue + ( m_flEndValue - m_flStartValue ) * clamp( ( ( gpGlobals->curtime - m_flStartTime ) / m_flTransitionTime ), 0.0f, 1.0f );
|
||||
}
|
||||
else
|
||||
{
|
||||
currentValue = m_flEndValue;
|
||||
}
|
||||
|
||||
if( debug_materialmodifycontrol_client.GetBool() && Q_stristr( m_pMaterial->GetName(), "faceandhair" ) && Q_stristr( m_pMaterialVar->GetName(), "warp" ) )
|
||||
{
|
||||
static int count = 0;
|
||||
DevMsg( 1, "CMaterialFloatLerpProxy::OnBind \"%s\" %s=%f %d\n", m_pMaterial->GetName(), m_pMaterialVar->GetName(), currentValue, count++ );
|
||||
}
|
||||
m_pMaterialVar->SetFloatValue( currentValue );
|
||||
}
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
// MATERIALMODIFYANIMATED PROXY
|
||||
//
|
||||
class CMaterialModifyAnimatedProxy : public CBaseAnimatedTextureProxy
|
||||
{
|
||||
public:
|
||||
CMaterialModifyAnimatedProxy() {};
|
||||
virtual ~CMaterialModifyAnimatedProxy() {};
|
||||
virtual bool Init( IMaterial *pMaterial, KeyValues *pKeyValues );
|
||||
virtual void OnBind( void *pEntity );
|
||||
|
||||
virtual float GetAnimationStartTime( void* pBaseEntity );
|
||||
virtual void AnimationWrapped( void* pC_BaseEntity );
|
||||
|
||||
private:
|
||||
IMaterial *m_pMaterial;
|
||||
int m_iFrameStart;
|
||||
int m_iFrameEnd;
|
||||
bool m_bReachedEnd;
|
||||
float m_flStartTime;
|
||||
bool m_bCustomWrap;
|
||||
float m_flCustomFramerate;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
bool CMaterialModifyAnimatedProxy::Init( IMaterial *pMaterial, KeyValues *pKeyValues )
|
||||
{
|
||||
m_pMaterial = pMaterial;
|
||||
m_iFrameStart = MATERIAL_MODIFY_ANIMATION_UNSET;
|
||||
m_iFrameEnd = MATERIAL_MODIFY_ANIMATION_UNSET;
|
||||
m_bReachedEnd = false;
|
||||
return CBaseAnimatedTextureProxy::Init( pMaterial, pKeyValues );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Does the dirty deed
|
||||
//-----------------------------------------------------------------------------
|
||||
void CMaterialModifyAnimatedProxy::OnBind( void *pEntity )
|
||||
{
|
||||
assert ( m_AnimatedTextureVar );
|
||||
if( m_AnimatedTextureVar->GetType() != MATERIAL_VAR_TYPE_TEXTURE )
|
||||
return;
|
||||
|
||||
ITexture *pTexture;
|
||||
pTexture = m_AnimatedTextureVar->GetTextureValue();
|
||||
|
||||
// Get the modified material vars from the entity input
|
||||
IClientRenderable *pRend = (IClientRenderable *)pEntity;
|
||||
if ( pRend )
|
||||
{
|
||||
C_BaseEntity *pBaseEntity = pRend->GetIClientUnknown()->GetBaseEntity();
|
||||
if ( pBaseEntity )
|
||||
{
|
||||
for ( C_BaseEntity *pChild = pBaseEntity->FirstMoveChild(); pChild; pChild = pChild->NextMovePeer() )
|
||||
{
|
||||
C_MaterialModifyControl *pControl = dynamic_cast<C_MaterialModifyControl*>( pChild );
|
||||
if ( !pControl )
|
||||
continue;
|
||||
|
||||
if ( !pControl->HasNewAnimationCommands() )
|
||||
continue;
|
||||
|
||||
// Read the data from the modify entity
|
||||
materialanimcommands_t sCommands;
|
||||
pControl->GetAnimationCommands( &sCommands );
|
||||
|
||||
m_iFrameStart = sCommands.iFrameStart;
|
||||
m_iFrameEnd = sCommands.iFrameEnd;
|
||||
m_bCustomWrap = sCommands.bWrap;
|
||||
m_flCustomFramerate = sCommands.flFrameRate;
|
||||
m_bReachedEnd = false;
|
||||
|
||||
m_flStartTime = gpGlobals->curtime;
|
||||
|
||||
pControl->ClearAnimationCommands();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Init all the vars based on whether we're using the base material settings,
|
||||
// or the custom ones from the entity input.
|
||||
int numFrames;
|
||||
bool bWrapAnimation;
|
||||
float flFrameRate;
|
||||
int iLastFrame;
|
||||
|
||||
// Do we have a custom frame section from the server?
|
||||
if ( m_iFrameStart != MATERIAL_MODIFY_ANIMATION_UNSET )
|
||||
{
|
||||
if ( m_iFrameEnd == MATERIAL_MODIFY_ANIMATION_UNSET )
|
||||
{
|
||||
m_iFrameEnd = pTexture->GetNumAnimationFrames();
|
||||
}
|
||||
|
||||
numFrames = (m_iFrameEnd - m_iFrameStart) + 1;
|
||||
bWrapAnimation = m_bCustomWrap;
|
||||
flFrameRate = m_flCustomFramerate;
|
||||
iLastFrame = (m_iFrameEnd - 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
numFrames = pTexture->GetNumAnimationFrames();
|
||||
bWrapAnimation = m_WrapAnimation;
|
||||
flFrameRate = m_FrameRate;
|
||||
iLastFrame = (numFrames - 1);
|
||||
}
|
||||
|
||||
// Have we already reached the end? If so, stay there.
|
||||
if ( m_bReachedEnd && !bWrapAnimation )
|
||||
{
|
||||
m_AnimatedTextureFrameNumVar->SetIntValue( iLastFrame );
|
||||
return;
|
||||
}
|
||||
|
||||
// NOTE: Must not use relative time based methods here
|
||||
// because the bind proxy can be called many times per frame.
|
||||
// Prevent multiple Wrap callbacks to be sent for no wrap mode
|
||||
float startTime;
|
||||
if ( m_iFrameStart != MATERIAL_MODIFY_ANIMATION_UNSET )
|
||||
{
|
||||
startTime = m_flStartTime;
|
||||
}
|
||||
else
|
||||
{
|
||||
startTime = GetAnimationStartTime(pEntity);
|
||||
}
|
||||
float deltaTime = gpGlobals->curtime - startTime;
|
||||
float prevTime = deltaTime - gpGlobals->frametime;
|
||||
|
||||
// Clamp..
|
||||
if (deltaTime < 0.0f)
|
||||
deltaTime = 0.0f;
|
||||
if (prevTime < 0.0f)
|
||||
prevTime = 0.0f;
|
||||
|
||||
float frame = flFrameRate * deltaTime;
|
||||
float prevFrame = flFrameRate * prevTime;
|
||||
|
||||
int intFrame = ((int)frame) % numFrames;
|
||||
int intPrevFrame = ((int)prevFrame) % numFrames;
|
||||
|
||||
if ( m_iFrameStart != MATERIAL_MODIFY_ANIMATION_UNSET )
|
||||
{
|
||||
intFrame += m_iFrameStart;
|
||||
intPrevFrame += m_iFrameStart;
|
||||
}
|
||||
|
||||
// Report wrap situation...
|
||||
if (intPrevFrame > intFrame)
|
||||
{
|
||||
m_bReachedEnd = true;
|
||||
|
||||
if (bWrapAnimation)
|
||||
{
|
||||
AnimationWrapped( pEntity );
|
||||
}
|
||||
else
|
||||
{
|
||||
// Only sent the wrapped message once.
|
||||
// when we're in non-wrapping mode
|
||||
if (prevFrame < numFrames)
|
||||
AnimationWrapped( pEntity );
|
||||
intFrame = numFrames - 1;
|
||||
}
|
||||
}
|
||||
|
||||
m_AnimatedTextureFrameNumVar->SetIntValue( intFrame );
|
||||
|
||||
if ( ToolsEnabled() )
|
||||
{
|
||||
ToolFramework_RecordMaterialParams( GetMaterial() );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
float CMaterialModifyAnimatedProxy::GetAnimationStartTime( void* pArg )
|
||||
{
|
||||
IClientRenderable *pRend = (IClientRenderable *)pArg;
|
||||
if (!pRend)
|
||||
return 0.0f;
|
||||
|
||||
C_BaseEntity* pEntity = pRend->GetIClientUnknown()->GetBaseEntity();
|
||||
if (pEntity)
|
||||
{
|
||||
return pEntity->GetTextureAnimationStartTime();
|
||||
}
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CMaterialModifyAnimatedProxy::AnimationWrapped( void* pArg )
|
||||
{
|
||||
IClientRenderable *pRend = (IClientRenderable *)pArg;
|
||||
if (!pRend)
|
||||
return;
|
||||
|
||||
C_BaseEntity* pEntity = pRend->GetIClientUnknown()->GetBaseEntity();
|
||||
if (pEntity)
|
||||
{
|
||||
pEntity->TextureAnimationWrapped();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
EXPOSE_INTERFACE( CMaterialModifyProxy, IMaterialProxy, "MaterialModify" IMATERIAL_PROXY_INTERFACE_VERSION );
|
||||
EXPOSE_INTERFACE( CMaterialModifyAnimatedProxy, IMaterialProxy, "MaterialModifyAnimated" IMATERIAL_PROXY_INTERFACE_VERSION );
|
||||
60
game/client/C_WaterLODControl.cpp
Normal file
60
game/client/C_WaterLODControl.cpp
Normal file
@@ -0,0 +1,60 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: Water LOD control entity.
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
#include "cbase.h"
|
||||
#include "iviewrender.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// FIXME: This really should inherit from something more lightweight
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Purpose : Water LOD control entity
|
||||
//------------------------------------------------------------------------------
|
||||
class C_WaterLODControl : public C_BaseEntity
|
||||
{
|
||||
public:
|
||||
DECLARE_CLASS( C_WaterLODControl, C_BaseEntity );
|
||||
|
||||
DECLARE_CLIENTCLASS();
|
||||
|
||||
void OnDataChanged(DataUpdateType_t updateType);
|
||||
bool ShouldDraw();
|
||||
|
||||
private:
|
||||
float m_flCheapWaterStartDistance;
|
||||
float m_flCheapWaterEndDistance;
|
||||
};
|
||||
|
||||
IMPLEMENT_CLIENTCLASS_DT(C_WaterLODControl, DT_WaterLODControl, CWaterLODControl)
|
||||
RecvPropFloat(RECVINFO(m_flCheapWaterStartDistance)),
|
||||
RecvPropFloat(RECVINFO(m_flCheapWaterEndDistance)),
|
||||
END_RECV_TABLE()
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Purpose :
|
||||
// Input :
|
||||
// Output :
|
||||
//------------------------------------------------------------------------------
|
||||
void C_WaterLODControl::OnDataChanged(DataUpdateType_t updateType)
|
||||
{
|
||||
view->SetCheapWaterStartDistance( m_flCheapWaterStartDistance );
|
||||
view->SetCheapWaterEndDistance( m_flCheapWaterEndDistance );
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// We don't draw...
|
||||
//------------------------------------------------------------------------------
|
||||
bool C_WaterLODControl::ShouldDraw()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
715
game/client/C_entitydissolveegon.cpp
Normal file
715
game/client/C_entitydissolveegon.cpp
Normal file
@@ -0,0 +1,715 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#include "cbase.h"
|
||||
|
||||
#include "iviewrender.h"
|
||||
#include "view.h"
|
||||
#include "studio.h"
|
||||
#include "bone_setup.h"
|
||||
#include "model_types.h"
|
||||
#include "beamdraw.h"
|
||||
#include "engine/ivdebugoverlay.h"
|
||||
#include "iviewrender_beams.h"
|
||||
#include "fx.h"
|
||||
#include "iefx.h"
|
||||
#include "dlight.h"
|
||||
#include "IEffects.h"
|
||||
#include "c_entitydissolveegon.h"
|
||||
#include "movevars_shared.h"
|
||||
#include "clienteffectprecachesystem.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
CLIENTEFFECT_REGISTER_BEGIN(PrecacheEffectBuild2)
|
||||
CLIENTEFFECT_MATERIAL("effects/tesla_glow_noz")
|
||||
CLIENTEFFECT_MATERIAL("effects/spark")
|
||||
CLIENTEFFECT_MATERIAL("effects/combinemuzzle2")
|
||||
CLIENTEFFECT_REGISTER_END()
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Networking
|
||||
//-----------------------------------------------------------------------------
|
||||
IMPLEMENT_CLIENTCLASS_DT(C_EntityDissolveEgon, DT_EntityDissolveEgon, CEntityDissolveEgon)
|
||||
RecvPropTime(RECVINFO(m_flStartTime)),
|
||||
RecvPropFloat(RECVINFO(m_flFadeOutStart)),
|
||||
RecvPropFloat(RECVINFO(m_flFadeOutLength)),
|
||||
RecvPropFloat(RECVINFO(m_flFadeOutModelStart)),
|
||||
RecvPropFloat(RECVINFO(m_flFadeOutModelLength)),
|
||||
RecvPropFloat(RECVINFO(m_flFadeInStart)),
|
||||
RecvPropFloat(RECVINFO(m_flFadeInLength)),
|
||||
RecvPropInt(RECVINFO(m_nDissolveType)),
|
||||
RecvPropVector(RECVINFO(m_vDissolverOrigin)),
|
||||
RecvPropInt(RECVINFO(m_nMagnitude)),
|
||||
END_RECV_TABLE()
|
||||
|
||||
extern PMaterialHandle g_Material_Spark;
|
||||
PMaterialHandle g_Material_AR2Glow = NULL;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
C_EntityDissolveEgon::C_EntityDissolveEgon(void)
|
||||
{
|
||||
m_bLinkedToServerEnt = true;
|
||||
m_pController = NULL;
|
||||
m_bCoreExplode = false;
|
||||
m_vEffectColor = Vector(255, 255, 255);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void C_EntityDissolveEgon::GetRenderBounds(Vector& theMins, Vector& theMaxs)
|
||||
{
|
||||
if (GetMoveParent())
|
||||
{
|
||||
GetMoveParent()->GetRenderBounds(theMins, theMaxs);
|
||||
}
|
||||
else
|
||||
{
|
||||
theMins = GetAbsOrigin();
|
||||
theMaxs = theMaxs;
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// On data changed
|
||||
//-----------------------------------------------------------------------------
|
||||
void C_EntityDissolveEgon::OnDataChanged(DataUpdateType_t updateType)
|
||||
{
|
||||
BaseClass::OnDataChanged(updateType);
|
||||
if (updateType == DATA_UPDATE_CREATED)
|
||||
{
|
||||
m_flNextSparkTime = m_flStartTime;
|
||||
SetNextClientThink(CLIENT_THINK_ALWAYS);
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Cleanup
|
||||
//-----------------------------------------------------------------------------
|
||||
void C_EntityDissolveEgon::UpdateOnRemove(void)
|
||||
{
|
||||
if (m_pController)
|
||||
{
|
||||
physenv->DestroyMotionController(m_pController);
|
||||
m_pController = NULL;
|
||||
}
|
||||
|
||||
BaseClass::UpdateOnRemove();
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Apply the forces to the entity
|
||||
//------------------------------------------------------------------------------
|
||||
IMotionEvent::simresult_e C_EntityDissolveEgon::Simulate(IPhysicsMotionController *pController, IPhysicsObject *pObject, float deltaTime, Vector &linear, AngularImpulse &angular)
|
||||
{
|
||||
linear.Init();
|
||||
angular.Init();
|
||||
|
||||
// Make it zero g
|
||||
linear.z -= -1.02 * GetCurrentGravity();
|
||||
|
||||
Vector vel;
|
||||
AngularImpulse angVel;
|
||||
pObject->GetVelocity(&vel, &angVel);
|
||||
vel += linear * deltaTime; // account for gravity scale
|
||||
|
||||
Vector unitVel = vel;
|
||||
Vector unitAngVel = angVel;
|
||||
|
||||
float speed = VectorNormalize(unitVel);
|
||||
// float angSpeed = VectorNormalize( unitAngVel );
|
||||
|
||||
// float speedScale = 0.0;
|
||||
// float angSpeedScale = 0.0;
|
||||
|
||||
float flLinearLimit = 50;
|
||||
float flLinearLimitDelta = 40;
|
||||
if (speed > flLinearLimit)
|
||||
{
|
||||
float flDeltaVel = (flLinearLimit - speed) / deltaTime;
|
||||
if (flLinearLimitDelta != 0.0f)
|
||||
{
|
||||
float flMaxDeltaVel = -flLinearLimitDelta / deltaTime;
|
||||
if (flDeltaVel < flMaxDeltaVel)
|
||||
{
|
||||
flDeltaVel = flMaxDeltaVel;
|
||||
}
|
||||
}
|
||||
VectorMA(linear, flDeltaVel, unitVel, linear);
|
||||
}
|
||||
|
||||
return SIM_GLOBAL_ACCELERATION;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Tesla effect
|
||||
//-----------------------------------------------------------------------------
|
||||
static void FX_BuildTesla(C_BaseEntity *pEntity, Vector &vecOrigin, Vector &vecEnd)
|
||||
{
|
||||
BeamInfo_t beamInfo;
|
||||
beamInfo.m_pStartEnt = pEntity;
|
||||
beamInfo.m_nStartAttachment = 0;
|
||||
beamInfo.m_pEndEnt = NULL;
|
||||
beamInfo.m_nEndAttachment = 0;
|
||||
beamInfo.m_nType = TE_BEAMTESLA;
|
||||
beamInfo.m_vecStart = vecOrigin;
|
||||
beamInfo.m_vecEnd = vecEnd;
|
||||
beamInfo.m_pszModelName = "sprites/lgtning.vmt";
|
||||
beamInfo.m_flHaloScale = 0.0;
|
||||
beamInfo.m_flLife = random->RandomFloat(0.25f, 1.0f);
|
||||
beamInfo.m_flWidth = random->RandomFloat(8.0f, 14.0f);
|
||||
beamInfo.m_flEndWidth = 1.0f;
|
||||
beamInfo.m_flFadeLength = 0.5f;
|
||||
beamInfo.m_flAmplitude = 24;
|
||||
beamInfo.m_flBrightness = 255.0;
|
||||
beamInfo.m_flSpeed = 150.0f;
|
||||
beamInfo.m_nStartFrame = 0.0;
|
||||
beamInfo.m_flFrameRate = 30.0;
|
||||
beamInfo.m_flRed = 138.0;
|
||||
beamInfo.m_flGreen = 112.0;
|
||||
beamInfo.m_flBlue = 234.0;
|
||||
beamInfo.m_nSegments = 18;
|
||||
beamInfo.m_bRenderable = true;
|
||||
beamInfo.m_nFlags = 0; //FBEAM_ONLYNOISEONCE;
|
||||
|
||||
beams->CreateBeamEntPoint(beamInfo);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Tesla effect
|
||||
//-----------------------------------------------------------------------------
|
||||
void C_EntityDissolveEgon::BuildTeslaEffect(mstudiobbox_t *pHitBox, const matrix3x4_t &hitboxToWorld, bool bRandom, float flYawOffset)
|
||||
{
|
||||
Vector vecOrigin;
|
||||
QAngle vecAngles;
|
||||
MatrixGetColumn(hitboxToWorld, 3, vecOrigin);
|
||||
MatrixAngles(hitboxToWorld, vecAngles.Base());
|
||||
C_BaseEntity *pEntity = GetMoveParent();
|
||||
|
||||
// Make a couple of tries at it
|
||||
int iTries = -1;
|
||||
Vector vecForward;
|
||||
trace_t tr;
|
||||
do
|
||||
{
|
||||
iTries++;
|
||||
|
||||
// Some beams are deliberatly aimed around the point, the rest are random.
|
||||
if (!bRandom)
|
||||
{
|
||||
QAngle vecTemp = vecAngles;
|
||||
vecTemp[YAW] += flYawOffset;
|
||||
AngleVectors(vecTemp, &vecForward);
|
||||
|
||||
// Randomly angle it up or down
|
||||
vecForward.z = RandomFloat(-1, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
vecForward = RandomVector(-1, 1);
|
||||
}
|
||||
|
||||
UTIL_TraceLine(vecOrigin, vecOrigin + (vecForward * 192), MASK_SHOT, pEntity, COLLISION_GROUP_NONE, &tr);
|
||||
} while (tr.fraction >= 1.0 && iTries < 3);
|
||||
|
||||
Vector vecEnd = tr.endpos - (vecForward * 8);
|
||||
|
||||
// Only spark & glow if we hit something
|
||||
if (tr.fraction < 1.0)
|
||||
{
|
||||
if (!EffectOccluded(tr.endpos))
|
||||
{
|
||||
// Move it towards the camera
|
||||
Vector vecFlash = tr.endpos;
|
||||
Vector vecForward;
|
||||
AngleVectors(MainViewAngles(), &vecForward);
|
||||
vecFlash -= (vecForward * 8);
|
||||
|
||||
g_pEffects->EnergySplash(vecFlash, -vecForward, false);
|
||||
|
||||
// End glow
|
||||
CSmartPtr<CSimpleEmitter> pSimple = CSimpleEmitter::Create("dust");
|
||||
pSimple->SetSortOrigin(vecFlash);
|
||||
SimpleParticle *pParticle;
|
||||
pParticle = (SimpleParticle *)pSimple->AddParticle(sizeof(SimpleParticle), pSimple->GetPMaterial("effects/tesla_glow_noz"), vecFlash);
|
||||
if (pParticle != NULL)
|
||||
{
|
||||
pParticle->m_flLifetime = 0.0f;
|
||||
pParticle->m_flDieTime = RandomFloat(0.5, 1);
|
||||
pParticle->m_vecVelocity = vec3_origin;
|
||||
Vector color(1, 1, 1);
|
||||
float colorRamp = RandomFloat(0.75f, 1.25f);
|
||||
pParticle->m_uchColor[0] = MIN(1.0f, color[0] * colorRamp) * 255.0f;
|
||||
pParticle->m_uchColor[1] = MIN(1.0f, color[1] * colorRamp) * 255.0f;
|
||||
pParticle->m_uchColor[2] = MIN(1.0f, color[2] * colorRamp) * 255.0f;
|
||||
pParticle->m_uchStartSize = RandomFloat(6, 13);
|
||||
pParticle->m_uchEndSize = pParticle->m_uchStartSize - 2;
|
||||
pParticle->m_uchStartAlpha = 255;
|
||||
pParticle->m_uchEndAlpha = 10;
|
||||
pParticle->m_flRoll = RandomFloat(0, 360);
|
||||
pParticle->m_flRollDelta = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Build the tesla
|
||||
FX_BuildTesla(pEntity, vecOrigin, tr.endpos);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Sorts the components of a vector
|
||||
//-----------------------------------------------------------------------------
|
||||
static inline void SortAbsVectorComponents(const Vector& src, int* pVecIdx)
|
||||
{
|
||||
Vector absVec(fabs(src[0]), fabs(src[1]), fabs(src[2]));
|
||||
|
||||
int maxIdx = (absVec[0] > absVec[1]) ? 0 : 1;
|
||||
if (absVec[2] > absVec[maxIdx])
|
||||
{
|
||||
maxIdx = 2;
|
||||
}
|
||||
|
||||
// always choose something right-handed....
|
||||
switch (maxIdx)
|
||||
{
|
||||
case 0:
|
||||
pVecIdx[0] = 1;
|
||||
pVecIdx[1] = 2;
|
||||
pVecIdx[2] = 0;
|
||||
break;
|
||||
case 1:
|
||||
pVecIdx[0] = 2;
|
||||
pVecIdx[1] = 0;
|
||||
pVecIdx[2] = 1;
|
||||
break;
|
||||
case 2:
|
||||
pVecIdx[0] = 0;
|
||||
pVecIdx[1] = 1;
|
||||
pVecIdx[2] = 2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Compute the bounding box's center, size, and basis
|
||||
//-----------------------------------------------------------------------------
|
||||
void C_EntityDissolveEgon::ComputeRenderInfo(mstudiobbox_t *pHitBox, const matrix3x4_t &hitboxToWorld,
|
||||
Vector *pVecAbsOrigin, Vector *pXVec, Vector *pYVec)
|
||||
{
|
||||
// Compute the center of the hitbox in worldspace
|
||||
Vector vecHitboxCenter;
|
||||
VectorAdd(pHitBox->bbmin, pHitBox->bbmax, vecHitboxCenter);
|
||||
vecHitboxCenter *= 0.5f;
|
||||
VectorTransform(vecHitboxCenter, hitboxToWorld, *pVecAbsOrigin);
|
||||
|
||||
// Get the object's basis
|
||||
Vector vec[3];
|
||||
MatrixGetColumn(hitboxToWorld, 0, vec[0]);
|
||||
MatrixGetColumn(hitboxToWorld, 1, vec[1]);
|
||||
MatrixGetColumn(hitboxToWorld, 2, vec[2]);
|
||||
// vec[1] *= -1.0f;
|
||||
|
||||
Vector vecViewDir;
|
||||
VectorSubtract(CurrentViewOrigin(), *pVecAbsOrigin, vecViewDir);
|
||||
VectorNormalize(vecViewDir);
|
||||
|
||||
// Project the shadow casting direction into the space of the hitbox
|
||||
Vector localViewDir;
|
||||
localViewDir[0] = DotProduct(vec[0], vecViewDir);
|
||||
localViewDir[1] = DotProduct(vec[1], vecViewDir);
|
||||
localViewDir[2] = DotProduct(vec[2], vecViewDir);
|
||||
|
||||
// Figure out which vector has the largest component perpendicular
|
||||
// to the view direction...
|
||||
// Sort by how perpendicular it is
|
||||
int vecIdx[3];
|
||||
SortAbsVectorComponents(localViewDir, vecIdx);
|
||||
|
||||
// Here's our hitbox basis vectors; namely the ones that are
|
||||
// most perpendicular to the view direction
|
||||
*pXVec = vec[vecIdx[0]];
|
||||
*pYVec = vec[vecIdx[1]];
|
||||
|
||||
// Project them into a plane perpendicular to the view direction
|
||||
*pXVec -= vecViewDir * DotProduct(vecViewDir, *pXVec);
|
||||
*pYVec -= vecViewDir * DotProduct(vecViewDir, *pYVec);
|
||||
VectorNormalize(*pXVec);
|
||||
VectorNormalize(*pYVec);
|
||||
|
||||
// Compute the hitbox size
|
||||
Vector boxSize;
|
||||
VectorSubtract(pHitBox->bbmax, pHitBox->bbmin, boxSize);
|
||||
|
||||
// We project the two longest sides into the vectors perpendicular
|
||||
// to the projection direction, then add in the projection of the perp direction
|
||||
Vector2D size(boxSize[vecIdx[0]], boxSize[vecIdx[1]]);
|
||||
size.x *= fabs(DotProduct(vec[vecIdx[0]], *pXVec));
|
||||
size.y *= fabs(DotProduct(vec[vecIdx[1]], *pYVec));
|
||||
|
||||
// Add the third component into x and y
|
||||
size.x += boxSize[vecIdx[2]] * fabs(DotProduct(vec[vecIdx[2]], *pXVec));
|
||||
size.y += boxSize[vecIdx[2]] * fabs(DotProduct(vec[vecIdx[2]], *pYVec));
|
||||
|
||||
// Bloat a bit, since the shadow wants to extend outside the model a bit
|
||||
size *= 2.0f;
|
||||
|
||||
// Clamp the minimum size
|
||||
Vector2DMax(size, Vector2D(10.0f, 10.0f), size);
|
||||
|
||||
// Factor the size into the xvec + yvec
|
||||
(*pXVec) *= size.x * 0.5f;
|
||||
(*pYVec) *= size.y * 0.5f;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Sparks!
|
||||
//-----------------------------------------------------------------------------
|
||||
void C_EntityDissolveEgon::DoSparks(mstudiohitboxset_t *set, matrix3x4_t *hitboxbones[MAXSTUDIOBONES])
|
||||
{
|
||||
if (m_flNextSparkTime > gpGlobals->curtime)
|
||||
return;
|
||||
|
||||
float dt = m_flStartTime + m_flFadeOutStart - gpGlobals->curtime;
|
||||
dt = clamp(dt, 0.0f, m_flFadeOutStart);
|
||||
|
||||
float flNextTime;
|
||||
if (m_nDissolveType == ENTITY_DISSOLVE_ELECTRICAL)
|
||||
{
|
||||
flNextTime = SimpleSplineRemapVal(dt, 0.0f, m_flFadeOutStart, 2.0f * TICK_INTERVAL, 0.4f);
|
||||
}
|
||||
else
|
||||
{
|
||||
// m_nDissolveType == ENTITY_DISSOLVE_ELECTRICAL_LIGHT);
|
||||
flNextTime = SimpleSplineRemapVal(dt, 0.0f, m_flFadeOutStart, 0.3f, 1.0f);
|
||||
}
|
||||
|
||||
m_flNextSparkTime = gpGlobals->curtime + flNextTime;
|
||||
|
||||
// Send out beams around us
|
||||
int iNumBeamsAround = 2;
|
||||
int iNumRandomBeams = 1;
|
||||
int iTotalBeams = iNumBeamsAround + iNumRandomBeams;
|
||||
float flYawOffset = RandomFloat(0, 360);
|
||||
for (int i = 0; i < iTotalBeams; i++)
|
||||
{
|
||||
int nHitbox = random->RandomInt(0, set->numhitboxes - 1);
|
||||
mstudiobbox_t *pBox = set->pHitbox(nHitbox);
|
||||
|
||||
float flActualYawOffset = 0;
|
||||
bool bRandom = (i >= iNumBeamsAround);
|
||||
if (!bRandom)
|
||||
{
|
||||
flActualYawOffset = anglemod(flYawOffset + ((360 / iTotalBeams) * i));
|
||||
}
|
||||
|
||||
BuildTeslaEffect(pBox, *hitboxbones[pBox->bone], bRandom, flActualYawOffset);
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void C_EntityDissolveEgon::SetupEmitter(void)
|
||||
{
|
||||
if (!m_pEmitter)
|
||||
{
|
||||
m_pEmitter = CSimpleEmitter::Create("C_EntityDissolveEgon");
|
||||
m_pEmitter->SetSortOrigin(GetAbsOrigin());
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Output : float
|
||||
//-----------------------------------------------------------------------------
|
||||
float C_EntityDissolveEgon::GetFadeInPercentage(void)
|
||||
{
|
||||
float dt = gpGlobals->curtime - m_flStartTime;
|
||||
|
||||
if (dt > m_flFadeOutStart)
|
||||
return 1.0f;
|
||||
|
||||
if (dt < m_flFadeInStart)
|
||||
return 0.0f;
|
||||
|
||||
if ((dt > m_flFadeInStart) && (dt < m_flFadeInStart + m_flFadeInLength))
|
||||
{
|
||||
dt -= m_flFadeInStart;
|
||||
|
||||
return (dt / m_flFadeInLength);
|
||||
}
|
||||
|
||||
return 1.0f;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Output : float
|
||||
//-----------------------------------------------------------------------------
|
||||
float C_EntityDissolveEgon::GetFadeOutPercentage(void)
|
||||
{
|
||||
float dt = gpGlobals->curtime - m_flStartTime;
|
||||
|
||||
if (dt < m_flFadeInStart)
|
||||
return 1.0f;
|
||||
|
||||
if (dt > m_flFadeOutStart)
|
||||
{
|
||||
dt -= m_flFadeOutStart;
|
||||
|
||||
if (dt > m_flFadeOutLength)
|
||||
return 0.0f;
|
||||
|
||||
return 1.0f - (dt / m_flFadeOutLength);
|
||||
}
|
||||
|
||||
return 1.0f;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Output : float
|
||||
//-----------------------------------------------------------------------------
|
||||
float C_EntityDissolveEgon::GetModelFadeOutPercentage(void)
|
||||
{
|
||||
float dt = gpGlobals->curtime - m_flStartTime;
|
||||
|
||||
if (dt < m_flFadeOutModelStart)
|
||||
return 1.0f;
|
||||
|
||||
if (dt > m_flFadeOutModelStart)
|
||||
{
|
||||
dt -= m_flFadeOutModelStart;
|
||||
|
||||
if (dt > m_flFadeOutModelLength)
|
||||
return 0.0f;
|
||||
|
||||
return 1.0f - (dt / m_flFadeOutModelLength);
|
||||
}
|
||||
|
||||
return 1.0f;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void C_EntityDissolveEgon::ClientThink(void)
|
||||
{
|
||||
C_BaseEntity *pEnt = GetMoveParent();
|
||||
if (!pEnt)
|
||||
return;
|
||||
|
||||
bool bIsRagdoll;
|
||||
#ifdef TF_CLIENT_DLL
|
||||
bIsRagdoll = true;
|
||||
#else
|
||||
C_BaseAnimating *pAnimating = GetMoveParent() ? GetMoveParent()->GetBaseAnimating() : NULL;
|
||||
if (!pAnimating)
|
||||
return;
|
||||
bIsRagdoll = pAnimating->IsRagdoll();
|
||||
#endif
|
||||
|
||||
// NOTE: IsRagdoll means *client-side* ragdoll. We shouldn't be trying to fight
|
||||
// the server ragdoll (or any server physics) on the client
|
||||
if ((!m_pController) && (m_nDissolveType == ENTITY_DISSOLVE_NORMAL) && bIsRagdoll)
|
||||
{
|
||||
IPhysicsObject *ppList[VPHYSICS_MAX_OBJECT_LIST_COUNT];
|
||||
int nCount = pEnt->VPhysicsGetObjectList(ppList, ARRAYSIZE(ppList));
|
||||
if (nCount > 0)
|
||||
{
|
||||
m_pController = physenv->CreateMotionController(this);
|
||||
for (int i = 0; i < nCount; ++i)
|
||||
{
|
||||
m_pController->AttachObject(ppList[i], true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
color32 color;
|
||||
|
||||
color.r = (1.0f - GetFadeInPercentage()) * m_vEffectColor.x;
|
||||
color.g = (1.0f - GetFadeInPercentage()) * m_vEffectColor.y;
|
||||
color.b = (1.0f - GetFadeInPercentage()) * m_vEffectColor.z;
|
||||
color.a = GetModelFadeOutPercentage() * 255.0f;
|
||||
|
||||
// Setup the entity fade
|
||||
pEnt->SetRenderMode(kRenderTransColor);
|
||||
pEnt->SetRenderColor(color.r, color.g, color.b, color.a);
|
||||
|
||||
if (GetModelFadeOutPercentage() <= 0.2f)
|
||||
{
|
||||
m_bCoreExplode = true;
|
||||
}
|
||||
|
||||
// If we're dead, fade out
|
||||
/*if (GetFadeOutPercentage() <= 0.0f)
|
||||
{
|
||||
// Do NOT remove from the client entity list. It'll confuse the local network backdoor, and the entity will never get destroyed
|
||||
// because when the server says to destroy it, the client won't be able to find it.
|
||||
// ClientEntityList().RemoveEntity( GetClientHandle() );
|
||||
|
||||
partition->Remove(PARTITION_CLIENT_SOLID_EDICTS | PARTITION_CLIENT_RESPONSIVE_EDICTS | PARTITION_CLIENT_NON_STATIC_EDICTS, CollisionProp()->GetPartitionHandle());
|
||||
|
||||
RemoveFromLeafSystem();
|
||||
|
||||
//FIXME: Ick!
|
||||
//Adrian: I'll assume we don't need the ragdoll either so I'll remove that too.
|
||||
if (m_bLinkedToServerEnt == false)
|
||||
{
|
||||
Release();
|
||||
|
||||
C_ClientRagdoll *pRagdoll = dynamic_cast <C_ClientRagdoll *> (pEnt);
|
||||
|
||||
if (pRagdoll)
|
||||
{
|
||||
pRagdoll->ReleaseRagdoll();
|
||||
}
|
||||
#ifdef TF_CLIENT_DLL
|
||||
else
|
||||
{
|
||||
pEnt->Release();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : flags -
|
||||
// Output : int
|
||||
//-----------------------------------------------------------------------------
|
||||
int C_EntityDissolveEgon::DrawModel(int flags)
|
||||
{
|
||||
// See if we should draw
|
||||
if (gpGlobals->frametime == 0 || m_bReadyToDraw == false)
|
||||
return 0;
|
||||
|
||||
C_BaseAnimating *pAnimating = GetMoveParent() ? GetMoveParent()->GetBaseAnimating() : NULL;
|
||||
if (pAnimating == NULL)
|
||||
return 0;
|
||||
|
||||
matrix3x4_t *hitboxbones[MAXSTUDIOBONES];
|
||||
if (pAnimating->HitboxToWorldTransforms(hitboxbones) == false)
|
||||
return 0;
|
||||
|
||||
studiohdr_t *pStudioHdr = modelinfo->GetStudiomodel(pAnimating->GetModel());
|
||||
if (pStudioHdr == NULL)
|
||||
return false;
|
||||
|
||||
mstudiohitboxset_t *set = pStudioHdr->pHitboxSet(pAnimating->GetHitboxSet());
|
||||
if (set == NULL)
|
||||
return false;
|
||||
|
||||
QAngle Ang;
|
||||
// Make sure the emitter is setup properly
|
||||
SetupEmitter();
|
||||
|
||||
// Get fade percentages for the effect
|
||||
float fadeInPerc = GetFadeInPercentage();
|
||||
float fadeOutPerc = GetFadeOutPercentage();
|
||||
|
||||
float fadePerc = (fadeInPerc >= 1.0f) ? fadeOutPerc : fadeInPerc;
|
||||
|
||||
Vector vecSkew = vec3_origin;
|
||||
|
||||
// Do extra effects under certain circumstances
|
||||
if ((fadePerc < 0.99f) && ((m_nDissolveType == ENTITY_DISSOLVE_ELECTRICAL) || (m_nDissolveType == ENTITY_DISSOLVE_ELECTRICAL_LIGHT)))
|
||||
{
|
||||
DoSparks(set, hitboxbones);
|
||||
}
|
||||
|
||||
// Skew the particles in front or in back of their targets
|
||||
vecSkew = CurrentViewForward() * (8.0f - ((1.0f - fadePerc) * 32.0f));
|
||||
|
||||
float spriteScale = ((gpGlobals->curtime - m_flStartTime) / m_flFadeOutLength);
|
||||
spriteScale = clamp(spriteScale, 0.75f, 1.0f);
|
||||
|
||||
// Cache off this material reference
|
||||
/*if (g_Material_Spark == NULL)
|
||||
{
|
||||
g_Material_Spark = ParticleMgr()->GetPMaterial("effects/spark");
|
||||
}
|
||||
|
||||
if (g_Material_AR2Glow == NULL)
|
||||
{
|
||||
g_Material_AR2Glow = ParticleMgr()->GetPMaterial("effects/combinemuzzle2");
|
||||
}
|
||||
|
||||
SimpleParticle *sParticle;*/
|
||||
|
||||
|
||||
for (int i = 0; i < set->numhitboxes; ++i)
|
||||
{
|
||||
Vector vecAbsOrigin, xvec, yvec;
|
||||
mstudiobbox_t *pBox = set->pHitbox(i);
|
||||
ComputeRenderInfo(pBox, *hitboxbones[pBox->bone], &vecAbsOrigin, &xvec, &yvec);
|
||||
|
||||
Vector offset;
|
||||
Vector xDir, yDir;
|
||||
|
||||
xDir = xvec;
|
||||
//float xScale = VectorNormalize(xDir) * 0.75f;
|
||||
|
||||
yDir = yvec;
|
||||
//float yScale = VectorNormalize(yDir) * 0.75f;
|
||||
|
||||
int numParticles = clamp(3.0f * fadePerc, 0.f, 3.f);
|
||||
|
||||
int iTempParts = 2;
|
||||
|
||||
if (m_nDissolveType == ENTITY_DISSOLVE_CORE)
|
||||
{
|
||||
if (m_bCoreExplode == true)
|
||||
{
|
||||
numParticles = 15;
|
||||
iTempParts = 20;
|
||||
}
|
||||
}
|
||||
/*for (int j = 0; j < iTempParts; j++)
|
||||
{
|
||||
// Skew the origin
|
||||
offset = xDir * Helper_RandomFloat(-xScale*0.5f, xScale*0.5f) + yDir * Helper_RandomFloat(-yScale*0.5f, yScale*0.5f);
|
||||
offset += vecSkew;
|
||||
|
||||
VectorAngles(vecAbsOrigin + offset, Ang);
|
||||
AddEffects(EF_EGONDISSOLVELIGHT);
|
||||
DispatchParticleEffect("dissolve_egon_warp", vecAbsOrigin + offset, Ang, NULL);
|
||||
}
|
||||
|
||||
for (int j = 0; j < numParticles; j++)
|
||||
{
|
||||
offset = xDir * Helper_RandomFloat(-xScale*0.5f, xScale*0.5f) + yDir * Helper_RandomFloat(-yScale*0.5f, yScale*0.5f);
|
||||
offset += vecSkew;
|
||||
|
||||
AddEffects(EF_EGONDISSOLVELIGHT);
|
||||
VectorAngles(vecAbsOrigin + offset, Ang);
|
||||
DispatchParticleEffect("dissolve_egon", vecAbsOrigin + offset, Ang, NULL);
|
||||
|
||||
}
|
||||
dlight_t *el = effects->CL_AllocDlight(index);//( index );
|
||||
el->origin = offset;
|
||||
|
||||
el->color.r = 64;
|
||||
el->color.g = 128;
|
||||
el->color.b = 255;
|
||||
el->color.exponent = 5;
|
||||
|
||||
el->radius = random->RandomInt(32, 128);
|
||||
el->decay = el->radius / 0.05f;
|
||||
el->die = gpGlobals->curtime + 0.05f;*/
|
||||
}
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
2
game/client/ClassDiagram.cd
Normal file
2
game/client/ClassDiagram.cd
Normal file
@@ -0,0 +1,2 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ClassDiagram />
|
||||
2
game/client/ClassDiagram1.cd
Normal file
2
game/client/ClassDiagram1.cd
Normal file
@@ -0,0 +1,2 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ClassDiagram />
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,2 @@
|
||||
#TargetFrameworkVersion=v4.0:PlatformToolSet=v120:EnableManagedIncrementalBuild=false:VCToolArchitecture=Native32Bit
|
||||
Debug|Win32|D:\SourceCodes\project_overcharged_build_10_rtt\src_RTT\|
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
game/client/Debug_mod_episodic/client.pch.codeanalysis
Normal file
BIN
game/client/Debug_mod_episodic/client.pch.codeanalysis
Normal file
Binary file not shown.
BIN
game/client/Debug_mod_episodic/client.pch.codeanalysisast
Normal file
BIN
game/client/Debug_mod_episodic/client.pch.codeanalysisast
Normal file
Binary file not shown.
BIN
game/client/Debug_mod_hl2/client.pch.codeanalysis
Normal file
BIN
game/client/Debug_mod_hl2/client.pch.codeanalysis
Normal file
Binary file not shown.
BIN
game/client/Debug_mod_hl2/client.pch.codeanalysisast
Normal file
BIN
game/client/Debug_mod_hl2/client.pch.codeanalysisast
Normal file
Binary file not shown.
198
game/client/DrawSpecialShaders.cpp
Normal file
198
game/client/DrawSpecialShaders.cpp
Normal file
@@ -0,0 +1,198 @@
|
||||
#include "cbase.h"
|
||||
#include "viewrender.h"
|
||||
#include "view_scene.h"
|
||||
#include "screen_overlay_multiple.h"//OverCharged
|
||||
#include "materialsystem/IMaterialSystem.h"
|
||||
#include "materialsystem/IMaterialVar.h"
|
||||
#include "materialsystem/imaterialsystemhardwareconfig.h"
|
||||
#include "rendertexture.h"
|
||||
#include "ivieweffects.h"
|
||||
#include "ClientEffectPrecacheSystem.h"
|
||||
#include "view.h"
|
||||
#include "shadereditor/shadereditorsystem.h"
|
||||
#include "shadereditor/ivshadereditor.h"
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
ConVar r_post_draw_bokeh_dof("r_post_draw_bokeh_dof", "0", FCVAR_ARCHIVE);
|
||||
ConVar r_post_draw_InReload_dof("r_post_draw_InReload_dof", "0", FCVAR_ARCHIVE);
|
||||
ConVar r_post_draw_ironsight_blur("r_post_draw_ironsight_blur", "0", FCVAR_ARCHIVE);
|
||||
|
||||
|
||||
ConVar r_post_draw_deferred("r_post_draw_deferred", "0", FCVAR_ARCHIVE);
|
||||
void CViewRender::DrawDOF(int x, int y, int width, int height)
|
||||
{
|
||||
if (r_post_draw_bokeh_dof.GetInt())
|
||||
{
|
||||
IMaterial *pMaterial3 = materials->FindMaterial("effects/shaders/postproc_bokeh", TEXTURE_GROUP_OTHER);
|
||||
DrawScreenEffectMaterial(pMaterial3, x, y, width, height);
|
||||
}
|
||||
if (!(r_post_draw_bokeh_dof.GetInt()))
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
if (r_post_draw_deferred.GetInt())
|
||||
{
|
||||
C_BasePlayer* pPlayer = C_BasePlayer::GetLocalPlayer();
|
||||
IMaterial *pMaterial = materials->FindMaterial("effects/shaders/postproc_deferred_lightning", TEXTURE_GROUP_OTHER);
|
||||
IMaterialVar *var;
|
||||
var = pMaterial->FindVar("$MUTABLE_01", NULL);
|
||||
|
||||
Vector vs_pos = pPlayer->EyePosition();
|
||||
|
||||
var->SetVecValue(vs_pos.x, vs_pos.y, vs_pos.z);
|
||||
|
||||
DrawScreenEffectMaterial(pMaterial, x, y, width, height);
|
||||
}
|
||||
}
|
||||
|
||||
void CViewRender::DrawIRDOF(int x, int y, int width, int height)
|
||||
{
|
||||
|
||||
C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer();
|
||||
if (pPlayer)
|
||||
{
|
||||
C_BaseCombatWeapon *pWeapon = pPlayer->GetActiveWeapon();
|
||||
|
||||
bool inReload = pWeapon != NULL ? pWeapon->IsInReload() && r_post_draw_InReload_dof.GetInt() : false;
|
||||
|
||||
if (pPlayer->IsInSelectionSlowMo() | inReload)
|
||||
{
|
||||
IMaterial *pMaterial4 = materials->FindMaterial("effects/shaders/downsample_4", TEXTURE_GROUP_OTHER);
|
||||
DrawScreenEffectMaterial(pMaterial4, x, y, width, height);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*float GetSceneFadeScalar()
|
||||
{
|
||||
byte color[4];
|
||||
bool blend;
|
||||
vieweffects->GetFadeParams(&color[0], &color[1], &color[2], &color[3], &blend);
|
||||
|
||||
return 1.0f - (color[3] / 255.0f);
|
||||
}
|
||||
void CViewRender::DrawSunRays(int x, int y, int width, int height)
|
||||
{
|
||||
if (!r_post_draw_sunrays.GetInt())
|
||||
return;
|
||||
else
|
||||
{
|
||||
if (!r_post_draw_sunrays_amount.GetFloat())
|
||||
{
|
||||
static const int iScreenSunRays = shaderEdit->GetPPEIndex(SUNRAYS_EDITOR_NAME);
|
||||
if (iScreenSunRays < 0)
|
||||
return;
|
||||
DEFINE_SHADEREDITOR_MATERIALVAR(SUNRAYS_EDITOR_NAME, "sunrays calc", "$MUTABLE_01", sunrays_calc);
|
||||
|
||||
sunrays_calc->SetVecValue(1.0f * GetSceneFadeScalar(), 0, 0, 0);
|
||||
|
||||
CMatRenderContextPtr pRenderContext(materials);
|
||||
|
||||
pRenderContext->PushRenderTargetAndViewport();
|
||||
|
||||
ITexture *dest_rt0 = materials->FindTexture("_rt_SEdit_Skymask", TEXTURE_GROUP_RENDER_TARGET);//"_rt_SmallFB0"
|
||||
|
||||
//SetRenderTargetAndViewPort(dest_rt0);
|
||||
pRenderContext->SetRenderTarget(dest_rt0);
|
||||
pRenderContext->Viewport(0, 0, dest_rt0->GetActualWidth(), dest_rt0->GetActualHeight());
|
||||
|
||||
//SetRenderTargetAndViewPort(dest_rt0);
|
||||
|
||||
pRenderContext->PopRenderTargetAndViewport();
|
||||
|
||||
Assert(sunrays_calc);
|
||||
|
||||
if (sunrays_calc == NULL)
|
||||
{
|
||||
Assert(0);
|
||||
return;
|
||||
}
|
||||
|
||||
pRenderContext->OverrideDepthEnable(true, true);
|
||||
shaderEdit->DrawPPEOnDemand(iScreenSunRays, x, y, width, height);
|
||||
pRenderContext->OverrideDepthEnable(false, false);
|
||||
|
||||
|
||||
|
||||
}
|
||||
else if (r_post_draw_sunrays_amount.GetFloat() == 1)
|
||||
{
|
||||
static const int iScreenSunRays2 = shaderEdit->GetPPEIndex(SUNRAYS2_EDITOR_NAME);
|
||||
if (iScreenSunRays2 < 0)
|
||||
return;
|
||||
DEFINE_SHADEREDITOR_MATERIALVAR(SUNRAYS_EDITOR_NAME, "sunrays calc", "$MUTABLE_01", sunrays_calc);
|
||||
|
||||
sunrays_calc->SetVecValue(1.0f * GetSceneFadeScalar(), 0, 0, 0);
|
||||
|
||||
CMatRenderContextPtr pRenderContext(materials);
|
||||
|
||||
pRenderContext->PushRenderTargetAndViewport();
|
||||
|
||||
ITexture *dest_rt0 = materials->FindTexture("_rt_SmallFB0", TEXTURE_GROUP_RENDER_TARGET);
|
||||
|
||||
//SetRenderTargetAndViewPort(dest_rt0);
|
||||
pRenderContext->SetRenderTarget(dest_rt0);
|
||||
pRenderContext->Viewport(0, 0, dest_rt0->GetActualWidth(), dest_rt0->GetActualHeight());
|
||||
|
||||
//SetRenderTargetAndViewPort(dest_rt0);
|
||||
|
||||
pRenderContext->PopRenderTargetAndViewport();
|
||||
|
||||
Assert(sunrays_calc);
|
||||
|
||||
if (sunrays_calc == NULL)
|
||||
{
|
||||
Assert(0);
|
||||
return;
|
||||
}
|
||||
|
||||
pRenderContext->OverrideDepthEnable(true, false);
|
||||
shaderEdit->DrawPPEOnDemand(iScreenSunRays2, x, y, width, height);
|
||||
pRenderContext->OverrideDepthEnable(false, false);
|
||||
}
|
||||
else if (r_post_draw_sunrays_amount.GetFloat() == 2)
|
||||
{
|
||||
static const int iScreenSunRays3 = shaderEdit->GetPPEIndex(SUNRAYS3_EDITOR_NAME);
|
||||
if (iScreenSunRays3 < 0)
|
||||
return;
|
||||
DEFINE_SHADEREDITOR_MATERIALVAR(SUNRAYS_EDITOR_NAME, "sunrays calc", "$MUTABLE_01", sunrays_calc);
|
||||
|
||||
sunrays_calc->SetVecValue(1.0f * GetSceneFadeScalar(), 0, 0, 0);
|
||||
|
||||
CMatRenderContextPtr pRenderContext(materials);
|
||||
|
||||
pRenderContext->PushRenderTargetAndViewport();
|
||||
|
||||
ITexture *dest_rt0 = materials->FindTexture("_rt_SmallFB0", TEXTURE_GROUP_RENDER_TARGET);
|
||||
|
||||
//SetRenderTargetAndViewPort(dest_rt0);
|
||||
pRenderContext->SetRenderTarget(dest_rt0);
|
||||
pRenderContext->Viewport(0, 0, dest_rt0->GetActualWidth(), dest_rt0->GetActualHeight());
|
||||
|
||||
//SetRenderTargetAndViewPort(dest_rt0);
|
||||
|
||||
pRenderContext->PopRenderTargetAndViewport();
|
||||
|
||||
Assert(sunrays_calc);
|
||||
|
||||
if (sunrays_calc == NULL)
|
||||
{
|
||||
Assert(0);
|
||||
return;
|
||||
}
|
||||
|
||||
pRenderContext->OverrideDepthEnable(true, false);
|
||||
shaderEdit->DrawPPEOnDemand(iScreenSunRays3, x, y, width, height);
|
||||
pRenderContext->OverrideDepthEnable(false, false);
|
||||
}
|
||||
|
||||
|
||||
if (!r_post_draw_sunrays.GetBool())
|
||||
return;
|
||||
|
||||
|
||||
}
|
||||
}*/
|
||||
231
game/client/EffectsClient.cpp
Normal file
231
game/client/EffectsClient.cpp
Normal file
@@ -0,0 +1,231 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: Utility code.
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
#include "cbase.h"
|
||||
#include "IEffects.h"
|
||||
#include "fx.h"
|
||||
#include "c_te_legacytempents.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Client-server neutral effects interface
|
||||
//-----------------------------------------------------------------------------
|
||||
class CEffectsClient : public IEffects
|
||||
{
|
||||
public:
|
||||
CEffectsClient();
|
||||
virtual ~CEffectsClient();
|
||||
|
||||
// Members of the IEffect interface
|
||||
virtual void Beam( const Vector &Start, const Vector &End, int nModelIndex,
|
||||
int nHaloIndex, unsigned char frameStart, unsigned char frameRate,
|
||||
float flLife, unsigned char width, unsigned char endWidth, unsigned char fadeLength,
|
||||
unsigned char noise, unsigned char red, unsigned char green,
|
||||
unsigned char blue, unsigned char brightness, unsigned char speed);
|
||||
virtual void Smoke( const Vector &origin, int modelIndex, float scale, float framerate );
|
||||
virtual void Sparks( const Vector &position, int nMagnitude = 1, int nTrailLength = 1, const Vector *pvecDir = NULL );
|
||||
virtual void Dust( const Vector &pos, const Vector &dir, float size, float speed );
|
||||
virtual void MuzzleFlash( const Vector &origin, const QAngle &angles, float fScale, int type );
|
||||
virtual void MetalSparks( const Vector &position, const Vector &direction );
|
||||
virtual void EnergySplash( const Vector &position, const Vector &direction, bool bExplosive = false );
|
||||
virtual void Ricochet( const Vector &position, const Vector &direction );
|
||||
|
||||
// FIXME: Should these methods remain in this interface? Or go in some
|
||||
// other client-server neutral interface?
|
||||
virtual float Time();
|
||||
virtual bool IsServer();
|
||||
virtual void SuppressEffectsSounds( bool bSuppress );
|
||||
|
||||
private:
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Returning true means don't even call TE func
|
||||
// Input : filter -
|
||||
// *suppress_host -
|
||||
// Output : static bool
|
||||
//-----------------------------------------------------------------------------
|
||||
bool SuppressTE( C_RecipientFilter& filter )
|
||||
{
|
||||
if ( !CanPredict() )
|
||||
return true;
|
||||
|
||||
if ( !filter.GetRecipientCount() )
|
||||
{
|
||||
// Suppress it
|
||||
return true;
|
||||
}
|
||||
|
||||
// There's at least one recipient
|
||||
return false;
|
||||
}
|
||||
|
||||
bool m_bSuppressSound;
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Client-server neutral effects interface accessor
|
||||
//-----------------------------------------------------------------------------
|
||||
static CEffectsClient s_EffectClient;
|
||||
EXPOSE_SINGLE_INTERFACE_GLOBALVAR(CEffectsClient, IEffects, IEFFECTS_INTERFACE_VERSION, s_EffectClient);
|
||||
IEffects *g_pEffects = &s_EffectClient;
|
||||
|
||||
ConVar r_decals( "r_decals", "2048" );
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// constructor, destructor
|
||||
//-----------------------------------------------------------------------------
|
||||
CEffectsClient::CEffectsClient()
|
||||
{
|
||||
m_bSuppressSound = false;
|
||||
}
|
||||
|
||||
CEffectsClient::~CEffectsClient()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Suppress sound on effects
|
||||
//-----------------------------------------------------------------------------
|
||||
void CEffectsClient::SuppressEffectsSounds( bool bSuppress )
|
||||
{
|
||||
m_bSuppressSound = bSuppress;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Generates a beam
|
||||
//-----------------------------------------------------------------------------
|
||||
void CEffectsClient::Beam( const Vector &vecStartPoint, const Vector &vecEndPoint,
|
||||
int nModelIndex, int nHaloIndex, unsigned char frameStart, unsigned char nFrameRate,
|
||||
float flLife, unsigned char nWidth, unsigned char nEndWidth, unsigned char nFadeLength,
|
||||
unsigned char noise, unsigned char r, unsigned char g,
|
||||
unsigned char b, unsigned char brightness, unsigned char nSpeed)
|
||||
{
|
||||
Assert(0);
|
||||
// CBroadcastRecipientFilter filter;
|
||||
// if ( !SuppressTE( filter ) )
|
||||
// {
|
||||
// beams->CreateBeamPoints( vecStartPoint, vecEndPoint, nModelIndex, nHaloIndex,
|
||||
// m_fHaloScale,
|
||||
// flLife, 0.1 * nWidth, 0.1 * nEndWidth, nFadeLength, 0.01 * nAmplitude, a, 0.1 * nSpeed,
|
||||
// m_nStartFrame, 0.1 * nFrameRate, r, g, b );
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Generates various tempent effects
|
||||
//-----------------------------------------------------------------------------
|
||||
void CEffectsClient::Smoke( const Vector &vecOrigin, int modelIndex, float scale, float framerate )
|
||||
{
|
||||
CPVSFilter filter( vecOrigin );
|
||||
if ( !SuppressTE( filter ) )
|
||||
{
|
||||
int iColor = random->RandomInt(20,35);
|
||||
color32 color;
|
||||
color.r = iColor;
|
||||
color.g = iColor;
|
||||
color.b = iColor;
|
||||
color.a = iColor;
|
||||
QAngle angles;
|
||||
VectorAngles( Vector(0,0,1), angles );
|
||||
FX_Smoke( vecOrigin, angles, scale * 0.1f, 4, (unsigned char *)&color, 255 );
|
||||
}
|
||||
}
|
||||
|
||||
void CEffectsClient::Sparks( const Vector &position, int nMagnitude, int nTrailLength, const Vector *pVecDir )
|
||||
{
|
||||
CPVSFilter filter( position );
|
||||
if ( !SuppressTE( filter ) )
|
||||
{
|
||||
FX_ElectricSpark( position, nMagnitude, nTrailLength, pVecDir );
|
||||
}
|
||||
}
|
||||
|
||||
void CEffectsClient::Dust( const Vector &pos, const Vector &dir, float size, float speed )
|
||||
{
|
||||
CPVSFilter filter( pos );
|
||||
if ( !SuppressTE( filter ) )
|
||||
{
|
||||
FX_Dust( pos, dir, size, speed );
|
||||
}
|
||||
}
|
||||
|
||||
void CEffectsClient::MuzzleFlash( const Vector &vecOrigin, const QAngle &vecAngles, float flScale, int iType )
|
||||
{
|
||||
CPVSFilter filter( vecOrigin );
|
||||
if ( !SuppressTE( filter ) )
|
||||
{
|
||||
switch( iType )
|
||||
{
|
||||
case MUZZLEFLASH_TYPE_DEFAULT:
|
||||
FX_MuzzleEffect( vecOrigin, vecAngles, flScale, INVALID_EHANDLE_INDEX );
|
||||
break;
|
||||
|
||||
case MUZZLEFLASH_TYPE_GUNSHIP:
|
||||
FX_GunshipMuzzleEffect( vecOrigin, vecAngles, flScale, INVALID_EHANDLE_INDEX );
|
||||
break;
|
||||
|
||||
case MUZZLEFLASH_TYPE_STRIDER:
|
||||
FX_StriderMuzzleEffect( vecOrigin, vecAngles, flScale, INVALID_EHANDLE_INDEX );
|
||||
break;
|
||||
|
||||
default:
|
||||
Msg("No case for Muzzleflash type: %d\n", iType );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CEffectsClient::MetalSparks( const Vector &position, const Vector &direction )
|
||||
{
|
||||
CPVSFilter filter( position );
|
||||
if ( !SuppressTE( filter ) )
|
||||
{
|
||||
FX_MetalSpark( position, direction, direction );
|
||||
}
|
||||
}
|
||||
|
||||
void CEffectsClient::EnergySplash( const Vector &position, const Vector &direction, bool bExplosive )
|
||||
{
|
||||
CPVSFilter filter( position );
|
||||
if ( !SuppressTE( filter ) )
|
||||
{
|
||||
FX_EnergySplash( position, direction, bExplosive );
|
||||
}
|
||||
}
|
||||
|
||||
void CEffectsClient::Ricochet( const Vector &position, const Vector &direction )
|
||||
{
|
||||
CPVSFilter filter( position );
|
||||
if ( !SuppressTE( filter ) )
|
||||
{
|
||||
FX_MetalSpark( position, direction, direction );
|
||||
|
||||
if ( !m_bSuppressSound )
|
||||
{
|
||||
FX_RicochetSound( position );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// FIXME: Should these methods remain in this interface? Or go in some
|
||||
// other client-server neutral interface?
|
||||
float CEffectsClient::Time()
|
||||
{
|
||||
return gpGlobals->curtime;
|
||||
}
|
||||
|
||||
|
||||
bool CEffectsClient::IsServer()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
955
game/client/FloatSlider.cpp
Normal file
955
game/client/FloatSlider.cpp
Normal file
@@ -0,0 +1,955 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#include "cbase.h"
|
||||
#include <stdio.h>
|
||||
#define PROTECTED_THINGS_DISABLE
|
||||
|
||||
#include <vgui/MouseCode.h>
|
||||
#include <KeyValues.h>
|
||||
#include <vgui/IBorder.h>
|
||||
#include <vgui/IInput.h>
|
||||
#include <vgui/ISystem.h>
|
||||
#include <vgui/IScheme.h>
|
||||
#include <vgui/ISurface.h>
|
||||
#include <vgui/ILocalize.h>
|
||||
|
||||
#include "game_controls/FloatSlider.h"
|
||||
#include <vgui_controls/Controls.h>
|
||||
#include <vgui_controls/TextImage.h>
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include <tier0/memdbgon.h>
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
DECLARE_BUILD_FACTORY(FloatSlider);
|
||||
|
||||
static const float NOB_SIZE = 8.0f;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Create a slider bar with ticks underneath it
|
||||
//-----------------------------------------------------------------------------
|
||||
FloatSlider::FloatSlider(Panel *parent, const char *panelName) : BaseClass(parent, panelName)
|
||||
{
|
||||
m_bIsDragOnRepositionNob = false;
|
||||
_dragging = false;
|
||||
_value = 0;
|
||||
_range[0] = 0;
|
||||
_range[1] = 0;
|
||||
_buttonOffset = 0;
|
||||
_sliderBorder = NULL;
|
||||
_insetBorder = NULL;
|
||||
m_nNumTicks = 10;
|
||||
_leftCaption = NULL;
|
||||
_rightCaption = NULL;
|
||||
|
||||
_subrange[0] = 0;
|
||||
_subrange[1] = 0;
|
||||
m_bUseSubRange = false;
|
||||
m_bInverted = false;
|
||||
|
||||
SetThumbWidth(8);
|
||||
RecomputeNobPosFromValue();
|
||||
AddActionSignalTarget(this);
|
||||
SetBlockDragChaining(true);
|
||||
}
|
||||
|
||||
// This allows the slider to behave like it's larger than what's actually being drawn
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : bEnable -
|
||||
// 0 -
|
||||
// 100 -
|
||||
//-----------------------------------------------------------------------------
|
||||
void FloatSlider::SetSliderThumbSubRange(bool bEnable, int nMin /*= 0*/, int nMax /*= 100*/)
|
||||
{
|
||||
m_bUseSubRange = bEnable;
|
||||
_subrange[0] = nMin;
|
||||
_subrange[1] = nMax;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Set the size of the slider bar.
|
||||
// Warning less than 30 pixels tall and everything probably won't fit.
|
||||
//-----------------------------------------------------------------------------
|
||||
void FloatSlider::OnSizeChanged(int wide, int tall)
|
||||
{
|
||||
BaseClass::OnSizeChanged(wide, tall);
|
||||
|
||||
RecomputeNobPosFromValue();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Set the value of the slider to one of the ticks.
|
||||
//-----------------------------------------------------------------------------
|
||||
void FloatSlider::SetValue(float value, bool bTriggerChangeMessage)
|
||||
{
|
||||
float oldValue = _value;
|
||||
|
||||
if (_range[0] < _range[1])
|
||||
{
|
||||
if (value<_range[0])
|
||||
{
|
||||
value = _range[0];
|
||||
}
|
||||
if (value>_range[1])
|
||||
{
|
||||
value = _range[1];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (value<_range[1])
|
||||
{
|
||||
value = _range[1];
|
||||
}
|
||||
if (value>_range[0])
|
||||
{
|
||||
value = _range[0];
|
||||
}
|
||||
}
|
||||
|
||||
_value = value;
|
||||
|
||||
RecomputeNobPosFromValue();
|
||||
|
||||
if (_value != oldValue && bTriggerChangeMessage)
|
||||
{
|
||||
SendSliderMovedMessage();
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Return the value of the slider
|
||||
//-----------------------------------------------------------------------------
|
||||
float FloatSlider::GetValue()
|
||||
{
|
||||
return _value;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Layout the slider before drawing it on screen.
|
||||
//-----------------------------------------------------------------------------
|
||||
void FloatSlider::PerformLayout()
|
||||
{
|
||||
BaseClass::PerformLayout();
|
||||
RecomputeNobPosFromValue();
|
||||
|
||||
if (_leftCaption)
|
||||
{
|
||||
_leftCaption->ResizeImageToContent();
|
||||
}
|
||||
if (_rightCaption)
|
||||
{
|
||||
_rightCaption->ResizeImageToContent();
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Move the nob on the slider in response to changing its value.
|
||||
//-----------------------------------------------------------------------------
|
||||
void FloatSlider::RecomputeNobPosFromValue()
|
||||
{
|
||||
//int wide,tall;
|
||||
//GetPaintSize(wide,tall);
|
||||
int x, y, wide, tall;
|
||||
GetTrackRect(x, y, wide, tall);
|
||||
|
||||
float usevalue = _value;
|
||||
float *userange = &_range[0];
|
||||
if (m_bUseSubRange)
|
||||
{
|
||||
userange = &_subrange[0];
|
||||
usevalue = clamp(_value, _subrange[0], _subrange[1]);
|
||||
}
|
||||
|
||||
float fwide = (float)wide;
|
||||
float frange = (float)(userange[1] - userange[0]);
|
||||
float fvalue = (float)(usevalue - userange[0]);
|
||||
float fper = (frange != 0.0f) ? fvalue / frange : 0.0f;
|
||||
|
||||
if (m_bInverted)
|
||||
fper = 1.0f - fper;
|
||||
|
||||
float freepixels = fwide - _nobSize;
|
||||
float leftpixel = (float)x;
|
||||
float firstpixel = leftpixel + freepixels * fper + 0.5f;
|
||||
|
||||
_nobPos[0] = (int)(firstpixel);
|
||||
_nobPos[1] = (int)(firstpixel + _nobSize);
|
||||
|
||||
|
||||
int rightEdge = x + wide;
|
||||
|
||||
if (_nobPos[1]> rightEdge)
|
||||
{
|
||||
_nobPos[0] = rightEdge - _nobSize;
|
||||
_nobPos[1] = rightEdge;
|
||||
}
|
||||
|
||||
Repaint();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Sync the slider's value up with the nob's position.
|
||||
//-----------------------------------------------------------------------------
|
||||
void FloatSlider::RecomputeValueFromNobPos()
|
||||
{
|
||||
float value = EstimateValueAtPos(_nobPos[0], 0);
|
||||
SetValue(value);
|
||||
}
|
||||
|
||||
float FloatSlider::EstimateValueAtPos(int localMouseX, int /*localMouseY*/)
|
||||
{
|
||||
int x, y, wide, tall;
|
||||
GetTrackRect(x, y, wide, tall);
|
||||
|
||||
float *userange = &_range[0];
|
||||
if (m_bUseSubRange)
|
||||
{
|
||||
userange = &_subrange[0];
|
||||
}
|
||||
|
||||
float fwide = (float)wide;
|
||||
float fvalue = (float)(_value - userange[0]);
|
||||
float fnob = (float)(localMouseX - x);
|
||||
float freepixels = fwide - _nobSize;
|
||||
|
||||
// Map into reduced range
|
||||
fvalue = freepixels != 0.0f ? fnob / freepixels : 0.0f;
|
||||
|
||||
return RemapVal(fvalue, 0.0, 1.0, userange[0], userange[1]);
|
||||
}
|
||||
|
||||
void FloatSlider::SetInverted(bool bInverted)
|
||||
{
|
||||
m_bInverted = bInverted;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Send a message to interested parties when the slider moves
|
||||
//-----------------------------------------------------------------------------
|
||||
void FloatSlider::SendSliderMovedMessage()
|
||||
{
|
||||
// send a changed message
|
||||
KeyValues *pParams = new KeyValues("SliderMoved", "position", _value);
|
||||
pParams->SetPtr("panel", this);
|
||||
PostActionSignal(pParams);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Send a message to interested parties when the user begins dragging the slider
|
||||
//-----------------------------------------------------------------------------
|
||||
void FloatSlider::SendSliderDragStartMessage()
|
||||
{
|
||||
// send a message
|
||||
KeyValues *pParams = new KeyValues("SliderDragStart", "position", _value);
|
||||
pParams->SetPtr("panel", this);
|
||||
PostActionSignal(pParams);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Send a message to interested parties when the user ends dragging the slider
|
||||
//-----------------------------------------------------------------------------
|
||||
void FloatSlider::SendSliderDragEndMessage()
|
||||
{
|
||||
// send a message
|
||||
KeyValues *pParams = new KeyValues("SliderDragEnd", "position", _value);
|
||||
pParams->SetPtr("panel", this);
|
||||
PostActionSignal(pParams);
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void FloatSlider::ApplySchemeSettings(IScheme *pScheme)
|
||||
{
|
||||
BaseClass::ApplySchemeSettings(pScheme);
|
||||
|
||||
SetFgColor(GetSchemeColor("FloatSlider.NobColor", pScheme));
|
||||
// this line is useful for debugging
|
||||
//SetBgColor(GetSchemeColor("0 0 0 255"));
|
||||
|
||||
m_TickColor = pScheme->GetColor("FloatSlider.TextColor", GetFgColor());
|
||||
m_TrackColor = pScheme->GetColor("FloatSlider.TrackColor", GetFgColor());
|
||||
|
||||
#ifdef _X360
|
||||
m_DepressedBgColor = GetSchemeColor("FloatSlider.NobFocusColor", pScheme);
|
||||
#endif
|
||||
|
||||
m_DisabledTextColor1 = pScheme->GetColor("FloatSlider.DisabledTextColor1", GetFgColor());
|
||||
m_DisabledTextColor2 = pScheme->GetColor("FloatSlider.DisabledTextColor2", GetFgColor());
|
||||
|
||||
_sliderBorder = pScheme->GetBorder("ButtonBorder");
|
||||
_insetBorder = pScheme->GetBorder("ButtonDepressedBorder");
|
||||
|
||||
if (_leftCaption)
|
||||
{
|
||||
_leftCaption->SetFont(pScheme->GetFont("DefaultVerySmall", IsProportional()));
|
||||
}
|
||||
|
||||
if (_rightCaption)
|
||||
{
|
||||
_rightCaption->SetFont(pScheme->GetFont("DefaultVerySmall", IsProportional()));
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void FloatSlider::GetSettings(KeyValues *outResourceData)
|
||||
{
|
||||
BaseClass::GetSettings(outResourceData);
|
||||
|
||||
char buf[256];
|
||||
if (_leftCaption)
|
||||
{
|
||||
_leftCaption->GetUnlocalizedText(buf, sizeof(buf));
|
||||
outResourceData->SetString("leftText", buf);
|
||||
}
|
||||
|
||||
if (_rightCaption)
|
||||
{
|
||||
_rightCaption->GetUnlocalizedText(buf, sizeof(buf));
|
||||
outResourceData->SetString("rightText", buf);
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void FloatSlider::ApplySettings(KeyValues *inResourceData)
|
||||
{
|
||||
BaseClass::ApplySettings(inResourceData);
|
||||
|
||||
const char *left = inResourceData->GetString("leftText", NULL);
|
||||
const char *right = inResourceData->GetString("rightText", NULL);
|
||||
|
||||
int thumbWidth = inResourceData->GetInt("thumbwidth", 0);
|
||||
if (thumbWidth != 0)
|
||||
{
|
||||
SetThumbWidth(thumbWidth);
|
||||
}
|
||||
|
||||
SetTickCaptions(left, right);
|
||||
|
||||
int nNumTicks = inResourceData->GetInt("numTicks", -1);
|
||||
if (nNumTicks >= 0)
|
||||
{
|
||||
SetNumTicks(nNumTicks);
|
||||
}
|
||||
|
||||
float nCurrentRange[2];
|
||||
GetRange(nCurrentRange[0], nCurrentRange[1]);
|
||||
KeyValues *pRangeMin = inResourceData->FindKey("rangeMin", false);
|
||||
KeyValues *pRangeMax = inResourceData->FindKey("rangeMax", false);
|
||||
bool bDoClamp = false;
|
||||
if (pRangeMin)
|
||||
{
|
||||
_range[0] = inResourceData->GetFloat("rangeMin");
|
||||
bDoClamp = true;
|
||||
}
|
||||
if (pRangeMax)
|
||||
{
|
||||
_range[1] = inResourceData->GetFloat("rangeMax");
|
||||
bDoClamp = true;
|
||||
}
|
||||
|
||||
if (bDoClamp)
|
||||
{
|
||||
ClampRange();
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
const char *FloatSlider::GetDescription()
|
||||
{
|
||||
static char buf[1024];
|
||||
Q_snprintf(buf, sizeof(buf), "%s, string leftText, string rightText", BaseClass::GetDescription());
|
||||
return buf;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Get the rectangle to draw the slider track in.
|
||||
//-----------------------------------------------------------------------------
|
||||
void FloatSlider::GetTrackRect(int& x, int& y, int& w, int& h)
|
||||
{
|
||||
int wide, tall;
|
||||
GetPaintSize(wide, tall);
|
||||
|
||||
x = 0;
|
||||
y = 8;
|
||||
w = wide - (int)_nobSize;
|
||||
h = 4;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Draw everything on screen
|
||||
//-----------------------------------------------------------------------------
|
||||
void FloatSlider::Paint()
|
||||
{
|
||||
DrawTicks();
|
||||
|
||||
DrawTickLabels();
|
||||
|
||||
// Draw nob last so it draws over ticks.
|
||||
DrawNob();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Draw the ticks below the slider.
|
||||
//-----------------------------------------------------------------------------
|
||||
void FloatSlider::DrawTicks()
|
||||
{
|
||||
int x, y;
|
||||
int wide, tall;
|
||||
GetTrackRect(x, y, wide, tall);
|
||||
|
||||
// Figure out how to draw the ticks
|
||||
// GetPaintSize( wide, tall );
|
||||
|
||||
float fwide = (float)wide;
|
||||
float freepixels = fwide - _nobSize;
|
||||
|
||||
float leftpixel = _nobSize / 2.0f;
|
||||
|
||||
float pixelspertick = freepixels / (m_nNumTicks);
|
||||
|
||||
y += (int)_nobSize;
|
||||
int tickHeight = 5;
|
||||
|
||||
if (IsEnabled())
|
||||
{
|
||||
surface()->DrawSetColor(m_TickColor); //vgui::Color( 127, 140, 127, 255 ) );
|
||||
for (int i = 0; i <= m_nNumTicks; i++)
|
||||
{
|
||||
int xpos = (int)(leftpixel + i * pixelspertick);
|
||||
|
||||
surface()->DrawFilledRect(xpos, y, xpos + 1, y + tickHeight);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
surface()->DrawSetColor(m_DisabledTextColor1); //vgui::Color( 127, 140, 127, 255 ) );
|
||||
for (int i = 0; i <= m_nNumTicks; i++)
|
||||
{
|
||||
int xpos = (int)(leftpixel + i * pixelspertick);
|
||||
surface()->DrawFilledRect(xpos + 1, y + 1, xpos + 2, y + tickHeight + 1);
|
||||
}
|
||||
surface()->DrawSetColor(m_DisabledTextColor2); //vgui::Color( 127, 140, 127, 255 ) );
|
||||
for (int i = 0; i <= m_nNumTicks; i++)
|
||||
{
|
||||
int xpos = (int)(leftpixel + i * pixelspertick);
|
||||
surface()->DrawFilledRect(xpos, y, xpos + 1, y + tickHeight);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Draw Tick labels under the ticks.
|
||||
//-----------------------------------------------------------------------------
|
||||
void FloatSlider::DrawTickLabels()
|
||||
{
|
||||
int x, y;
|
||||
int wide, tall;
|
||||
GetTrackRect(x, y, wide, tall);
|
||||
|
||||
// Figure out how to draw the ticks
|
||||
// GetPaintSize( wide, tall );
|
||||
y += (int)NOB_SIZE + 4;
|
||||
|
||||
// Draw Start and end range values
|
||||
if (IsEnabled())
|
||||
surface()->DrawSetTextColor(m_TickColor); //vgui::Color( 127, 140, 127, 255 ) );
|
||||
else
|
||||
surface()->DrawSetTextColor(m_DisabledTextColor1); //vgui::Color( 127, 140, 127, 255 ) );
|
||||
|
||||
|
||||
if (_leftCaption != NULL)
|
||||
{
|
||||
_leftCaption->SetPos(0, y);
|
||||
if (IsEnabled())
|
||||
{
|
||||
_leftCaption->SetColor(m_TickColor);
|
||||
}
|
||||
else
|
||||
{
|
||||
_leftCaption->SetColor(m_DisabledTextColor1);
|
||||
}
|
||||
|
||||
_leftCaption->Paint();
|
||||
}
|
||||
|
||||
if (_rightCaption != NULL)
|
||||
{
|
||||
int rwide, rtall;
|
||||
_rightCaption->GetSize(rwide, rtall);
|
||||
_rightCaption->SetPos((int)(wide - rwide), y);
|
||||
if (IsEnabled())
|
||||
{
|
||||
_rightCaption->SetColor(m_TickColor);
|
||||
}
|
||||
else
|
||||
{
|
||||
_rightCaption->SetColor(m_DisabledTextColor1);
|
||||
}
|
||||
|
||||
_rightCaption->Paint();
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Draw the nob part of the slider.
|
||||
//-----------------------------------------------------------------------------
|
||||
void FloatSlider::DrawNob()
|
||||
{
|
||||
// horizontal nob
|
||||
int x, y;
|
||||
int wide, tall;
|
||||
GetTrackRect(x, y, wide, tall);
|
||||
Color col = GetFgColor();
|
||||
#ifdef _X360
|
||||
if (HasFocus())
|
||||
{
|
||||
col = m_DepressedBgColor;
|
||||
}
|
||||
#endif
|
||||
surface()->DrawSetColor(col);
|
||||
|
||||
int nobheight = 16;
|
||||
|
||||
surface()->DrawFilledRect(
|
||||
_nobPos[0],
|
||||
y + tall / 2 - nobheight / 2,
|
||||
_nobPos[1],
|
||||
y + tall / 2 + nobheight / 2);
|
||||
// border
|
||||
if (_sliderBorder)
|
||||
{
|
||||
_sliderBorder->Paint(
|
||||
_nobPos[0],
|
||||
y + tall / 2 - nobheight / 2,
|
||||
_nobPos[1],
|
||||
y + tall / 2 + nobheight / 2);
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Set the text labels of the Start and end ticks.
|
||||
//-----------------------------------------------------------------------------
|
||||
void FloatSlider::SetTickCaptions(const char *left, const char *right)
|
||||
{
|
||||
if (left)
|
||||
{
|
||||
if (_leftCaption)
|
||||
{
|
||||
_leftCaption->SetText(left);
|
||||
}
|
||||
else
|
||||
{
|
||||
_leftCaption = new TextImage(left);
|
||||
}
|
||||
}
|
||||
if (right)
|
||||
{
|
||||
if (_rightCaption)
|
||||
{
|
||||
_rightCaption->SetText(right);
|
||||
}
|
||||
else
|
||||
{
|
||||
_rightCaption = new TextImage(right);
|
||||
}
|
||||
}
|
||||
InvalidateLayout();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Set the text labels of the Start and end ticks.
|
||||
//-----------------------------------------------------------------------------
|
||||
void FloatSlider::SetTickCaptions(const wchar_t *left, const wchar_t *right)
|
||||
{
|
||||
if (left)
|
||||
{
|
||||
if (_leftCaption)
|
||||
{
|
||||
_leftCaption->SetText(left);
|
||||
}
|
||||
else
|
||||
{
|
||||
_leftCaption = new TextImage(left);
|
||||
}
|
||||
}
|
||||
if (right)
|
||||
{
|
||||
if (_rightCaption)
|
||||
{
|
||||
_rightCaption->SetText(right);
|
||||
}
|
||||
else
|
||||
{
|
||||
_rightCaption = new TextImage(right);
|
||||
}
|
||||
}
|
||||
InvalidateLayout();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Draw the slider track
|
||||
//-----------------------------------------------------------------------------
|
||||
void FloatSlider::PaintBackground()
|
||||
{
|
||||
BaseClass::PaintBackground();
|
||||
|
||||
int x, y;
|
||||
int wide, tall;
|
||||
|
||||
GetTrackRect(x, y, wide, tall);
|
||||
|
||||
surface()->DrawSetColor(m_TrackColor);
|
||||
surface()->DrawFilledRect(x, y, x + wide, y + tall);
|
||||
if (_insetBorder)
|
||||
{
|
||||
_insetBorder->Paint(x, y, x + wide, y + tall);
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Set the range of the slider.
|
||||
//-----------------------------------------------------------------------------
|
||||
void FloatSlider::SetRange(float min, float max)
|
||||
{
|
||||
_range[0] = min;
|
||||
_range[1] = max;
|
||||
|
||||
ClampRange();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Sanity check and clamp the range if necessary.
|
||||
//-----------------------------------------------------------------------------
|
||||
void FloatSlider::ClampRange()
|
||||
{
|
||||
if (_range[0] < _range[1])
|
||||
{
|
||||
if (_value<_range[0])
|
||||
{
|
||||
SetValue(_range[0], false);
|
||||
}
|
||||
else if (_value>_range[1])
|
||||
{
|
||||
SetValue(_range[1], false);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_value<_range[1])
|
||||
{
|
||||
SetValue(_range[1], false);
|
||||
}
|
||||
else if (_value>_range[0])
|
||||
{
|
||||
SetValue(_range[0], false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Get the max and min values of the slider
|
||||
//-----------------------------------------------------------------------------
|
||||
void FloatSlider::GetRange(float& min, float& max)
|
||||
{
|
||||
min = _range[0];
|
||||
max = _range[1];
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Respond when the cursor is moved in our window if we are clicking
|
||||
// and dragging.
|
||||
//-----------------------------------------------------------------------------
|
||||
void FloatSlider::OnCursorMoved(int x, int y)
|
||||
{
|
||||
if (!_dragging)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// input()->GetCursorPos(x,y);
|
||||
input()->GetCursorPosition(x, y);
|
||||
ScreenToLocal(x, y);
|
||||
|
||||
// int wide,tall;
|
||||
// GetPaintSize(wide,tall);
|
||||
int _x, _y, wide, tall;
|
||||
GetTrackRect(_x, _y, wide, tall);
|
||||
|
||||
_nobPos[0] = _nobDragStartPos[0] + (x - _dragStartPos[0]);
|
||||
_nobPos[1] = _nobDragStartPos[1] + (x - _dragStartPos[0]);
|
||||
|
||||
int rightEdge = _x + wide;
|
||||
int unclamped = _nobPos[0];
|
||||
|
||||
if (_nobPos[1]>rightEdge)
|
||||
{
|
||||
_nobPos[0] = rightEdge - (_nobPos[1] - _nobPos[0]);
|
||||
_nobPos[1] = rightEdge;
|
||||
}
|
||||
|
||||
if (_nobPos[0]<_x)
|
||||
{
|
||||
int offset = _x - _nobPos[0];
|
||||
_nobPos[1] = _nobPos[1] - offset;
|
||||
_nobPos[0] = 0;
|
||||
}
|
||||
|
||||
int value = EstimateValueAtPos(unclamped, 0);
|
||||
SetValue(value);
|
||||
|
||||
// RecomputeValueFromNobPos();
|
||||
Repaint();
|
||||
SendSliderMovedMessage();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: If you click on the slider outside of the nob, the nob jumps
|
||||
// to the click position, and if this setting is enabled, the nob
|
||||
// is then draggable from the new position until the mouse is released
|
||||
// Input : state -
|
||||
//-----------------------------------------------------------------------------
|
||||
void FloatSlider::SetDragOnRepositionNob(bool state)
|
||||
{
|
||||
m_bIsDragOnRepositionNob = state;
|
||||
}
|
||||
|
||||
bool FloatSlider::IsDragOnRepositionNob() const
|
||||
{
|
||||
return m_bIsDragOnRepositionNob;
|
||||
}
|
||||
|
||||
bool FloatSlider::IsDragged(void) const
|
||||
{
|
||||
return _dragging;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Respond to mouse presses. Trigger Record staring positon.
|
||||
//-----------------------------------------------------------------------------
|
||||
void FloatSlider::OnMousePressed(MouseCode code)
|
||||
{
|
||||
int x, y;
|
||||
|
||||
if (!IsEnabled())
|
||||
return;
|
||||
|
||||
// input()->GetCursorPos(x,y);
|
||||
input()->GetCursorPosition(x, y);
|
||||
|
||||
ScreenToLocal(x, y);
|
||||
RequestFocus();
|
||||
|
||||
bool startdragging = false, bPostDragStartSignal = false;
|
||||
|
||||
if ((x >= _nobPos[0]) && (x < _nobPos[1]))
|
||||
{
|
||||
startdragging = true;
|
||||
bPostDragStartSignal = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// we clicked elsewhere on the slider; move the nob to that position
|
||||
float min, max;
|
||||
GetRange(min, max);
|
||||
if (m_bUseSubRange)
|
||||
{
|
||||
min = _subrange[0];
|
||||
max = _subrange[1];
|
||||
}
|
||||
|
||||
// int wide = GetWide();
|
||||
int _x, _y, wide, tall;
|
||||
GetTrackRect(_x, _y, wide, tall);
|
||||
if (wide > 0)
|
||||
{
|
||||
float frange = (float)(max - min);
|
||||
float clickFrac = clamp((float)(x - _x) / (float)(wide - 1), 0.0f, 1.0f);
|
||||
|
||||
float value = (float)min + clickFrac * frange;
|
||||
|
||||
startdragging = IsDragOnRepositionNob();
|
||||
|
||||
if (startdragging)
|
||||
{
|
||||
_dragging = true; // Required when as
|
||||
SendSliderDragStartMessage();
|
||||
}
|
||||
|
||||
SetValue(value);
|
||||
}
|
||||
}
|
||||
|
||||
if (startdragging)
|
||||
{
|
||||
// drag the nob
|
||||
_dragging = true;
|
||||
input()->SetMouseCapture(GetVPanel());
|
||||
_nobDragStartPos[0] = _nobPos[0];
|
||||
_nobDragStartPos[1] = _nobPos[1];
|
||||
_dragStartPos[0] = x;
|
||||
_dragStartPos[1] = y;
|
||||
}
|
||||
|
||||
if (bPostDragStartSignal)
|
||||
SendSliderDragStartMessage();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Just handle double presses like mouse presses
|
||||
//-----------------------------------------------------------------------------
|
||||
void FloatSlider::OnMouseDoublePressed(MouseCode code)
|
||||
{
|
||||
OnMousePressed(code);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
#ifdef _X360
|
||||
void FloatSlider::OnKeyCodePressed(KeyCode code)
|
||||
{
|
||||
switch (GetBaseButtonCode(code))
|
||||
{
|
||||
case KEY_XBUTTON_LEFT:
|
||||
case KEY_XSTICK1_LEFT:
|
||||
case KEY_XSTICK2_LEFT:
|
||||
SetValue(GetValue() - 1);
|
||||
break;
|
||||
case KEY_XBUTTON_RIGHT:
|
||||
case KEY_XSTICK1_RIGHT:
|
||||
case KEY_XSTICK2_RIGHT:
|
||||
SetValue(GetValue() + 1);
|
||||
break;
|
||||
default:
|
||||
BaseClass::OnKeyCodePressed(code);
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Handle key presses
|
||||
//-----------------------------------------------------------------------------
|
||||
void FloatSlider::OnKeyCodeTyped(KeyCode code)
|
||||
{
|
||||
switch (code)
|
||||
{
|
||||
// for now left and right arrows just open or close submenus if they are there.
|
||||
case KEY_LEFT:
|
||||
case KEY_DOWN:
|
||||
{
|
||||
float val = GetValue();
|
||||
SetValue(val - 0.1f);
|
||||
break;
|
||||
}
|
||||
case KEY_RIGHT:
|
||||
case KEY_UP:
|
||||
{
|
||||
int val = GetValue();
|
||||
SetValue(val + 0.1f);
|
||||
break;
|
||||
}
|
||||
case KEY_PAGEDOWN:
|
||||
{
|
||||
float min, max;
|
||||
GetRange(min, max);
|
||||
float range = max - min;
|
||||
float pertick = range / m_nNumTicks;
|
||||
float val = GetValue();
|
||||
SetValue(val - pertick);
|
||||
break;
|
||||
}
|
||||
case KEY_PAGEUP:
|
||||
{
|
||||
float min, max;
|
||||
GetRange(min, max);
|
||||
float range = max - min;
|
||||
float pertick = range / m_nNumTicks;
|
||||
float val = GetValue();
|
||||
SetValue(val + pertick);
|
||||
break;
|
||||
}
|
||||
case KEY_HOME:
|
||||
{
|
||||
float min, max;
|
||||
GetRange(min, max);
|
||||
SetValue(min);
|
||||
break;
|
||||
}
|
||||
case KEY_END:
|
||||
{
|
||||
float min, max;
|
||||
GetRange(min, max);
|
||||
SetValue(max);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
BaseClass::OnKeyCodeTyped(code);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Stop dragging when the mouse is released.
|
||||
//-----------------------------------------------------------------------------
|
||||
void FloatSlider::OnMouseReleased(MouseCode code)
|
||||
{
|
||||
if (_dragging)
|
||||
{
|
||||
_dragging = false;
|
||||
input()->SetMouseCapture(null);
|
||||
}
|
||||
|
||||
if (IsEnabled())
|
||||
{
|
||||
SendSliderDragEndMessage();
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Get the nob's position (the ends of each side of the nob)
|
||||
//-----------------------------------------------------------------------------
|
||||
void FloatSlider::GetNobPos(float& min, float& max)
|
||||
{
|
||||
min = _nobPos[0];
|
||||
max = _nobPos[1];
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void FloatSlider::SetButtonOffset(int buttonOffset)
|
||||
{
|
||||
_buttonOffset = buttonOffset;
|
||||
}
|
||||
|
||||
void FloatSlider::SetThumbWidth(int width)
|
||||
{
|
||||
_nobSize = (float)width;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Set the number of ticks that appear under the slider.
|
||||
//-----------------------------------------------------------------------------
|
||||
void FloatSlider::SetNumTicks(int ticks)
|
||||
{
|
||||
m_nNumTicks = ticks;
|
||||
}
|
||||
63
game/client/IsNPCProxy.cpp
Normal file
63
game/client/IsNPCProxy.cpp
Normal file
@@ -0,0 +1,63 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
#include "cbase.h"
|
||||
#include "functionproxy.h"
|
||||
#include "toolframework_client.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
// forward declarations
|
||||
void ToolFramework_RecordMaterialParams( IMaterial *pMaterial );
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Returns the player health (from 0 to 1)
|
||||
//-----------------------------------------------------------------------------
|
||||
class CProxyIsNPC : public CResultProxy
|
||||
{
|
||||
public:
|
||||
bool Init( IMaterial *pMaterial, KeyValues *pKeyValues );
|
||||
void OnBind( void *pC_BaseEntity );
|
||||
|
||||
private:
|
||||
CFloatInput m_Factor;
|
||||
};
|
||||
|
||||
bool CProxyIsNPC::Init( IMaterial *pMaterial, KeyValues *pKeyValues )
|
||||
{
|
||||
if (!CResultProxy::Init( pMaterial, pKeyValues ))
|
||||
return false;
|
||||
|
||||
if (!m_Factor.Init( pMaterial, pKeyValues, "scale", 1 ))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CProxyIsNPC::OnBind( void *pC_BaseEntity )
|
||||
{
|
||||
if ( !pC_BaseEntity )
|
||||
return;
|
||||
|
||||
C_BaseEntity *pEntity = BindArgToEntity( pC_BaseEntity );
|
||||
if ( pEntity && pEntity->IsNPC() )
|
||||
{
|
||||
SetFloatResult( m_Factor.GetFloat() );
|
||||
}
|
||||
else
|
||||
{
|
||||
SetFloatResult( 0.0f );
|
||||
}
|
||||
if ( ToolsEnabled() )
|
||||
{
|
||||
ToolFramework_RecordMaterialParams( GetMaterial() );
|
||||
}
|
||||
}
|
||||
|
||||
EXPOSE_INTERFACE( CProxyIsNPC, IMaterialProxy, "IsNPC" IMATERIAL_PROXY_INTERFACE_VERSION );
|
||||
|
||||
|
||||
60
game/client/MonitorMaterialProxy.cpp
Normal file
60
game/client/MonitorMaterialProxy.cpp
Normal file
@@ -0,0 +1,60 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
#include "cbase.h"
|
||||
#include "materialsystem/imaterialproxy.h"
|
||||
#include "materialsystem/imaterial.h"
|
||||
#include "materialsystem/imaterialvar.h"
|
||||
|
||||
// $monitorTextureVar
|
||||
class CMonitorMaterialProxy : public IMaterialProxy
|
||||
{
|
||||
public:
|
||||
CMonitorMaterialProxy();
|
||||
virtual ~CMonitorMaterialProxy();
|
||||
virtual bool Init( IMaterial *pMaterial, KeyValues *pKeyValues );
|
||||
virtual void OnBind( void *pC_BaseEntity );
|
||||
virtual void Release( void ) { delete this; }
|
||||
private:
|
||||
IMaterialVar *m_pMonitorTextureVar;
|
||||
};
|
||||
|
||||
CMonitorMaterialProxy::CMonitorMaterialProxy()
|
||||
{
|
||||
m_pMonitorTextureVar = NULL;
|
||||
}
|
||||
|
||||
CMonitorMaterialProxy::~CMonitorMaterialProxy()
|
||||
{
|
||||
m_pMonitorTextureVar = NULL;
|
||||
}
|
||||
|
||||
|
||||
bool CMonitorMaterialProxy::Init( IMaterial *pMaterial, KeyValues *pKeyValues )
|
||||
{
|
||||
char const* pMonitorTextureVarName = pKeyValues->getString( "$monitorTextureVar" );
|
||||
if( !pMonitorTextureVarName )
|
||||
return false;
|
||||
|
||||
bool foundVar;
|
||||
m_pMonitorTextureVar = pMaterial->FindVar( pMonitorTextureVarName, &foundVar, false );
|
||||
if( !foundVar )
|
||||
{
|
||||
m_pMonitorTextureVar = NULL;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void CMonitorMaterialProxy::OnBind( void *pC_BaseEntity )
|
||||
{
|
||||
if( !m_pMonitorTextureVar )
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
EXPOSE_INTERFACE( CMonitorMaterialProxy, IMaterialProxy, "Monitor" IMATERIAL_PROXY_INTERFACE_VERSION );
|
||||
0
game/client/OVRCommonButton.h
Normal file
0
game/client/OVRCommonButton.h
Normal file
59
game/client/ProxyHealth.cpp
Normal file
59
game/client/ProxyHealth.cpp
Normal file
@@ -0,0 +1,59 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
#include "cbase.h"
|
||||
#include "functionproxy.h"
|
||||
#include "toolframework_client.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
// forward declarations
|
||||
void ToolFramework_RecordMaterialParams( IMaterial *pMaterial );
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Returns the player health (from 0 to 1)
|
||||
//-----------------------------------------------------------------------------
|
||||
class CProxyHealth : public CResultProxy
|
||||
{
|
||||
public:
|
||||
bool Init( IMaterial *pMaterial, KeyValues *pKeyValues );
|
||||
void OnBind( void *pC_BaseEntity );
|
||||
|
||||
private:
|
||||
CFloatInput m_Factor;
|
||||
};
|
||||
|
||||
bool CProxyHealth::Init( IMaterial *pMaterial, KeyValues *pKeyValues )
|
||||
{
|
||||
if (!CResultProxy::Init( pMaterial, pKeyValues ))
|
||||
return false;
|
||||
|
||||
if (!m_Factor.Init( pMaterial, pKeyValues, "scale", 1 ))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CProxyHealth::OnBind( void *pC_BaseEntity )
|
||||
{
|
||||
if (!pC_BaseEntity)
|
||||
return;
|
||||
|
||||
C_BaseEntity *pEntity = BindArgToEntity( pC_BaseEntity );
|
||||
|
||||
Assert( m_pResult );
|
||||
SetFloatResult( pEntity->HealthFraction() * m_Factor.GetFloat() );
|
||||
|
||||
if ( ToolsEnabled() )
|
||||
{
|
||||
ToolFramework_RecordMaterialParams( GetMaterial() );
|
||||
}
|
||||
}
|
||||
|
||||
EXPOSE_INTERFACE( CProxyHealth, IMaterialProxy, "Health" IMATERIAL_PROXY_INTERFACE_VERSION );
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,2 @@
|
||||
#TargetFrameworkVersion=v4.0:PlatformToolSet=v120:EnableManagedIncrementalBuild=false:VCToolArchitecture=Native32Bit
|
||||
Release|Win32|D:\SourceCodes\project_overcharged_build_10_rtt\src_RTT\|
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,2 @@
|
||||
#TargetFrameworkVersion=v4.0:PlatformToolSet=v120_xp:EnableManagedIncrementalBuild=false:VCToolArchitecture=Native32Bit
|
||||
Release|Win32|C:\games\source-sdk-2013-master\sp\src\|
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
game/client/Release_mod_hl2/Client (HL2).tlog/CL.read.1.tlog
Normal file
BIN
game/client/Release_mod_hl2/Client (HL2).tlog/CL.read.1.tlog
Normal file
Binary file not shown.
BIN
game/client/Release_mod_hl2/Client (HL2).tlog/CL.write.1.tlog
Normal file
BIN
game/client/Release_mod_hl2/Client (HL2).tlog/CL.write.1.tlog
Normal file
Binary file not shown.
@@ -0,0 +1,2 @@
|
||||
#TargetFrameworkVersion=v4.0:PlatformToolSet=v120:EnableManagedIncrementalBuild=false:VCToolArchitecture=Native32Bit
|
||||
Release|Win32|D:\PROJECTS\aMOD_scode\project_overcharged_build_10_rtt\src_RTT\|
|
||||
BIN
game/client/Release_mod_hl2/Client (HL2).tlog/cl.command.1.tlog
Normal file
BIN
game/client/Release_mod_hl2/Client (HL2).tlog/cl.command.1.tlog
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
1257
game/client/RenderView_Overwrite.cpp
Normal file
1257
game/client/RenderView_Overwrite.cpp
Normal file
File diff suppressed because it is too large
Load Diff
317
game/client/ScreenSpaceEffects.cpp
Normal file
317
game/client/ScreenSpaceEffects.cpp
Normal file
@@ -0,0 +1,317 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
#include "cbase.h"
|
||||
|
||||
#include "KeyValues.h"
|
||||
#include "cdll_client_int.h"
|
||||
#include "view_scene.h"
|
||||
#include "viewrender.h"
|
||||
#include "tier0/icommandline.h"
|
||||
#include "materialsystem/imesh.h"
|
||||
#include "materialsystem/imaterial.h"
|
||||
#include "materialsystem/imaterialsystemhardwareconfig.h"
|
||||
#include "materialsystem/imaterialvar.h"
|
||||
|
||||
#include "ScreenSpaceEffects.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// CScreenSpaceEffectRegistration code
|
||||
// Used to register and effect with the IScreenSpaceEffectManager
|
||||
//------------------------------------------------------------------------------
|
||||
CScreenSpaceEffectRegistration *CScreenSpaceEffectRegistration::s_pHead = NULL;
|
||||
|
||||
CScreenSpaceEffectRegistration::CScreenSpaceEffectRegistration( const char *pName, IScreenSpaceEffect *pEffect )
|
||||
{
|
||||
m_pEffectName = pName;
|
||||
m_pEffect = pEffect;
|
||||
m_pNext = s_pHead;
|
||||
s_pHead = this;
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// CScreenSpaceEffectManager - Implementation of IScreenSpaceEffectManager
|
||||
//------------------------------------------------------------------------------
|
||||
class CScreenSpaceEffectManager : public IScreenSpaceEffectManager
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void InitScreenSpaceEffects( );
|
||||
virtual void ShutdownScreenSpaceEffects( );
|
||||
|
||||
virtual IScreenSpaceEffect *GetScreenSpaceEffect( const char *pEffectName );
|
||||
|
||||
virtual void SetScreenSpaceEffectParams( const char *pEffectName, KeyValues *params );
|
||||
virtual void SetScreenSpaceEffectParams( IScreenSpaceEffect *pEffect, KeyValues *params );
|
||||
|
||||
virtual void EnableScreenSpaceEffect( const char *pEffectName );
|
||||
virtual void EnableScreenSpaceEffect( IScreenSpaceEffect *pEffect );
|
||||
|
||||
virtual void DisableScreenSpaceEffect( const char *pEffectName );
|
||||
virtual void DisableScreenSpaceEffect( IScreenSpaceEffect *pEffect );
|
||||
|
||||
virtual void DisableAllScreenSpaceEffects( );
|
||||
|
||||
virtual void RenderEffects( int x, int y, int w, int h );
|
||||
};
|
||||
|
||||
CScreenSpaceEffectManager g_ScreenSpaceEffectManager;
|
||||
IScreenSpaceEffectManager *g_pScreenSpaceEffects = &g_ScreenSpaceEffectManager;
|
||||
|
||||
//---------------------------------------------------------------------------------------
|
||||
// CScreenSpaceEffectManager::InitScreenSpaceEffects - Initialise all registered effects
|
||||
//---------------------------------------------------------------------------------------
|
||||
void CScreenSpaceEffectManager::InitScreenSpaceEffects( )
|
||||
{
|
||||
if ( CommandLine()->FindParm( "-filmgrain" ) )
|
||||
{
|
||||
GetScreenSpaceEffect( "filmgrain" )->Enable( true );
|
||||
}
|
||||
|
||||
for( CScreenSpaceEffectRegistration *pReg=CScreenSpaceEffectRegistration::s_pHead; pReg!=NULL; pReg=pReg->m_pNext )
|
||||
{
|
||||
IScreenSpaceEffect *pEffect = pReg->m_pEffect;
|
||||
if( pEffect )
|
||||
{
|
||||
bool bIsEnabled = pEffect->IsEnabled( );
|
||||
pEffect->Init( );
|
||||
pEffect->Enable( bIsEnabled );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
// CScreenSpaceEffectManager::ShutdownScreenSpaceEffects - Shutdown all registered effects
|
||||
//----------------------------------------------------------------------------------------
|
||||
void CScreenSpaceEffectManager::ShutdownScreenSpaceEffects( )
|
||||
{
|
||||
for( CScreenSpaceEffectRegistration *pReg=CScreenSpaceEffectRegistration::s_pHead; pReg!=NULL; pReg=pReg->m_pNext )
|
||||
{
|
||||
IScreenSpaceEffect *pEffect = pReg->m_pEffect;
|
||||
if( pEffect )
|
||||
{
|
||||
pEffect->Shutdown( );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------------------
|
||||
// CScreenSpaceEffectManager::GetScreenSpaceEffect - Returns a point to the named effect
|
||||
//---------------------------------------------------------------------------------------
|
||||
IScreenSpaceEffect *CScreenSpaceEffectManager::GetScreenSpaceEffect( const char *pEffectName )
|
||||
{
|
||||
for( CScreenSpaceEffectRegistration *pReg=CScreenSpaceEffectRegistration::s_pHead; pReg!=NULL; pReg=pReg->m_pNext )
|
||||
{
|
||||
if( !Q_stricmp( pReg->m_pEffectName, pEffectName ) )
|
||||
{
|
||||
IScreenSpaceEffect *pEffect = pReg->m_pEffect;
|
||||
return pEffect;
|
||||
}
|
||||
}
|
||||
|
||||
Warning( "Could not find screen space effect %s\n", pEffectName );
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------------------
|
||||
// CScreenSpaceEffectManager::SetScreenSpaceEffectParams
|
||||
// - Assign parameters to the specified effect
|
||||
//---------------------------------------------------------------------------------------
|
||||
void CScreenSpaceEffectManager::SetScreenSpaceEffectParams( const char *pEffectName, KeyValues *params )
|
||||
{
|
||||
IScreenSpaceEffect *pEffect = GetScreenSpaceEffect( pEffectName );
|
||||
if( pEffect )
|
||||
SetScreenSpaceEffectParams( pEffect, params );
|
||||
}
|
||||
|
||||
void CScreenSpaceEffectManager::SetScreenSpaceEffectParams( IScreenSpaceEffect *pEffect, KeyValues *params )
|
||||
{
|
||||
if( pEffect )
|
||||
pEffect->SetParameters( params );
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------------------
|
||||
// CScreenSpaceEffectManager::EnableScreenSpaceEffect
|
||||
// - Enables the specified effect
|
||||
//---------------------------------------------------------------------------------------
|
||||
void CScreenSpaceEffectManager::EnableScreenSpaceEffect( const char *pEffectName )
|
||||
{
|
||||
IScreenSpaceEffect *pEffect = GetScreenSpaceEffect( pEffectName );
|
||||
if( pEffect )
|
||||
EnableScreenSpaceEffect( pEffect );
|
||||
}
|
||||
|
||||
void CScreenSpaceEffectManager::EnableScreenSpaceEffect( IScreenSpaceEffect *pEffect )
|
||||
{
|
||||
if( pEffect )
|
||||
pEffect->Enable( true );
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------------------
|
||||
// CScreenSpaceEffectManager::DisableScreenSpaceEffect
|
||||
// - Disables the specified effect
|
||||
//---------------------------------------------------------------------------------------
|
||||
void CScreenSpaceEffectManager::DisableScreenSpaceEffect( const char *pEffectName )
|
||||
{
|
||||
IScreenSpaceEffect *pEffect = GetScreenSpaceEffect( pEffectName );
|
||||
if( pEffect )
|
||||
DisableScreenSpaceEffect( pEffect );
|
||||
}
|
||||
|
||||
void CScreenSpaceEffectManager::DisableScreenSpaceEffect( IScreenSpaceEffect *pEffect )
|
||||
{
|
||||
if( pEffect )
|
||||
pEffect->Enable( false );
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------------------
|
||||
// CScreenSpaceEffectManager::DisableAllScreenSpaceEffects
|
||||
// - Disables all registered screen space effects
|
||||
//---------------------------------------------------------------------------------------
|
||||
void CScreenSpaceEffectManager::DisableAllScreenSpaceEffects( )
|
||||
{
|
||||
for( CScreenSpaceEffectRegistration *pReg=CScreenSpaceEffectRegistration::s_pHead; pReg!=NULL; pReg=pReg->m_pNext )
|
||||
{
|
||||
IScreenSpaceEffect *pEffect = pReg->m_pEffect;
|
||||
if( pEffect )
|
||||
{
|
||||
pEffect->Enable( false );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------------------
|
||||
// CScreenSpaceEffectManager::RenderEffects
|
||||
// - Renders all registered screen space effects
|
||||
//---------------------------------------------------------------------------------------
|
||||
void CScreenSpaceEffectManager::RenderEffects( int x, int y, int w, int h )
|
||||
{
|
||||
for( CScreenSpaceEffectRegistration *pReg=CScreenSpaceEffectRegistration::s_pHead; pReg!=NULL; pReg=pReg->m_pNext )
|
||||
{
|
||||
IScreenSpaceEffect *pEffect = pReg->m_pEffect;
|
||||
if( pEffect )
|
||||
{
|
||||
pEffect->Render( x, y, w, h );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Example post-processing effect
|
||||
//------------------------------------------------------------------------------
|
||||
class CExampleEffect : public IScreenSpaceEffect
|
||||
{
|
||||
public:
|
||||
CExampleEffect( );
|
||||
~CExampleEffect( );
|
||||
|
||||
void Init( );
|
||||
void Shutdown( );
|
||||
|
||||
void SetParameters( KeyValues *params );
|
||||
|
||||
void Render( int x, int y, int w, int h );
|
||||
|
||||
void Enable( bool bEnable );
|
||||
bool IsEnabled( );
|
||||
|
||||
private:
|
||||
|
||||
bool m_bEnable;
|
||||
|
||||
CMaterialReference m_Material;
|
||||
};
|
||||
|
||||
ADD_SCREENSPACE_EFFECT( CExampleEffect, exampleeffect );
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// CExampleEffect constructor
|
||||
//------------------------------------------------------------------------------
|
||||
CExampleEffect::CExampleEffect( )
|
||||
{
|
||||
m_bEnable = false;
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// CExampleEffect destructor
|
||||
//------------------------------------------------------------------------------
|
||||
CExampleEffect::~CExampleEffect( )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// CExampleEffect init
|
||||
//------------------------------------------------------------------------------
|
||||
void CExampleEffect::Init( )
|
||||
{
|
||||
// This is just example code, init your effect material here
|
||||
//m_Material.Init( "engine/exampleeffect", TEXTURE_GROUP_OTHER );
|
||||
|
||||
m_bEnable = false;
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// CExampleEffect shutdown
|
||||
//------------------------------------------------------------------------------
|
||||
void CExampleEffect::Shutdown( )
|
||||
{
|
||||
m_Material.Shutdown();
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// CExampleEffect enable
|
||||
//------------------------------------------------------------------------------
|
||||
void CExampleEffect::Enable( bool bEnable )
|
||||
{
|
||||
// This is just example code, don't enable it
|
||||
// m_bEnable = bEnable;
|
||||
}
|
||||
|
||||
bool CExampleEffect::IsEnabled( )
|
||||
{
|
||||
return m_bEnable;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// CExampleEffect SetParameters
|
||||
//------------------------------------------------------------------------------
|
||||
void CExampleEffect::SetParameters( KeyValues *params )
|
||||
{
|
||||
if( params->GetDataType( "example_param" ) == KeyValues::TYPE_STRING )
|
||||
{
|
||||
// ...
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// CExampleEffect render
|
||||
//------------------------------------------------------------------------------
|
||||
void CExampleEffect::Render( int x, int y, int w, int h )
|
||||
{
|
||||
if ( !IsEnabled() )
|
||||
return;
|
||||
|
||||
// Render Effect
|
||||
Rect_t actualRect;
|
||||
UpdateScreenEffectTexture( 0, x, y, w, h, false, &actualRect );
|
||||
ITexture *pTexture = GetFullFrameFrameBufferTexture( 0 );
|
||||
|
||||
CMatRenderContextPtr pRenderContext( materials );
|
||||
|
||||
pRenderContext->DrawScreenSpaceRectangle( m_Material, x, y, w, h,
|
||||
actualRect.x, actualRect.y, actualRect.x+actualRect.width-1, actualRect.y+actualRect.height-1,
|
||||
pTexture->GetActualWidth(), pTexture->GetActualHeight() );
|
||||
}
|
||||
88
game/client/ScreenSpaceEffects.h
Normal file
88
game/client/ScreenSpaceEffects.h
Normal file
@@ -0,0 +1,88 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//
|
||||
//=====================================================================================//
|
||||
|
||||
#ifndef SCREENSPACEEFFECTS_H
|
||||
#define SCREENSPACEEFFECTS_H
|
||||
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
class KeyValues;
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Simple base class for screen space post-processing effects
|
||||
//------------------------------------------------------------------------------
|
||||
abstract_class IScreenSpaceEffect
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void Init( ) = 0;
|
||||
virtual void Shutdown( ) = 0;
|
||||
|
||||
virtual void SetParameters( KeyValues *params ) = 0;
|
||||
|
||||
virtual void Render( int x, int y, int w, int h ) = 0;
|
||||
|
||||
virtual void Enable( bool bEnable ) = 0;
|
||||
virtual bool IsEnabled( ) = 0;
|
||||
};
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Interface class for managing screen space post-processing effects
|
||||
//------------------------------------------------------------------------------
|
||||
abstract_class IScreenSpaceEffectManager
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void InitScreenSpaceEffects( ) = 0;
|
||||
virtual void ShutdownScreenSpaceEffects( ) = 0;
|
||||
|
||||
virtual IScreenSpaceEffect *GetScreenSpaceEffect( const char *pEffectName ) = 0;
|
||||
|
||||
virtual void SetScreenSpaceEffectParams( const char *pEffectName, KeyValues *params ) = 0;
|
||||
virtual void SetScreenSpaceEffectParams( IScreenSpaceEffect *pEffect, KeyValues *params ) = 0;
|
||||
|
||||
virtual void EnableScreenSpaceEffect( const char *pEffectName ) = 0;
|
||||
virtual void EnableScreenSpaceEffect( IScreenSpaceEffect *pEffect ) = 0;
|
||||
|
||||
virtual void DisableScreenSpaceEffect( const char *pEffectName ) = 0;
|
||||
virtual void DisableScreenSpaceEffect( IScreenSpaceEffect *pEffect ) = 0;
|
||||
|
||||
virtual void DisableAllScreenSpaceEffects( ) = 0;
|
||||
|
||||
virtual void RenderEffects( int x, int y, int w, int h ) = 0;
|
||||
};
|
||||
|
||||
extern IScreenSpaceEffectManager *g_pScreenSpaceEffects;
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------
|
||||
// Registration class for adding screen space effects to the IScreenSpaceEffectManager
|
||||
//-------------------------------------------------------------------------------------
|
||||
class CScreenSpaceEffectRegistration
|
||||
{
|
||||
public:
|
||||
CScreenSpaceEffectRegistration( const char *pName, IScreenSpaceEffect *pEffect );
|
||||
|
||||
const char *m_pEffectName;
|
||||
IScreenSpaceEffect *m_pEffect;
|
||||
|
||||
CScreenSpaceEffectRegistration *m_pNext;
|
||||
|
||||
static CScreenSpaceEffectRegistration *s_pHead;
|
||||
};
|
||||
|
||||
#define ADD_SCREENSPACE_EFFECT( CEffect, pEffectName ) CEffect pEffectName##_effect; \
|
||||
CScreenSpaceEffectRegistration pEffectName##_reg( #pEffectName, &pEffectName##_effect );
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
1498
game/client/ShaderEditor/Grass/CGrassCluster.cpp
Normal file
1498
game/client/ShaderEditor/Grass/CGrassCluster.cpp
Normal file
File diff suppressed because it is too large
Load Diff
133
game/client/ShaderEditor/Grass/CGrassCluster.h
Normal file
133
game/client/ShaderEditor/Grass/CGrassCluster.h
Normal file
@@ -0,0 +1,133 @@
|
||||
#ifndef GRASS_CLUSTER_H
|
||||
#define GRASS_CLUSTER_H
|
||||
|
||||
#include "cbase.h"
|
||||
|
||||
class CFastTimer;
|
||||
|
||||
struct _grassPressureData
|
||||
{
|
||||
_grassPressureData();
|
||||
~_grassPressureData();
|
||||
|
||||
void Init(int num);
|
||||
|
||||
int iNumGrassObjects;
|
||||
|
||||
Vector *vecPos;
|
||||
Vector *vecDir;
|
||||
float *flAmt;
|
||||
float *flHeight;
|
||||
float *flLastMoveTime;
|
||||
float *flLastUpdateTime;
|
||||
bool *bDirty;
|
||||
};
|
||||
|
||||
struct _grassClusterInfo
|
||||
{
|
||||
public:
|
||||
_grassClusterInfo();
|
||||
|
||||
Vector orig;
|
||||
Vector4D color;
|
||||
Vector2D uv_min, uv_max;
|
||||
float flSortDist;
|
||||
};
|
||||
|
||||
struct _grassClusterData
|
||||
{
|
||||
public:
|
||||
_grassClusterData();
|
||||
~_grassClusterData();
|
||||
// flat copy on purpose!!!
|
||||
|
||||
void Destroy();
|
||||
int Draw();
|
||||
|
||||
IMesh *pGrassMesh;
|
||||
_grassPressureData *pPressureInfo;
|
||||
Vector pos;
|
||||
|
||||
int iNumQuads;
|
||||
Vector extents_min, extents_max;
|
||||
|
||||
int iNextLodThreshold;
|
||||
_grassClusterData *pLOD;
|
||||
|
||||
|
||||
void CreateLightingPatch(const CUtlVector< _grassClusterInfo > &hints);
|
||||
const Vector GetLightingForPoint(const Vector &pos);
|
||||
void DestroyLightingPatch();
|
||||
int iLPatchSize_x, iLPatchSize_y;
|
||||
float flLPatchStep_x, flLPatchStep_y;
|
||||
Vector *lighting;
|
||||
};
|
||||
|
||||
struct clusterMaterial
|
||||
{
|
||||
clusterMaterial();
|
||||
void Init(const char *pszMat);
|
||||
void Shutdown();
|
||||
bool IsValid();
|
||||
|
||||
IMaterialVar *GetVarDir();
|
||||
IMaterialVar *GetVarAng();
|
||||
IMaterialVar *GetTimeScale();
|
||||
IMaterial *GetMaterial();
|
||||
|
||||
CMaterialReference mat;
|
||||
unsigned int ivar_dir;
|
||||
unsigned int ivar_ang;
|
||||
};
|
||||
|
||||
class CGrassClusterManager : public CAutoGameSystemPerFrame
|
||||
{
|
||||
public:
|
||||
|
||||
CGrassClusterManager();
|
||||
~CGrassClusterManager();
|
||||
|
||||
static CGrassClusterManager *GetInstance();
|
||||
|
||||
bool Init();
|
||||
void Shutdown();
|
||||
void LevelInitPostEntity();
|
||||
void LevelShutdownPostEntity();
|
||||
|
||||
void Update(float frametime);
|
||||
void PreRender();
|
||||
void PostRender();
|
||||
void RenderClusters(bool bShadowDepth);
|
||||
|
||||
void AddClusterHint(_grassClusterInfo hint);
|
||||
void ClearClusterData();
|
||||
|
||||
private:
|
||||
|
||||
void GenerateClusterData();
|
||||
void BuildClusterMesh(_grassClusterData &data, const CUtlVector< _grassClusterInfo > &hints, int iObjectMultiplier, _grassPressureData *pMorphInfo = NULL);
|
||||
void BuildSingleGrassObject(CMeshBuilder &builder, _grassClusterData &clusterData, const _grassClusterInfo &hint,
|
||||
const float avgDist, const int grassObjectIndex, _grassPressureData *pMorphInfo = NULL);
|
||||
|
||||
void UpdateMorphInfo();
|
||||
void InjectMorph(int i);
|
||||
|
||||
CUtlVector< _grassClusterInfo >m_hClusterInfo;
|
||||
CUtlVector< _grassClusterData >m_hClusterData;
|
||||
|
||||
IMaterial *GetActiveMaterial();
|
||||
//CMaterialReference *m_refMaterial;
|
||||
clusterMaterial *m_refMaterials;
|
||||
int m_iCurrentMaterial;
|
||||
|
||||
int m_iCurObjectsPerHint;
|
||||
int m_iDrawnQuads;
|
||||
int m_iDrawnCluster;
|
||||
int m_iDrawnPerDrawcall;
|
||||
int m_iDrawnEngineMax;
|
||||
|
||||
double m_flMorphTime;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
144
game/client/ShaderEditor/Grass/README_GRASS.txt
Normal file
144
game/client/ShaderEditor/Grass/README_GRASS.txt
Normal file
@@ -0,0 +1,144 @@
|
||||
//**********************************************//
|
||||
// //
|
||||
// Installation instructions for grass clusters //
|
||||
// //
|
||||
//**********************************************//
|
||||
|
||||
*** ONLY TESTED WITH SOURCE 2007, SO DON'T EXPECT SWARM COMPATIBILITY ***
|
||||
|
||||
The grass clusters are meant to replace the existing detail props. They'll use
|
||||
the lighting and positioning information from them to generate their geometry.
|
||||
Do not use a huge texture atlas for them from which you only read some parts but
|
||||
use actual unique materials for each type of grass (PERFO), note that you have
|
||||
to add any map dependent functionality yourself for that matter!
|
||||
Also, don't use alpha blending on them, it WON'T WORK. And that won't change because
|
||||
grass objects should stay batched. If you can't stand alpha testing use alpha to coverage,
|
||||
which requires more performance.
|
||||
|
||||
|
||||
|
||||
Make sure to have the shader editor and its example materials and shaders installed too
|
||||
or export them and update all references accordingly. VERIFY THAT YOU HAVE THE SHADER 'detail_prop_shader'
|
||||
COMPILED AND IN YOUR PRECACHE LIST.
|
||||
|
||||
|
||||
|
||||
In case you're experiencing errors that you don't understand, go there: http://www.learncpp.com/
|
||||
and READ it. 'Reading' in a sense of actually understanding what's written there. That includes the possibility
|
||||
of iteratively examining a passage for a variable number of times until comprehension has been acquired.
|
||||
|
||||
|
||||
|
||||
If you're using the source sdk base 2007 you can apply the subversion patch (dprop_and_shadow_patch.patch)
|
||||
and skip to step 5 now, other branches MIGHT NOT BE COMPATIBLE.
|
||||
|
||||
|
||||
|
||||
Step 1.
|
||||
|
||||
client/clientshadowmgr.cpp
|
||||
|
||||
|
||||
Find this line:
|
||||
|
||||
ShadowType_t GetActualShadowCastType( ClientShadowHandle_t handle ) const;
|
||||
|
||||
|
||||
Replace it with these:
|
||||
|
||||
public:
|
||||
ShadowHandle_t GetShadowHandle( ClientShadowHandle_t clienthandle ){ return m_Shadows[ clienthandle ].m_ShadowHandle; };
|
||||
int GetNumShadowDepthtextures(){ return m_DepthTextureCache.Count(); };
|
||||
CTextureReference GetShadowDepthTex( int num ){ return m_DepthTextureCache[num]; };
|
||||
|
||||
ShadowType_t GetActualShadowCastType( ClientShadowHandle_t handle ) const;
|
||||
private:
|
||||
|
||||
|
||||
Step 2.
|
||||
|
||||
client/detailobjectsystem.cpp
|
||||
|
||||
|
||||
Find this line:
|
||||
|
||||
#include "c_world.h"
|
||||
|
||||
|
||||
Add this line below:
|
||||
|
||||
#include "ShaderEditor/Grass/CGrassCluster.h"
|
||||
|
||||
|
||||
Find this line:
|
||||
|
||||
pSpritex4->m_pSpriteDefs[nSubField] = pSDef;
|
||||
|
||||
|
||||
Add these lines below:
|
||||
|
||||
_grassClusterInfo clusterHint;
|
||||
clusterHint.orig = pos;
|
||||
clusterHint.color.Init( color[0], color[1], color[2], 1 );
|
||||
clusterHint.uv_min = pSDef->m_TexLR;
|
||||
clusterHint.uv_max = pSDef->m_TexUL;
|
||||
CGrassClusterManager::GetInstance()->AddClusterHint( clusterHint );
|
||||
|
||||
|
||||
Step 3.
|
||||
|
||||
client/iclientshadowmgr.h
|
||||
|
||||
|
||||
Find this line:
|
||||
|
||||
virtual void ComputeShadowDepthTextures( const CViewSetup &pView ) = 0;
|
||||
|
||||
|
||||
Add these lines below:
|
||||
|
||||
virtual ShadowHandle_t GetShadowHandle( ClientShadowHandle_t clienthandle ) = 0;
|
||||
virtual ShadowType_t GetActualShadowCastType( ClientShadowHandle_t handle ) const = 0;
|
||||
virtual int GetNumShadowDepthtextures() = 0;
|
||||
virtual CTextureReference GetShadowDepthTex( int num ) = 0;
|
||||
|
||||
|
||||
Step 4.
|
||||
|
||||
client/viewrender.cpp
|
||||
|
||||
|
||||
Find this line:
|
||||
|
||||
#include "con_nprint.h"
|
||||
|
||||
|
||||
Add this line below:
|
||||
|
||||
#include "ShaderEditor/Grass/CGrassCluster.h"
|
||||
|
||||
|
||||
Find this line in the function void CRendering3dView::DrawOpaqueRenderables( bool bShadowDepth ):
|
||||
|
||||
g_pParticleSystemMgr->DrawRenderCache( bShadowDepth );
|
||||
|
||||
|
||||
Add this line below for 2007 / swarm:
|
||||
|
||||
CGrassClusterManager::GetInstance()->RenderClusters( bShadowDepth );
|
||||
|
||||
OR this line for 2013:
|
||||
|
||||
CGrassClusterManager::GetInstance()->RenderClusters( DepthMode == DEPTH_MODE_SHADOW );
|
||||
|
||||
|
||||
Step 5.
|
||||
|
||||
Copy the folder 'Grass' and both files to /client/ShaderEditor/. If you want to put them elsewhere,
|
||||
you'll have to change the include paths in the respective files.
|
||||
|
||||
|
||||
Step 6.
|
||||
|
||||
Add both files in /Grass/ to your client project and compile it. Grass clusters will now be
|
||||
created wherever you placed standard simple detail sprites.
|
||||
80
game/client/ShaderEditor/Grass/dprop_and_shadow_patch.patch
Normal file
80
game/client/ShaderEditor/Grass/dprop_and_shadow_patch.patch
Normal file
@@ -0,0 +1,80 @@
|
||||
Index: client/clientshadowmgr.cpp
|
||||
===================================================================
|
||||
--- client/clientshadowmgr.cpp (revision 1)
|
||||
+++ client/clientshadowmgr.cpp (working copy)
|
||||
@@ -853,7 +853,13 @@
|
||||
void RemoveShadowFromDirtyList( ClientShadowHandle_t handle );
|
||||
|
||||
// NOTE: this will ONLY return SHADOWS_NONE, SHADOWS_SIMPLE, or SHADOW_RENDER_TO_TEXTURE.
|
||||
+public:
|
||||
+ ShadowHandle_t GetShadowHandle( ClientShadowHandle_t clienthandle ){ return m_Shadows[ clienthandle ].m_ShadowHandle; };
|
||||
+ int GetNumShadowDepthtextures(){ return m_DepthTextureCache.Count(); };
|
||||
+ CTextureReference GetShadowDepthTex( int num ){ return m_DepthTextureCache[num]; };
|
||||
+
|
||||
ShadowType_t GetActualShadowCastType( ClientShadowHandle_t handle ) const;
|
||||
+private:
|
||||
ShadowType_t GetActualShadowCastType( IClientRenderable *pRenderable ) const;
|
||||
|
||||
// Builds a simple blobby shadow
|
||||
Index: client/detailobjectsystem.cpp
|
||||
===================================================================
|
||||
--- client/detailobjectsystem.cpp (revision 1)
|
||||
+++ client/detailobjectsystem.cpp (working copy)
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "env_detail_controller.h"
|
||||
#include "tier0/icommandline.h"
|
||||
#include "c_world.h"
|
||||
+#include "ShaderEditor/Grass/CGrassCluster.h"
|
||||
|
||||
//Tony; add the SDK into this as well by default.
|
||||
#if defined(DOD_DLL) || defined(CSTRIKE_DLL) || defined( SDK_DLL )
|
||||
@@ -1940,6 +1941,13 @@
|
||||
pSpritex4->m_RGBColor[nSubField][3] = 255;
|
||||
|
||||
pSpritex4->m_pSpriteDefs[nSubField] = pSDef;
|
||||
+
|
||||
+ _grassClusterInfo clusterHint;
|
||||
+ clusterHint.orig = pos;
|
||||
+ clusterHint.color.Init( color[0], color[1], color[2], 1 );
|
||||
+ clusterHint.uv_min = pSDef->m_TexLR;
|
||||
+ clusterHint.uv_max = pSDef->m_TexUL;
|
||||
+ CGrassClusterManager::GetInstance()->AddClusterHint( clusterHint );
|
||||
}
|
||||
|
||||
|
||||
Index: client/iclientshadowmgr.h
|
||||
===================================================================
|
||||
--- client/iclientshadowmgr.h (revision 1)
|
||||
+++ client/iclientshadowmgr.h (working copy)
|
||||
@@ -101,6 +100,10 @@
|
||||
|
||||
virtual void ComputeShadowDepthTextures( const CViewSetup &pView ) = 0;
|
||||
|
||||
+ virtual ShadowHandle_t GetShadowHandle( ClientShadowHandle_t clienthandle ) = 0;
|
||||
+ virtual ShadowType_t GetActualShadowCastType( ClientShadowHandle_t handle ) const = 0;
|
||||
+ virtual int GetNumShadowDepthtextures() = 0;
|
||||
+ virtual CTextureReference GetShadowDepthTex( int num ) = 0;
|
||||
};
|
||||
|
||||
|
||||
Index: client/viewrender.cpp
|
||||
===================================================================
|
||||
--- client/viewrender.cpp (revision 1)
|
||||
+++ client/viewrender.cpp (working copy)
|
||||
@@ -48,6 +48,7 @@
|
||||
#include "keyvalues.h"
|
||||
#include "renderparm.h"
|
||||
#include "con_nprint.h"
|
||||
+#include "ShaderEditor/Grass/CGrassCluster.h"
|
||||
|
||||
#ifdef PORTAL
|
||||
//#include "C_Portal_Player.h"
|
||||
@@ -3856,6 +3870,8 @@
|
||||
//
|
||||
RopeManager()->DrawRenderCache( bShadowDepth );
|
||||
g_pParticleSystemMgr->DrawRenderCache( bShadowDepth );
|
||||
+
|
||||
+ CGrassClusterManager::GetInstance()->RenderClusters( bShadowDepth );
|
||||
}
|
||||
|
||||
|
||||
41
game/client/ShaderEditor/ISEdit_ModelRender.h
Normal file
41
game/client/ShaderEditor/ISEdit_ModelRender.h
Normal file
@@ -0,0 +1,41 @@
|
||||
#ifndef IV_SHADEREDITOR_MRENDER
|
||||
#define IV_SHADEREDITOR_MRENDER
|
||||
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif // _WIN32
|
||||
|
||||
#ifdef SHADER_EDITOR_DLL
|
||||
#include "../public/tier1/interface.h"
|
||||
#else
|
||||
#include "interface.h"
|
||||
#include "shadereditor/shadereditorsystem.h"
|
||||
#endif // NOT SHADER_EDITOR_DLL
|
||||
|
||||
|
||||
class ISEditModelRender
|
||||
{
|
||||
public:
|
||||
virtual bool LoadModel(const char *localPath) = 0;
|
||||
virtual void DestroyModel() = 0;
|
||||
virtual void GetModelCenter(float *pFl3_ViewOffset) = 0;
|
||||
|
||||
virtual int QuerySequences(char ***list) = 0;
|
||||
virtual void SetSequence(const char *name) = 0;
|
||||
|
||||
virtual void ExecRender() = 0;
|
||||
virtual void DoPostProc(int x, int y, int w, int h) = 0;
|
||||
virtual int MaterialPicker(char ***szMat) = 0;
|
||||
|
||||
virtual void DestroyCharPtrList(char ***szList) = 0;
|
||||
};
|
||||
|
||||
|
||||
#ifdef SHADER_EDITOR_DLL
|
||||
extern ISEditModelRender *sEditMRender;
|
||||
#else
|
||||
class SEditModelRender;
|
||||
extern SEditModelRender *sEditMRender;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
148
game/client/ShaderEditor/IVShaderEditor.h
Normal file
148
game/client/ShaderEditor/IVShaderEditor.h
Normal file
@@ -0,0 +1,148 @@
|
||||
#ifndef IV_SHADEREDITOR
|
||||
#define IV_SHADEREDITOR
|
||||
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif // _WIN32
|
||||
|
||||
#define pFnClCallback( x ) void(* x )( float *pfl4 )
|
||||
#define pFnClCallback_Declare( x ) void x( float *pfl4 )
|
||||
|
||||
#define pFnVrCallback( x ) void(* x )( bool * const pbOptions, int * const piOptions,\
|
||||
float * const pflOptions, char ** const pszOptions )
|
||||
#define pFnVrCallback_Declare( x ) void x( bool * const pbOptions, int * const piOptions,\
|
||||
float * const pflOptions, char ** const pszOptions )
|
||||
|
||||
#define DEFINE_SHADEREDITOR_MATERIALVAR( effectName, nodeName, materialVarName, localVarName ) \
|
||||
static ShaderEditVarToken token_ ## localVarName = SHADEREDIT_MVAR_TOKEN_INVALID; \
|
||||
IMaterialVar *localVarName = shaderEdit->GetPPEMaterialVarFast( \
|
||||
token_ ## localVarName, effectName, nodeName, materialVarName )
|
||||
|
||||
#ifndef PROCSHADER_DLL
|
||||
|
||||
#ifdef SHADER_EDITOR_DLL
|
||||
#include "../public/tier1/interface.h"
|
||||
#include "view_shared.h"
|
||||
#else
|
||||
#include "interface.h"
|
||||
#include "shadereditor/shadereditorsystem.h"
|
||||
#endif // NOT SHADER_EDITOR_DLL
|
||||
|
||||
class IMaterial;
|
||||
class IMaterialVar;
|
||||
|
||||
typedef unsigned int ShaderEditVarToken;
|
||||
|
||||
enum SEDIT_SKYMASK_MODE
|
||||
{
|
||||
SKYMASK_OFF = 0,
|
||||
SKYMASK_QUARTER, // render at 1/4 fb size where possible
|
||||
SKYMASK_FULL, // render at full fb size
|
||||
};
|
||||
|
||||
class CViewSetup_SEdit_Shared
|
||||
{
|
||||
public:
|
||||
CViewSetup_SEdit_Shared()
|
||||
{
|
||||
Q_memset(this, 0, sizeof(CViewSetup_SEdit_Shared));
|
||||
};
|
||||
CViewSetup_SEdit_Shared(const CViewSetup &o)
|
||||
{
|
||||
x = o.x;
|
||||
y = o.y;
|
||||
width = o.width;
|
||||
height = o.height;
|
||||
fov = o.fov;
|
||||
fovViewmodel = o.fovViewmodel;
|
||||
origin = o.origin;
|
||||
angles = o.angles;
|
||||
zNear = o.zNear;
|
||||
zFar = o.zFar;
|
||||
zNearViewmodel = o.zNearViewmodel;
|
||||
zFarViewmodel = o.zFarViewmodel;
|
||||
m_flAspectRatio = o.m_flAspectRatio;
|
||||
};
|
||||
int x, y, width, height;
|
||||
float fov, fovViewmodel;
|
||||
Vector origin;
|
||||
QAngle angles;
|
||||
float zNear, zFar, zNearViewmodel, zFarViewmodel;
|
||||
float m_flAspectRatio;
|
||||
};
|
||||
|
||||
|
||||
class IVShaderEditor : public IBaseInterface
|
||||
{
|
||||
public:
|
||||
virtual bool Init(CreateInterfaceFn appSystemFactory, CGlobalVarsBase *pGlobals,
|
||||
void *pSEditMRender,
|
||||
bool bCreateEditor, bool bEnablePrimaryDebug, int iSkymaskMode) = 0;
|
||||
virtual void Shutdown() = 0;
|
||||
virtual void PrecacheData() = 0;
|
||||
|
||||
// call before Init() to overwrite any paths, pass in NULL for the ones that shouldn't be overwritten
|
||||
virtual void OverridePaths(const char *pszWorkingDirectory,
|
||||
const char *pszCompilePath = NULL, // abs path to compiler binaries
|
||||
const char *pszLocalCompilePath = NULL, // local path to compiler binaries, relative to shader source directory
|
||||
const char *pszGamePath = NULL,
|
||||
const char *pszCanvas = NULL, // path to canvas files
|
||||
const char *pszShaderSource = NULL, // path to shader source files
|
||||
const char *pszDumps = NULL, // path to shader configuration files
|
||||
const char *pszUserFunctions = NULL, // path to custom function bodies
|
||||
const char *pszEditorRoot = NULL) = 0; // path to 'shadereditorui' home directory
|
||||
|
||||
// update the lib
|
||||
virtual void OnFrame(float frametime) = 0;
|
||||
virtual void OnPreRender(void *viewsetup) = 0;
|
||||
virtual void OnSceneRender() = 0;
|
||||
virtual void OnUpdateSkymask(bool bCombineMode, int x, int y, int w, int h) = 0;
|
||||
virtual void OnPostRender(bool bUpdateFB) = 0;
|
||||
|
||||
// data callbacks for hlsl constants
|
||||
virtual void RegisterClientCallback(const char *name, pFnClCallback(callback), int numComponents) = 0;
|
||||
virtual void LockClientCallbacks() = 0;
|
||||
|
||||
// view render callbacks for post processing graphs
|
||||
virtual void RegisterViewRenderCallback(const char *pszVrCName, pFnVrCallback(callback),
|
||||
const char **pszBoolNames = NULL, const bool *pBoolDefaults = NULL, const int numBoolParams = 0,
|
||||
const char **pszIntNames = NULL, const int *pIntDefaults = NULL, const int numIntParams = 0,
|
||||
const char **pszFloatNames = NULL, const float *pFloatDefaults = NULL, const int numFloatParams = 0,
|
||||
const char **pszStringNames = NULL, const char **pStringDefaults = NULL, const int numStringParams = 0) = 0;
|
||||
virtual void LockViewRenderCallbacks() = 0;
|
||||
|
||||
// post processing effect manipulation (precached effects accessible)
|
||||
// the index becomes invalid when editing the precache list
|
||||
virtual int GetPPEIndex(const char *pszName) = 0; // returns -1 when not found, case insensitive
|
||||
virtual bool IsPPEEnabled(const int &index) = 0;
|
||||
virtual void SetPPEEnabled(const int &index, const bool &bEnabled) = 0;
|
||||
virtual IMaterial *GetPPEMaterial(const int &index, const char *pszNodeName) = 0;
|
||||
|
||||
// Draws a PPE graph right now or adds it to the render queue (r_queued_post_processing!)
|
||||
// Does not push a new RT but uses the current one
|
||||
// If you have 'during scene' nodes, make sure to call it twice in the appropriate places
|
||||
virtual void DrawPPEOnDemand(const int &index, const bool bInScene = false) = 0;
|
||||
virtual void DrawPPEOnDemand(const int &index, int x, int y, int w, int h, const bool bInScene = false) = 0;
|
||||
|
||||
// access a materialvar based on an incrementing token
|
||||
// you don't need to cache the returned value, it's okay to call this each frame
|
||||
// initialize the token with SHADEREDIT_MVAR_TOKEN_INVALID
|
||||
virtual IMaterialVar *GetPPEMaterialVarFast(ShaderEditVarToken &token,
|
||||
const char *pszPPEName, const char *pszNodeName, const char *pszVarName) = 0;
|
||||
};
|
||||
|
||||
#define SHADEREDIT_MVAR_TOKEN_INVALID 0
|
||||
#define SHADEREDIT_MVAR_TOKEN_FAILED 0xFFFFFFFF
|
||||
|
||||
#define SHADEREDIT_INTERFACE_VERSION "ShaderEditor005"
|
||||
|
||||
#ifdef SHADER_EDITOR_DLL
|
||||
class ShaderEditorInterface;
|
||||
extern ShaderEditorInterface *shaderEdit;
|
||||
#else
|
||||
extern IVShaderEditor *shaderEdit;
|
||||
#endif // NOT SHADER_EDITOR_DLL
|
||||
|
||||
#endif // NOT PROCSHADER_DLL
|
||||
|
||||
#endif // NOT IV_SHADEREDITOR
|
||||
424
game/client/ShaderEditor/SEdit_ModelRender.cpp
Normal file
424
game/client/ShaderEditor/SEdit_ModelRender.cpp
Normal file
@@ -0,0 +1,424 @@
|
||||
// ******************************************************
|
||||
//
|
||||
// Purpose:
|
||||
// - Handles model rendering requests from the
|
||||
// shader editor library
|
||||
//
|
||||
// ******************************************************
|
||||
|
||||
#include "cbase.h"
|
||||
|
||||
#include "vgui/IInput.h"
|
||||
#include "vgui_controls/Controls.h"
|
||||
|
||||
#include "shadereditor/sedit_modelrender.h"
|
||||
#include "model_types.h"
|
||||
|
||||
#ifndef SOURCE_2006
|
||||
#include "viewpostprocess.h"
|
||||
#endif
|
||||
|
||||
#include "view.h"
|
||||
#include "input.h"
|
||||
|
||||
#include "beamdraw.h"
|
||||
|
||||
#ifdef SOURCE_2006
|
||||
void ScreenToWorld(int mousex, int mousey, float fov,
|
||||
const Vector& vecRenderOrigin,
|
||||
const QAngle& vecRenderAngles,
|
||||
Vector& vecPickingRay)
|
||||
{
|
||||
float dx, dy;
|
||||
float c_x, c_y;
|
||||
float dist;
|
||||
Vector vpn, vup, vright;
|
||||
|
||||
float scaled_fov = ScaleFOVByWidthRatio(fov, engine->GetScreenAspectRatio() * 0.75f);
|
||||
|
||||
c_x = ScreenWidth() / 2;
|
||||
c_y = ScreenHeight() / 2;
|
||||
|
||||
dx = (float)mousex - c_x;
|
||||
dy = c_y - (float)mousey;
|
||||
|
||||
float dist_denom = tan(M_PI * scaled_fov / 360.0f);
|
||||
dist = c_x / dist_denom;
|
||||
AngleVectors(vecRenderAngles, &vpn, &vright, &vup);
|
||||
vecPickingRay = vpn * dist + vright * (dx)+vup * (dy);
|
||||
VectorNormalize(vecPickingRay);
|
||||
}
|
||||
#else
|
||||
extern void ScreenToWorld(int mousex, int mousey, float fov,
|
||||
const Vector& vecRenderOrigin,
|
||||
const QAngle& vecRenderAngles,
|
||||
Vector& vecPickingRay);
|
||||
#endif
|
||||
|
||||
SEditModelRender __g_ShaderEditorMReder("ShEditMRender");
|
||||
SEditModelRender *sEditMRender = &__g_ShaderEditorMReder;
|
||||
|
||||
SEditModelRender::SEditModelRender(char const *name) : CAutoGameSystemPerFrame(name)
|
||||
{
|
||||
pModelInstance = NULL;
|
||||
m_iNumPoseParams = 0;
|
||||
DestroyModel();
|
||||
}
|
||||
SEditModelRender::~SEditModelRender()
|
||||
{
|
||||
DestroyModel();
|
||||
}
|
||||
|
||||
bool SEditModelRender::Init()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
void SEditModelRender::Shutdown()
|
||||
{
|
||||
}
|
||||
void SEditModelRender::Update(float frametime)
|
||||
{
|
||||
if (!IsModelReady())
|
||||
return;
|
||||
|
||||
pModelInstance->StudioFrameAdvance();
|
||||
if (pModelInstance->GetCycle() >= 1.0f)
|
||||
pModelInstance->SetCycle(pModelInstance->GetCycle() - 1.0f);
|
||||
}
|
||||
void SEditModelRender::LevelInitPostEntity()
|
||||
{
|
||||
ResetModel();
|
||||
}
|
||||
void SEditModelRender::LevelShutdownPostEntity()
|
||||
{
|
||||
ResetModel();
|
||||
}
|
||||
void SEditModelRender::ResetModel()
|
||||
{
|
||||
if (!IsModelReady())
|
||||
return;
|
||||
pModelInstance->m_flAnimTime = gpGlobals->curtime;
|
||||
pModelInstance->m_flOldAnimTime = gpGlobals->curtime;
|
||||
}
|
||||
bool SEditModelRender::IsModelReady()
|
||||
{
|
||||
if (!pModelInstance)
|
||||
return false;
|
||||
|
||||
bool bValid = !!pModelInstance->GetModel();
|
||||
|
||||
if (bValid && Q_strlen(m_szModelPath))
|
||||
{
|
||||
const model_t *pMdl = modelinfo ? modelinfo->FindOrLoadModel(m_szModelPath) : NULL;
|
||||
if (pMdl)
|
||||
pModelInstance->SetModelPointer(pMdl);
|
||||
bValid = !!pMdl;
|
||||
}
|
||||
|
||||
if (!bValid)
|
||||
DestroyModel();
|
||||
|
||||
return bValid;
|
||||
}
|
||||
bool SEditModelRender::LoadModel(const char *localPath)
|
||||
{
|
||||
DestroyModel();
|
||||
|
||||
const model_t *mdl = modelinfo->FindOrLoadModel(localPath);
|
||||
if (!mdl)
|
||||
return false;
|
||||
|
||||
Q_strcpy(m_szModelPath, localPath);
|
||||
|
||||
C_BaseFlex *pEnt = new C_BaseFlex();
|
||||
pEnt->InitializeAsClientEntity(NULL,
|
||||
#if SWARM_DLL
|
||||
false
|
||||
#else
|
||||
RENDER_GROUP_OPAQUE_ENTITY
|
||||
#endif
|
||||
);
|
||||
MDLCACHE_CRITICAL_SECTION();
|
||||
pEnt->SetModelPointer(mdl);
|
||||
pEnt->Spawn();
|
||||
|
||||
pEnt->SetAbsAngles(vec3_angle);
|
||||
pEnt->SetAbsOrigin(vec3_origin);
|
||||
|
||||
pEnt->AddEffects(EF_NODRAW | EF_NOINTERP);
|
||||
pEnt->m_EntClientFlags |= ENTCLIENTFLAG_DONTUSEIK;
|
||||
|
||||
// leave it alone.
|
||||
pEnt->RemoveFromLeafSystem();
|
||||
cl_entitylist->RemoveEntity(pEnt->GetRefEHandle());
|
||||
pEnt->CollisionProp()->DestroyPartitionHandle();
|
||||
|
||||
CStudioHdr *pHdr = pEnt->GetModelPtr();
|
||||
m_iNumPoseParams = pHdr ? pHdr->GetNumPoseParameters() : 0;
|
||||
|
||||
pModelInstance = pEnt;
|
||||
return true;
|
||||
}
|
||||
void SEditModelRender::DestroyModel()
|
||||
{
|
||||
if (pModelInstance)
|
||||
pModelInstance->Remove();
|
||||
|
||||
pModelInstance = NULL;
|
||||
m_szModelPath[0] = '\0';
|
||||
m_iNumPoseParams = 0;
|
||||
}
|
||||
void SEditModelRender::GetModelCenter(float *pFl3_ViewOffset)
|
||||
{
|
||||
Q_memset(pFl3_ViewOffset, 0, sizeof(float) * 3);
|
||||
if (IsModelReady())
|
||||
{
|
||||
MDLCACHE_CRITICAL_SECTION();
|
||||
if (pModelInstance->GetModelPtr())
|
||||
{
|
||||
const Vector &vecMin = pModelInstance->GetModelPtr()->hull_min();
|
||||
const Vector &vecMax = pModelInstance->GetModelPtr()->hull_max();
|
||||
Vector vecPos = (vecMin + (vecMax - vecMin) * 0.5f);
|
||||
if (pFl3_ViewOffset)
|
||||
Q_memcpy(pFl3_ViewOffset, vecPos.Base(), sizeof(float) * 3);
|
||||
}
|
||||
}
|
||||
}
|
||||
void SEditModelRender::DestroyCharPtrList(char ***szList)
|
||||
{
|
||||
Assert(szList);
|
||||
if (*szList)
|
||||
{
|
||||
delete[](**szList);
|
||||
delete[](*szList);
|
||||
*szList = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
int SequenceSort(mstudioseqdesc_t *const *seq1, mstudioseqdesc_t *const *seq2)
|
||||
{
|
||||
return Q_stricmp((*seq1)->pszLabel(), (*seq2)->pszLabel());
|
||||
}
|
||||
int SEditModelRender::QuerySequences(char ***list)
|
||||
{
|
||||
if (!IsModelReady())
|
||||
return 0;
|
||||
|
||||
MDLCACHE_CRITICAL_SECTION();
|
||||
CStudioHdr *pHdr = pModelInstance->GetModelPtr();
|
||||
if (!pHdr)
|
||||
return 0;
|
||||
|
||||
CUtlVector< mstudioseqdesc_t* >hSeqs;
|
||||
for (int i = 0; i < pHdr->GetNumSeq(); i++)
|
||||
if (!(pHdr->pSeqdesc(i).flags & STUDIO_HIDDEN))
|
||||
hSeqs.AddToTail(&pHdr->pSeqdesc(i));
|
||||
|
||||
int numSequences = hSeqs.Count();
|
||||
|
||||
if (!numSequences)
|
||||
return 0;
|
||||
|
||||
hSeqs.Sort(SequenceSort);
|
||||
|
||||
CUtlVector< const char* >hNameList;
|
||||
for (int i = 0; i < numSequences; i++)
|
||||
{
|
||||
const char *seqName = NULL;
|
||||
const mstudioseqdesc_t &seqPtr = *hSeqs[i];
|
||||
if (seqPtr.pszLabel())
|
||||
seqName = seqPtr.pszLabel();
|
||||
else
|
||||
seqName = "Unknown Sequence";
|
||||
|
||||
hNameList.AddToTail(seqName);
|
||||
}
|
||||
|
||||
*list = new char*[numSequences];
|
||||
|
||||
int iTotalLength = 0;
|
||||
for (int i = 0; i < numSequences; i++)
|
||||
iTotalLength += Q_strlen(hNameList[i]) + 1;
|
||||
|
||||
**list = new char[iTotalLength];
|
||||
|
||||
int curpos = 0;
|
||||
for (int i = 0; i < numSequences; i++)
|
||||
{
|
||||
int curLength = Q_strlen(hNameList[i]) + 1;
|
||||
(*list)[i] = **list + curpos;
|
||||
Q_strcpy((*list)[i], hNameList[i]);
|
||||
curpos += curLength;
|
||||
}
|
||||
|
||||
hNameList.Purge();
|
||||
hSeqs.Purge();
|
||||
return numSequences;
|
||||
}
|
||||
void SEditModelRender::SetSequence(const char *name)
|
||||
{
|
||||
if (!IsModelReady())
|
||||
return;
|
||||
|
||||
MDLCACHE_CRITICAL_SECTION();
|
||||
pModelInstance->ResetSequence(pModelInstance->LookupSequence(name));
|
||||
}
|
||||
void SEditModelRender::ExecRender()
|
||||
{
|
||||
if (!IsModelReady())
|
||||
return;
|
||||
|
||||
MDLCACHE_CRITICAL_SECTION();
|
||||
for (int i = 0; i < m_iNumPoseParams; i++)
|
||||
pModelInstance->SetPoseParameter(i, 0);
|
||||
|
||||
#if SWARM_DLL
|
||||
RenderableInstance_t instance;
|
||||
instance.m_nAlpha = 255;
|
||||
#endif
|
||||
pModelInstance->DrawModel(STUDIO_RENDER
|
||||
#if SWARM_DLL
|
||||
, instance
|
||||
#endif
|
||||
);
|
||||
}
|
||||
void SEditModelRender::DoPostProc(int x, int y, int w, int h)
|
||||
{
|
||||
#ifndef SOURCE_2006
|
||||
if (view && view->GetPlayerViewSetup()->m_bDoBloomAndToneMapping)
|
||||
DoEnginePostProcessing(x, y, w, h, false, false);
|
||||
#endif
|
||||
}
|
||||
int SEditModelRender::MaterialPicker(char ***szMat)
|
||||
{
|
||||
int mx, my;
|
||||
#ifdef SOURCE_2006
|
||||
vgui::input()->GetCursorPos(mx, my);
|
||||
#else
|
||||
vgui::input()->GetCursorPosition(mx, my);
|
||||
#endif
|
||||
|
||||
Vector ray;
|
||||
const CViewSetup *pViewSetup = view->GetPlayerViewSetup();
|
||||
float ratio = engine->GetScreenAspectRatio(
|
||||
#if SWARM_DLL
|
||||
pViewSetup->width, pViewSetup->height
|
||||
#endif
|
||||
);
|
||||
|
||||
ratio = (1.0f / ratio) * (4.0f / 3.0f);
|
||||
float flFov = ScaleFOVByWidthRatio(pViewSetup->fov, ratio);
|
||||
ScreenToWorld(mx, my, flFov, pViewSetup->origin, pViewSetup->angles, ray);
|
||||
|
||||
Vector start = pViewSetup->origin;
|
||||
Vector end = start + ray * MAX_TRACE_LENGTH;
|
||||
trace_t tr;
|
||||
C_BaseEntity *pIgnore = input->CAM_IsThirdPerson() ? NULL : C_BasePlayer::GetLocalPlayer();
|
||||
UTIL_TraceLine(start, end, MASK_SOLID, pIgnore, COLLISION_GROUP_NONE, &tr);
|
||||
|
||||
if (!tr.DidHit())
|
||||
return 0;
|
||||
|
||||
int numMaterials = 0;
|
||||
IMaterial **MatList = NULL;
|
||||
studiohdr_t *pSHdr = NULL;
|
||||
|
||||
if (tr.DidHitWorld())
|
||||
{
|
||||
if (tr.hitbox == 0)
|
||||
{
|
||||
Vector dummy;
|
||||
IMaterial *pMat = engine->TraceLineMaterialAndLighting(start, end, dummy, dummy);
|
||||
if (pMat)
|
||||
{
|
||||
numMaterials = 1;
|
||||
MatList = new IMaterial*[1];
|
||||
MatList[0] = pMat;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ICollideable *prop = staticpropmgr->GetStaticPropByIndex(tr.hitbox - 1);
|
||||
if (prop)
|
||||
{
|
||||
IClientRenderable *pRenderProp = prop->GetIClientUnknown()->GetClientRenderable();
|
||||
if (pRenderProp)
|
||||
{
|
||||
const model_t *pModel = pRenderProp->GetModel();
|
||||
if (pModel)
|
||||
pSHdr = modelinfo->GetStudiomodel(pModel);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (tr.m_pEnt)
|
||||
{
|
||||
const model_t *pModel = tr.m_pEnt->GetModel();
|
||||
if (pModel)
|
||||
pSHdr = modelinfo->GetStudiomodel(pModel);
|
||||
}
|
||||
|
||||
if (pSHdr)
|
||||
{
|
||||
Assert(!numMaterials && !MatList);
|
||||
numMaterials = pSHdr->numtextures;
|
||||
const int numPaths = pSHdr->numcdtextures;
|
||||
|
||||
if (numMaterials)
|
||||
{
|
||||
CUtlVector< IMaterial* >hValidMaterials;
|
||||
for (int i = 0; i < numMaterials; i++)
|
||||
{
|
||||
mstudiotexture_t *pStudioTex = pSHdr->pTexture(i);
|
||||
const char *matName = pStudioTex->pszName();
|
||||
|
||||
for (int p = 0; p < numPaths; p++)
|
||||
{
|
||||
char tmpPath[MAX_PATH];
|
||||
Q_snprintf(tmpPath, MAX_PATH, "%s%s\0", pSHdr->pCdtexture(p), matName);
|
||||
Q_FixSlashes(tmpPath);
|
||||
IMaterial *pTempMat = materials->FindMaterial(tmpPath, TEXTURE_GROUP_MODEL);
|
||||
if (!IsErrorMaterial(pTempMat))
|
||||
{
|
||||
hValidMaterials.AddToTail(pTempMat);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
numMaterials = hValidMaterials.Count();
|
||||
if (numMaterials)
|
||||
{
|
||||
MatList = new IMaterial*[numMaterials];
|
||||
for (int i = 0; i < numMaterials; i++)
|
||||
MatList[i] = hValidMaterials[i];
|
||||
}
|
||||
|
||||
hValidMaterials.Purge();
|
||||
}
|
||||
}
|
||||
|
||||
*szMat = new char*[numMaterials];
|
||||
|
||||
int iTotalLength = 0;
|
||||
for (int i = 0; i < numMaterials; i++)
|
||||
iTotalLength += Q_strlen(MatList[i]->GetName()) + 1;
|
||||
|
||||
**szMat = new char[iTotalLength];
|
||||
|
||||
int curpos = 0;
|
||||
for (int i = 0; i < numMaterials; i++)
|
||||
{
|
||||
const char *pszName = MatList[i]->GetName();
|
||||
|
||||
int curLength = Q_strlen(pszName) + 1;
|
||||
(*szMat)[i] = **szMat + curpos;
|
||||
Q_strcpy((*szMat)[i], pszName);
|
||||
curpos += curLength;
|
||||
}
|
||||
|
||||
if (MatList)
|
||||
delete[] MatList;
|
||||
|
||||
return numMaterials;
|
||||
}
|
||||
48
game/client/ShaderEditor/SEdit_ModelRender.h
Normal file
48
game/client/ShaderEditor/SEdit_ModelRender.h
Normal file
@@ -0,0 +1,48 @@
|
||||
#ifndef SHEDITMRENDER_H
|
||||
#define SHEDITMRENDER_H
|
||||
|
||||
#include "cbase.h"
|
||||
#include "shadereditor/isedit_modelrender.h"
|
||||
|
||||
class C_BaseFlex_OverrideLod;
|
||||
|
||||
class SEditModelRender : public ISEditModelRender, public CAutoGameSystemPerFrame
|
||||
{
|
||||
public:
|
||||
SEditModelRender(char const *name);
|
||||
~SEditModelRender();
|
||||
|
||||
// autogamesystem
|
||||
virtual bool Init();
|
||||
virtual void Shutdown();
|
||||
virtual void Update(float frametime);
|
||||
|
||||
virtual void LevelInitPostEntity();
|
||||
virtual void LevelShutdownPostEntity();
|
||||
|
||||
// interface
|
||||
virtual bool LoadModel(const char *localPath);
|
||||
virtual void DestroyModel();
|
||||
virtual void GetModelCenter(float *pFl3_ViewOffset);
|
||||
|
||||
virtual int QuerySequences(char ***list);
|
||||
virtual void SetSequence(const char *name);
|
||||
|
||||
virtual void ExecRender();
|
||||
virtual void DoPostProc(int x, int y, int w, int h);
|
||||
|
||||
virtual int MaterialPicker(char ***szMat);
|
||||
|
||||
virtual void DestroyCharPtrList(char ***szList);
|
||||
|
||||
private:
|
||||
|
||||
bool IsModelReady();
|
||||
void ResetModel();
|
||||
|
||||
C_BaseFlex *pModelInstance;
|
||||
char m_szModelPath[MAX_PATH];
|
||||
int m_iNumPoseParams;
|
||||
};
|
||||
|
||||
#endif
|
||||
1833
game/client/ShaderEditor/ShaderEditorSystem.cpp
Normal file
1833
game/client/ShaderEditor/ShaderEditorSystem.cpp
Normal file
File diff suppressed because it is too large
Load Diff
62
game/client/ShaderEditor/ShaderEditorSystem.h
Normal file
62
game/client/ShaderEditor/ShaderEditorSystem.h
Normal file
@@ -0,0 +1,62 @@
|
||||
#ifndef SHEDITSYSTEM_H
|
||||
#define SHEDITSYSTEM_H
|
||||
|
||||
#include "cbase.h"
|
||||
|
||||
#include "datacache/imdlcache.h"
|
||||
|
||||
#include "iviewrender.h"
|
||||
#include "view_shared.h"
|
||||
#include "viewrender.h"
|
||||
|
||||
|
||||
class ShaderEditorHandler : public CAutoGameSystemPerFrame
|
||||
{
|
||||
public:
|
||||
ShaderEditorHandler(char const *name);
|
||||
~ShaderEditorHandler();
|
||||
|
||||
virtual bool Init();
|
||||
virtual void Shutdown();
|
||||
|
||||
virtual void Update(float frametime);
|
||||
virtual void PreRender();
|
||||
virtual void PostRender();
|
||||
|
||||
#ifdef SOURCE_2006
|
||||
void CustomViewRender(int *viewId, const VisibleFogVolumeInfo_t &fogVolumeInfo);
|
||||
#else
|
||||
void CustomViewRender(int *viewId, const VisibleFogVolumeInfo_t &fogVolumeInfo, const WaterRenderInfo_t &waterRenderInfo);
|
||||
#endif
|
||||
void CustomPostRender();
|
||||
void UpdateSkymask(int x, int y, int w, int h, bool bCombineMode = false);
|
||||
|
||||
const bool IsReady();
|
||||
int &GetViewIdForModify();
|
||||
const VisibleFogVolumeInfo_t &GetFogVolumeInfo();
|
||||
#ifndef SOURCE_2006
|
||||
const WaterRenderInfo_t &GetWaterRenderInfo();
|
||||
#endif
|
||||
|
||||
private:
|
||||
bool m_bReady;
|
||||
|
||||
void RegisterCallbacks();
|
||||
void PrepareCallbackData();
|
||||
|
||||
void RegisterViewRenderCallbacks();
|
||||
|
||||
int *m_piCurrentViewId;
|
||||
VisibleFogVolumeInfo_t m_tFogVolumeInfo;
|
||||
#ifndef SOURCE_2006
|
||||
WaterRenderInfo_t m_tWaterRenderInfo;
|
||||
#endif
|
||||
|
||||
float m_flNextAlpha;
|
||||
float m_flAlpha;
|
||||
};
|
||||
|
||||
extern ShaderEditorHandler *g_ShaderEditorSystem;
|
||||
|
||||
|
||||
#endif
|
||||
172
game/client/TeamBitmapImage.cpp
Normal file
172
game/client/TeamBitmapImage.cpp
Normal file
@@ -0,0 +1,172 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: This is a panel which is rendered image on top of an entity
|
||||
//
|
||||
// $Revision: $
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
#include "cbase.h"
|
||||
#include "TeamBitmapImage.h"
|
||||
#include <KeyValues.h>
|
||||
#include "vgui_bitmapimage.h"
|
||||
#include "panelmetaclassmgr.h"
|
||||
#include "VGuiMatSurface/IMatSystemSurface.h"
|
||||
#include <vgui_controls/Panel.h>
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// A multiplexer bitmap that chooses a bitmap based on team
|
||||
//-----------------------------------------------------------------------------
|
||||
CTeamBitmapImage::CTeamBitmapImage() : m_Alpha(1.0f)
|
||||
{
|
||||
memset( m_ppImage, 0, BITMAP_COUNT * sizeof(BitmapImage*) );
|
||||
m_pEntity = NULL;
|
||||
m_bRelativeTeams = 0;
|
||||
}
|
||||
|
||||
CTeamBitmapImage::~CTeamBitmapImage()
|
||||
{
|
||||
int i;
|
||||
for ( i = 0; i < BITMAP_COUNT; ++i )
|
||||
{
|
||||
if (m_ppImage[i])
|
||||
delete m_ppImage[i];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// initialization
|
||||
//-----------------------------------------------------------------------------
|
||||
bool CTeamBitmapImage::Init( vgui::Panel *pParent, KeyValues* pInitData, C_BaseEntity* pEntity )
|
||||
{
|
||||
static const char *pRelativeTeamNames[BITMAP_COUNT] =
|
||||
{
|
||||
"NoTeam",
|
||||
"MyTeam",
|
||||
"EnemyTeam",
|
||||
};
|
||||
|
||||
static const char *pAbsoluteTeamNames[BITMAP_COUNT] =
|
||||
{
|
||||
"Team0",
|
||||
"Team1",
|
||||
"Team2",
|
||||
};
|
||||
|
||||
m_pEntity = pEntity;
|
||||
m_bRelativeTeams = (pInitData->GetInt( "relativeteam" ) != 0);
|
||||
|
||||
const char **ppTeamNames = m_bRelativeTeams ? pRelativeTeamNames : pAbsoluteTeamNames;
|
||||
|
||||
int i;
|
||||
for ( i = 0 ; i < BITMAP_COUNT; ++i )
|
||||
{
|
||||
// Default to null
|
||||
m_ppImage[i] = NULL;
|
||||
|
||||
// Look for team section
|
||||
KeyValues *pTeamKV = pInitData->FindKey( ppTeamNames[i] );
|
||||
if ( !pTeamKV )
|
||||
continue;
|
||||
|
||||
char const* pClassImage = pTeamKV->GetString( "material" );
|
||||
if ( !pClassImage || !pClassImage[ 0 ] )
|
||||
return false;
|
||||
|
||||
// modulation color
|
||||
Color color;
|
||||
if (!ParseRGBA( pTeamKV, "color", color ))
|
||||
color.SetColor( 255, 255, 255, 255 );
|
||||
|
||||
// hook in the bitmap
|
||||
m_ppImage[i] = new BitmapImage( pParent->GetVPanel(), pClassImage );
|
||||
m_ppImage[i]->SetColor( color );
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Alpha modulate...
|
||||
//-----------------------------------------------------------------------------
|
||||
void CTeamBitmapImage::SetAlpha( float alpha )
|
||||
{
|
||||
m_Alpha = clamp( alpha, 0.0f, 1.0f );
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// draw
|
||||
//-----------------------------------------------------------------------------
|
||||
void CTeamBitmapImage::Paint( float yaw /*= 0.0f*/ )
|
||||
{
|
||||
if (m_Alpha == 0.0f)
|
||||
return;
|
||||
|
||||
int team = 0;
|
||||
if (m_bRelativeTeams)
|
||||
{
|
||||
if (GetEntity())
|
||||
{
|
||||
if (GetEntity()->GetTeamNumber() != 0)
|
||||
{
|
||||
team = GetEntity()->InLocalTeam() ? 1 : 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (GetEntity())
|
||||
team = GetEntity()->GetTeamNumber();
|
||||
}
|
||||
|
||||
// Paint the image for the current team
|
||||
if (m_ppImage[team])
|
||||
{
|
||||
// Modulate the color based on the alpha....
|
||||
Color color = m_ppImage[team]->GetColor();
|
||||
int alpha = color[3];
|
||||
color[3] = (alpha * m_Alpha);
|
||||
m_ppImage[team]->SetColor( color );
|
||||
|
||||
if ( yaw != 0.0f )
|
||||
{
|
||||
g_pMatSystemSurface->DisableClipping( true );
|
||||
|
||||
m_ppImage[team]->DoPaint( m_ppImage[team]->GetRenderSizePanel(), yaw );
|
||||
|
||||
g_pMatSystemSurface->DisableClipping( false );
|
||||
}
|
||||
else
|
||||
{
|
||||
// Paint
|
||||
m_ppImage[team]->Paint();
|
||||
}
|
||||
|
||||
// restore previous color
|
||||
color[3] = alpha;
|
||||
m_ppImage[team]->SetColor( color );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Helper method to initialize a team image from KeyValues data..
|
||||
//-----------------------------------------------------------------------------
|
||||
bool InitializeTeamImage( KeyValues *pInitData, const char* pSectionName, vgui::Panel *pParent, C_BaseEntity *pEntity, CTeamBitmapImage* pTeamImage )
|
||||
{
|
||||
KeyValues *pTeamImageSection = pInitData;
|
||||
if (pSectionName)
|
||||
{
|
||||
pTeamImageSection = pInitData->FindKey( pSectionName );
|
||||
if ( !pTeamImageSection )
|
||||
return false;
|
||||
}
|
||||
|
||||
return pTeamImage->Init( pParent, pTeamImageSection, pEntity );
|
||||
}
|
||||
|
||||
80
game/client/TeamBitmapImage.h
Normal file
80
game/client/TeamBitmapImage.h
Normal file
@@ -0,0 +1,80 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: This is a panel which is rendered image on top of an entity
|
||||
//
|
||||
// $Revision: $
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef TEAMBITMAPIMAGE_H
|
||||
#define TEAMBITMAPIMAGE_H
|
||||
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
//#include "tf_shareddefs.h"
|
||||
|
||||
#include <vgui/VGUI.h>
|
||||
|
||||
namespace vgui
|
||||
{
|
||||
class Panel;
|
||||
}
|
||||
|
||||
class BitmapImage;
|
||||
class C_BaseEntity;
|
||||
class KeyValues;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// A multiplexer bitmap that chooses a bitmap based on team
|
||||
//-----------------------------------------------------------------------------
|
||||
class CTeamBitmapImage
|
||||
{
|
||||
public:
|
||||
// construction, destruction
|
||||
CTeamBitmapImage();
|
||||
~CTeamBitmapImage();
|
||||
|
||||
// initialization
|
||||
bool Init( vgui::Panel *pParent, KeyValues* pInitData, C_BaseEntity* pEntity );
|
||||
|
||||
// Alpha override...
|
||||
void SetAlpha( float alpha );
|
||||
|
||||
// Paint the sucka. Paint it the size of the parent panel
|
||||
void Paint( float yaw = 0.0f );
|
||||
|
||||
protected:
|
||||
// Wrapper so we can implement this with EHANDLES some day
|
||||
C_BaseEntity *GetEntity() { return m_pEntity; }
|
||||
|
||||
private:
|
||||
enum
|
||||
{
|
||||
// NOTE: Was MAX_TF_TEAMS not 4, but I don't like the dependency here.
|
||||
BITMAP_COUNT = 4 + 1
|
||||
};
|
||||
|
||||
BitmapImage *m_ppImage[ BITMAP_COUNT ];
|
||||
C_BaseEntity *m_pEntity;
|
||||
float m_Alpha;
|
||||
bool m_bRelativeTeams;
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Helper method to initialize a team image from KeyValues data..
|
||||
// KeyValues contains the bitmap data. pSectionName, if it exists,
|
||||
// indicates which subsection of pInitData should be looked at to get at the
|
||||
// image data. The final argument is the bitmap image to initialize.
|
||||
// The function returns true if it succeeded.
|
||||
//
|
||||
// NOTE: This function looks for the key values 'material' and 'color'
|
||||
// and uses them to set up the material + modulation color of the image
|
||||
//-----------------------------------------------------------------------------
|
||||
bool InitializeTeamImage( KeyValues *pInitData, const char* pSectionName,
|
||||
vgui::Panel *pParent, C_BaseEntity *pEntity, CTeamBitmapImage* pBitmapImage );
|
||||
|
||||
|
||||
#endif // TEAMBITMAPIMAGE_H
|
||||
32
game/client/Tracer_Filter.h
Normal file
32
game/client/Tracer_Filter.h
Normal file
@@ -0,0 +1,32 @@
|
||||
#ifndef c_tracer_filter
|
||||
#define c_tracer_filter
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
class CTraceFilterSkipPlayerAndViewModel : public CTraceFilter
|
||||
{
|
||||
public:
|
||||
virtual bool ShouldHitEntity(IHandleEntity *pServerEntity, int contentsMask)
|
||||
{
|
||||
// Test against the vehicle too?
|
||||
// FLASHLIGHTFIXME: how do you know that you are actually inside of the vehicle?
|
||||
C_BaseEntity *pEntity = EntityFromEntityHandle(pServerEntity);
|
||||
if (!pEntity)
|
||||
return true;
|
||||
|
||||
if ((dynamic_cast<C_BaseViewModel *>(pEntity) != NULL) ||
|
||||
(dynamic_cast<C_BasePlayer *>(pEntity) != NULL) ||
|
||||
pEntity->GetCollisionGroup() == COLLISION_GROUP_DEBRIS ||
|
||||
pEntity->GetCollisionGroup() == COLLISION_GROUP_INTERACTIVE_DEBRIS)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
83
game/client/ViewConeImage.cpp
Normal file
83
game/client/ViewConeImage.cpp
Normal file
@@ -0,0 +1,83 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: This is a panel which is rendered image on top of an entity
|
||||
//
|
||||
// $Revision: $
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
#include "cbase.h"
|
||||
#include "ViewConeImage.h"
|
||||
#include <KeyValues.h>
|
||||
#include <vgui_controls/Panel.h>
|
||||
#include "VGuiMatSurface/IMatSystemSurface.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// initialization
|
||||
//-----------------------------------------------------------------------------
|
||||
bool CViewConeImage::Init( vgui::Panel *pParent, KeyValues* pInitData )
|
||||
{
|
||||
Assert( pParent );
|
||||
|
||||
// Load viewcone material
|
||||
if (!m_Image.Init( pParent->GetVPanel(), pInitData ))
|
||||
return false;
|
||||
|
||||
// Position the view cone...
|
||||
int viewconesize = pInitData->GetInt( "size", 32 );
|
||||
m_Image.SetRenderSize( viewconesize, viewconesize );
|
||||
|
||||
int cx, cy;
|
||||
pParent->GetSize( cx, cy );
|
||||
m_Image.SetPos( (cx - viewconesize) / 2, (cy - viewconesize) / 2 );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Paint the sucka
|
||||
//-----------------------------------------------------------------------------
|
||||
void CViewConeImage::Paint( float yaw )
|
||||
{
|
||||
g_pMatSystemSurface->DisableClipping( true );
|
||||
|
||||
m_Image.DoPaint( NULL, yaw );
|
||||
|
||||
g_pMatSystemSurface->DisableClipping( false );
|
||||
}
|
||||
|
||||
void CViewConeImage::SetColor( int r, int g, int b )
|
||||
{
|
||||
m_Image.SetColor( Color( r, g, b, 255 ) );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Helper method to initialize a view cone image from KeyValues data..
|
||||
// KeyValues contains the bitmap data, pSectionName, if it exists,
|
||||
// indicates which subsection of pInitData should be looked at to get at the
|
||||
// image data. The final argument is the bitmap image to initialize.
|
||||
// The function returns true if it succeeded.
|
||||
//
|
||||
// NOTE: This function looks for the key values 'material' and 'color'
|
||||
// and uses them to set up the material + modulation color of the image
|
||||
//-----------------------------------------------------------------------------
|
||||
bool InitializeViewConeImage( KeyValues *pInitData, const char* pSectionName,
|
||||
vgui::Panel *pParent, CViewConeImage* pViewConeImage )
|
||||
{
|
||||
KeyValues *pViewConeImageSection;
|
||||
if (pSectionName)
|
||||
{
|
||||
pViewConeImageSection = pInitData->FindKey( pSectionName );
|
||||
if ( !pViewConeImageSection )
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
pViewConeImageSection = pInitData;
|
||||
}
|
||||
|
||||
return pViewConeImage->Init( pParent, pViewConeImageSection );
|
||||
}
|
||||
|
||||
56
game/client/ViewConeImage.h
Normal file
56
game/client/ViewConeImage.h
Normal file
@@ -0,0 +1,56 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: This is a panel which draws a viewcone
|
||||
//
|
||||
// $Revision: $
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef VIEWCONEIMAGE_H
|
||||
#define VIEWCONEIMAGE_H
|
||||
|
||||
#include "shareddefs.h"
|
||||
#include "vgui_bitmapimage.h"
|
||||
|
||||
namespace vgui
|
||||
{
|
||||
class Panel;
|
||||
}
|
||||
|
||||
class C_BaseEntity;
|
||||
class KeyValues;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// A bitmap that renders a view cone based on angles
|
||||
//-----------------------------------------------------------------------------
|
||||
class CViewConeImage
|
||||
{
|
||||
public:
|
||||
// initialization
|
||||
bool Init( vgui::Panel *pParent, KeyValues* pInitData );
|
||||
|
||||
// Paint the sucka
|
||||
void Paint( float yaw );
|
||||
|
||||
void SetColor( int r, int g, int b );
|
||||
|
||||
private:
|
||||
BitmapImage m_Image;
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Helper method to initialize a view cone image from KeyValues data..
|
||||
// KeyValues contains the bitmap data, pSectionName, if it exists,
|
||||
// indicates which subsection of pInitData should be looked at to get at the
|
||||
// image data. The final argument is the bitmap image to initialize.
|
||||
// The function returns true if it succeeded.
|
||||
//
|
||||
// NOTE: This function looks for the key values 'material' and 'color'
|
||||
// and uses them to set up the material + modulation color of the image
|
||||
//-----------------------------------------------------------------------------
|
||||
bool InitializeViewConeImage( KeyValues *pInitData, const char* pSectionName,
|
||||
vgui::Panel *pParent, CViewConeImage* pViewConeImage );
|
||||
|
||||
|
||||
#endif // VIEWCONEIMAGE_H
|
||||
83
game/client/WaterLODMaterialProxy.cpp
Normal file
83
game/client/WaterLODMaterialProxy.cpp
Normal file
@@ -0,0 +1,83 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
#include "cbase.h"
|
||||
#include "materialsystem/imaterialproxy.h"
|
||||
#include "materialsystem/imaterial.h"
|
||||
#include "materialsystem/imaterialvar.h"
|
||||
#include "iviewrender.h"
|
||||
#include "toolframework_client.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
// forward declarations
|
||||
void ToolFramework_RecordMaterialParams( IMaterial *pMaterial );
|
||||
|
||||
// no inputs, assumes that the results go into $CHEAPWATERSTARTDISTANCE and $CHEAPWATERENDDISTANCE
|
||||
class CWaterLODMaterialProxy : public IMaterialProxy
|
||||
{
|
||||
public:
|
||||
CWaterLODMaterialProxy();
|
||||
virtual ~CWaterLODMaterialProxy();
|
||||
virtual bool Init( IMaterial *pMaterial, KeyValues *pKeyValues );
|
||||
virtual void OnBind( void *pC_BaseEntity );
|
||||
virtual void Release( void ) { delete this; }
|
||||
virtual IMaterial *GetMaterial();
|
||||
|
||||
private:
|
||||
IMaterialVar *m_pCheapWaterStartDistanceVar;
|
||||
IMaterialVar *m_pCheapWaterEndDistanceVar;
|
||||
};
|
||||
|
||||
CWaterLODMaterialProxy::CWaterLODMaterialProxy()
|
||||
{
|
||||
m_pCheapWaterStartDistanceVar = NULL;
|
||||
m_pCheapWaterEndDistanceVar = NULL;
|
||||
}
|
||||
|
||||
CWaterLODMaterialProxy::~CWaterLODMaterialProxy()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
bool CWaterLODMaterialProxy::Init( IMaterial *pMaterial, KeyValues *pKeyValues )
|
||||
{
|
||||
bool foundVar;
|
||||
m_pCheapWaterStartDistanceVar = pMaterial->FindVar( "$CHEAPWATERSTARTDISTANCE", &foundVar, false );
|
||||
if( !foundVar )
|
||||
return false;
|
||||
|
||||
m_pCheapWaterEndDistanceVar = pMaterial->FindVar( "$CHEAPWATERENDDISTANCE", &foundVar, false );
|
||||
if( !foundVar )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CWaterLODMaterialProxy::OnBind( void *pC_BaseEntity )
|
||||
{
|
||||
if( !m_pCheapWaterStartDistanceVar || !m_pCheapWaterEndDistanceVar )
|
||||
{
|
||||
return;
|
||||
}
|
||||
float start, end;
|
||||
view->GetWaterLODParams( start, end );
|
||||
m_pCheapWaterStartDistanceVar->SetFloatValue( start );
|
||||
m_pCheapWaterEndDistanceVar->SetFloatValue( end );
|
||||
|
||||
if ( ToolsEnabled() )
|
||||
{
|
||||
ToolFramework_RecordMaterialParams( GetMaterial() );
|
||||
}
|
||||
}
|
||||
|
||||
IMaterial *CWaterLODMaterialProxy::GetMaterial()
|
||||
{
|
||||
return m_pCheapWaterStartDistanceVar->GetOwningMaterial();
|
||||
}
|
||||
|
||||
EXPOSE_INTERFACE( CWaterLODMaterialProxy, IMaterialProxy, "WaterLOD" IMATERIAL_PROXY_INTERFACE_VERSION );
|
||||
78
game/client/WorldDimsProxy.cpp
Normal file
78
game/client/WorldDimsProxy.cpp
Normal file
@@ -0,0 +1,78 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================//
|
||||
|
||||
#include "cbase.h"
|
||||
#include "materialsystem/imaterialproxy.h"
|
||||
#include "materialsystem/imaterial.h"
|
||||
#include "materialsystem/imaterialvar.h"
|
||||
#include "c_world.h"
|
||||
#include "toolframework_client.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
// forward declarations
|
||||
void ToolFramework_RecordMaterialParams( IMaterial *pMaterial );
|
||||
|
||||
class CWorldDimsProxy : public IMaterialProxy
|
||||
{
|
||||
public:
|
||||
CWorldDimsProxy();
|
||||
virtual ~CWorldDimsProxy();
|
||||
virtual bool Init( IMaterial *pMaterial, KeyValues *pKeyValues );
|
||||
virtual void OnBind( void *pC_BaseEntity );
|
||||
virtual void Release( void ) { delete this; }
|
||||
virtual IMaterial *GetMaterial();
|
||||
|
||||
|
||||
public:
|
||||
IMaterialVar *m_pMinsVar;
|
||||
IMaterialVar *m_pMaxsVar;
|
||||
};
|
||||
|
||||
|
||||
CWorldDimsProxy::CWorldDimsProxy()
|
||||
{
|
||||
m_pMinsVar = m_pMaxsVar = NULL;
|
||||
}
|
||||
|
||||
CWorldDimsProxy::~CWorldDimsProxy()
|
||||
{
|
||||
}
|
||||
|
||||
bool CWorldDimsProxy::Init( IMaterial *pMaterial, KeyValues *pKeyValues )
|
||||
{
|
||||
m_pMinsVar = pMaterial->FindVar( "$world_mins", NULL, false );
|
||||
m_pMaxsVar = pMaterial->FindVar( "$world_maxs", NULL, false );
|
||||
return true;
|
||||
}
|
||||
|
||||
void CWorldDimsProxy::OnBind( void *pC_BaseEntity )
|
||||
{
|
||||
if ( m_pMinsVar && m_pMaxsVar )
|
||||
{
|
||||
C_World *pWorld = GetClientWorldEntity();
|
||||
if ( pWorld )
|
||||
{
|
||||
m_pMinsVar->SetVecValue( (const float*)&pWorld->m_WorldMins, 3 );
|
||||
m_pMaxsVar->SetVecValue( (const float*)&pWorld->m_WorldMaxs, 3 );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ToolsEnabled() )
|
||||
{
|
||||
ToolFramework_RecordMaterialParams( GetMaterial() );
|
||||
}
|
||||
}
|
||||
|
||||
IMaterial *CWorldDimsProxy::GetMaterial()
|
||||
{
|
||||
return m_pMinsVar->GetOwningMaterial();
|
||||
}
|
||||
|
||||
EXPOSE_INTERFACE( CWorldDimsProxy, IMaterialProxy, "WorldDims" IMATERIAL_PROXY_INTERFACE_VERSION );
|
||||
|
||||
|
||||
272
game/client/achievement_notification_panel.cpp
Normal file
272
game/client/achievement_notification_panel.cpp
Normal file
@@ -0,0 +1,272 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#include "cbase.h"
|
||||
#include "hud.h"
|
||||
#include "hud_macros.h"
|
||||
#include "hudelement.h"
|
||||
#include "iclientmode.h"
|
||||
#include "ienginevgui.h"
|
||||
#include <vgui/ILocalize.h>
|
||||
#include <vgui/ISurface.h>
|
||||
#include <vgui/IVGui.h>
|
||||
#include <vgui_controls/EditablePanel.h>
|
||||
#include <vgui_controls/Label.h>
|
||||
#include <vgui_controls/ImagePanel.h>
|
||||
#include "achievement_notification_panel.h"
|
||||
#include "steam/steam_api.h"
|
||||
#include "iachievementmgr.h"
|
||||
#include "fmtstr.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
#define ACHIEVEMENT_NOTIFICATION_DURATION 10.0f
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
DECLARE_HUDELEMENT_DEPTH( CAchievementNotificationPanel, 100 );
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
CAchievementNotificationPanel::CAchievementNotificationPanel( const char *pElementName ) : CHudElement( pElementName ), BaseClass( NULL, "AchievementNotificationPanel" )
|
||||
{
|
||||
Panel *pParent = g_pClientMode->GetViewport();
|
||||
SetParent( pParent );
|
||||
|
||||
m_flHideTime = 0;
|
||||
m_pPanelBackground = new EditablePanel( this, "Notification_Background" );
|
||||
m_pIcon = new ImagePanel( this, "Notification_Icon" );
|
||||
m_pLabelHeading = new Label( this, "HeadingLabel", "" );
|
||||
m_pLabelTitle = new Label( this, "TitleLabel", "" );
|
||||
|
||||
m_pIcon->SetShouldScaleImage( true );
|
||||
|
||||
vgui::ivgui()->AddTickSignal( GetVPanel() );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CAchievementNotificationPanel::Init()
|
||||
{
|
||||
ListenForGameEvent( "achievement_event" );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CAchievementNotificationPanel::ApplySchemeSettings( IScheme *pScheme )
|
||||
{
|
||||
// load control settings...
|
||||
LoadControlSettings( "resource/UI/AchievementNotification.res" );
|
||||
|
||||
BaseClass::ApplySchemeSettings( pScheme );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CAchievementNotificationPanel::PerformLayout( void )
|
||||
{
|
||||
BaseClass::PerformLayout();
|
||||
|
||||
// Set background color of various elements. Need to do this in code, if we do it in res file it gets slammed by the
|
||||
// scheme. (Incl. label background: some products don't have label background colors set in their scheme and helpfully slam it to white.)
|
||||
SetBgColor( Color( 0, 0, 0, 0 ) );
|
||||
m_pLabelHeading->SetBgColor( Color( 0, 0, 0, 0 ) );
|
||||
m_pLabelTitle->SetBgColor( Color( 0, 0, 0, 0 ) );
|
||||
m_pPanelBackground->SetBgColor( Color( 62,70,55, 200 ) );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CAchievementNotificationPanel::FireGameEvent( IGameEvent * event )
|
||||
{
|
||||
const char *name = event->GetName();
|
||||
if ( 0 == Q_strcmp( name, "achievement_event" ) )
|
||||
{
|
||||
const char *pchName = event->GetString( "achievement_name" );
|
||||
int iCur = event->GetInt( "cur_val" );
|
||||
int iMax = event->GetInt( "max_val" );
|
||||
wchar_t szLocalizedName[256]=L"";
|
||||
|
||||
if ( IsPC() )
|
||||
{
|
||||
// shouldn't ever get achievement progress if steam not running and user logged in, but check just in case
|
||||
if ( !steamapicontext->SteamUserStats() )
|
||||
{
|
||||
Msg( "Steam not running, achievement progress notification not displayed\n" );
|
||||
}
|
||||
else
|
||||
{
|
||||
// use Steam to show achievement progress UI
|
||||
steamapicontext->SteamUserStats()->IndicateAchievementProgress( pchName, iCur, iMax );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// on X360 we need to show our own achievement progress UI
|
||||
|
||||
const wchar_t *pchLocalizedName = ACHIEVEMENT_LOCALIZED_NAME_FROM_STR( pchName );
|
||||
Assert( pchLocalizedName );
|
||||
if ( !pchLocalizedName || !pchLocalizedName[0] )
|
||||
return;
|
||||
Q_wcsncpy( szLocalizedName, pchLocalizedName, sizeof( szLocalizedName ) );
|
||||
|
||||
// this is achievement progress, compose the message of form: "<name> (<#>/<max>)"
|
||||
wchar_t szFmt[128]=L"";
|
||||
wchar_t szText[512]=L"";
|
||||
wchar_t szNumFound[16]=L"";
|
||||
wchar_t szNumTotal[16]=L"";
|
||||
_snwprintf( szNumFound, ARRAYSIZE( szNumFound ), L"%i", iCur );
|
||||
_snwprintf( szNumTotal, ARRAYSIZE( szNumTotal ), L"%i", iMax );
|
||||
|
||||
const wchar_t *pchFmt = g_pVGuiLocalize->Find( "#GameUI_Achievement_Progress_Fmt" );
|
||||
if ( !pchFmt || !pchFmt[0] )
|
||||
return;
|
||||
Q_wcsncpy( szFmt, pchFmt, sizeof( szFmt ) );
|
||||
|
||||
g_pVGuiLocalize->ConstructString( szText, sizeof( szText ), szFmt, 3, szLocalizedName, szNumFound, szNumTotal );
|
||||
AddNotification( pchName, g_pVGuiLocalize->Find( "#GameUI_Achievement_Progress" ), szText );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Called on each tick
|
||||
//-----------------------------------------------------------------------------
|
||||
void CAchievementNotificationPanel::OnTick( void )
|
||||
{
|
||||
if ( ( m_flHideTime > 0 ) && ( m_flHideTime < gpGlobals->curtime ) )
|
||||
{
|
||||
m_flHideTime = 0;
|
||||
ShowNextNotification();
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
bool CAchievementNotificationPanel::ShouldDraw( void )
|
||||
{
|
||||
return ( ( m_flHideTime > 0 ) && ( m_flHideTime > gpGlobals->curtime ) && CHudElement::ShouldDraw() );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CAchievementNotificationPanel::AddNotification( const char *szIconBaseName, const wchar_t *pHeading, const wchar_t *pTitle )
|
||||
{
|
||||
// put this notification in our queue
|
||||
int iQueueItem = m_queueNotification.AddToTail();
|
||||
Notification_t ¬ification = m_queueNotification[iQueueItem];
|
||||
Q_strncpy( notification.szIconBaseName, szIconBaseName, ARRAYSIZE( notification.szIconBaseName ) );
|
||||
Q_wcsncpy( notification.szHeading, pHeading, sizeof( notification.szHeading ) );
|
||||
Q_wcsncpy( notification.szTitle, pTitle, sizeof( notification.szTitle ) );
|
||||
|
||||
// if we are not currently displaying a notification, go ahead and show this one
|
||||
if ( 0 == m_flHideTime )
|
||||
{
|
||||
ShowNextNotification();
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Shows next notification in queue if there is one
|
||||
//-----------------------------------------------------------------------------
|
||||
void CAchievementNotificationPanel::ShowNextNotification()
|
||||
{
|
||||
// see if we have anything to do
|
||||
if ( 0 == m_queueNotification.Count() )
|
||||
{
|
||||
m_flHideTime = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
Notification_t ¬ification = m_queueNotification[ m_queueNotification.Head() ];
|
||||
|
||||
m_flHideTime = gpGlobals->curtime + ACHIEVEMENT_NOTIFICATION_DURATION;
|
||||
|
||||
// set the text and icon in the dialog
|
||||
SetDialogVariable( "heading", notification.szHeading );
|
||||
SetDialogVariable( "title", notification.szTitle );
|
||||
const char *pchIconBaseName = notification.szIconBaseName;
|
||||
if ( pchIconBaseName && pchIconBaseName[0] )
|
||||
{
|
||||
m_pIcon->SetImage( CFmtStr( "achievements/%s.vmt", pchIconBaseName ) );
|
||||
}
|
||||
|
||||
// resize the panel so it always looks good
|
||||
|
||||
// get fonts
|
||||
HFont hFontHeading = m_pLabelHeading->GetFont();
|
||||
HFont hFontTitle = m_pLabelTitle->GetFont();
|
||||
// determine how wide the text strings are
|
||||
int iHeadingWidth = UTIL_ComputeStringWidth( hFontHeading, notification.szHeading );
|
||||
int iTitleWidth = UTIL_ComputeStringWidth( hFontTitle, notification.szTitle );
|
||||
// use the widest string
|
||||
int iTextWidth = MAX( iHeadingWidth, iTitleWidth );
|
||||
// don't let it be insanely wide
|
||||
iTextWidth = MIN( iTextWidth, XRES( 300 ) );
|
||||
int iIconWidth = m_pIcon->GetWide();
|
||||
int iSpacing = XRES( 10 );
|
||||
int iPanelWidth = iSpacing + iIconWidth + iSpacing + iTextWidth + iSpacing;
|
||||
int iPanelX = GetWide() - iPanelWidth;
|
||||
int iIconX = iPanelX + iSpacing;
|
||||
int iTextX = iIconX + iIconWidth + iSpacing;
|
||||
// resize all the elements
|
||||
SetXAndWide( m_pPanelBackground, iPanelX, iPanelWidth );
|
||||
SetXAndWide( m_pIcon, iIconX, iIconWidth );
|
||||
SetXAndWide( m_pLabelHeading, iTextX, iTextWidth );
|
||||
SetXAndWide( m_pLabelTitle, iTextX, iTextWidth );
|
||||
|
||||
m_queueNotification.Remove( m_queueNotification.Head() );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CAchievementNotificationPanel::SetXAndWide( Panel *pPanel, int x, int wide )
|
||||
{
|
||||
int xCur, yCur;
|
||||
pPanel->GetPos( xCur, yCur );
|
||||
pPanel->SetPos( x, yCur );
|
||||
pPanel->SetWide( wide );
|
||||
}
|
||||
|
||||
CON_COMMAND_F( achievement_notification_test, "Test the hud notification UI", FCVAR_CHEAT | FCVAR_DEVELOPMENTONLY )
|
||||
{
|
||||
static int iCount=0;
|
||||
|
||||
CAchievementNotificationPanel *pPanel = GET_HUDELEMENT( CAchievementNotificationPanel );
|
||||
if ( pPanel )
|
||||
{
|
||||
pPanel->AddNotification( "HL2_KILL_ODESSAGUNSHIP", L"Achievement Progress", ( 0 == ( iCount % 2 ) ? L"Test Notification Message A (1/10)" :
|
||||
L"Test Message B" ) );
|
||||
}
|
||||
|
||||
#if 0
|
||||
IGameEvent *event = gameeventmanager->CreateEvent( "achievement_event" );
|
||||
if ( event )
|
||||
{
|
||||
const char *szTestStr[] = { "TF_GET_HEADSHOTS", "TF_PLAY_GAME_EVERYMAP", "TF_PLAY_GAME_EVERYCLASS", "TF_GET_HEALPOINTS" };
|
||||
event->SetString( "achievement_name", szTestStr[iCount%ARRAYSIZE(szTestStr)] );
|
||||
event->SetInt( "cur_val", ( iCount%9 ) + 1 );
|
||||
event->SetInt( "max_val", 10 );
|
||||
gameeventmanager->FireEvent( event );
|
||||
}
|
||||
#endif
|
||||
|
||||
iCount++;
|
||||
}
|
||||
57
game/client/achievement_notification_panel.h
Normal file
57
game/client/achievement_notification_panel.h
Normal file
@@ -0,0 +1,57 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef ACHIEVEMENT_NOTIFICATION_PANEL_H
|
||||
#define ACHIEVEMENT_NOTIFICATION_PANEL_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <vgui_controls/EditablePanel.h>
|
||||
#include "hudelement.h"
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
class CAchievementNotificationPanel : public CHudElement, public EditablePanel
|
||||
{
|
||||
DECLARE_CLASS_SIMPLE( CAchievementNotificationPanel, EditablePanel );
|
||||
|
||||
public:
|
||||
CAchievementNotificationPanel( const char *pElementName );
|
||||
|
||||
virtual void Init();
|
||||
virtual void ApplySchemeSettings( IScheme *scheme );
|
||||
virtual bool ShouldDraw( void );
|
||||
virtual void PerformLayout( void );
|
||||
virtual void LevelInit( void ) { m_flHideTime = 0; }
|
||||
virtual void FireGameEvent( IGameEvent * event );
|
||||
virtual void OnTick( void );
|
||||
|
||||
void AddNotification( const char *szIconBaseName, const wchar_t *pHeading, const wchar_t *pTitle );
|
||||
|
||||
private:
|
||||
void ShowNextNotification();
|
||||
void SetXAndWide( Panel *pPanel, int x, int wide );
|
||||
|
||||
float m_flHideTime;
|
||||
|
||||
Label *m_pLabelHeading;
|
||||
Label *m_pLabelTitle;
|
||||
EditablePanel *m_pPanelBackground;
|
||||
ImagePanel *m_pIcon;
|
||||
|
||||
struct Notification_t
|
||||
{
|
||||
char szIconBaseName[255];
|
||||
wchar_t szHeading[255];
|
||||
wchar_t szTitle[255];
|
||||
};
|
||||
|
||||
CUtlLinkedList<Notification_t> m_queueNotification;
|
||||
};
|
||||
|
||||
#endif // ACHIEVEMENT_NOTIFICATION_PANEL_H
|
||||
62
game/client/alphamaterialproxy.cpp
Normal file
62
game/client/alphamaterialproxy.cpp
Normal file
@@ -0,0 +1,62 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
#include "cbase.h"
|
||||
#include "proxyentity.h"
|
||||
#include "materialsystem/imaterial.h"
|
||||
#include "materialsystem/imaterialvar.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
// $sineVar : name of variable that controls the alpha level (float)
|
||||
class CAlphaMaterialProxy : public CEntityMaterialProxy
|
||||
{
|
||||
public:
|
||||
CAlphaMaterialProxy();
|
||||
virtual ~CAlphaMaterialProxy();
|
||||
virtual bool Init( IMaterial *pMaterial, KeyValues *pKeyValues );
|
||||
virtual void OnBind( C_BaseEntity *pEntity );
|
||||
virtual IMaterial *GetMaterial();
|
||||
|
||||
private:
|
||||
IMaterialVar *m_AlphaVar;
|
||||
};
|
||||
|
||||
CAlphaMaterialProxy::CAlphaMaterialProxy()
|
||||
{
|
||||
m_AlphaVar = NULL;
|
||||
}
|
||||
|
||||
CAlphaMaterialProxy::~CAlphaMaterialProxy()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
bool CAlphaMaterialProxy::Init( IMaterial *pMaterial, KeyValues *pKeyValues )
|
||||
{
|
||||
bool foundVar;
|
||||
m_AlphaVar = pMaterial->FindVar( "$alpha", &foundVar, false );
|
||||
return foundVar;
|
||||
}
|
||||
|
||||
void CAlphaMaterialProxy::OnBind( C_BaseEntity *pEnt )
|
||||
{
|
||||
if (m_AlphaVar)
|
||||
{
|
||||
m_AlphaVar->SetFloatValue( pEnt->m_clrRender->a );
|
||||
}
|
||||
}
|
||||
|
||||
IMaterial *CAlphaMaterialProxy::GetMaterial()
|
||||
{
|
||||
if ( !m_AlphaVar )
|
||||
return NULL;
|
||||
|
||||
return m_AlphaVar->GetOwningMaterial();
|
||||
}
|
||||
|
||||
EXPOSE_INTERFACE( CAlphaMaterialProxy, IMaterialProxy, "Alpha" IMATERIAL_PROXY_INTERFACE_VERSION );
|
||||
51
game/client/animatedentitytextureproxy.cpp
Normal file
51
game/client/animatedentitytextureproxy.cpp
Normal file
@@ -0,0 +1,51 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
#include "cbase.h"
|
||||
#include "baseanimatedtextureproxy.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
class CAnimatedEntityTextureProxy : public CBaseAnimatedTextureProxy
|
||||
{
|
||||
public:
|
||||
CAnimatedEntityTextureProxy() {}
|
||||
virtual ~CAnimatedEntityTextureProxy() {}
|
||||
|
||||
virtual float GetAnimationStartTime( void* pBaseEntity );
|
||||
virtual void AnimationWrapped( void* pC_BaseEntity );
|
||||
|
||||
};
|
||||
|
||||
EXPOSE_INTERFACE( CAnimatedEntityTextureProxy, IMaterialProxy, "AnimatedEntityTexture" IMATERIAL_PROXY_INTERFACE_VERSION );
|
||||
|
||||
float CAnimatedEntityTextureProxy::GetAnimationStartTime( void* pArg )
|
||||
{
|
||||
IClientRenderable *pRend = (IClientRenderable *)pArg;
|
||||
if (!pRend)
|
||||
return 0.0f;
|
||||
|
||||
C_BaseEntity* pEntity = pRend->GetIClientUnknown()->GetBaseEntity();
|
||||
if (pEntity)
|
||||
{
|
||||
return pEntity->GetTextureAnimationStartTime();
|
||||
}
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
void CAnimatedEntityTextureProxy::AnimationWrapped( void* pArg )
|
||||
{
|
||||
IClientRenderable *pRend = (IClientRenderable *)pArg;
|
||||
if (!pRend)
|
||||
return;
|
||||
|
||||
C_BaseEntity* pEntity = pRend->GetIClientUnknown()->GetBaseEntity();
|
||||
if (pEntity)
|
||||
{
|
||||
pEntity->TextureAnimationWrapped();
|
||||
}
|
||||
}
|
||||
56
game/client/animatedoffsettextureproxy.cpp
Normal file
56
game/client/animatedoffsettextureproxy.cpp
Normal file
@@ -0,0 +1,56 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================//
|
||||
|
||||
#include "cbase.h"
|
||||
#include "baseanimatedtextureproxy.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
class CAnimatedOffsetTextureProxy : public CBaseAnimatedTextureProxy
|
||||
{
|
||||
public:
|
||||
CAnimatedOffsetTextureProxy() : m_flFrameOffset( 0.0f ) {}
|
||||
|
||||
virtual ~CAnimatedOffsetTextureProxy() {}
|
||||
|
||||
virtual float GetAnimationStartTime( void* pBaseEntity );
|
||||
virtual void OnBind( void *pBaseEntity );
|
||||
|
||||
protected:
|
||||
|
||||
float m_flFrameOffset;
|
||||
};
|
||||
|
||||
EXPOSE_INTERFACE( CAnimatedOffsetTextureProxy, IMaterialProxy, "AnimatedOffsetTexture" IMATERIAL_PROXY_INTERFACE_VERSION );
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : pArg -
|
||||
// Output : float
|
||||
//-----------------------------------------------------------------------------
|
||||
float CAnimatedOffsetTextureProxy::GetAnimationStartTime( void* pArg )
|
||||
{
|
||||
return m_flFrameOffset;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : *pBaseEntity -
|
||||
//-----------------------------------------------------------------------------
|
||||
void CAnimatedOffsetTextureProxy::OnBind( void *pBaseEntity )
|
||||
{
|
||||
C_BaseEntity* pEntity = (C_BaseEntity*)pBaseEntity;
|
||||
|
||||
if ( pEntity )
|
||||
{
|
||||
m_flFrameOffset = pEntity->GetTextureAnimationStartTime();
|
||||
}
|
||||
|
||||
// Call into the base class
|
||||
CBaseAnimatedTextureProxy::OnBind( pBaseEntity );
|
||||
}
|
||||
|
||||
29
game/client/animatedtextureproxy.cpp
Normal file
29
game/client/animatedtextureproxy.cpp
Normal file
@@ -0,0 +1,29 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
#include "cbase.h"
|
||||
#include "baseanimatedtextureproxy.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
class CAnimatedTextureProxy : public CBaseAnimatedTextureProxy
|
||||
{
|
||||
public:
|
||||
CAnimatedTextureProxy() {}
|
||||
virtual ~CAnimatedTextureProxy() {}
|
||||
virtual float GetAnimationStartTime( void* pBaseEntity );
|
||||
};
|
||||
|
||||
EXPOSE_INTERFACE( CAnimatedTextureProxy, IMaterialProxy, "AnimatedTexture" IMATERIAL_PROXY_INTERFACE_VERSION );
|
||||
|
||||
#pragma warning (disable : 4100)
|
||||
|
||||
float CAnimatedTextureProxy::GetAnimationStartTime( void* pBaseEntity )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
213
game/client/animationlayer.h
Normal file
213
game/client/animationlayer.h
Normal file
@@ -0,0 +1,213 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef ANIMATIONLAYER_H
|
||||
#define ANIMATIONLAYER_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
|
||||
#include "rangecheckedvar.h"
|
||||
#include "lerp_functions.h"
|
||||
#include "networkvar.h"
|
||||
|
||||
class C_AnimationLayer
|
||||
{
|
||||
public:
|
||||
|
||||
// This allows the datatables to access private members.
|
||||
ALLOW_DATATABLES_PRIVATE_ACCESS();
|
||||
|
||||
C_AnimationLayer();
|
||||
void Reset();
|
||||
|
||||
void SetOrder( int order );
|
||||
|
||||
public:
|
||||
|
||||
bool IsActive( void );
|
||||
|
||||
CRangeCheckedVar<int, -1, 65535, 0> m_nSequence;
|
||||
CRangeCheckedVar<float, -2, 2, 0> m_flPrevCycle;
|
||||
CRangeCheckedVar<float, -5, 5, 0> m_flWeight;
|
||||
int m_nOrder;
|
||||
|
||||
// used for automatic crossfades between sequence changes
|
||||
CRangeCheckedVar<float, -50, 50, 1> m_flPlaybackRate;
|
||||
CRangeCheckedVar<float, -2, 2, 0> m_flCycle;
|
||||
|
||||
float GetFadeout( float flCurTime );
|
||||
|
||||
void BlendWeight();
|
||||
|
||||
float m_flLayerAnimtime;
|
||||
float m_flLayerFadeOuttime;
|
||||
|
||||
float m_flBlendIn;
|
||||
float m_flBlendOut;
|
||||
|
||||
bool m_bClientBlend;
|
||||
};
|
||||
#ifdef CLIENT_DLL
|
||||
#define CAnimationLayer C_AnimationLayer
|
||||
#endif
|
||||
|
||||
inline C_AnimationLayer::C_AnimationLayer()
|
||||
{
|
||||
Reset();
|
||||
}
|
||||
|
||||
inline void C_AnimationLayer::Reset()
|
||||
{
|
||||
m_nSequence = 0;
|
||||
m_flPrevCycle = 0;
|
||||
m_flWeight = 0;
|
||||
m_flPlaybackRate = 0;
|
||||
m_flCycle = 0;
|
||||
m_flLayerAnimtime = 0;
|
||||
m_flLayerFadeOuttime = 0;
|
||||
m_flBlendIn = 0;
|
||||
m_flBlendOut = 0;
|
||||
m_bClientBlend = false;
|
||||
}
|
||||
|
||||
|
||||
inline void C_AnimationLayer::SetOrder( int order )
|
||||
{
|
||||
m_nOrder = order;
|
||||
}
|
||||
|
||||
inline float C_AnimationLayer::GetFadeout( float flCurTime )
|
||||
{
|
||||
float s;
|
||||
|
||||
if (m_flLayerFadeOuttime <= 0.0f)
|
||||
{
|
||||
s = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
// blend in over 0.2 seconds
|
||||
s = 1.0 - (flCurTime - m_flLayerAnimtime) / m_flLayerFadeOuttime;
|
||||
if (s > 0 && s <= 1.0)
|
||||
{
|
||||
// do a nice spline curve
|
||||
s = 3 * s * s - 2 * s * s * s;
|
||||
}
|
||||
else if ( s > 1.0f )
|
||||
{
|
||||
// Shouldn't happen, but maybe curtime is behind animtime?
|
||||
s = 1.0f;
|
||||
}
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
inline C_AnimationLayer LoopingLerp( float flPercent, C_AnimationLayer& from, C_AnimationLayer& to )
|
||||
{
|
||||
C_AnimationLayer output;
|
||||
|
||||
output.m_nSequence = to.m_nSequence;
|
||||
output.m_flCycle = LoopingLerp( flPercent, (float)from.m_flCycle, (float)to.m_flCycle );
|
||||
output.m_flPrevCycle = to.m_flPrevCycle;
|
||||
output.m_flWeight = Lerp( flPercent, from.m_flWeight, to.m_flWeight );
|
||||
output.m_nOrder = to.m_nOrder;
|
||||
|
||||
output.m_flLayerAnimtime = to.m_flLayerAnimtime;
|
||||
output.m_flLayerFadeOuttime = to.m_flLayerFadeOuttime;
|
||||
return output;
|
||||
}
|
||||
|
||||
inline C_AnimationLayer Lerp( float flPercent, const C_AnimationLayer& from, const C_AnimationLayer& to )
|
||||
{
|
||||
C_AnimationLayer output;
|
||||
|
||||
output.m_nSequence = to.m_nSequence;
|
||||
output.m_flCycle = Lerp( flPercent, from.m_flCycle, to.m_flCycle );
|
||||
output.m_flPrevCycle = to.m_flPrevCycle;
|
||||
output.m_flWeight = Lerp( flPercent, from.m_flWeight, to.m_flWeight );
|
||||
output.m_nOrder = to.m_nOrder;
|
||||
|
||||
output.m_flLayerAnimtime = to.m_flLayerAnimtime;
|
||||
output.m_flLayerFadeOuttime = to.m_flLayerFadeOuttime;
|
||||
return output;
|
||||
}
|
||||
|
||||
inline C_AnimationLayer LoopingLerp_Hermite( float flPercent, C_AnimationLayer& prev, C_AnimationLayer& from, C_AnimationLayer& to )
|
||||
{
|
||||
C_AnimationLayer output;
|
||||
|
||||
output.m_nSequence = to.m_nSequence;
|
||||
output.m_flCycle = LoopingLerp_Hermite( flPercent, (float)prev.m_flCycle, (float)from.m_flCycle, (float)to.m_flCycle );
|
||||
output.m_flPrevCycle = to.m_flPrevCycle;
|
||||
output.m_flWeight = Lerp( flPercent, from.m_flWeight, to.m_flWeight );
|
||||
output.m_nOrder = to.m_nOrder;
|
||||
|
||||
output.m_flLayerAnimtime = to.m_flLayerAnimtime;
|
||||
output.m_flLayerFadeOuttime = to.m_flLayerFadeOuttime;
|
||||
return output;
|
||||
}
|
||||
|
||||
// YWB: Specialization for interpolating euler angles via quaternions...
|
||||
inline C_AnimationLayer Lerp_Hermite( float flPercent, const C_AnimationLayer& prev, const C_AnimationLayer& from, const C_AnimationLayer& to )
|
||||
{
|
||||
C_AnimationLayer output;
|
||||
|
||||
output.m_nSequence = to.m_nSequence;
|
||||
output.m_flCycle = Lerp_Hermite( flPercent, prev.m_flCycle, from.m_flCycle, to.m_flCycle );
|
||||
output.m_flPrevCycle = to.m_flPrevCycle;
|
||||
output.m_flWeight = Lerp( flPercent, from.m_flWeight, to.m_flWeight );
|
||||
output.m_nOrder = to.m_nOrder;
|
||||
|
||||
output.m_flLayerAnimtime = to.m_flLayerAnimtime;
|
||||
output.m_flLayerFadeOuttime = to.m_flLayerFadeOuttime;
|
||||
return output;
|
||||
}
|
||||
|
||||
inline void Lerp_Clamp( C_AnimationLayer &val )
|
||||
{
|
||||
Lerp_Clamp( val.m_nSequence );
|
||||
Lerp_Clamp( val.m_flCycle );
|
||||
Lerp_Clamp( val.m_flPrevCycle );
|
||||
Lerp_Clamp( val.m_flWeight );
|
||||
Lerp_Clamp( val.m_nOrder );
|
||||
Lerp_Clamp( val.m_flLayerAnimtime );
|
||||
Lerp_Clamp( val.m_flLayerFadeOuttime );
|
||||
}
|
||||
|
||||
inline void C_AnimationLayer::BlendWeight()
|
||||
{
|
||||
if ( !m_bClientBlend )
|
||||
return;
|
||||
|
||||
m_flWeight = 1;
|
||||
|
||||
// blend in?
|
||||
if ( m_flBlendIn != 0.0f )
|
||||
{
|
||||
if (m_flCycle < m_flBlendIn)
|
||||
{
|
||||
m_flWeight = m_flCycle / m_flBlendIn;
|
||||
}
|
||||
}
|
||||
|
||||
// blend out?
|
||||
if ( m_flBlendOut != 0.0f )
|
||||
{
|
||||
if (m_flCycle > 1.0 - m_flBlendOut)
|
||||
{
|
||||
m_flWeight = (1.0 - m_flCycle) / m_flBlendOut;
|
||||
}
|
||||
}
|
||||
|
||||
m_flWeight = 3.0 * m_flWeight * m_flWeight - 2.0 * m_flWeight * m_flWeight * m_flWeight;
|
||||
if (m_nSequence == 0)
|
||||
m_flWeight = 0;
|
||||
}
|
||||
|
||||
#endif // ANIMATIONLAYER_H
|
||||
138
game/client/baseanimatedtextureproxy.cpp
Normal file
138
game/client/baseanimatedtextureproxy.cpp
Normal file
@@ -0,0 +1,138 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
#include "cbase.h"
|
||||
#include "baseanimatedtextureproxy.h"
|
||||
#include "materialsystem/imaterial.h"
|
||||
#include "materialsystem/imaterialvar.h"
|
||||
#include "materialsystem/itexture.h"
|
||||
#include "tier1/KeyValues.h"
|
||||
#include "toolframework_client.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
// forward declarations
|
||||
void ToolFramework_RecordMaterialParams( IMaterial *pMaterial );
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Constructor, destructor:
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
CBaseAnimatedTextureProxy::CBaseAnimatedTextureProxy()
|
||||
{
|
||||
Cleanup();
|
||||
}
|
||||
|
||||
CBaseAnimatedTextureProxy::~CBaseAnimatedTextureProxy()
|
||||
{
|
||||
Cleanup();
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Initialization, shutdown
|
||||
//-----------------------------------------------------------------------------
|
||||
bool CBaseAnimatedTextureProxy::Init( IMaterial *pMaterial, KeyValues *pKeyValues )
|
||||
{
|
||||
char const* pAnimatedTextureVarName = pKeyValues->GetString( "animatedTextureVar" );
|
||||
if( !pAnimatedTextureVarName )
|
||||
return false;
|
||||
|
||||
bool foundVar;
|
||||
m_AnimatedTextureVar = pMaterial->FindVar( pAnimatedTextureVarName, &foundVar, false );
|
||||
if( !foundVar )
|
||||
return false;
|
||||
|
||||
char const* pAnimatedTextureFrameNumVarName = pKeyValues->GetString( "animatedTextureFrameNumVar" );
|
||||
if( !pAnimatedTextureFrameNumVarName )
|
||||
return false;
|
||||
|
||||
m_AnimatedTextureFrameNumVar = pMaterial->FindVar( pAnimatedTextureFrameNumVarName, &foundVar, false );
|
||||
if( !foundVar )
|
||||
return false;
|
||||
|
||||
m_FrameRate = pKeyValues->GetFloat( "animatedTextureFrameRate", 15 );
|
||||
m_WrapAnimation = !pKeyValues->GetInt( "animationNoWrap", 0 );
|
||||
return true;
|
||||
}
|
||||
|
||||
void CBaseAnimatedTextureProxy::Cleanup()
|
||||
{
|
||||
m_AnimatedTextureVar = NULL;
|
||||
m_AnimatedTextureFrameNumVar = NULL;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Does the dirty deed
|
||||
//-----------------------------------------------------------------------------
|
||||
void CBaseAnimatedTextureProxy::OnBind( void *pEntity )
|
||||
{
|
||||
Assert ( m_AnimatedTextureVar );
|
||||
|
||||
if( m_AnimatedTextureVar->GetType() != MATERIAL_VAR_TYPE_TEXTURE )
|
||||
{
|
||||
return;
|
||||
}
|
||||
ITexture *pTexture;
|
||||
pTexture = m_AnimatedTextureVar->GetTextureValue();
|
||||
int numFrames = pTexture->GetNumAnimationFrames();
|
||||
|
||||
if ( numFrames <= 0 )
|
||||
{
|
||||
Assert( !"0 frames in material calling animated texture proxy" );
|
||||
return;
|
||||
}
|
||||
|
||||
// NOTE: Must not use relative time based methods here
|
||||
// because the bind proxy can be called many times per frame.
|
||||
// Prevent multiple Wrap callbacks to be sent for no wrap mode
|
||||
float startTime = GetAnimationStartTime(pEntity);
|
||||
float deltaTime = gpGlobals->curtime - startTime;
|
||||
float prevTime = deltaTime - gpGlobals->frametime;
|
||||
|
||||
// Clamp..
|
||||
if (deltaTime < 0.0f)
|
||||
deltaTime = 0.0f;
|
||||
if (prevTime < 0.0f)
|
||||
prevTime = 0.0f;
|
||||
|
||||
float frame = m_FrameRate * deltaTime;
|
||||
float prevFrame = m_FrameRate * prevTime;
|
||||
|
||||
int intFrame = ((int)frame) % numFrames;
|
||||
int intPrevFrame = ((int)prevFrame) % numFrames;
|
||||
|
||||
// Report wrap situation...
|
||||
if (intPrevFrame > intFrame)
|
||||
{
|
||||
if (m_WrapAnimation)
|
||||
{
|
||||
AnimationWrapped( pEntity );
|
||||
}
|
||||
else
|
||||
{
|
||||
// Only sent the wrapped message once.
|
||||
// when we're in non-wrapping mode
|
||||
if (prevFrame < numFrames)
|
||||
AnimationWrapped( pEntity );
|
||||
intFrame = numFrames - 1;
|
||||
}
|
||||
}
|
||||
|
||||
m_AnimatedTextureFrameNumVar->SetIntValue( intFrame );
|
||||
|
||||
if ( ToolsEnabled() )
|
||||
{
|
||||
ToolFramework_RecordMaterialParams( GetMaterial() );
|
||||
}
|
||||
}
|
||||
|
||||
IMaterial *CBaseAnimatedTextureProxy::GetMaterial()
|
||||
{
|
||||
return m_AnimatedTextureVar->GetOwningMaterial();
|
||||
}
|
||||
47
game/client/baseanimatedtextureproxy.h
Normal file
47
game/client/baseanimatedtextureproxy.h
Normal file
@@ -0,0 +1,47 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef BASEANIMATEDTEXTUREPROXY
|
||||
#define BASEANIMATEDTEXTUREPROXY
|
||||
|
||||
#include "materialsystem/imaterialproxy.h"
|
||||
|
||||
class IMaterial;
|
||||
class IMaterialVar;
|
||||
|
||||
#pragma warning (disable : 4100)
|
||||
|
||||
class CBaseAnimatedTextureProxy : public IMaterialProxy
|
||||
{
|
||||
public:
|
||||
CBaseAnimatedTextureProxy();
|
||||
virtual ~CBaseAnimatedTextureProxy();
|
||||
|
||||
virtual bool Init( IMaterial *pMaterial, KeyValues *pKeyValues );
|
||||
virtual void OnBind( void *pC_BaseEntity );
|
||||
virtual void Release( void ) { delete this; }
|
||||
virtual IMaterial *GetMaterial();
|
||||
|
||||
protected:
|
||||
// derived classes must implement this; it returns the time
|
||||
// that the animation began
|
||||
virtual float GetAnimationStartTime( void* pBaseEntity ) = 0;
|
||||
|
||||
// Derived classes may implement this if they choose;
|
||||
// this method is called whenever the animation wraps...
|
||||
virtual void AnimationWrapped( void* pBaseEntity ) {}
|
||||
|
||||
protected:
|
||||
void Cleanup();
|
||||
|
||||
IMaterialVar *m_AnimatedTextureVar;
|
||||
IMaterialVar *m_AnimatedTextureFrameNumVar;
|
||||
float m_FrameRate;
|
||||
bool m_WrapAnimation;
|
||||
};
|
||||
|
||||
#endif // BASEANIMATEDTEXTUREPROXY
|
||||
78
game/client/baseclientrendertargets.cpp
Normal file
78
game/client/baseclientrendertargets.cpp
Normal file
@@ -0,0 +1,78 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: Implementation for CBaseClientRenderTargets class.
|
||||
// Provides Init functions for common render textures used by the engine.
|
||||
// Mod makers can inherit from this class, and call the Create functions for
|
||||
// only the render textures the want for their mod.
|
||||
//=============================================================================//
|
||||
|
||||
#include "cbase.h"
|
||||
#include "baseclientrendertargets.h" // header
|
||||
#include "materialsystem/imaterialsystemhardwareconfig.h" // Hardware config checks
|
||||
#include "tier0/icommandline.h"
|
||||
|
||||
ITexture* CBaseClientRenderTargets::CreateWaterReflectionTexture( IMaterialSystem* pMaterialSystem, int iSize )
|
||||
{
|
||||
return pMaterialSystem->CreateNamedRenderTargetTextureEx2(
|
||||
"_rt_WaterReflection",
|
||||
iSize, iSize, RT_SIZE_PICMIP,
|
||||
pMaterialSystem->GetBackBufferFormat(),
|
||||
MATERIAL_RT_DEPTH_SHARED,
|
||||
TEXTUREFLAGS_CLAMPS | TEXTUREFLAGS_CLAMPT,
|
||||
CREATERENDERTARGETFLAGS_HDR );
|
||||
}
|
||||
|
||||
ITexture* CBaseClientRenderTargets::CreateWaterRefractionTexture( IMaterialSystem* pMaterialSystem, int iSize )
|
||||
{
|
||||
return pMaterialSystem->CreateNamedRenderTargetTextureEx2(
|
||||
"_rt_WaterRefraction",
|
||||
iSize, iSize, RT_SIZE_PICMIP,
|
||||
// This is different than reflection because it has to have alpha for fog factor.
|
||||
IMAGE_FORMAT_RGBA8888,
|
||||
MATERIAL_RT_DEPTH_SHARED,
|
||||
TEXTUREFLAGS_CLAMPS | TEXTUREFLAGS_CLAMPT,
|
||||
CREATERENDERTARGETFLAGS_HDR );
|
||||
}
|
||||
|
||||
ITexture* CBaseClientRenderTargets::CreateCameraTexture( IMaterialSystem* pMaterialSystem, int iSize )
|
||||
{
|
||||
return pMaterialSystem->CreateNamedRenderTargetTextureEx2(
|
||||
"_rt_Camera",
|
||||
iSize, iSize, RT_SIZE_DEFAULT,
|
||||
pMaterialSystem->GetBackBufferFormat(),
|
||||
MATERIAL_RT_DEPTH_SHARED,
|
||||
0,
|
||||
CREATERENDERTARGETFLAGS_HDR );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Called by the engine in material system init and shutdown.
|
||||
// Clients should override this in their inherited version, but the base
|
||||
// is to init all standard render targets for use.
|
||||
// Input : pMaterialSystem - the engine's material system (our singleton is not yet inited at the time this is called)
|
||||
// pHardwareConfig - the user hardware config, useful for conditional render target setup
|
||||
//-----------------------------------------------------------------------------
|
||||
void CBaseClientRenderTargets::InitClientRenderTargets( IMaterialSystem* pMaterialSystem, IMaterialSystemHardwareConfig* pHardwareConfig, int iWaterTextureSize, int iCameraTextureSize )
|
||||
{
|
||||
// Water effects
|
||||
m_WaterReflectionTexture.Init( CreateWaterReflectionTexture( pMaterialSystem, iWaterTextureSize ) );
|
||||
m_WaterRefractionTexture.Init( CreateWaterRefractionTexture( pMaterialSystem, iWaterTextureSize ) );
|
||||
|
||||
// Monitors
|
||||
m_CameraTexture.Init( CreateCameraTexture( pMaterialSystem, iCameraTextureSize ) );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Shut down each CTextureReference we created in InitClientRenderTargets.
|
||||
// Called by the engine in material system shutdown.
|
||||
// Input : -
|
||||
//-----------------------------------------------------------------------------
|
||||
void CBaseClientRenderTargets::ShutdownClientRenderTargets()
|
||||
{
|
||||
// Water effects
|
||||
m_WaterReflectionTexture.Shutdown();
|
||||
m_WaterRefractionTexture.Shutdown();
|
||||
|
||||
// Monitors
|
||||
m_CameraTexture.Shutdown();
|
||||
}
|
||||
64
game/client/baseclientrendertargets.h
Normal file
64
game/client/baseclientrendertargets.h
Normal file
@@ -0,0 +1,64 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: Has init functions for all the standard render targets used by most games.
|
||||
// Mods who wish to make their own render targets can inherit from this class
|
||||
// and in the 'InitClientRenderTargets' interface called by the engine, set up
|
||||
// their own render targets as well as calling the init functions for various
|
||||
// common render targets provided by this class.
|
||||
//
|
||||
// Note: Unless the client defines a singleton interface by inheriting from
|
||||
// this class and exposing the singleton instance, these init and shutdown
|
||||
// functions WILL NOT be called by the engine.
|
||||
//
|
||||
//
|
||||
// $Workfile: $
|
||||
// $Date: $
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
#ifndef CLIENTRENDERTARTETS_H_
|
||||
#define CLIENTRENDERTARTETS_H_
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "game/client/iclientrendertargets.h" // base class with interfaces called by the engine
|
||||
#include "materialsystem/imaterialsystem.h" // for material system classes and interfaces
|
||||
|
||||
|
||||
// Externs
|
||||
class IMaterialSystem;
|
||||
class IMaterialSystemHardwareConfig;
|
||||
|
||||
class CBaseClientRenderTargets : public IClientRenderTargets
|
||||
{
|
||||
// no networked vars
|
||||
DECLARE_CLASS_GAMEROOT( CBaseClientRenderTargets, IClientRenderTargets );
|
||||
public:
|
||||
// Interface called by engine during material system startup.
|
||||
virtual void InitClientRenderTargets ( IMaterialSystem* pMaterialSystem, IMaterialSystemHardwareConfig* pHardwareConfig, int iWaterTextureSize = 1024, int iCameraTextureSize = 256 );
|
||||
// Shutdown all custom render targets here.
|
||||
virtual void ShutdownClientRenderTargets ( void );
|
||||
|
||||
protected:
|
||||
|
||||
// Standard render textures used by most mods-- Classes inheriting from
|
||||
// this can choose to init these or not depending on their needs.
|
||||
|
||||
// For reflective and refracting water
|
||||
CTextureReference m_WaterReflectionTexture;
|
||||
CTextureReference m_WaterRefractionTexture;
|
||||
|
||||
// Used for monitors
|
||||
CTextureReference m_CameraTexture;
|
||||
|
||||
// Used for the HUD in stereo and head tracking mode
|
||||
CTextureReference m_UITexture;
|
||||
|
||||
// Init functions for the common render targets
|
||||
ITexture* CreateWaterReflectionTexture( IMaterialSystem* pMaterialSystem, int iSize = 1024 );
|
||||
ITexture* CreateWaterRefractionTexture( IMaterialSystem* pMaterialSystem, int iSize = 1024 );
|
||||
ITexture* CreateCameraTexture( IMaterialSystem* pMaterialSystem, int iSize = 256 );
|
||||
|
||||
};
|
||||
|
||||
#endif // CLIENTRENDERTARTETS_H_
|
||||
94
game/client/basepresence.cpp
Normal file
94
game/client/basepresence.cpp
Normal file
@@ -0,0 +1,94 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: Base presence implementation for PC
|
||||
//
|
||||
//=====================================================================================//
|
||||
|
||||
#include "cbase.h"
|
||||
#include "basepresence.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
// Default global singleton. Mods should override this.
|
||||
static CBasePresence s_basePresence;
|
||||
IPresence *presence = NULL;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Steam version of Rich Presence is a WIP, so PC implementation is stubbed for now.
|
||||
//-----------------------------------------------------------------------------
|
||||
bool CBasePresence::Init( void )
|
||||
{
|
||||
if ( !presence )
|
||||
{
|
||||
// Mod didn't override, default to base implementation
|
||||
presence = &s_basePresence;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
void CBasePresence::Shutdown( void )
|
||||
{
|
||||
// TODO: Implement for PC
|
||||
}
|
||||
void CBasePresence::Update( float frametime )
|
||||
{
|
||||
// TODO: Implement for PC
|
||||
}
|
||||
void CBasePresence::UserSetContext( unsigned int nUserIndex, unsigned int nContextId, unsigned int nContextValue, bool bAsync )
|
||||
{
|
||||
// TODO: Implement for PC
|
||||
}
|
||||
void CBasePresence::UserSetProperty( unsigned int nUserIndex, unsigned int nPropertyId, unsigned int nBytes, const void *pvValue, bool bAsync )
|
||||
{
|
||||
// TODO: Implement for PC
|
||||
}
|
||||
void CBasePresence::SetupGameProperties( CUtlVector< XUSER_CONTEXT > &contexts, CUtlVector< XUSER_PROPERTY > &properties )
|
||||
{
|
||||
// TODO: Implement for PC
|
||||
}
|
||||
unsigned int CBasePresence::GetPresenceID( const char *pIDName )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
const char *CBasePresence::GetPropertyIdString( const uint id )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
void CBasePresence::GetPropertyDisplayString( uint id, uint value, char *pOutput, int nBytes )
|
||||
{
|
||||
}
|
||||
void CBasePresence::StartStatsReporting( HANDLE handle, bool bArbitrated )
|
||||
{
|
||||
}
|
||||
void CBasePresence::SetStat( uint iPropertyId, int iPropertyValue, int dataType )
|
||||
{
|
||||
}
|
||||
void CBasePresence::UploadStats()
|
||||
{
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
// Debug support
|
||||
//---------------------------------------------------------
|
||||
void CBasePresence::DebugUserSetContext( const CCommand &args )
|
||||
{
|
||||
if ( args.ArgC() == 3 )
|
||||
{
|
||||
UserSetContext( 0, atoi( args.Arg( 1 ) ), atoi( args.Arg( 2 ) ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
Warning( "user_context <context id> <context value>\n" );
|
||||
}
|
||||
}
|
||||
void CBasePresence::DebugUserSetProperty( const CCommand &args )
|
||||
{
|
||||
if ( args.ArgC() == 3 )
|
||||
{
|
||||
UserSetProperty( 0, strtoul( args.Arg( 1 ), NULL, 0 ), sizeof(int), args.Arg( 2 ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
Warning( "user_property <property id> <property value>\n" );
|
||||
}
|
||||
}
|
||||
55
game/client/basepresence.h
Normal file
55
game/client/basepresence.h
Normal file
@@ -0,0 +1,55 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: Base implementation of the IPresence interface
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
#ifndef BASEPRESENCE_H
|
||||
#define BASEPRESENCE_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "ipresence.h"
|
||||
#include "igamesystem.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Common implementation for setting user contexts and properties.
|
||||
// Each client should inherit from this to implement mod-specific presence info.
|
||||
//-----------------------------------------------------------------------------
|
||||
class CBasePresence : public IPresence, public CAutoGameSystemPerFrame
|
||||
{
|
||||
public:
|
||||
// CBaseGameSystemPerFrame overrides
|
||||
virtual bool Init( void );
|
||||
virtual void Shutdown( void );
|
||||
virtual void Update( float frametime );
|
||||
virtual char const *Name( void ) { return "presence"; }
|
||||
|
||||
// IPresence Interface
|
||||
virtual void UserSetContext( unsigned int nUserIndex, unsigned int nContextId, unsigned int nContextValue, bool bAsync = false );
|
||||
virtual void UserSetProperty( unsigned int nUserIndex, unsigned int nPropertyId, unsigned int nBytes, const void *pvValue, bool bAsync = false );
|
||||
virtual void SetupGameProperties( CUtlVector< XUSER_CONTEXT > &contexts, CUtlVector< XUSER_PROPERTY > &properties );
|
||||
virtual uint GetPresenceID( const char *pIdName );
|
||||
virtual void GetPropertyDisplayString( uint id, uint value, char *pOutput, int nBytes );
|
||||
virtual const char *GetPropertyIdString( const uint id );
|
||||
|
||||
// Stats reporting
|
||||
virtual void StartStatsReporting( HANDLE handle, bool bArbitrated );
|
||||
virtual void SetStat( uint iPropertyId, int iPropertyValue, int dataType );
|
||||
virtual void UploadStats();
|
||||
|
||||
protected:
|
||||
bool m_bArbitrated;
|
||||
bool m_bReportingStats;
|
||||
HANDLE m_hSession;
|
||||
CUtlVector< XUSER_PROPERTY > m_PlayerStats;
|
||||
|
||||
//---------------------------------------------------------
|
||||
// Debug support
|
||||
//---------------------------------------------------------
|
||||
CON_COMMAND_MEMBER_F( CBasePresence, "user_context", DebugUserSetContext, "Set a Rich Presence Context: user_context <context id> <context value>", 0 )
|
||||
CON_COMMAND_MEMBER_F( CBasePresence, "user_property", DebugUserSetProperty, "Set a Rich Presence Property: user_property <property id>", 0 )
|
||||
};
|
||||
|
||||
#endif // BASEPRESENCE_H
|
||||
167
game/client/basepresence_xbox.cpp
Normal file
167
game/client/basepresence_xbox.cpp
Normal file
@@ -0,0 +1,167 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: Base rich presence implementation for Xbox360
|
||||
//
|
||||
//=====================================================================================//
|
||||
|
||||
#include "cbase.h"
|
||||
#include "basepresence.h"
|
||||
#include "cdll_client_int.h"
|
||||
#include "ixboxsystem.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
// Default global instance. Mods should override this.
|
||||
static CBasePresence s_basePresence;
|
||||
IPresence *presence = NULL;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Init
|
||||
//-----------------------------------------------------------------------------
|
||||
bool CBasePresence::Init( void )
|
||||
{
|
||||
if ( !presence )
|
||||
{
|
||||
// Mod didn't override, default to base implementation
|
||||
presence = &s_basePresence;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Shutdown
|
||||
//-----------------------------------------------------------------------------
|
||||
void CBasePresence::Shutdown( void )
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Per-frame update
|
||||
//-----------------------------------------------------------------------------
|
||||
void CBasePresence::Update( float frametime )
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Contexts are strings that describe the current state of the game.
|
||||
//-----------------------------------------------------------------------------
|
||||
void CBasePresence::UserSetContext( unsigned int nUserIndex, unsigned int nContextId, unsigned int nContextValue, bool bAsync )
|
||||
{
|
||||
if ( !xboxsystem->UserSetContext( nUserIndex, nContextId, nContextValue, bAsync ) )
|
||||
{
|
||||
Warning( "CBasePresence: UserSetContext failed.\n" );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Properties are (usually) numeric values that can be insterted into context strings.
|
||||
//-----------------------------------------------------------------------------
|
||||
void CBasePresence::UserSetProperty( unsigned int nUserIndex, unsigned int nPropertyId, unsigned int nBytes, const void *pvValue, bool bAsync )
|
||||
{
|
||||
if ( !xboxsystem->UserSetProperty( nUserIndex, nPropertyId, nBytes, pvValue, bAsync ) )
|
||||
{
|
||||
Warning( "CBasePresence: UserSetProperty failed.\n" );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Get game session properties from matchmaking.
|
||||
//-----------------------------------------------------------------------------
|
||||
void CBasePresence::SetupGameProperties( CUtlVector< XUSER_CONTEXT > &contexts, CUtlVector< XUSER_PROPERTY > &properties )
|
||||
{
|
||||
Assert( 0 );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Convert a string to a presence ID.
|
||||
//-----------------------------------------------------------------------------
|
||||
uint CBasePresence::GetPresenceID( const char *pIdName )
|
||||
{
|
||||
Assert( 0 );
|
||||
return 0;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Convert a presence ID to a string.
|
||||
//-----------------------------------------------------------------------------
|
||||
const char *CBasePresence::GetPropertyIdString( const uint id )
|
||||
{
|
||||
Assert( 0 );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Get display string for a game property.
|
||||
//-----------------------------------------------------------------------------
|
||||
void CBasePresence::GetPropertyDisplayString( uint id, uint value, char *pOutput, int nBytes )
|
||||
{
|
||||
Assert( 0 );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Set up for reporting stats to Live.
|
||||
//-----------------------------------------------------------------------------
|
||||
void CBasePresence::StartStatsReporting( HANDLE handle, bool bArbitrated )
|
||||
{
|
||||
m_bArbitrated = bArbitrated;
|
||||
m_hSession = handle;
|
||||
m_bReportingStats = true;
|
||||
m_PlayerStats.RemoveAll();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Set a specific stat property.
|
||||
//-----------------------------------------------------------------------------
|
||||
void CBasePresence::SetStat( uint iPropertyId, int iPropertyValue, int dataType )
|
||||
{
|
||||
if ( m_bReportingStats )
|
||||
{
|
||||
XUSER_PROPERTY prop;
|
||||
prop.dwPropertyId = iPropertyId;
|
||||
prop.value.nData = iPropertyValue;
|
||||
prop.value.type = dataType;
|
||||
m_PlayerStats.AddToTail( prop );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Upload the stats to Live.
|
||||
//-----------------------------------------------------------------------------
|
||||
void CBasePresence::UploadStats()
|
||||
{
|
||||
Assert( 0 );
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
// Debug support
|
||||
//---------------------------------------------------------
|
||||
void CBasePresence::DebugUserSetContext( const CCommand &args )
|
||||
{
|
||||
if ( args.ArgC() == 3 )
|
||||
{
|
||||
UserSetContext( XBX_GetPrimaryUserId(), atoi( args.Arg( 1 ) ), atoi( args.Arg( 2 ) ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
Warning( "user_context <context id> <context value>\n" );
|
||||
}
|
||||
}
|
||||
void CBasePresence::DebugUserSetProperty( const CCommand &args )
|
||||
{
|
||||
if ( args.ArgC() == 3 )
|
||||
{
|
||||
int value = atoi( args.Arg( 2 ) );
|
||||
UserSetProperty( XBX_GetPrimaryUserId(), strtoul( args.Arg( 1 ), NULL, 0 ), sizeof(int), &value );
|
||||
}
|
||||
else
|
||||
{
|
||||
Warning( "user_property <property id> <property value>\n" );
|
||||
}
|
||||
}
|
||||
1637
game/client/beamdraw.cpp
Normal file
1637
game/client/beamdraw.cpp
Normal file
File diff suppressed because it is too large
Load Diff
174
game/client/beamdraw.h
Normal file
174
game/client/beamdraw.h
Normal file
@@ -0,0 +1,174 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//===========================================================================//
|
||||
#if !defined( BEAMDRAW_H )
|
||||
#define BEAMDRAW_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "materialsystem/imaterial.h"
|
||||
#include "materialsystem/imesh.h"
|
||||
#include "mathlib/vector.h"
|
||||
#include "tier2/beamsegdraw.h"
|
||||
#include "c_pixel_visibility.h"
|
||||
|
||||
#define NOISE_DIVISIONS 128
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Forward declarations
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
struct model_t;
|
||||
struct BeamTrail_t;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Beams fill out this data structure
|
||||
// This is also used for rendering
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class Beam_t : public CDefaultClientRenderable
|
||||
{
|
||||
public:
|
||||
Beam_t();
|
||||
|
||||
// Methods of IClientRenderable
|
||||
virtual const Vector& GetRenderOrigin( void );
|
||||
virtual const QAngle& GetRenderAngles( void );
|
||||
virtual const matrix3x4_t &RenderableToWorldTransform();
|
||||
virtual void GetRenderBounds( Vector& mins, Vector& maxs );
|
||||
virtual bool ShouldDraw( void );
|
||||
virtual bool IsTransparent( void );
|
||||
virtual int DrawModel( int flags );
|
||||
virtual void ComputeFxBlend( );
|
||||
virtual int GetFxBlend( );
|
||||
|
||||
// Resets the beam state
|
||||
void Reset();
|
||||
|
||||
// Method to computing the bounding box
|
||||
void ComputeBounds();
|
||||
|
||||
// Bounding box...
|
||||
Vector m_Mins;
|
||||
Vector m_Maxs;
|
||||
pixelvis_handle_t *m_queryHandleHalo;
|
||||
float m_haloProxySize;
|
||||
|
||||
// Data is below..
|
||||
|
||||
// Next beam in list
|
||||
Beam_t* next;
|
||||
|
||||
// Type of beam
|
||||
int type;
|
||||
int flags;
|
||||
|
||||
// Control points for the beam
|
||||
int numAttachments;
|
||||
Vector attachment[MAX_BEAM_ENTS];
|
||||
Vector delta;
|
||||
|
||||
// 0 .. 1 over lifetime of beam
|
||||
float t;
|
||||
float freq;
|
||||
|
||||
// Time when beam should die
|
||||
float die;
|
||||
float width;
|
||||
float endWidth;
|
||||
float fadeLength;
|
||||
float amplitude;
|
||||
float life;
|
||||
|
||||
// Color
|
||||
float r, g, b;
|
||||
float brightness;
|
||||
|
||||
// Speed
|
||||
float speed;
|
||||
|
||||
// Animation
|
||||
float frameRate;
|
||||
float frame;
|
||||
int segments;
|
||||
|
||||
// Attachment entities for the beam
|
||||
EHANDLE entity[MAX_BEAM_ENTS];
|
||||
int attachmentIndex[MAX_BEAM_ENTS];
|
||||
|
||||
// Model info
|
||||
int modelIndex;
|
||||
int haloIndex;
|
||||
|
||||
float haloScale;
|
||||
int frameCount;
|
||||
|
||||
float rgNoise[NOISE_DIVISIONS+1];
|
||||
|
||||
// Popcorn trail for beam follows to use
|
||||
BeamTrail_t* trail;
|
||||
|
||||
// for TE_BEAMRINGPOINT
|
||||
float start_radius;
|
||||
float end_radius;
|
||||
|
||||
// for FBEAM_ONLYNOISEONCE
|
||||
bool m_bCalculatedNoise;
|
||||
|
||||
float m_flHDRColorScale;
|
||||
|
||||
#ifdef PORTAL
|
||||
bool m_bDrawInMainRender;
|
||||
bool m_bDrawInPortalRender;
|
||||
#endif //#ifdef PORTAL
|
||||
};
|
||||
|
||||
|
||||
int ScreenTransform( const Vector& point, Vector& screen );
|
||||
|
||||
void DrawSegs( int noise_divisions, float *prgNoise, const model_t* spritemodel,
|
||||
float frame, int rendermode, const Vector& source, const Vector& delta,
|
||||
float startWidth, float endWidth, float scale, float freq, float speed, int segments,
|
||||
int flags, float* color, float fadeLength, float flHDRColorScale = 1.0f );
|
||||
void DrawTeslaSegs( int noise_divisions, float *prgNoise, const model_t* spritemodel,
|
||||
float frame, int rendermode, const Vector& source, const Vector& delta,
|
||||
float startWidth, float endWidth, float scale, float freq, float speed, int segments,
|
||||
int flags, float* color, float fadeLength, float flHDRColorScale = 1.0f );
|
||||
void DrawSplineSegs( int noise_divisions, float *prgNoise,
|
||||
const model_t* beammodel, const model_t* halomodel, float flHaloScale,
|
||||
float frame, int rendermode, int numAttachments, Vector* attachment,
|
||||
float startWidth, float endWidth, float scale, float freq, float speed, int segments,
|
||||
int flags, float* color, float fadeLength, float flHDRColorScale = 1.0f );
|
||||
void DrawHalo(IMaterial* pMaterial, const Vector& source, float scale, float const* color, float flHDRColorScale = 1.0f );
|
||||
void BeamDrawHalo( const model_t* spritemodel, float frame, int rendermode, const Vector& source,
|
||||
float scale, float* color, float flHDRColorScale = 1.0f );
|
||||
void DrawDisk( int noise_divisions, float *prgNoise, const model_t* spritemodel,
|
||||
float frame, int rendermode, const Vector& source, const Vector& delta,
|
||||
float width, float scale, float freq, float speed,
|
||||
int segments, float* color, float flHDRColorScale = 1.0f );
|
||||
void DrawCylinder( int noise_divisions, float *prgNoise, const model_t* spritemodel,
|
||||
float frame, int rendermode, const Vector& source,
|
||||
const Vector& delta, float width, float scale, float freq,
|
||||
float speed, int segments, float* color, float flHDRColorScale = 1.0f );
|
||||
void DrawRing( int noise_divisions, float *prgNoise, void (*pfnNoise)( float *noise, int divs, float scale ),
|
||||
const model_t* spritemodel, float frame, int rendermode,
|
||||
const Vector& source, const Vector& delta, float width, float amplitude,
|
||||
float freq, float speed, int segments, float* color, float flHDRColorScale = 1.0f );
|
||||
void DrawBeamFollow( const model_t* spritemodel, BeamTrail_t* pHead, int frame, int rendermode, Vector& delta,
|
||||
Vector& screen, Vector& screenLast, float die, const Vector& source,
|
||||
int flags, float width, float amplitude, float freq, float* color, float flHDRColorScale = 1.0f );
|
||||
|
||||
void DrawBeamQuadratic( const Vector &start, const Vector &control, const Vector &end, float width, const Vector &color, float scrollOffset, float flHDRColorScale = 1.0f );
|
||||
void DrawBeamQuadraticDouble(const Vector &start, const Vector &control, const Vector &control2, const Vector &end, float width, const Vector &color, float scrollOffset, float flHDRColorScale = 1.0f);
|
||||
class CEngineSprite *Draw_SetSpriteTexture( const model_t *pSpriteModel, int frame, int rendermode );
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Assumes the material has already been bound
|
||||
//-----------------------------------------------------------------------------
|
||||
void DrawSprite( const Vector &vecOrigin, float flWidth, float flHeight, color32 color );
|
||||
|
||||
#endif // BEAMDRAW_H
|
||||
288
game/client/bone_merge_cache.cpp
Normal file
288
game/client/bone_merge_cache.cpp
Normal file
@@ -0,0 +1,288 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//
|
||||
//=============================================================================//
|
||||
|
||||
#include "cbase.h"
|
||||
#include "bone_merge_cache.h"
|
||||
#include "bone_setup.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// CBoneMergeCache
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
CBoneMergeCache::CBoneMergeCache()
|
||||
{
|
||||
m_pOwner = NULL;
|
||||
m_pFollow = NULL;
|
||||
m_pFollowHdr = NULL;
|
||||
m_pFollowRenderHdr = NULL;
|
||||
m_pOwnerHdr = NULL;
|
||||
m_nFollowBoneSetupMask = 0;
|
||||
}
|
||||
|
||||
void CBoneMergeCache::Init( C_BaseAnimating *pOwner )
|
||||
{
|
||||
m_pOwner = pOwner;
|
||||
m_pFollow = NULL;
|
||||
m_pFollowHdr = NULL;
|
||||
m_pFollowRenderHdr = NULL;
|
||||
m_pOwnerHdr = NULL;
|
||||
m_nFollowBoneSetupMask = 0;
|
||||
}
|
||||
|
||||
void CBoneMergeCache::UpdateCache()
|
||||
{
|
||||
CStudioHdr *pOwnerHdr = m_pOwner ? m_pOwner->GetModelPtr() : NULL;
|
||||
if ( !pOwnerHdr )
|
||||
{
|
||||
if ( m_pOwnerHdr )
|
||||
{
|
||||
// Owner's model got swapped out
|
||||
m_MergedBones.Purge();
|
||||
m_BoneMergeBits.Purge();
|
||||
m_pFollow = NULL;
|
||||
m_pFollowHdr = NULL;
|
||||
m_pFollowRenderHdr = NULL;
|
||||
m_pOwnerHdr = NULL;
|
||||
m_nFollowBoneSetupMask = 0;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
C_BaseAnimating *pTestFollow = m_pOwner->FindFollowedEntity();
|
||||
CStudioHdr *pTestHdr = (pTestFollow ? pTestFollow->GetModelPtr() : NULL);
|
||||
const studiohdr_t *pTestStudioHDR = (pTestHdr ? pTestHdr->GetRenderHdr() : NULL);
|
||||
if ( pTestFollow != m_pFollow || pTestHdr != m_pFollowHdr || pTestStudioHDR != m_pFollowRenderHdr || pOwnerHdr != m_pOwnerHdr )
|
||||
{
|
||||
m_MergedBones.Purge();
|
||||
m_BoneMergeBits.Purge();
|
||||
|
||||
// Update the cache.
|
||||
if ( pTestFollow && pTestHdr && pOwnerHdr )
|
||||
{
|
||||
m_pFollow = pTestFollow;
|
||||
m_pFollowHdr = pTestHdr;
|
||||
m_pFollowRenderHdr = pTestStudioHDR;
|
||||
m_pOwnerHdr = pOwnerHdr;
|
||||
|
||||
m_BoneMergeBits.SetSize( pOwnerHdr->numbones() / 8 + 1 );
|
||||
memset( m_BoneMergeBits.Base(), 0, m_BoneMergeBits.Count() );
|
||||
|
||||
mstudiobone_t *pOwnerBones = m_pOwnerHdr->pBone( 0 );
|
||||
|
||||
m_nFollowBoneSetupMask = BONE_USED_BY_BONE_MERGE;
|
||||
for ( int i = 0; i < m_pOwnerHdr->numbones(); i++ )
|
||||
{
|
||||
int parentBoneIndex = Studio_BoneIndexByName( m_pFollowHdr, pOwnerBones[i].pszName() );
|
||||
if ( parentBoneIndex < 0 )
|
||||
continue;
|
||||
|
||||
// Add a merged bone here.
|
||||
CMergedBone mergedBone;
|
||||
mergedBone.m_iMyBone = i;
|
||||
mergedBone.m_iParentBone = parentBoneIndex;
|
||||
m_MergedBones.AddToTail( mergedBone );
|
||||
|
||||
m_BoneMergeBits[i>>3] |= ( 1 << ( i & 7 ) );
|
||||
|
||||
if ( ( m_pFollowHdr->boneFlags( parentBoneIndex ) & BONE_USED_BY_BONE_MERGE ) == 0 )
|
||||
{
|
||||
m_nFollowBoneSetupMask = BONE_USED_BY_ANYTHING;
|
||||
// Warning("Performance warning: Merge with '%s'. Mark bone '%s' in model '%s' as being used by bone merge in the .qc!\n",
|
||||
// pOwnerHdr->pszName(), m_pFollowHdr->pBone( parentBoneIndex )->pszName(), m_pFollowHdr->pszName() );
|
||||
}
|
||||
}
|
||||
|
||||
// No merged bones found? Slam the mask to 0
|
||||
if ( !m_MergedBones.Count() )
|
||||
{
|
||||
m_nFollowBoneSetupMask = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pFollow = NULL;
|
||||
m_pFollowHdr = NULL;
|
||||
m_pFollowRenderHdr = NULL;
|
||||
m_pOwnerHdr = NULL;
|
||||
m_nFollowBoneSetupMask = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#ifdef STAGING_ONLY
|
||||
ConVar r_captain_canteen_is_angry ( "r_captain_canteen_is_angry", "1" );
|
||||
#endif
|
||||
|
||||
void CBoneMergeCache::MergeMatchingBones( int boneMask )
|
||||
{
|
||||
UpdateCache();
|
||||
|
||||
// If this is set, then all the other cache data is set.
|
||||
if ( !m_pOwnerHdr || m_MergedBones.Count() == 0 )
|
||||
return;
|
||||
|
||||
// Have the entity we're following setup its bones.
|
||||
bool bWorked = m_pFollow->SetupBones( NULL, -1, m_nFollowBoneSetupMask, gpGlobals->curtime );
|
||||
// We suspect there's some cases where SetupBones couldn't do its thing, and then this causes Captain Canteen.
|
||||
Assert ( bWorked );
|
||||
if ( !bWorked )
|
||||
{
|
||||
// Usually this means your parent is invisible or gone or whatever.
|
||||
// This routine has no way to tell its caller not to draw itself unfortunately.
|
||||
// But we can shrink all the bones down to zero size.
|
||||
// But it might still spawn particle systems? :-(
|
||||
matrix3x4_t NewBone;
|
||||
MatrixScaleByZero ( NewBone );
|
||||
MatrixSetTranslation ( Vector ( 0.0f, 0.0f, 0.0f ), NewBone );
|
||||
#ifdef STAGING_ONLY
|
||||
if ( r_captain_canteen_is_angry.GetBool() )
|
||||
{
|
||||
// We actually want to see when Captain Canteen happened, and make it really obvious that (a) he was here and (b) this code would have fixed him.
|
||||
float HowAngry = 20.0f; // Leon's getting larger!
|
||||
MatrixSetColumn ( Vector ( HowAngry, 0.0f, 0.0f ), 0, NewBone );
|
||||
MatrixSetColumn ( Vector ( 0.0f, HowAngry, 0.0f ), 1, NewBone );
|
||||
MatrixSetColumn ( Vector ( 0.0f, 0.0f, HowAngry ), 2, NewBone );
|
||||
}
|
||||
#endif
|
||||
|
||||
for ( int i=0; i < m_MergedBones.Count(); i++ )
|
||||
{
|
||||
int iOwnerBone = m_MergedBones[i].m_iMyBone;
|
||||
|
||||
// Only update bones reference by the bone mask.
|
||||
if ( !( m_pOwnerHdr->boneFlags( iOwnerBone ) & boneMask ) )
|
||||
continue;
|
||||
|
||||
m_pOwner->GetBoneForWrite( iOwnerBone ) = NewBone;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Now copy the bone matrices.
|
||||
for ( int i=0; i < m_MergedBones.Count(); i++ )
|
||||
{
|
||||
int iOwnerBone = m_MergedBones[i].m_iMyBone;
|
||||
int iParentBone = m_MergedBones[i].m_iParentBone;
|
||||
|
||||
// Only update bones reference by the bone mask.
|
||||
if ( !( m_pOwnerHdr->boneFlags( iOwnerBone ) & boneMask ) )
|
||||
continue;
|
||||
|
||||
MatrixCopy( m_pFollow->GetBone( iParentBone ), m_pOwner->GetBoneForWrite( iOwnerBone ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// copy bones instead of matrices
|
||||
void CBoneMergeCache::CopyParentToChild( const Vector parentPos[], const Quaternion parentQ[], Vector childPos[], Quaternion childQ[], int boneMask )
|
||||
{
|
||||
UpdateCache();
|
||||
|
||||
// If this is set, then all the other cache data is set.
|
||||
if ( !m_pOwnerHdr || m_MergedBones.Count() == 0 )
|
||||
return;
|
||||
|
||||
// Now copy the bone matrices.
|
||||
for ( int i=0; i < m_MergedBones.Count(); i++ )
|
||||
{
|
||||
int iOwnerBone = m_MergedBones[i].m_iMyBone;
|
||||
int iParentBone = m_MergedBones[i].m_iParentBone;
|
||||
|
||||
if ( m_pOwnerHdr->boneParent( iOwnerBone ) == -1 || m_pFollowHdr->boneParent( iParentBone ) == -1 )
|
||||
continue;
|
||||
|
||||
// Only update bones reference by the bone mask.
|
||||
if ( !( m_pOwnerHdr->boneFlags( iOwnerBone ) & boneMask ) )
|
||||
continue;
|
||||
|
||||
childPos[ iOwnerBone ] = parentPos[ iParentBone ];
|
||||
childQ[ iOwnerBone ] = parentQ[ iParentBone ];
|
||||
}
|
||||
}
|
||||
|
||||
void CBoneMergeCache::CopyChildToParent( const Vector childPos[], const Quaternion childQ[], Vector parentPos[], Quaternion parentQ[], int boneMask )
|
||||
{
|
||||
UpdateCache();
|
||||
|
||||
// If this is set, then all the other cache data is set.
|
||||
if ( !m_pOwnerHdr || m_MergedBones.Count() == 0 )
|
||||
return;
|
||||
|
||||
// Now copy the bone matrices.
|
||||
for ( int i=0; i < m_MergedBones.Count(); i++ )
|
||||
{
|
||||
int iOwnerBone = m_MergedBones[i].m_iMyBone;
|
||||
int iParentBone = m_MergedBones[i].m_iParentBone;
|
||||
|
||||
if ( m_pOwnerHdr->boneParent( iOwnerBone ) == -1 || m_pFollowHdr->boneParent( iParentBone ) == -1 )
|
||||
continue;
|
||||
|
||||
// Only update bones reference by the bone mask.
|
||||
if ( !( m_pOwnerHdr->boneFlags( iOwnerBone ) & boneMask ) )
|
||||
continue;
|
||||
|
||||
parentPos[ iParentBone ] = childPos[ iOwnerBone ];
|
||||
parentQ[ iParentBone ] = childQ[ iOwnerBone ];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool CBoneMergeCache::GetAimEntOrigin( Vector *pAbsOrigin, QAngle *pAbsAngles )
|
||||
{
|
||||
UpdateCache();
|
||||
|
||||
// If this is set, then all the other cache data is set.
|
||||
if ( !m_pOwnerHdr || m_MergedBones.Count() == 0 )
|
||||
return false;
|
||||
|
||||
// We want the abs origin such that if we put the entity there, the first merged bone
|
||||
// will be aligned. This way the entity will be culled in the correct position.
|
||||
//
|
||||
// ie: mEntity * mBoneLocal = mFollowBone
|
||||
// so: mEntity = mFollowBone * Inverse( mBoneLocal )
|
||||
//
|
||||
// Note: the code below doesn't take animation into account. If the attached entity animates
|
||||
// all over the place, then this won't get the right results.
|
||||
|
||||
// Get mFollowBone.
|
||||
m_pFollow->SetupBones( NULL, -1, m_nFollowBoneSetupMask, gpGlobals->curtime );
|
||||
const matrix3x4_t &mFollowBone = m_pFollow->GetBone( m_MergedBones[0].m_iParentBone );
|
||||
|
||||
// Get Inverse( mBoneLocal )
|
||||
matrix3x4_t mBoneLocal, mBoneLocalInv;
|
||||
SetupSingleBoneMatrix( m_pOwnerHdr, m_pOwner->GetSequence(), 0, m_MergedBones[0].m_iMyBone, mBoneLocal );
|
||||
MatrixInvert( mBoneLocal, mBoneLocalInv );
|
||||
|
||||
// Now calculate mEntity = mFollowBone * Inverse( mBoneLocal )
|
||||
matrix3x4_t mEntity;
|
||||
ConcatTransforms( mFollowBone, mBoneLocalInv, mEntity );
|
||||
MatrixAngles( mEntity, *pAbsAngles, *pAbsOrigin );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CBoneMergeCache::GetRootBone( matrix3x4_t &rootBone )
|
||||
{
|
||||
UpdateCache();
|
||||
|
||||
// If this is set, then all the other cache data is set.
|
||||
if ( !m_pOwnerHdr || m_MergedBones.Count() == 0 )
|
||||
return false;
|
||||
|
||||
// Get mFollowBone.
|
||||
m_pFollow->SetupBones( NULL, -1, m_nFollowBoneSetupMask, gpGlobals->curtime );
|
||||
rootBone = m_pFollow->GetBone( m_MergedBones[0].m_iParentBone );
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
85
game/client/bone_merge_cache.h
Normal file
85
game/client/bone_merge_cache.h
Normal file
@@ -0,0 +1,85 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef BONE_MERGE_CACHE_H
|
||||
#define BONE_MERGE_CACHE_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
|
||||
class C_BaseAnimating;
|
||||
class CStudioHdr;
|
||||
|
||||
|
||||
#include "mathlib/vector.h"
|
||||
|
||||
|
||||
class CBoneMergeCache
|
||||
{
|
||||
public:
|
||||
|
||||
CBoneMergeCache();
|
||||
|
||||
void Init( C_BaseAnimating *pOwner );
|
||||
|
||||
// Updates the lookups that let it merge bones quickly.
|
||||
void UpdateCache();
|
||||
|
||||
// This copies the transform from all bones in the followed entity that have
|
||||
// names that match our bones.
|
||||
void MergeMatchingBones( int boneMask );
|
||||
|
||||
// copy bones instead of matrices
|
||||
void CopyParentToChild( const Vector parentPos[], const Quaternion parentQ[], Vector childPos[], Quaternion childQ[], int boneMask );
|
||||
void CopyChildToParent( const Vector childPos[], const Quaternion childQ[], Vector parentPos[], Quaternion parentQ[], int boneMask );
|
||||
|
||||
// Returns true if the specified bone is one that gets merged in MergeMatchingBones.
|
||||
int IsBoneMerged( int iBone ) const;
|
||||
|
||||
// Gets the origin for the first merge bone on the parent.
|
||||
bool GetAimEntOrigin( Vector *pAbsOrigin, QAngle *pAbsAngles );
|
||||
|
||||
bool GetRootBone( matrix3x4_t &rootBone );
|
||||
|
||||
private:
|
||||
|
||||
// This is the entity that we're keeping the cache updated for.
|
||||
C_BaseAnimating *m_pOwner;
|
||||
|
||||
// All the cache data is based off these. When they change, the cache data is regenerated.
|
||||
// These are either all valid pointers or all NULL.
|
||||
C_BaseAnimating *m_pFollow;
|
||||
CStudioHdr *m_pFollowHdr;
|
||||
const studiohdr_t *m_pFollowRenderHdr;
|
||||
CStudioHdr *m_pOwnerHdr;
|
||||
|
||||
// This is the mask we need to use to set up bones on the followed entity to do the bone merge
|
||||
int m_nFollowBoneSetupMask;
|
||||
|
||||
// Cache data.
|
||||
class CMergedBone
|
||||
{
|
||||
public:
|
||||
unsigned short m_iMyBone;
|
||||
unsigned short m_iParentBone;
|
||||
};
|
||||
|
||||
CUtlVector<CMergedBone> m_MergedBones;
|
||||
CUtlVector<unsigned char> m_BoneMergeBits; // One bit for each bone. The bit is set if the bone gets merged.
|
||||
};
|
||||
|
||||
|
||||
inline int CBoneMergeCache::IsBoneMerged( int iBone ) const
|
||||
{
|
||||
if ( m_pOwnerHdr )
|
||||
return m_BoneMergeBits[iBone >> 3] & ( 1 << ( iBone & 7 ) );
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
#endif // BONE_MERGE_CACHE_H
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user