1
0
mirror of https://github.com/alliedmodders/hl2sdk.git synced 2025-09-19 03:56:10 +08:00

First version of the SOurce SDK 2013

This commit is contained in:
Joe Ludwig
2013-06-26 15:22:04 -07:00
commit e7d6f4c174
3682 changed files with 1624327 additions and 0 deletions

View File

@ -0,0 +1,73 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $Revision: $
// $NoKeywords: $
//
// This file contains code to allow us to associate client data with bsp leaves.
//
//=============================================================================//
#if !defined( ICLIENTLEAFSYSTEM_H )
#define ICLIENTLEAFSYSTEM_H
#ifdef _WIN32
#pragma once
#endif
#include "client_render_handle.h"
//-----------------------------------------------------------------------------
// Render groups
//-----------------------------------------------------------------------------
enum RenderGroup_Config_t
{
// Number of buckets that are used to hold opaque entities
// and opaque static props by size. The bucketing should be used to reduce overdraw.
RENDER_GROUP_CFG_NUM_OPAQUE_ENT_BUCKETS = 4,
};
enum RenderGroup_t
{
RENDER_GROUP_OPAQUE_STATIC_HUGE = 0, // Huge static prop
RENDER_GROUP_OPAQUE_ENTITY_HUGE = 1, // Huge opaque entity
RENDER_GROUP_OPAQUE_STATIC = RENDER_GROUP_OPAQUE_STATIC_HUGE + ( RENDER_GROUP_CFG_NUM_OPAQUE_ENT_BUCKETS - 1 ) * 2,
RENDER_GROUP_OPAQUE_ENTITY, // Opaque entity (smallest size, or default)
RENDER_GROUP_TRANSLUCENT_ENTITY,
RENDER_GROUP_TWOPASS, // Implied opaque and translucent in two passes
RENDER_GROUP_VIEW_MODEL_OPAQUE, // Solid weapon view models
RENDER_GROUP_VIEW_MODEL_TRANSLUCENT, // Transparent overlays etc
RENDER_GROUP_OPAQUE_BRUSH, // Brushes
RENDER_GROUP_OTHER, // Unclassfied. Won't get drawn.
// This one's always gotta be last
RENDER_GROUP_COUNT
};
#define CLIENTLEAFSYSTEM_INTERFACE_VERSION_1 "ClientLeafSystem001"
#define CLIENTLEAFSYSTEM_INTERFACE_VERSION "ClientLeafSystem002"
//-----------------------------------------------------------------------------
// The client leaf system
//-----------------------------------------------------------------------------
abstract_class IClientLeafSystemEngine
{
public:
// Adds and removes renderables from the leaf lists
// CreateRenderableHandle stores the handle inside pRenderable.
virtual void CreateRenderableHandle( IClientRenderable* pRenderable, bool bIsStaticProp = false ) = 0;
virtual void RemoveRenderable( ClientRenderHandle_t handle ) = 0;
virtual void AddRenderableToLeaves( ClientRenderHandle_t renderable, int nLeafCount, unsigned short *pLeaves ) = 0;
virtual void ChangeRenderableRenderGroup( ClientRenderHandle_t handle, RenderGroup_t group ) = 0;
};
#endif // ICLIENTLEAFSYSTEM_H

View File

@ -0,0 +1,84 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================//
#ifndef ENGINE_ICOLLIDEABLE_H
#define ENGINE_ICOLLIDEABLE_H
#ifdef _WIN32
#pragma once
#endif
enum SolidType_t;
class IHandleEntity;
struct Ray_t;
struct model_t;
class Vector;
class QAngle;
class CGameTrace;
typedef CGameTrace trace_t;
class IClientUnknown;
abstract_class ICollideable
{
public:
// Gets at the entity handle associated with the collideable
virtual IHandleEntity *GetEntityHandle() = 0;
// These methods return the bounds of an OBB measured in "collision" space
// which can be retreived through the CollisionToWorldTransform or
// GetCollisionOrigin/GetCollisionAngles methods
virtual const Vector& OBBMinsPreScaled() const = 0;
virtual const Vector& OBBMaxsPreScaled() const = 0;
virtual const Vector& OBBMins() const = 0;
virtual const Vector& OBBMaxs() const = 0;
// Returns the bounds of a world-space box used when the collideable is being traced
// against as a trigger. It's only valid to call these methods if the solid flags
// have the FSOLID_USE_TRIGGER_BOUNDS flag set.
virtual void WorldSpaceTriggerBounds( Vector *pVecWorldMins, Vector *pVecWorldMaxs ) const = 0;
// custom collision test
virtual bool TestCollision( const Ray_t &ray, unsigned int fContentsMask, trace_t& tr ) = 0;
// Perform hitbox test, returns true *if hitboxes were tested at all*!!
virtual bool TestHitboxes( const Ray_t &ray, unsigned int fContentsMask, trace_t& tr ) = 0;
// Returns the BRUSH model index if this is a brush model. Otherwise, returns -1.
virtual int GetCollisionModelIndex() = 0;
// Return the model, if it's a studio model.
virtual const model_t* GetCollisionModel() = 0;
// Get angles and origin.
virtual const Vector& GetCollisionOrigin() const = 0;
virtual const QAngle& GetCollisionAngles() const = 0;
virtual const matrix3x4_t& CollisionToWorldTransform() const = 0;
// Return a SOLID_ define.
virtual SolidType_t GetSolid() const = 0;
virtual int GetSolidFlags() const = 0;
// Gets at the containing class...
virtual IClientUnknown* GetIClientUnknown() = 0;
// We can filter out collisions based on collision group
virtual int GetCollisionGroup() const = 0;
// Returns a world-aligned box guaranteed to surround *everything* in the collision representation
// Note that this will surround hitboxes, trigger bounds, physics.
// It may or may not be a tight-fitting box and its volume may suddenly change
virtual void WorldSpaceSurroundingBounds( Vector *pVecMins, Vector *pVecMaxs ) = 0;
virtual bool ShouldTouchTrigger( int triggerSolidFlags ) const = 0;
// returns NULL unless this collideable has specified FSOLID_ROOT_PARENT_ALIGNED
virtual const matrix3x4_t *GetRootParentToWorldTransform() const = 0;
};
#endif // ENGINE_ICOLLIDEABLE_H

View File

@ -0,0 +1,123 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: Client-server neutral sound interface
//
// $NoKeywords: $
//=============================================================================//
#ifndef IENGINESOUND_H
#define IENGINESOUND_H
#ifdef _WIN32
#pragma once
#endif
#include "basetypes.h"
#include "interface.h"
#include "soundflags.h"
#include "irecipientfilter.h"
#include "utlvector.h"
#include "engine/SndInfo.h"
//-----------------------------------------------------------------------------
// forward declaration
//-----------------------------------------------------------------------------
class Vector;
// Handy defines for EmitSound
#define SOUND_FROM_UI_PANEL -2 // Sound being played inside a UI panel on the client
#define SOUND_FROM_LOCAL_PLAYER -1
#define SOUND_FROM_WORLD 0
// These are used to feed a soundlevel to the sound system and have it use
// goldsrc-type attenuation. We should use this as little as possible and
// phase it out as soon as possible.
// Take a regular sndlevel and convert it to compatibility mode.
#define SNDLEVEL_TO_COMPATIBILITY_MODE( x ) ((soundlevel_t)(int)( (x) + 256 ))
// Take a compatibility-mode sndlevel and get the REAL sndlevel out of it.
#define SNDLEVEL_FROM_COMPATIBILITY_MODE( x ) ((soundlevel_t)(int)( (x) - 256 ))
// Tells if the given sndlevel is marked as compatibility mode.
#define SNDLEVEL_IS_COMPATIBILITY_MODE( x ) ( (x) >= 256 )
//-----------------------------------------------------------------------------
// Client-server neutral effects interface
//-----------------------------------------------------------------------------
#define IENGINESOUND_CLIENT_INTERFACE_VERSION "IEngineSoundClient003"
#define IENGINESOUND_SERVER_INTERFACE_VERSION "IEngineSoundServer003"
abstract_class IEngineSound
{
public:
// Precache a particular sample
virtual bool PrecacheSound( const char *pSample, bool bPreload = false, bool bIsUISound = false ) = 0;
virtual bool IsSoundPrecached( const char *pSample ) = 0;
virtual void PrefetchSound( const char *pSample ) = 0;
// Just loads the file header and checks for duration (not hooked up for .mp3's yet)
// Is accessible to server and client though
virtual float GetSoundDuration( const char *pSample ) = 0;
// Pitch of 100 is no pitch shift. Pitch > 100 up to 255 is a higher pitch, pitch < 100
// down to 1 is a lower pitch. 150 to 70 is the realistic range.
// EmitSound with pitch != 100 should be used sparingly, as it's not quite as
// fast (the pitchshift mixer is not native coded).
// NOTE: setting iEntIndex to -1 will cause the sound to be emitted from the local
// player (client-side only)
virtual void EmitSound( IRecipientFilter& filter, int iEntIndex, int iChannel, const char *pSample,
float flVolume, float flAttenuation, int iFlags = 0, int iPitch = PITCH_NORM, int iSpecialDSP = 0,
const Vector *pOrigin = NULL, const Vector *pDirection = NULL, CUtlVector< Vector >* pUtlVecOrigins = NULL, bool bUpdatePositions = true, float soundtime = 0.0f, int speakerentity = -1 ) = 0;
virtual void EmitSound( IRecipientFilter& filter, int iEntIndex, int iChannel, const char *pSample,
float flVolume, soundlevel_t iSoundlevel, int iFlags = 0, int iPitch = PITCH_NORM, int iSpecialDSP = 0,
const Vector *pOrigin = NULL, const Vector *pDirection = NULL, CUtlVector< Vector >* pUtlVecOrigins = NULL, bool bUpdatePositions = true, float soundtime = 0.0f, int speakerentity = -1 ) = 0;
virtual void EmitSentenceByIndex( IRecipientFilter& filter, int iEntIndex, int iChannel, int iSentenceIndex,
float flVolume, soundlevel_t iSoundlevel, int iFlags = 0, int iPitch = PITCH_NORM,int iSpecialDSP = 0,
const Vector *pOrigin = NULL, const Vector *pDirection = NULL, CUtlVector< Vector >* pUtlVecOrigins = NULL, bool bUpdatePositions = true, float soundtime = 0.0f, int speakerentity = -1 ) = 0;
virtual void StopSound( int iEntIndex, int iChannel, const char *pSample ) = 0;
// stop all active sounds (client only)
virtual void StopAllSounds(bool bClearBuffers) = 0;
// Set the room type for a player (client only)
virtual void SetRoomType( IRecipientFilter& filter, int roomType ) = 0;
// Set the dsp preset for a player (client only)
virtual void SetPlayerDSP( IRecipientFilter& filter, int dspType, bool fastReset ) = 0;
// emit an "ambient" sound that isn't spatialized
// only available on the client, assert on server
virtual void EmitAmbientSound( const char *pSample, float flVolume, int iPitch = PITCH_NORM, int flags = 0, float soundtime = 0.0f ) = 0;
// virtual EntChannel_t CreateEntChannel() = 0;
virtual float GetDistGainFromSoundLevel( soundlevel_t soundlevel, float dist ) = 0;
// Client .dll only functions
virtual int GetGuidForLastSoundEmitted() = 0;
virtual bool IsSoundStillPlaying( int guid ) = 0;
virtual void StopSoundByGuid( int guid ) = 0;
// Set's master volume (0.0->1.0)
virtual void SetVolumeByGuid( int guid, float fvol ) = 0;
// Retrieves list of all active sounds
virtual void GetActiveSounds( CUtlVector< SndInfo_t >& sndlist ) = 0;
virtual void PrecacheSentenceGroup( const char *pGroupName ) = 0;
virtual void NotifyBeginMoviePlayback() = 0;
virtual void NotifyEndMoviePlayback() = 0;
};
#endif // IENGINESOUND_H

View File

@ -0,0 +1,192 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
//
//=============================================================================//
#ifndef ENGINE_IENGINETRACE_H
#define ENGINE_IENGINETRACE_H
#ifdef _WIN32
#pragma once
#endif
#include "basehandle.h"
#include "utlvector.h" //need CUtlVector for IEngineTrace::GetBrushesIn*()
#include "mathlib/vector4d.h"
class Vector;
class IHandleEntity;
struct Ray_t;
class CGameTrace;
typedef CGameTrace trace_t;
class ICollideable;
class QAngle;
class CTraceListData;
class CPhysCollide;
struct cplane_t;
//-----------------------------------------------------------------------------
// The standard trace filter... NOTE: Most normal traces inherit from CTraceFilter!!!
//-----------------------------------------------------------------------------
enum TraceType_t
{
TRACE_EVERYTHING = 0,
TRACE_WORLD_ONLY, // NOTE: This does *not* test static props!!!
TRACE_ENTITIES_ONLY, // NOTE: This version will *not* test static props
TRACE_EVERYTHING_FILTER_PROPS, // NOTE: This version will pass the IHandleEntity for props through the filter, unlike all other filters
};
abstract_class ITraceFilter
{
public:
virtual bool ShouldHitEntity( IHandleEntity *pEntity, int contentsMask ) = 0;
virtual TraceType_t GetTraceType() const = 0;
};
//-----------------------------------------------------------------------------
// Classes are expected to inherit these + implement the ShouldHitEntity method
//-----------------------------------------------------------------------------
// This is the one most normal traces will inherit from
class CTraceFilter : public ITraceFilter
{
public:
virtual TraceType_t GetTraceType() const
{
return TRACE_EVERYTHING;
}
};
class CTraceFilterEntitiesOnly : public ITraceFilter
{
public:
virtual TraceType_t GetTraceType() const
{
return TRACE_ENTITIES_ONLY;
}
};
//-----------------------------------------------------------------------------
// Classes need not inherit from these
//-----------------------------------------------------------------------------
class CTraceFilterWorldOnly : public ITraceFilter
{
public:
bool ShouldHitEntity( IHandleEntity *pServerEntity, int contentsMask )
{
return false;
}
virtual TraceType_t GetTraceType() const
{
return TRACE_WORLD_ONLY;
}
};
class CTraceFilterWorldAndPropsOnly : public ITraceFilter
{
public:
bool ShouldHitEntity( IHandleEntity *pServerEntity, int contentsMask )
{
return false;
}
virtual TraceType_t GetTraceType() const
{
return TRACE_EVERYTHING;
}
};
class CTraceFilterHitAll : public CTraceFilter
{
public:
virtual bool ShouldHitEntity( IHandleEntity *pServerEntity, int contentsMask )
{
return true;
}
};
//-----------------------------------------------------------------------------
// Enumeration interface for EnumerateLinkEntities
//-----------------------------------------------------------------------------
abstract_class IEntityEnumerator
{
public:
// This gets called with each handle
virtual bool EnumEntity( IHandleEntity *pHandleEntity ) = 0;
};
//-----------------------------------------------------------------------------
// Interface the engine exposes to the game DLL
//-----------------------------------------------------------------------------
#define INTERFACEVERSION_ENGINETRACE_SERVER "EngineTraceServer003"
#define INTERFACEVERSION_ENGINETRACE_CLIENT "EngineTraceClient003"
abstract_class IEngineTrace
{
public:
// Returns the contents mask + entity at a particular world-space position
virtual int GetPointContents( const Vector &vecAbsPosition, IHandleEntity** ppEntity = NULL ) = 0;
// Get the point contents, but only test the specific entity. This works
// on static props and brush models.
//
// If the entity isn't a static prop or a brush model, it returns CONTENTS_EMPTY and sets
// bFailed to true if bFailed is non-null.
virtual int GetPointContents_Collideable( ICollideable *pCollide, const Vector &vecAbsPosition ) = 0;
// Traces a ray against a particular entity
virtual void ClipRayToEntity( const Ray_t &ray, unsigned int fMask, IHandleEntity *pEnt, trace_t *pTrace ) = 0;
// Traces a ray against a particular entity
virtual void ClipRayToCollideable( const Ray_t &ray, unsigned int fMask, ICollideable *pCollide, trace_t *pTrace ) = 0;
// A version that simply accepts a ray (can work as a traceline or tracehull)
virtual void TraceRay( const Ray_t &ray, unsigned int fMask, ITraceFilter *pTraceFilter, trace_t *pTrace ) = 0;
// A version that sets up the leaf and entity lists and allows you to pass those in for collision.
virtual void SetupLeafAndEntityListRay( const Ray_t &ray, CTraceListData &traceData ) = 0;
virtual void SetupLeafAndEntityListBox( const Vector &vecBoxMin, const Vector &vecBoxMax, CTraceListData &traceData ) = 0;
virtual void TraceRayAgainstLeafAndEntityList( const Ray_t &ray, CTraceListData &traceData, unsigned int fMask, ITraceFilter *pTraceFilter, trace_t *pTrace ) = 0;
// A version that sweeps a collideable through the world
// abs start + abs end represents the collision origins you want to sweep the collideable through
// vecAngles represents the collision angles of the collideable during the sweep
virtual void SweepCollideable( ICollideable *pCollide, const Vector &vecAbsStart, const Vector &vecAbsEnd,
const QAngle &vecAngles, unsigned int fMask, ITraceFilter *pTraceFilter, trace_t *pTrace ) = 0;
// Enumerates over all entities along a ray
// If triggers == true, it enumerates all triggers along a ray
virtual void EnumerateEntities( const Ray_t &ray, bool triggers, IEntityEnumerator *pEnumerator ) = 0;
// Same thing, but enumerate entitys within a box
virtual void EnumerateEntities( const Vector &vecAbsMins, const Vector &vecAbsMaxs, IEntityEnumerator *pEnumerator ) = 0;
// Convert a handle entity to a collideable. Useful inside enumer
virtual ICollideable *GetCollideable( IHandleEntity *pEntity ) = 0;
// HACKHACK: Temp for performance measurments
virtual int GetStatByIndex( int index, bool bClear ) = 0;
//finds brushes in an AABB, prone to some false positives
virtual void GetBrushesInAABB( const Vector &vMins, const Vector &vMaxs, CUtlVector<int> *pOutput, int iContentsMask = 0xFFFFFFFF ) = 0;
//Creates a CPhysCollide out of all displacements wholly or partially contained in the specified AABB
virtual CPhysCollide* GetCollidableFromDisplacementsInAABB( const Vector& vMins, const Vector& vMaxs ) = 0;
//retrieve brush planes and contents, returns true if data is being returned in the output pointers, false if the brush doesn't exist
virtual bool GetBrushInfo( int iBrush, CUtlVector<Vector4D> *pPlanesOut, int *pContentsOut ) = 0;
virtual bool PointOutsideWorld( const Vector &ptTest ) = 0; //Tests a point to see if it's outside any playable area
// Walks bsp to find the leaf containing the specified point
virtual int GetLeafContainingPoint( const Vector &ptTest ) = 0;
};
#endif // ENGINE_IENGINETRACE_H

View File

@ -0,0 +1,99 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================//
#ifndef IPROPS_H
#define IPROPS_H
#ifdef _WIN32
#pragma once
#endif
#include "interface.h"
#include "mathlib/vector.h"
#include "utlvector.h"
#include "basehandle.h"
struct vcollide_t;
struct Ray_t;
class IClientRenderable;
class CGameTrace;
typedef CGameTrace trace_t;
class IVPhysicsKeyHandler;
class IPhysicsEnvironment;
class ICollideable;
//-----------------------------------------------------------------------------
// Interface versions for static props
//-----------------------------------------------------------------------------
#define INTERFACEVERSION_STATICPROPMGR_CLIENT "StaticPropMgrClient004"
#define INTERFACEVERSION_STATICPROPMGR_SERVER "StaticPropMgrServer002"
//-----------------------------------------------------------------------------
// Interface for static props
//-----------------------------------------------------------------------------
abstract_class IStaticPropMgr
{
public:
// Create physics representations of props
virtual void CreateVPhysicsRepresentations( IPhysicsEnvironment *physenv, IVPhysicsKeyHandler *pDefaults, void *pGameData ) = 0;
// Purpose: Trace a ray against the specified static Prop. Returns point of intersection in trace_t
virtual void TraceRayAgainstStaticProp( const Ray_t& ray, int staticPropIndex, trace_t& tr ) = 0;
// Is a base handle a static prop?
virtual bool IsStaticProp( IHandleEntity *pHandleEntity ) const = 0;
virtual bool IsStaticProp( CBaseHandle handle ) const = 0;
// returns a collideable interface to static props
virtual ICollideable *GetStaticPropByIndex( int propIndex ) = 0;
};
abstract_class IStaticPropMgrClient : public IStaticPropMgr
{
public:
// Recomputes the static prop opacity given a view origin
virtual void ComputePropOpacity( const Vector &viewOrigin, float factor ) = 0;
// Adds decals to static props, returns point of decal in trace_t
virtual void AddDecalToStaticProp( const Vector& rayStart, const Vector& rayEnd,
int staticPropIndex, int decalIndex, bool doTrace, trace_t& tr ) = 0;
// Adds/removes shadows from static props
virtual void AddShadowToStaticProp( unsigned short shadowHandle, IClientRenderable* pRenderable ) = 0;
virtual void RemoveAllShadowsFromStaticProp( IClientRenderable* pRenderable ) = 0;
// Gets the lighting + material color of a static prop
virtual void GetStaticPropMaterialColorAndLighting( trace_t* pTrace,
int staticPropIndex, Vector& lighting, Vector& matColor ) = 0;
//Changes made specifically to support the Portal mod (smack Dave Kircher if something breaks) (Added separately to both client and server to not mess with versioning)
//===================================================================
virtual void GetAllStaticProps( CUtlVector<ICollideable *> *pOutput ) = 0; //testing function that will eventually be removed
virtual void GetAllStaticPropsInAABB( const Vector &vMins, const Vector &vMaxs, CUtlVector<ICollideable *> *pOutput ) = 0; //get all static props that exist wholly or partially in an AABB
virtual void GetAllStaticPropsInOBB( const Vector &ptOrigin, const Vector &vExtent1, const Vector &vExtent2, const Vector &vExtent3, CUtlVector<ICollideable *> *pOutput ) = 0; //get all static props that exist wholly or partially in an OBB
//===================================================================
virtual void DrawStaticProps( IClientRenderable **pProps, int count, bool bShadowDepth, bool drawVCollideWireframe ) = 0;
};
class IStaticPropMgrServer : public IStaticPropMgr
{
public:
//Changes made specifically to support the Portal mod (smack Dave Kircher if something breaks) (Added separately to both client and server to not mess with versioning)
//===================================================================
virtual void GetAllStaticProps( CUtlVector<ICollideable *> *pOutput ) = 0; //testing function that will eventually be removed
virtual void GetAllStaticPropsInAABB( const Vector &vMins, const Vector &vMaxs, CUtlVector<ICollideable *> *pOutput ) = 0; //get all static props that exist wholly or partially in an AABB
virtual void GetAllStaticPropsInOBB( const Vector &ptOrigin, const Vector &vExtent1, const Vector &vExtent2, const Vector &vExtent3, CUtlVector<ICollideable *> *pOutput ) = 0; //get all static props that exist wholly or partially in an OBB
//===================================================================
};
#endif // IPROPS_H

51
public/engine/SndInfo.h Normal file
View File

@ -0,0 +1,51 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
//=============================================================================
#ifndef SNDINFO_H
#define SNDINFO_H
#ifdef _WIN32
#pragma once
#endif
class Vector;
#include "utlsymbol.h"
//-----------------------------------------------------------------------------
// Purpose: Client side only
//-----------------------------------------------------------------------------
struct SndInfo_t
{
// Sound Guid
int m_nGuid;
FileNameHandle_t m_filenameHandle; // filesystem filename handle - call IFilesystem to conver this to a string
int m_nSoundSource;
int m_nChannel;
// If a sound is being played through a speaker entity (e.g., on a monitor,), this is the
// entity upon which to show the lips moving, if the sound has sentence data
int m_nSpeakerEntity;
float m_flVolume;
float m_flLastSpatializedVolume;
// Radius of this sound effect (spatialization is different within the radius)
float m_flRadius;
int m_nPitch;
Vector *m_pOrigin;
Vector *m_pDirection;
// if true, assume sound source can move and update according to entity
bool m_bUpdatePositions;
// true if playing linked sentence
bool m_bIsSentence;
// if true, bypass all dsp processing for this sound (ie: music)
bool m_bDryMix;
// true if sound is playing through in-game speaker entity.
bool m_bSpeaker;
// true if sound is playing with special DSP effect
bool m_bSpecialDSP;
// for snd_show, networked sounds get colored differently than local sounds
bool m_bFromServer;
};
#endif // SNDINFO_H

44
public/engine/http.h Normal file
View File

@ -0,0 +1,44 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
//=======================================================================================//
#ifndef HTTP_H
#define HTTP_H
#ifdef _WIN32
#pragma once
#endif
//--------------------------------------------------------------------------------------------------------------
/**
* Status of the download thread, as set in RequestContext::status.
*/
enum HTTPStatus_t
{
HTTP_INVALID = -1,
HTTP_CONNECTING = 0,///< This is set in the main thread before the download thread starts.
HTTP_FETCH, ///< The download thread sets this when it starts reading data.
HTTP_DONE, ///< The download thread sets this if it has read all the data successfully.
HTTP_ABORTED, ///< The download thread sets this if it aborts because it's RequestContext::shouldStop has been set.
HTTP_ERROR ///< The download thread sets this if there is an error connecting or downloading. Partial data may be present, so the main thread can check.
};
//--------------------------------------------------------------------------------------------------------------
/**
* Error encountered in the download thread, as set in RequestContext::error.
*/
enum HTTPError_t
{
HTTP_ERROR_NONE = 0,
HTTP_ERROR_ZERO_LENGTH_FILE,
HTTP_ERROR_CONNECTION_CLOSED,
HTTP_ERROR_INVALID_URL, ///< InternetCrackUrl failed
HTTP_ERROR_INVALID_PROTOCOL, ///< URL didn't start with http:// or https://
HTTP_ERROR_CANT_BIND_SOCKET,
HTTP_ERROR_CANT_CONNECT,
HTTP_ERROR_NO_HEADERS, ///< Cannot read HTTP headers
HTTP_ERROR_FILE_NONEXISTENT,
HTTP_ERROR_MAX
};
#endif // HTTP_H

View File

@ -0,0 +1,42 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: Engine voice interface
//
// $NoKeywords: $
//=============================================================================//
#ifndef IENGINEVOICE_H
#define IENGINEVOICE_H
#ifdef _WIN32
#pragma once
#endif
#include "basetypes.h"
#define IENGINEVOICE_INTERFACE_VERSION "IEngineVoice001"
abstract_class IEngineVoice
{
public:
virtual bool IsHeadsetPresent( int iController ) = 0;
virtual bool IsLocalPlayerTalking( int iController ) = 0;
virtual void AddPlayerToVoiceList( XUID xPlayer, int iController ) = 0;
virtual void RemovePlayerFromVoiceList( XUID xPlayer, int iController ) = 0;
virtual void GetRemoteTalkers( int *pNumTalkers, XUID *pRemoteTalkers ) = 0;
virtual bool VoiceUpdateData( int iController ) = 0;
virtual void GetVoiceData( int iController, const byte **ppvVoiceDataBuffer, unsigned int *pnumVoiceDataBytes ) = 0;
virtual void VoiceResetLocalData( int iController ) = 0;
virtual void SetPlaybackPriority( XUID remoteTalker, int iController, int iAllowPlayback ) = 0;
virtual void PlayIncomingVoiceData( XUID xuid, const byte *pbData, unsigned int dwDataSize, const bool *bAudiblePlayers = NULL ) = 0;
virtual void RemoveAllTalkers() = 0;
};
#endif // IENGINEVOICE_H

View File

@ -0,0 +1,117 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
//===========================================================================//
#ifndef IMATCHMAKING_H
#define IMATCHMAKING_H
#ifdef _WIN32
#pragma once
#endif
#include "const.h"
#include "vgui/VGUI.h"
#if !defined( _X360 )
#include "xbox/xboxstubs.h"
#endif
class KeyValues;
enum SESSION_NOTIFY
{
SESSION_NOTIFY_FAIL_SEARCH,
SESSION_NOTIFY_SEARCH_COMPLETED,
SESSION_NOFIFY_MODIFYING_SESSION,
SESSION_NOTIFY_MODIFYING_COMPLETED_HOST,
SESSION_NOTIFY_MODIFYING_COMPLETED_CLIENT,
SESSION_NOTIFY_MIGRATION_COMPLETED,
SESSION_NOTIFY_CONNECT_SESSIONFULL,
SESSION_NOTIFY_CONNECT_NOTAVAILABLE,
SESSION_NOTIFY_CONNECTED_TOSESSION,
SESSION_NOTIFY_CONNECTED_TOSERVER,
SESSION_NOTIFY_CONNECT_FAILED,
SESSION_NOTIFY_FAIL_CREATE,
SESSION_NOTIFY_FAIL_MIGRATE,
SESSION_NOTIFY_REGISTER_COMPLETED,
SESSION_NOTIFY_FAIL_REGISTER,
SESSION_NOTIFY_CLIENT_KICKED,
SESSION_NOTIFY_CREATED_HOST,
SESSION_NOTIFY_CREATED_CLIENT,
SESSION_NOTIFY_LOST_HOST,
SESSION_NOTIFY_LOST_SERVER,
SESSION_NOTIFY_COUNTDOWN,
SESSION_NOTIFY_ENDGAME_RANKED, // Ranked
SESSION_NOTIFY_ENDGAME_HOST, // Unranked
SESSION_NOTIFY_ENDGAME_CLIENT, // Unranked
SESSION_NOTIFY_DUMPSTATS, // debugging
SESSION_NOTIFY_WELCOME, // Close all dialogs and show the welcome main menu
};
enum SESSION_PROPS
{
SESSION_CONTEXT,
SESSION_PROPERTY,
SESSION_FLAG,
};
struct hostData_s
{
char hostName[MAX_PLAYER_NAME_LENGTH];
char scenario[MAX_MAP_NAME];
int gameState;
int gameTime;
XUID xuid;
};
struct MM_QOS_t
{
int nPingMsMin; // Minimum round-trip time in ms
int nPingMsMed; // Median round-trip time in ms
float flBwUpKbs; // Bandwidth upstream in kilobytes/s
float flBwDnKbs; // Bandwidth downstream in kilobytes/s
float flLoss; // Average packet loss in percents
};
#define NO_TIME_LIMIT 65000
abstract_class IMatchmaking
{
public:
virtual void SessionNotification( const SESSION_NOTIFY notification, const int param = 0 ) = 0;
virtual void AddSessionProperty( const uint nType, const char *pID, const char *pValue, const char *pValueType ) = 0;
virtual void SetSessionProperties( KeyValues *pPropertyKeys ) = 0;
virtual void SelectSession( uint idx ) = 0;
virtual void ModifySession() = 0;
virtual void UpdateMuteList() = 0;
virtual void StartHost( bool bSystemLink = false ) = 0;
virtual void StartClient( bool bSystemLink = false ) = 0;
virtual bool StartGame() = 0;
virtual bool CancelStartGame() = 0;
virtual void ChangeTeam( const char *pTeamName ) = 0;
virtual void TellClientsToConnect() = 0;
virtual void CancelCurrentOperation() = 0;
virtual void KickPlayerFromSession( uint64 id ) = 0;
virtual void JoinInviteSession( XSESSION_INFO *pHostInfo ) = 0;
virtual void JoinInviteSessionByID( XNKID nSessionID ) = 0;
virtual void EndStatsReporting() = 0;
// For Gameui
virtual KeyValues *GetSessionProperties() = 0;
// For voice chat
virtual uint64 PlayerIdToXuid( int playerId ) = 0;
virtual bool IsPlayerMuted( int iUserId, XUID id ) = 0;
// To determine host Quality-of-Service
virtual MM_QOS_t GetQosWithLIVE() = 0;
// Used by non-'host' local machines which are starting a map to "prime" the caches. Will sit at near completion indefinitely --
// the client is waiting for a TellClientsToConnect message
virtual bool PreventFullServerStartup() = 0;
};
#define VENGINE_MATCHMAKING_VERSION "VENGINE_MATCHMAKING_VERSION001"
#endif // IMATCHMAKING_H

View File

@ -0,0 +1,163 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
//
//=============================================================================//
#ifndef ISERVERPLUGIN_H
#define ISERVERPLUGIN_H
#ifdef _WIN32
#pragma once
#endif
#include "edict.h"
#include "tier1/interface.h"
#include "tier1/KeyValues.h"
class CCommand;
//
// you will also want to listen for game events via IGameEventManager::AddListener()
//
typedef enum
{
PLUGIN_CONTINUE = 0, // keep going
PLUGIN_OVERRIDE, // run the game dll function but use our return value instead
PLUGIN_STOP, // don't run the game dll function at all
} PLUGIN_RESULT;
typedef enum
{
eQueryCvarValueStatus_ValueIntact=0, // It got the value fine.
eQueryCvarValueStatus_CvarNotFound=1,
eQueryCvarValueStatus_NotACvar=2, // There's a ConCommand, but it's not a ConVar.
eQueryCvarValueStatus_CvarProtected=3 // The cvar was marked with FCVAR_SERVER_CAN_NOT_QUERY, so the server is not allowed to have its value.
} EQueryCvarValueStatus;
typedef int QueryCvarCookie_t;
#define InvalidQueryCvarCookie -1
#define INTERFACEVERSION_ISERVERPLUGINCALLBACKS_VERSION_1 "ISERVERPLUGINCALLBACKS001"
#define INTERFACEVERSION_ISERVERPLUGINCALLBACKS_VERSION_2 "ISERVERPLUGINCALLBACKS002"
#define INTERFACEVERSION_ISERVERPLUGINCALLBACKS "ISERVERPLUGINCALLBACKS003"
//-----------------------------------------------------------------------------
// Purpose: callbacks the engine exposes to the 3rd party plugins (ala MetaMod)
//-----------------------------------------------------------------------------
abstract_class IServerPluginCallbacks
{
public:
// Initialize the plugin to run
// Return false if there is an error during startup.
virtual bool Load( CreateInterfaceFn interfaceFactory, CreateInterfaceFn gameServerFactory ) = 0;
// Called when the plugin should be shutdown
virtual void Unload( void ) = 0;
// called when a plugins execution is stopped but the plugin is not unloaded
virtual void Pause( void ) = 0;
// called when a plugin should start executing again (sometime after a Pause() call)
virtual void UnPause( void ) = 0;
// Returns string describing current plugin. e.g., Admin-Mod.
virtual const char *GetPluginDescription( void ) = 0;
// Called any time a new level is started (after GameInit() also on level transitions within a game)
virtual void LevelInit( char const *pMapName ) = 0;
// The server is about to activate
virtual void ServerActivate( edict_t *pEdictList, int edictCount, int clientMax ) = 0;
// The server should run physics/think on all edicts
virtual void GameFrame( bool simulating ) = 0;
// Called when a level is shutdown (including changing levels)
virtual void LevelShutdown( void ) = 0;
// Client is going active
virtual void ClientActive( edict_t *pEntity ) = 0;
// Client is disconnecting from server
virtual void ClientDisconnect( edict_t *pEntity ) = 0;
// Client is connected and should be put in the game
virtual void ClientPutInServer( edict_t *pEntity, char const *playername ) = 0;
// Sets the client index for the client who typed the command into their console
virtual void SetCommandClient( int index ) = 0;
// A player changed one/several replicated cvars (name etc)
virtual void ClientSettingsChanged( edict_t *pEdict ) = 0;
// Client is connecting to server ( set retVal to false to reject the connection )
// You can specify a rejection message by writing it into reject
virtual PLUGIN_RESULT ClientConnect( bool *bAllowConnect, edict_t *pEntity, const char *pszName, const char *pszAddress, char *reject, int maxrejectlen ) = 0;
// The client has typed a command at the console
virtual PLUGIN_RESULT ClientCommand( edict_t *pEntity, const CCommand &args ) = 0;
// A user has had their network id setup and validated
virtual PLUGIN_RESULT NetworkIDValidated( const char *pszUserName, const char *pszNetworkID ) = 0;
// This is called when a query from IServerPluginHelpers::StartQueryCvarValue is finished.
// iCookie is the value returned by IServerPluginHelpers::StartQueryCvarValue.
// Added with version 2 of the interface.
virtual void OnQueryCvarValueFinished( QueryCvarCookie_t iCookie, edict_t *pPlayerEntity, EQueryCvarValueStatus eStatus, const char *pCvarName, const char *pCvarValue ) = 0;
// added with version 3 of the interface.
virtual void OnEdictAllocated( edict_t *edict ) = 0;
virtual void OnEdictFreed( const edict_t *edict ) = 0;
};
#define INTERFACEVERSION_ISERVERPLUGINHELPERS "ISERVERPLUGINHELPERS001"
typedef enum
{
DIALOG_MSG = 0, // just an on screen message
DIALOG_MENU, // an options menu
DIALOG_TEXT, // a richtext dialog
DIALOG_ENTRY, // an entry box
DIALOG_ASKCONNECT // Ask the client to connect to a specified IP address. Only the "time" and "title" keys are used.
} DIALOG_TYPE;
//-----------------------------------------------------------------------------
// Purpose: functions that only 3rd party plugins need
//-----------------------------------------------------------------------------
abstract_class IServerPluginHelpers
{
public:
// creates an onscreen menu with various option buttons
// The keyvalues param can contain these fields:
// "title" - (string) the title to show in the hud and in the title bar
// "msg" - (string) a longer message shown in the GameUI
// "color" - (color) the color to display the message in the hud (white by default)
// "level" - (int) the priority of this message (closer to 0 is higher), only 1 message can be outstanding at a time
// "time" - (int) the time in seconds this message should stay active in the GameUI (min 10 sec, max 200 sec)
//
// For DIALOG_MENU add sub keys for each option with these fields:
// "command" - (string) client command to run if selected
// "msg" - (string) button text for this option
//
virtual void CreateMessage( edict_t *pEntity, DIALOG_TYPE type, KeyValues *data, IServerPluginCallbacks *plugin ) = 0;
virtual void ClientCommand( edict_t *pEntity, const char *cmd ) = 0;
// Call this to find out the value of a cvar on the client.
//
// It is an asynchronous query, and it will call IServerPluginCallbacks::OnQueryCvarValueFinished when
// the value comes in from the client.
//
// Store the return value if you want to match this specific query to the OnQueryCvarValueFinished call.
// Returns InvalidQueryCvarCookie if the entity is invalid.
virtual QueryCvarCookie_t StartQueryCvarValue( edict_t *pEntity, const char *pName ) = 0;
};
#endif //ISERVERPLUGIN_H

189
public/engine/ishadowmgr.h Normal file
View File

@ -0,0 +1,189 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
//
//=============================================================================//
#ifndef ISHADOWMGR_H
#define ISHADOWMGR_H
#ifdef _WIN32
#pragma once
#endif
#include "interface.h"
#include "mathlib/vmatrix.h"
//-----------------------------------------------------------------------------
// forward declarations
//-----------------------------------------------------------------------------
class IMaterial;
class Vector;
class Vector2D;
struct model_t;
typedef unsigned short ModelInstanceHandle_t;
class IClientRenderable;
class ITexture;
// change this when the new version is incompatable with the old
#define ENGINE_SHADOWMGR_INTERFACE_VERSION "VEngineShadowMgr002"
//-----------------------------------------------------------------------------
// Flags for the creation method
//-----------------------------------------------------------------------------
enum ShadowFlags_t
{
SHADOW_FLAGS_FLASHLIGHT = (1 << 0),
SHADOW_FLAGS_SHADOW = (1 << 1),
// Update this if you add flags
SHADOW_FLAGS_LAST_FLAG = SHADOW_FLAGS_SHADOW
};
#define SHADOW_FLAGS_PROJECTED_TEXTURE_TYPE_MASK ( SHADOW_FLAGS_FLASHLIGHT | SHADOW_FLAGS_SHADOW )
//-----------------------------------------------------------------------------
//
// Shadow-related functionality exported by the engine
//
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// This is a handle to shadows, clients can create as many as they want
//-----------------------------------------------------------------------------
typedef unsigned short ShadowHandle_t;
enum
{
SHADOW_HANDLE_INVALID = (ShadowHandle_t)~0
};
//-----------------------------------------------------------------------------
// Used for the creation Flags field of CreateShadow
//-----------------------------------------------------------------------------
enum ShadowCreateFlags_t
{
SHADOW_CACHE_VERTS = ( 1 << 0 ),
SHADOW_FLASHLIGHT = ( 1 << 1 ),
SHADOW_LAST_FLAG = SHADOW_FLASHLIGHT,
};
//-----------------------------------------------------------------------------
// Information about a particular shadow
//-----------------------------------------------------------------------------
struct ShadowInfo_t
{
// Transforms from world space into texture space of the shadow
VMatrix m_WorldToShadow;
// The shadow should no longer be drawn once it's further than MaxDist
// along z in shadow texture coordinates.
float m_FalloffOffset;
float m_MaxDist;
float m_FalloffAmount; // how much to lighten the shadow maximally
Vector2D m_TexOrigin;
Vector2D m_TexSize;
unsigned char m_FalloffBias;
};
struct FlashlightState_t;
//-----------------------------------------------------------------------------
// The engine's interface to the shadow manager
//-----------------------------------------------------------------------------
abstract_class IShadowMgr
{
public:
// Create, destroy shadows (see ShadowCreateFlags_t for creationFlags)
virtual ShadowHandle_t CreateShadow( IMaterial* pMaterial, IMaterial* pModelMaterial, void* pBindProxy, int creationFlags ) = 0;
virtual void DestroyShadow( ShadowHandle_t handle ) = 0;
// Resets the shadow material (useful for shadow LOD.. doing blobby at distance)
virtual void SetShadowMaterial( ShadowHandle_t handle, IMaterial* pMaterial, IMaterial* pModelMaterial, void* pBindProxy ) = 0;
// Shadow opacity
// virtual void SetShadowOpacity( ShadowHandle_t handle, float alpha ) = 0;
// virtual float GetShadowOpacity( ShadowHandle_t handle ) const = 0;
// Project a shadow into the world
// The two points specify the upper left coordinate and the lower-right
// coordinate of the shadow specified in a shadow "viewplane". The
// projection matrix is a shadow viewplane->world transformation,
// and can be orthographic orperspective.
// I expect that the client DLL will call this method any time the shadow
// changes because the light changes, or because the entity casting the
// shadow moves
// Note that we can't really control the shadows from the engine because
// the engine only knows about pevs, which don't exist on the client
// The shadow matrix specifies a world-space transform for the shadow
// the shadow is projected down the z direction, and the origin of the
// shadow matrix is the origin of the projection ray. The size indicates
// the shadow size measured in the space of the shadow matrix; the
// shadow goes from +/- size.x/2 along the x axis of the shadow matrix
// and +/- size.y/2 along the y axis of the shadow matrix.
virtual void ProjectShadow( ShadowHandle_t handle, const Vector &origin,
const Vector& projectionDir, const VMatrix& worldToShadow, const Vector2D& size,
int nLeafCount, const int *pLeafList,
float maxHeight, float falloffOffset, float falloffAmount, const Vector &vecCasterOrigin ) = 0;
virtual void ProjectFlashlight( ShadowHandle_t handle, const VMatrix &worldToShadow, int nLeafCount, const int *pLeafList ) = 0;
// Gets at information about a particular shadow
virtual const ShadowInfo_t &GetInfo( ShadowHandle_t handle ) = 0;
virtual const Frustum_t &GetFlashlightFrustum( ShadowHandle_t handle ) = 0;
// Methods related to shadows on brush models
virtual void AddShadowToBrushModel( ShadowHandle_t handle,
model_t* pModel, const Vector& origin, const QAngle& angles ) = 0;
// Removes all shadows from a brush model
virtual void RemoveAllShadowsFromBrushModel( model_t* pModel ) = 0;
// Sets the texture coordinate range for a shadow...
virtual void SetShadowTexCoord( ShadowHandle_t handle, float x, float y, float w, float h ) = 0;
// Methods related to shadows on studio models
virtual void AddShadowToModel( ShadowHandle_t shadow, ModelInstanceHandle_t instance ) = 0;
virtual void RemoveAllShadowsFromModel( ModelInstanceHandle_t instance ) = 0;
// Set extra clip planes related to shadows...
// These are used to prevent pokethru and back-casting
virtual void ClearExtraClipPlanes( ShadowHandle_t shadow ) = 0;
virtual void AddExtraClipPlane( ShadowHandle_t shadow, const Vector& normal, float dist ) = 0;
// Allows us to disable particular shadows
virtual void EnableShadow( ShadowHandle_t shadow, bool bEnable ) = 0;
// Set the darkness falloff bias
virtual void SetFalloffBias( ShadowHandle_t shadow, unsigned char ucBias ) = 0;
// Update the state for a flashlight.
virtual void UpdateFlashlightState( ShadowHandle_t shadowHandle, const FlashlightState_t &lightState ) = 0;
virtual void DrawFlashlightDepthTexture( ) = 0;
virtual void AddFlashlightRenderable( ShadowHandle_t shadow, IClientRenderable *pRenderable ) = 0;
virtual ShadowHandle_t CreateShadowEx( IMaterial* pMaterial, IMaterial* pModelMaterial, void* pBindProxy, int creationFlags ) = 0;
virtual void SetFlashlightDepthTexture( ShadowHandle_t shadowHandle, ITexture *pFlashlightDepthTexture, unsigned char ucShadowStencilBit ) = 0;
virtual const FlashlightState_t &GetFlashlightState( ShadowHandle_t handle ) = 0;
virtual void SetFlashlightRenderState( ShadowHandle_t handle ) = 0;
};
#endif

View File

@ -0,0 +1,63 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
//
//=============================================================================//
//
// cdll_int.h
//
// 4-23-98
// JOHN: client dll interface declarations
//
#ifndef IVDEBUGOVERLAY_H
#define IVDEBUGOVERLAY_H
#ifdef _WIN32
#pragma once
#endif
class Vector;
#define VDEBUG_OVERLAY_INTERFACE_VERSION "VDebugOverlay003"
// When used as a duration by a server-side NDebugOverlay:: call,
// causes the overlay to persist until the next server update.
#define NDEBUG_PERSIST_TILL_NEXT_SERVER (0.01023f)
class OverlayText_t;
abstract_class IVDebugOverlay
{
public:
virtual void AddEntityTextOverlay(int ent_index, int line_offset, float duration, int r, int g, int b, int a, PRINTF_FORMAT_STRING const char *format, ...) = 0;
virtual void AddBoxOverlay(const Vector& origin, const Vector& mins, const Vector& max, QAngle const& orientation, int r, int g, int b, int a, float duration) = 0;
virtual void AddTriangleOverlay(const Vector& p1, const Vector& p2, const Vector& p3, int r, int g, int b, int a, bool noDepthTest, float duration) = 0;
virtual void AddLineOverlay(const Vector& origin, const Vector& dest, int r, int g, int b,bool noDepthTest, float duration) = 0;
virtual void AddTextOverlay(const Vector& origin, float duration, PRINTF_FORMAT_STRING const char *format, ...) = 0;
virtual void AddTextOverlay(const Vector& origin, int line_offset, float duration, PRINTF_FORMAT_STRING const char *format, ...) = 0;
virtual void AddScreenTextOverlay(float flXPos, float flYPos,float flDuration, int r, int g, int b, int a, const char *text) = 0;
virtual void AddSweptBoxOverlay(const Vector& start, const Vector& end, const Vector& mins, const Vector& max, const QAngle & angles, int r, int g, int b, int a, float flDuration) = 0;
virtual void AddGridOverlay(const Vector& origin) = 0;
virtual int ScreenPosition(const Vector& point, Vector& screen) = 0;
virtual int ScreenPosition(float flXPos, float flYPos, Vector& screen) = 0;
virtual OverlayText_t *GetFirst( void ) = 0;
virtual OverlayText_t *GetNext( OverlayText_t *current ) = 0;
virtual void ClearDeadOverlays( void ) = 0;
virtual void ClearAllOverlays() = 0;
virtual void AddTextOverlayRGB(const Vector& origin, int line_offset, float duration, float r, float g, float b, float alpha, PRINTF_FORMAT_STRING const char *format, ...) = 0;
virtual void AddTextOverlayRGB(const Vector& origin, int line_offset, float duration, int r, int g, int b, int a, PRINTF_FORMAT_STRING const char *format, ...) = 0;
virtual void AddLineOverlayAlpha(const Vector& origin, const Vector& dest, int r, int g, int b, int a, bool noDepthTest, float duration) = 0;
virtual void AddBoxOverlay2( const Vector& origin, const Vector& mins, const Vector& max, QAngle const& orientation, const Color& faceColor, const Color& edgeColor, float duration ) = 0;
private:
inline void AddTextOverlay(const Vector& origin, int line_offset, float duration, int r, int g, int b, int a, PRINTF_FORMAT_STRING const char *format, ...) {} /* catch improper use of bad interface. Needed because '0' duration can be resolved by compiler to NULL format string (i.e., compiles but calls wrong function) */
};
#endif // IVDEBUGOVERLAY_H

261
public/engine/ivmodelinfo.h Normal file
View File

@ -0,0 +1,261 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
//===========================================================================//
#ifndef IVMODELINFO_H
#define IVMODELINFO_H
#ifdef _WIN32
#pragma once
#endif
#include "platform.h"
#include "dbg.h"
//-----------------------------------------------------------------------------
// Forward declarations
//-----------------------------------------------------------------------------
class IMaterial;
class KeyValues;
struct vcollide_t;
struct model_t;
class Vector;
class QAngle;
class CGameTrace;
struct cplane_t;
typedef CGameTrace trace_t;
struct studiohdr_t;
struct virtualmodel_t;
typedef unsigned char byte;
struct virtualterrainparams_t;
class CPhysCollide;
typedef unsigned short MDLHandle_t;
class CUtlBuffer;
class IClientRenderable;
//-----------------------------------------------------------------------------
// Purpose: a callback class that is notified when a model has finished loading
//-----------------------------------------------------------------------------
abstract_class IModelLoadCallback
{
public:
virtual void OnModelLoadComplete( const model_t* pModel ) = 0;
protected:
// Protected destructor so that nobody tries to delete via this interface.
// Automatically unregisters if the callback is destroyed while still pending.
~IModelLoadCallback();
};
//-----------------------------------------------------------------------------
// Purpose: Automate refcount tracking on a model index
//-----------------------------------------------------------------------------
class CRefCountedModelIndex
{
private:
int m_nIndex;
public:
CRefCountedModelIndex() : m_nIndex( -1 ) { }
~CRefCountedModelIndex() { Set( -1 ); }
CRefCountedModelIndex( const CRefCountedModelIndex& src ) : m_nIndex( -1 ) { Set( src.m_nIndex ); }
CRefCountedModelIndex& operator=( const CRefCountedModelIndex& src ) { Set( src.m_nIndex ); return *this; }
explicit CRefCountedModelIndex( int i ) : m_nIndex( -1 ) { Set( i ); }
CRefCountedModelIndex& operator=( int i ) { Set( i ); return *this; }
int Get() const { return m_nIndex; }
void Set( int i );
void Clear() { Set( -1 ); }
operator int () const { return m_nIndex; }
};
//-----------------------------------------------------------------------------
// Model info interface
//-----------------------------------------------------------------------------
// change this when the new version is incompatable with the old
#define VMODELINFO_CLIENT_INTERFACE_VERSION "VModelInfoClient006"
#define VMODELINFO_SERVER_INTERFACE_VERSION_3 "VModelInfoServer003"
#define VMODELINFO_SERVER_INTERFACE_VERSION "VModelInfoServer004"
// MODEL INDEX RULES
// If index >= 0, then index references the precached model string table
// If index == -1, then the model is invalid
// If index < -1, then the model is DYNAMIC and has a DYNAMIC INDEX of (-2 - index)
// - if the dynamic index is ODD, then the model is CLIENT ONLY
// and has a m_LocalDynamicModels lookup index of (dynamic index)>>1
// - if the dynamic index is EVEN, then the model is NETWORKED
// and has a dynamic model string table index of (dynamic index)>>1
inline bool IsDynamicModelIndex( int modelindex ) { return modelindex < -1; }
inline bool IsClientOnlyModelIndex( int modelindex ) { return modelindex < -1 && (modelindex & 1); }
abstract_class IVModelInfo
{
public:
virtual ~IVModelInfo( void ) { }
// Returns model_t* pointer for a model given a precached or dynamic model index.
virtual const model_t *GetModel( int modelindex ) = 0;
// Returns index of model by name for precached or known dynamic models.
// Does not adjust reference count for dynamic models.
virtual int GetModelIndex( const char *name ) const = 0;
// Returns name of model
virtual const char *GetModelName( const model_t *model ) const = 0;
virtual vcollide_t *GetVCollide( const model_t *model ) = 0;
virtual vcollide_t *GetVCollide( int modelindex ) = 0;
virtual void GetModelBounds( const model_t *model, Vector& mins, Vector& maxs ) const = 0;
virtual void GetModelRenderBounds( const model_t *model, Vector& mins, Vector& maxs ) const = 0;
virtual int GetModelFrameCount( const model_t *model ) const = 0;
virtual int GetModelType( const model_t *model ) const = 0;
virtual void *GetModelExtraData( const model_t *model ) = 0;
virtual bool ModelHasMaterialProxy( const model_t *model ) const = 0;
virtual bool IsTranslucent( model_t const* model ) const = 0;
virtual bool IsTranslucentTwoPass( const model_t *model ) const = 0;
virtual void RecomputeTranslucency( const model_t *model, int nSkin, int nBody, void /*IClientRenderable*/ *pClientRenderable, float fInstanceAlphaModulate=1.0f) = 0;
virtual int GetModelMaterialCount( const model_t* model ) const = 0;
virtual void GetModelMaterials( const model_t *model, int count, IMaterial** ppMaterial ) = 0;
virtual bool IsModelVertexLit( const model_t *model ) const = 0;
virtual const char *GetModelKeyValueText( const model_t *model ) = 0;
virtual bool GetModelKeyValue( const model_t *model, CUtlBuffer &buf ) = 0; // supports keyvalue blocks in submodels
virtual float GetModelRadius( const model_t *model ) = 0;
virtual const studiohdr_t *FindModel( const studiohdr_t *pStudioHdr, void **cache, const char *modelname ) const = 0;
virtual const studiohdr_t *FindModel( void *cache ) const = 0;
virtual virtualmodel_t *GetVirtualModel( const studiohdr_t *pStudioHdr ) const = 0;
virtual byte *GetAnimBlock( const studiohdr_t *pStudioHdr, int iBlock ) const = 0;
// Available on client only!!!
virtual void GetModelMaterialColorAndLighting( const model_t *model, Vector const& origin,
QAngle const& angles, trace_t* pTrace,
Vector& lighting, Vector& matColor ) = 0;
virtual void GetIlluminationPoint( const model_t *model, IClientRenderable *pRenderable, Vector const& origin,
QAngle const& angles, Vector* pLightingCenter ) = 0;
virtual int GetModelContents( int modelIndex ) = 0;
virtual studiohdr_t *GetStudiomodel( const model_t *mod ) = 0;
virtual int GetModelSpriteWidth( const model_t *model ) const = 0;
virtual int GetModelSpriteHeight( const model_t *model ) const = 0;
// Sets/gets a map-specified fade range (client only)
virtual void SetLevelScreenFadeRange( float flMinSize, float flMaxSize ) = 0;
virtual void GetLevelScreenFadeRange( float *pMinArea, float *pMaxArea ) const = 0;
// Sets/gets a map-specified per-view fade range (client only)
virtual void SetViewScreenFadeRange( float flMinSize, float flMaxSize ) = 0;
// Computes fade alpha based on distance fade + screen fade (client only)
virtual unsigned char ComputeLevelScreenFade( const Vector &vecAbsOrigin, float flRadius, float flFadeScale ) const = 0;
virtual unsigned char ComputeViewScreenFade( const Vector &vecAbsOrigin, float flRadius, float flFadeScale ) const = 0;
// both client and server
virtual int GetAutoplayList( const studiohdr_t *pStudioHdr, unsigned short **pAutoplayList ) const = 0;
// Gets a virtual terrain collision model (creates if necessary)
// NOTE: This may return NULL if the terrain model cannot be virtualized
virtual CPhysCollide *GetCollideForVirtualTerrain( int index ) = 0;
virtual bool IsUsingFBTexture( const model_t *model, int nSkin, int nBody, void /*IClientRenderable*/ *pClientRenderable ) const = 0;
// Obsolete methods. These are left in to maintain binary compatibility with clients using the IVModelInfo old version.
virtual const model_t *FindOrLoadModel( const char *name ) { Warning( "IVModelInfo::FindOrLoadModel is now obsolte.\n" ); return NULL; }
virtual void InitDynamicModels( ) { Warning( "IVModelInfo::InitDynamicModels is now obsolte.\n" ); }
virtual void ShutdownDynamicModels( ) { Warning( "IVModelInfo::ShutdownDynamicModels is now obsolte.\n" ); }
virtual void AddDynamicModel( const char *name, int nModelIndex = -1 ) { Warning( "IVModelInfo::AddDynamicModel is now obsolte.\n" ); }
virtual void ReferenceModel( int modelindex ) { Warning( "IVModelInfo::ReferenceModel is now obsolte.\n" ); }
virtual void UnreferenceModel( int modelindex ) { Warning( "IVModelInfo::UnreferenceModel is now obsolte.\n" ); }
virtual void CleanupDynamicModels( bool bForce = false ) { Warning( "IVModelInfo::CleanupDynamicModels is now obsolte.\n" ); }
virtual MDLHandle_t GetCacheHandle( const model_t *model ) const = 0;
// Returns planes of non-nodraw brush model surfaces
virtual int GetBrushModelPlaneCount( const model_t *model ) const = 0;
virtual void GetBrushModelPlane( const model_t *model, int nIndex, cplane_t &plane, Vector *pOrigin ) const = 0;
virtual int GetSurfacepropsForVirtualTerrain( int index ) = 0;
// Poked by engine host system
virtual void OnLevelChange() = 0;
virtual int GetModelClientSideIndex( const char *name ) const = 0;
// Returns index of model by name, dynamically registered if not already known.
virtual int RegisterDynamicModel( const char *name, bool bClientSide ) = 0;
virtual bool IsDynamicModelLoading( int modelIndex ) = 0;
virtual void AddRefDynamicModel( int modelIndex ) = 0;
virtual void ReleaseDynamicModel( int modelIndex ) = 0;
// Registers callback for when dynamic model has finished loading.
// Automatically adds reference, pair with ReleaseDynamicModel.
virtual bool RegisterModelLoadCallback( int modelindex, IModelLoadCallback* pCallback, bool bCallImmediatelyIfLoaded = true ) = 0;
virtual void UnregisterModelLoadCallback( int modelindex, IModelLoadCallback* pCallback ) = 0;
};
typedef IVModelInfo IVModelInfo003;
abstract_class IVModelInfoClient : public IVModelInfo
{
public:
virtual void OnDynamicModelsStringTableChange( int nStringIndex, const char *pString, const void *pData ) = 0;
// For tools only!
virtual const model_t *FindOrLoadModel( const char *name ) = 0;
};
struct virtualterrainparams_t
{
// UNDONE: Add grouping here, specified in BSP file? (test grouping to see if this is necessary)
int index;
};
//-----------------------------------------------------------------------------
// Purpose: Force removal from callback list on destruction to avoid crashes.
//-----------------------------------------------------------------------------
inline IModelLoadCallback::~IModelLoadCallback()
{
#ifdef CLIENT_DLL
extern IVModelInfoClient *modelinfo;
#else
extern IVModelInfo *modelinfo;
#endif
if ( modelinfo )
{
modelinfo->UnregisterModelLoadCallback( -1, this );
}
}
//-----------------------------------------------------------------------------
// Purpose: Automate refcount tracking on a model index
//-----------------------------------------------------------------------------
inline void CRefCountedModelIndex::Set( int i )
{
#ifdef CLIENT_DLL
extern IVModelInfoClient *modelinfo;
#else
extern IVModelInfo *modelinfo;
#endif
if ( i == m_nIndex )
return;
modelinfo->AddRefDynamicModel( i );
modelinfo->ReleaseDynamicModel( m_nIndex );
m_nIndex = i;
}
#endif // IVMODELINFO_H

View File

@ -0,0 +1,180 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
//
//===========================================================================//
#ifndef IVMODELRENDER_H
#define IVMODELRENDER_H
#ifdef _WIN32
#pragma once
#endif
#include "interface.h"
#include "mathlib/mathlib.h"
#include "istudiorender.h"
//-----------------------------------------------------------------------------
// forward declarations
//-----------------------------------------------------------------------------
struct mstudioanimdesc_t;
struct mstudioseqdesc_t;
struct model_t;
class IClientRenderable;
class Vector;
struct studiohdr_t;
class IMaterial;
class CStudioHdr;
FORWARD_DECLARE_HANDLE( LightCacheHandle_t );
//-----------------------------------------------------------------------------
// Model rendering state
//-----------------------------------------------------------------------------
struct DrawModelState_t
{
studiohdr_t* m_pStudioHdr;
studiohwdata_t* m_pStudioHWData;
IClientRenderable* m_pRenderable;
const matrix3x4_t *m_pModelToWorld;
StudioDecalHandle_t m_decals;
int m_drawFlags;
int m_lod;
};
//-----------------------------------------------------------------------------
// Model Rendering + instance data
//-----------------------------------------------------------------------------
// change this when the new version is incompatable with the old
#define VENGINE_HUDMODEL_INTERFACE_VERSION "VEngineModel016"
typedef unsigned short ModelInstanceHandle_t;
enum
{
MODEL_INSTANCE_INVALID = (ModelInstanceHandle_t)~0
};
struct ModelRenderInfo_t
{
Vector origin;
QAngle angles;
IClientRenderable *pRenderable;
const model_t *pModel;
const matrix3x4_t *pModelToWorld;
const matrix3x4_t *pLightingOffset;
const Vector *pLightingOrigin;
int flags;
int entity_index;
int skin;
int body;
int hitboxset;
ModelInstanceHandle_t instance;
ModelRenderInfo_t()
{
pModelToWorld = NULL;
pLightingOffset = NULL;
pLightingOrigin = NULL;
}
};
struct StaticPropRenderInfo_t
{
const matrix3x4_t *pModelToWorld;
const model_t *pModel;
IClientRenderable *pRenderable;
Vector *pLightingOrigin;
short skin;
ModelInstanceHandle_t instance;
};
// UNDONE: Move this to hud export code, subsume previous functions
abstract_class IVModelRender
{
public:
virtual int DrawModel( int flags,
IClientRenderable *pRenderable,
ModelInstanceHandle_t instance,
int entity_index,
const model_t *model,
Vector const& origin,
QAngle const& angles,
int skin,
int body,
int hitboxset,
const matrix3x4_t *modelToWorld = NULL,
const matrix3x4_t *pLightingOffset = NULL ) = 0;
// This causes a material to be used when rendering the model instead
// of the materials the model was compiled with
virtual void ForcedMaterialOverride( IMaterial *newMaterial, OverrideType_t nOverrideType = OVERRIDE_NORMAL ) = 0;
virtual void SetViewTarget( const CStudioHdr *pStudioHdr, int nBodyIndex, const Vector& target ) = 0;
// Creates, destroys instance data to be associated with the model
virtual ModelInstanceHandle_t CreateInstance( IClientRenderable *pRenderable, LightCacheHandle_t *pCache = NULL ) = 0;
virtual void DestroyInstance( ModelInstanceHandle_t handle ) = 0;
// Associates a particular lighting condition with a model instance handle.
// FIXME: This feature currently only works for static props. To make it work for entities, etc.,
// we must clean up the lightcache handles as the model instances are removed.
// At the moment, since only the static prop manager uses this, it cleans up all LightCacheHandles
// at level shutdown.
virtual void SetStaticLighting( ModelInstanceHandle_t handle, LightCacheHandle_t* pHandle ) = 0;
virtual LightCacheHandle_t GetStaticLighting( ModelInstanceHandle_t handle ) = 0;
// moves an existing InstanceHandle to a nex Renderable to keep decals etc. Models must be the same
virtual bool ChangeInstance( ModelInstanceHandle_t handle, IClientRenderable *pRenderable ) = 0;
// Creates a decal on a model instance by doing a planar projection
// along the ray. The material is the decal material, the radius is the
// radius of the decal to create.
virtual void AddDecal( ModelInstanceHandle_t handle, Ray_t const& ray,
Vector const& decalUp, int decalIndex, int body, bool noPokeThru = false, int maxLODToDecal = ADDDECAL_TO_ALL_LODS ) = 0;
// Removes all the decals on a model instance
virtual void RemoveAllDecals( ModelInstanceHandle_t handle ) = 0;
// Remove all decals from all models
virtual void RemoveAllDecalsFromAllModels() = 0;
// Shadow rendering, DrawModelShadowSetup returns the address of the bone-to-world array, NULL in case of error
virtual matrix3x4_t* DrawModelShadowSetup( IClientRenderable *pRenderable, int body, int skin, DrawModelInfo_t *pInfo, matrix3x4_t *pCustomBoneToWorld = NULL ) = 0;
virtual void DrawModelShadow( IClientRenderable *pRenderable, const DrawModelInfo_t &info, matrix3x4_t *pCustomBoneToWorld = NULL ) = 0;
// This gets called when overbright, etc gets changed to recompute static prop lighting.
virtual bool RecomputeStaticLighting( ModelInstanceHandle_t handle ) = 0;
virtual void ReleaseAllStaticPropColorData( void ) = 0;
virtual void RestoreAllStaticPropColorData( void ) = 0;
// Extended version of drawmodel
virtual int DrawModelEx( ModelRenderInfo_t &pInfo ) = 0;
virtual int DrawModelExStaticProp( ModelRenderInfo_t &pInfo ) = 0;
virtual bool DrawModelSetup( ModelRenderInfo_t &pInfo, DrawModelState_t *pState, matrix3x4_t *pCustomBoneToWorld, matrix3x4_t** ppBoneToWorldOut ) = 0;
virtual void DrawModelExecute( const DrawModelState_t &state, const ModelRenderInfo_t &pInfo, matrix3x4_t *pCustomBoneToWorld = NULL ) = 0;
// Sets up lighting context for a point in space
virtual void SetupLighting( const Vector &vecCenter ) = 0;
// doesn't support any debug visualization modes or other model options, but draws static props in the
// fastest way possible
virtual int DrawStaticPropArrayFast( StaticPropRenderInfo_t *pProps, int count, bool bShadowDepth ) = 0;
// Allow client to override lighting state
virtual void SuppressEngineLighting( bool bSuppress ) = 0;
virtual void SetupColorMeshes( int nTotalVerts ) = 0;
};
#endif // IVMODELRENDER_H

View File

@ -0,0 +1,94 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
//=============================================================================//
#ifndef VIEW_SHAREDV1_H
#define VIEW_SHAREDV1_H
#ifdef _WIN32
#pragma once
#endif
//-----------------------------------------------------------------------------
// Purpose: Renderer setup data.
//-----------------------------------------------------------------------------
class CViewSetupV1
{
public:
CViewSetupV1()
{
m_bForceAspectRatio1To1 = false;
m_bRenderToSubrectOfLargerScreen = false;
bForceClearWholeRenderTarget = false;
m_bUseRenderTargetAspectRatio = false;
}
// shared by 2D & 3D views
// User specified context
int context;
// left side of view window
int x;
// top side of view window
int y;
// width of view window
int width;
// height of view window
int height;
// clear the color buffer before rendering this view?
bool clearColor;
// clear the Depth buffer before rendering this view?
bool clearDepth;
// NOTE: This is for a workaround on ATI with building cubemaps. Clearing just the viewport doesn't seem to work properly.
bool bForceClearWholeRenderTarget;
// the rest are only used by 3D views
// Orthographic projection?
bool m_bOrtho;
// View-space rectangle for ortho projection.
float m_OrthoLeft;
float m_OrthoTop;
float m_OrthoRight;
float m_OrthoBottom;
// horizontal FOV in degrees
float fov;
// horizontal FOV in degrees for in-view model
float fovViewmodel;
// 3D origin of camera
Vector origin;
// Origin gets reflected on the water surface, but things like
// displacement LOD need to be calculated from the viewer's
// real position.
Vector m_vUnreflectedOrigin;
// heading of camera (pitch, yaw, roll)
QAngle angles;
// local Z coordinate of near plane of camera
float zNear;
// local Z coordinate of far plane of camera
float zFar;
// local Z coordinate of near plane of camera ( when rendering view model )
float zNearViewmodel;
// local Z coordinate of far plane of camera ( when rendering view model )
float zFarViewmodel;
bool m_bForceAspectRatio1To1;
// set to true if this is to draw into a subrect of the larger screen
// this really is a hack, but no more than the rest of the way this class is used
bool m_bRenderToSubrectOfLargerScreen;
// Use this for situations like water where you want to render the aspect ratio of the
// back buffer into a square (or otherwise) render target.
bool m_bUseRenderTargetAspectRatio;
};
#endif // VIEW_SHAREDV1_H