16 Mar 2010

This commit is contained in:
g-cont 2010-03-16 00:00:00 +03:00 committed by Alibek Omarov
parent 6d88c3904b
commit 42e086780b
58 changed files with 3453 additions and 2614 deletions

View File

@ -117,6 +117,10 @@ SOURCE="$(InputPath)"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat;for;f90"
# Begin Source File
SOURCE=.\global\aurora.cpp
# End Source File
# Begin Source File
SOURCE=.\global\dll_int.cpp
# End Source File
# Begin Source File
@ -261,14 +265,66 @@ SOURCE=.\global\view.cpp
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# Begin Source File
SOURCE=..\common\anorms.h
# End Source File
# Begin Source File
SOURCE=.\global\aurora.h
# End Source File
# Begin Source File
SOURCE=..\common\basetypes.h
# End Source File
# Begin Source File
SOURCE=..\common\beam_def.h
# End Source File
# Begin Source File
SOURCE=..\common\bullets.h
# End Source File
# Begin Source File
SOURCE=..\common\clgame_api.h
# End Source File
# Begin Source File
SOURCE=..\common\const.h
# End Source File
# Begin Source File
SOURCE=..\common\cvardef.h
# End Source File
# Begin Source File
SOURCE=..\common\effects_api.h
# End Source File
# Begin Source File
SOURCE=.\global\enginecallback.h
# End Source File
# Begin Source File
SOURCE=..\common\entity_def.h
# End Source File
# Begin Source File
SOURCE=..\common\entity_state.h
# End Source File
# Begin Source File
SOURCE=..\common\event_api.h
# End Source File
# Begin Source File
SOURCE=.\global\extdll.h
# End Source File
# Begin Source File
SOURCE=..\common\game_shared.h
# End Source File
# Begin Source File
SOURCE=.\hud\hud.h
# End Source File
# Begin Source File
@ -301,6 +357,10 @@ SOURCE=..\pm_shared\pm_movevars.h
# End Source File
# Begin Source File
SOURCE=..\common\pm_shared.h
# End Source File
# Begin Source File
SOURCE=.\global\r_beams.h
# End Source File
# Begin Source File
@ -313,6 +373,38 @@ SOURCE=.\global\r_weather.h
# End Source File
# Begin Source File
SOURCE=..\common\ref_params.h
# End Source File
# Begin Source File
SOURCE=..\common\studio_event.h
# End Source File
# Begin Source File
SOURCE=..\common\studio_ref.h
# End Source File
# Begin Source File
SOURCE=..\common\te_shared.h
# End Source File
# Begin Source File
SOURCE=..\common\tmpent_def.h
# End Source File
# Begin Source File
SOURCE=..\common\trace_def.h
# End Source File
# Begin Source File
SOURCE=..\common\triangle_api.h
# End Source File
# Begin Source File
SOURCE=..\common\usercmd.h
# End Source File
# Begin Source File
SOURCE=.\global\utils.h
# End Source File
# Begin Source File

1016
client/global/aurora.cpp Normal file

File diff suppressed because it is too large Load Diff

212
client/global/aurora.h Normal file
View File

@ -0,0 +1,212 @@
// 02/08/02 November235: Particle System
#pragma once
class ParticleType;
class ParticleSystem;
void CreateAurora( int idx, char *file ); //make new partsystem
#define COLLISION_NONE 0
#define COLLISION_DIE 1
#define COLLISION_BOUNCE 2
struct particle
{
particle *nextpart;
particle *m_pOverlay; // for making multi-layered particles
ParticleType *pType;
Vector origin;
Vector velocity;
Vector accel;
Vector m_vecWind;
int m_iEntIndex; // if non-zero, this particle is tied to the given entity
float m_fRed;
float m_fGreen;
float m_fBlue;
float m_fRedStep;
float m_fGreenStep;
float m_fBlueStep;
float m_fAlpha;
float m_fAlphaStep;
float frame;
float m_fFrameStep;
float m_fAngle;
float m_fAngleStep;
float m_fSize;
float m_fSizeStep;
float m_fDrag;
float age;
float age_death;
float age_spray;
};
class RandomRange
{
public:
RandomRange() { m_fMin = m_fMax = 0; m_bDefined = false; }
RandomRange(float fValue) { m_fMin = m_fMax = fValue; m_bDefined = true; }
RandomRange(float fMin, float fMax) { m_fMin = fMin; m_fMax = fMax; m_bDefined = true; }
RandomRange( char *szToken );
float m_fMax;
float m_fMin;
bool m_bDefined;
float GetInstance()
{
return RANDOM_FLOAT( m_fMin, m_fMax );
}
float GetOffset( float fBasis )
{
return GetInstance() - fBasis;
}
bool IsDefined( void )
{
return m_bDefined;
}
};
#define MAX_TYPENAME 256
class ParticleType
{
public:
ParticleType( ParticleType *pNext = NULL );
ParticleType( char *szFilename );
bool m_bIsDefined; // is this ParticleType just a placeholder?
kRenderMode_t m_iRenderMode;
int m_iDrawCond;
int m_iCollision;
RandomRange m_Bounce;
RandomRange m_BounceFriction;
bool m_bBouncing;
RandomRange m_Life;
RandomRange m_StartAlpha;
RandomRange m_EndAlpha;
RandomRange m_StartRed;
RandomRange m_EndRed;
RandomRange m_StartGreen;
RandomRange m_EndGreen;
RandomRange m_StartBlue;
RandomRange m_EndBlue;
RandomRange m_StartSize;
RandomRange m_SizeDelta;
RandomRange m_EndSize;
RandomRange m_StartFrame;
RandomRange m_EndFrame;
RandomRange m_FrameRate; // incompatible with EndFrame
bool m_bEndFrame;
RandomRange m_StartAngle;
RandomRange m_AngleDelta;
RandomRange m_SprayRate;
RandomRange m_SprayForce;
RandomRange m_SprayPitch;
RandomRange m_SprayYaw;
RandomRange m_SprayRoll;
ParticleType *m_pSprayType;
RandomRange m_Gravity;
RandomRange m_WindStrength;
RandomRange m_WindYaw;
int m_SpriteIndex;
ParticleType *m_pOverlayType;
RandomRange m_Drag;
ParticleType *m_pNext;
char m_szName[MAX_TYPENAME];
// here is a particle system. Add a (set of) particles according to this type, and initialise their values.
particle* CreateParticle(ParticleSystem *pSys);//particle *pPart);
// initialise this particle. Does not define velocity or age.
void InitParticle(particle *pPart, ParticleSystem *pSys);
};
class ParticleSystem
{
public:
ParticleSystem( int entindex, char *szFilename );
~ParticleSystem( void );
void AllocateParticles( int iParticles );
void CalculateDistance();
ParticleType *GetType( const char *szName );
ParticleType *AddPlaceholderType( const char *szName );
ParticleType *ParseType( const char **szFile );
edict_t *GetEntity() { return GetEntityByIndex( m_iEntIndex ); }
static float c_fCosTable[360 + 90];
static bool c_bCosTableInit;
// General functions
bool UpdateSystem( float frametime ); //If this function returns false, the manager deletes the system
void DrawSystem();
particle *ActivateParticle(); // adds one of the free particles to the active list, and returns it for initialisation.
static float CosLookup(int angle) { return angle < 0? c_fCosTable[angle+360]: c_fCosTable[angle]; }
static float SinLookup(int angle) { return angle < -90? c_fCosTable[angle+450]: c_fCosTable[angle+90]; }
// returns false if the particle has died
bool UpdateParticle( particle *part, float frametime );
void DrawParticle( particle* part, Vector &right, Vector &up );
// Utility functions that have to be public
bool ParticleIsVisible( particle* part );
// Pointer to next system for linked list structure
ParticleSystem* m_pNextSystem;
particle* m_pActiveParticle;
float m_fViewerDist;
int m_iEntIndex;
int m_iEntAttachment;
int m_iKillCondition;
int enable;
private:
// the block of allocated particles
particle* m_pAllParticles;
// First particles in the linked list for the active particles and the dead particles
particle* m_pFreeParticle;
particle* m_pMainParticle; // the "source" particle.
ParticleType *m_pFirstType;
ParticleType *m_pMainType;
};
class ParticleSystemManager
{
public:
ParticleSystemManager( void );
~ParticleSystemManager( void );
ParticleSystem *FindSystem( edict_t* pEntity );
void SortSystems( void );
void AddSystem( ParticleSystem* );
void UpdateSystems( void );
void ClearSystems( void );
ParticleSystem *m_pFirstSystem;
};
extern ParticleSystemManager* g_pParticleSystems;

View File

@ -8,6 +8,7 @@
#include "ref_params.h"
#include "studio_ref.h"
#include "hud.h"
#include "aurora.h"
#include "r_particle.h"
#include "r_tempents.h"
#include "r_beams.h"
@ -79,12 +80,15 @@ int CreateAPI( HUD_FUNCTIONS *pFunctionTable, cl_enginefuncs_t* pEngfuncsFromEng
int HUD_VidInit( void )
{
if( g_pParticleSystems )
if ( g_pParticleSystems )
g_pParticleSystems->ClearSystems();
if( g_pViewRenderBeams )
if ( g_pViewRenderBeams )
g_pViewRenderBeams->ClearBeams();
if ( g_pParticles )
g_pParticles->Clear();
if ( g_pTempEnts )
g_pTempEnts->Clear();
@ -111,6 +115,13 @@ void HUD_ShutdownEffects( void )
g_pViewRenderBeams = NULL;
}
if ( g_pParticles )
{
// init particles
delete g_pParticles;
g_pParticles = NULL;
}
if ( g_pTempEnts )
{
// init client tempents
@ -137,6 +148,7 @@ void HUD_Init( void )
g_pParticleSystems = new ParticleSystemManager();
g_pViewRenderBeams = new CViewRenderBeams();
g_pParticles = new CParticleSystem();
g_pTempEnts = new CTempEnts();
InitRain(); // init weather system
@ -345,7 +357,7 @@ int HUD_AddVisibleEntity( edict_t *pEnt, int ed_type )
float shellScale = 1.0f;
int result;
if( pEnt->v.renderfx == kRenderFxGlowShell )
if ( pEnt->v.renderfx == kRenderFxGlowShell )
{
oldRenderAmt = pEnt->v.renderamt;
oldScale = pEnt->v.scale;
@ -355,7 +367,7 @@ int HUD_AddVisibleEntity( edict_t *pEnt, int ed_type )
result = CL_AddEntity( pEnt, ed_type, -1 );
if( pEnt->v.renderfx == kRenderFxGlowShell )
if ( pEnt->v.renderfx == kRenderFxGlowShell )
{
shellScale = (oldRenderAmt * 0.0015f); // shellOffset
pEnt->v.scale = oldScale + shellScale; // sets new scale
@ -370,19 +382,39 @@ int HUD_AddVisibleEntity( edict_t *pEnt, int ed_type )
}
// add in muzzleflash effect
if( ed_type == ED_VIEWMODEL && pEnt->v.effects & EF_MUZZLEFLASH )
if ( pEnt->v.effects & EF_MUZZLEFLASH )
{
pEnt->v.effects &= ~EF_MUZZLEFLASH;
if( ed_type == ED_VIEWMODEL )
pEnt->v.effects &= ~EF_MUZZLEFLASH;
g_pTempEnts->WeaponFlash( pEnt, 1 );
}
// add light effect
if( pEnt->v.effects & EF_LIGHT )
if ( pEnt->v.effects & EF_LIGHT )
{
g_pTempEnts->AllocDLight( pEnt->v.origin, 200, 0.01f, 0 );
g_pTempEnts->AllocDLight( pEnt->v.origin, 100, 100, 100, 200, 0.001f, 0 );
g_pTempEnts->RocketFlare( pEnt->v.origin );
}
// add dimlight
if ( pEnt->v.effects & EF_DIMLIGHT )
{
if ( ed_type == ED_CLIENT )
{
EV_UpadteFlashlight( pEnt );
}
else
{
g_pTempEnts->AllocDLight( pEnt->v.origin, RANDOM_LONG( 200, 230 ), 0.001f, 0 );
}
}
if ( pEnt->v.effects & EF_BRIGHTLIGHT )
{
Vector pos( pEnt->v.origin.x, pEnt->v.origin.y, pEnt->v.origin.z + 16 );
g_pTempEnts->AllocDLight( pos, RANDOM_LONG( 400, 430 ), 0.001f, 0 );
}
return result;
}

View File

@ -172,6 +172,29 @@ void EV_MuzzleFlash( void )
ent->v.effects |= EF_MUZZLEFLASH;
}
//=================
// EV_FlashLight
//=================
void EV_UpadteFlashlight( edict_t *pEnt )
{
Vector vecSrc, vecEnd, vecPos, forward;
float rgba[4] = { 1.0f, 1.0f, 1.0f, 1.0f };
TraceResult tr;
AngleVectors( pEnt->v.viewangles, forward, NULL, NULL );
vecSrc = pEnt->v.origin +pEnt->v.view_ofs;
vecEnd = vecSrc + forward * 256;
UTIL_TraceLine( vecSrc, vecEnd, dont_ignore_monsters, pEnt, &tr );
if( tr.flFraction != 1.0f )
vecPos = tr.vecEndPos + (tr.vecPlaneNormal * -16.0f);
else vecPos = tr.vecEndPos;
// update flashlight endpos
g_engfuncs.pEfxAPI->CL_AllocDLight( vecPos, rgba, 96, 0.001f, 0, pEnt->serialnumber );
}
void HUD_CmdStart( const edict_t *player, int runfuncs )
{
}

View File

@ -6,6 +6,7 @@
#include "extdll.h"
#include "utils.h"
#include "r_beams.h"
#include "r_particle.h"
#include "r_tempents.h"
#include "effects_api.h"
#include "pm_materials.h"
@ -309,7 +310,7 @@ void EV_HLDM_GunshotDecalTrace( TraceResult *pTrace, char *decalName )
HSPRITE decal_tex = g_engfuncs.pEfxAPI->CL_DecalIndexFromName( decalName );
g_pTempEnts->PlaceDecal( pTrace->vecEndPos, pEnt, decal_tex );
CL_BulletParticles( pTrace->vecEndPos, Vector( 0, 0, -1 ));
g_pParticles->BulletParticles( pTrace->vecEndPos, Vector( 0, 0, -1 ));
}
}
@ -330,8 +331,7 @@ void EV_HLDM_DecalGunshot( TraceResult *pTrace, int iBulletType )
case BULLET_MP5:
case BULLET_357:
case BULLET_BUCKSHOT:
default:
// smoke and decal
default: // smoke and decal
EV_HLDM_GunshotDecalTrace( pTrace, EV_HLDM_DamageDecal( pe ));
break;
}

View File

@ -136,5 +136,6 @@ void EV_GetGunPosition( event_args_t *args, float *pos, float *origin );
void EV_CreateTracer( float *start, float *end );
void EV_EjectBrass( float *origin, float *velocity, float rotation, int model, int soundtype );
void EV_GetDefaultShellInfo( event_args_t *args, float *origin, float *velocity, float *ShellVelocity, float *ShellOrigin, float *forward, float *right, float *up, float forwardScale, float upScale, float rightScale );
void EV_UpadteFlashlight( edict_t *pEnt );
#endif // EV_HLDMH

View File

@ -33,6 +33,8 @@ cvar_t *cl_pitchdown;
cvar_t *v_centermove;
cvar_t *v_centerspeed;
cvar_t *cl_mouseaccel;
cvar_t *cl_particlelod;
cvar_t *cl_particles;
cvar_t *m_sensitivity;
cvar_t *m_filter; // mouse filtering
@ -688,6 +690,9 @@ void IN_Init( void )
m_yaw = CVAR_REGISTER ("m_yaw", "0.022", 0, "mouse yaw value" );
m_forward = CVAR_REGISTER ("m_forward", "1", 0, "mouse forward speed" );
m_side = CVAR_REGISTER ("m_side", "1", 0, "mouse side speed" );
cl_particles = CVAR_REGISTER ( "cl_particles", "1", FCVAR_ARCHIVE, "disables particle effects" );
cl_particlelod = CVAR_REGISTER ( "cl_lod_particle", "0", FCVAR_ARCHIVE, "enables particle LOD (1, 2, 3)" );
Cmd_AddCommand ("centerview", IN_CenterView, "gradually recenter view (stop looking up/down)" );

View File

@ -7,7 +7,7 @@
#define R_BEAMS_H
#include "beam_def.h"
#include "tempents.h"
#include "te_shared.h"
#define NOISE_DIVISIONS 128
#define MAX_BEAM_ENTS 2 // start & end entity

File diff suppressed because it is too large Load Diff

View File

@ -1,212 +1,84 @@
// 02/08/02 November235: Particle System
#pragma once
//=======================================================================
// Copyright XashXT Group 2010 ©
// r_particle.h - another particle manager (come from q2e 0.40)
//=======================================================================
class ParticleType;
class ParticleSystem;
void CreateAurora( int idx, char *file ); //make new partsystem
#ifndef R_PARTICLE_H
#define R_PARTICLE_H
#define COLLISION_NONE 0
#define COLLISION_DIE 1
#define COLLISION_BOUNCE 2
#define MAX_PARTICLES 2048
struct particle
{
particle *nextpart;
particle *m_pOverlay; // for making multi-layered particles
ParticleType *pType;
// built-in particle-system flags
#define FPART_BOUNCE (1<<0) // makes a bouncy particle
#define FPART_FRICTION (1<<1)
#define FPART_VERTEXLIGHT (1<<2) // give some ambient light for it
#define FPART_STRETCH (1<<3)
#define FPART_UNDERWATER (1<<4)
#define FPART_INSTANT (1<<5)
vec3_t origin;
vec3_t velocity;
vec3_t accel;
vec3_t m_vecWind;
int m_iEntIndex; // if non-zero, this particle is tied to the given entity
float m_fRed;
float m_fGreen;
float m_fBlue;
float m_fRedStep;
float m_fGreenStep;
float m_fBlueStep;
float m_fAlpha;
float m_fAlphaStep;
float frame;
float m_fFrameStep;
float m_fAngle;
float m_fAngleStep;
float m_fSize;
float m_fSizeStep;
float m_fDrag;
float age;
float age_death;
float age_spray;
};
class RandomRange
class CParticle
{
public:
RandomRange() { m_fMin = m_fMax = 0; m_bDefined = false; }
RandomRange(float fValue) { m_fMin = m_fMax = fValue; m_bDefined = true; }
RandomRange(float fMin, float fMax) { m_fMin = fMin; m_fMax = fMax; m_bDefined = true; }
RandomRange( char *szToken );
Vector origin;
Vector oldorigin;
float m_fMax;
float m_fMin;
bool m_bDefined;
Vector velocity; // linear velocity
Vector accel;
Vector color;
Vector colorVelocity;
float alpha;
float alphaVelocity;
float radius;
float radiusVelocity;
float length;
float lengthVelocity;
float rotation; // texture ROLL angle
float bounceFactor;
float scale;
float GetInstance()
{
return RANDOM_FLOAT( m_fMin, m_fMax );
}
CParticle *next;
HSPRITE m_hSprite;
float GetOffset( float fBasis )
{
return GetInstance() - fBasis;
}
float flTime;
int flags;
bool IsDefined( void )
{
return m_bDefined;
}
bool Evaluate( float gravity );
};
#define MAX_TYPENAME 256
class ParticleType
class CParticleSystem
{
CParticle *m_pActiveParticles;
CParticle *m_pFreeParticles;
CParticle m_pParticles[MAX_PARTICLES];
// private partsystem shaders
HSPRITE m_hDefaultParticle;
HSPRITE m_hGlowParticle;
HSPRITE m_hDroplet;
HSPRITE m_hBubble;
HSPRITE m_hSparks;
HSPRITE m_hSmoke;
public:
ParticleType( ParticleType *pNext = NULL );
ParticleType( char *szFilename );
CParticleSystem( void );
virtual ~CParticleSystem( void );
bool m_bIsDefined; // is this ParticleType just a placeholder?
kRenderMode_t m_iRenderMode;
int m_iDrawCond;
int m_iCollision;
RandomRange m_Bounce;
RandomRange m_BounceFriction;
bool m_bBouncing;
void Clear( void );
void Update( void );
void FreeParticle( CParticle *pCur );
CParticle *AllocParticle( void );
bool AddParticle( CParticle *src, HSPRITE shader, int flags );
RandomRange m_Life;
RandomRange m_StartAlpha;
RandomRange m_EndAlpha;
RandomRange m_StartRed;
RandomRange m_EndRed;
RandomRange m_StartGreen;
RandomRange m_EndGreen;
RandomRange m_StartBlue;
RandomRange m_EndBlue;
RandomRange m_StartSize;
RandomRange m_SizeDelta;
RandomRange m_EndSize;
RandomRange m_StartFrame;
RandomRange m_EndFrame;
RandomRange m_FrameRate; // incompatible with EndFrame
bool m_bEndFrame;
RandomRange m_StartAngle;
RandomRange m_AngleDelta;
RandomRange m_SprayRate;
RandomRange m_SprayForce;
RandomRange m_SprayPitch;
RandomRange m_SprayYaw;
RandomRange m_SprayRoll;
ParticleType *m_pSprayType;
RandomRange m_Gravity;
RandomRange m_WindStrength;
RandomRange m_WindYaw;
int m_SpriteIndex;
ParticleType *m_pOverlayType;
RandomRange m_Drag;
ParticleType *m_pNext;
char m_szName[MAX_TYPENAME];
// here is a particle system. Add a (set of) particles according to this type, and initialise their values.
particle* CreateParticle(ParticleSystem *pSys);//particle *pPart);
// initialise this particle. Does not define velocity or age.
void InitParticle(particle *pPart, ParticleSystem *pSys);
// example presets
void ExplosionParticles( const Vector pos );
void BulletParticles( const Vector org, const Vector dir );
void BubbleParticles( const Vector org, int count, float magnitude );
void SparkParticles( const Vector org, const Vector dir );
void RicochetSparks( const Vector org, float scale );
void SmokeParticles( const Vector pos, int count );
void TeleportParticles( const Vector org );
};
class ParticleSystem
{
public:
ParticleSystem( int entindex, char *szFilename );
~ParticleSystem( void );
void AllocateParticles( int iParticles );
void CalculateDistance();
extern CParticleSystem *g_pParticles;
extern ref_params_t *gpViewParams;
ParticleType *GetType( const char *szName );
ParticleType *AddPlaceholderType( const char *szName );
ParticleType *ParseType( const char **szFile );
edict_t *GetEntity() { return GetEntityByIndex( m_iEntIndex ); }
static float c_fCosTable[360 + 90];
static bool c_bCosTableInit;
// General functions
bool UpdateSystem( float frametime ); //If this function returns false, the manager deletes the system
void DrawSystem();
particle *ActivateParticle(); // adds one of the free particles to the active list, and returns it for initialisation.
static float CosLookup(int angle) { return angle < 0? c_fCosTable[angle+360]: c_fCosTable[angle]; }
static float SinLookup(int angle) { return angle < -90? c_fCosTable[angle+450]: c_fCosTable[angle+90]; }
// returns false if the particle has died
bool UpdateParticle( particle *part, float frametime );
void DrawParticle( particle* part, vec3_t &right, vec3_t &up );
// Utility functions that have to be public
bool ParticleIsVisible( particle* part );
// Pointer to next system for linked list structure
ParticleSystem* m_pNextSystem;
particle* m_pActiveParticle;
float m_fViewerDist;
int m_iEntIndex;
int m_iEntAttachment;
int m_iKillCondition;
int enable;
private:
// the block of allocated particles
particle* m_pAllParticles;
// First particles in the linked list for the active particles and the dead particles
particle* m_pFreeParticle;
particle* m_pMainParticle; // the "source" particle.
ParticleType *m_pFirstType;
ParticleType *m_pMainType;
};
class ParticleSystemManager
{
public:
ParticleSystemManager( void );
~ParticleSystemManager( void );
ParticleSystem *FindSystem( edict_t* pEntity );
void SortSystems( void );
void AddSystem( ParticleSystem* );
void UpdateSystems( void );
void ClearSystems( void );
ParticleSystem *m_pFirstSystem;
};
extern ParticleSystemManager* g_pParticleSystems;
#endif//R_PARTICLE_H

View File

@ -9,6 +9,7 @@
#include "triangle_api.h"
#include "effects_api.h"
#include "pm_movevars.h"
#include "r_particle.h"
#include "r_tempents.h"
#include "ev_hldm.h"
#include "r_beams.h"
@ -1059,9 +1060,9 @@ void CTempEnts::Sprite_Trail( int type, const Vector &vecStart, const Vector &ve
void CTempEnts::TracerEffect( const Vector &start, const Vector &end )
{
vec3_t vec;
cparticle_t src;
int pal = 238; // nice color for tracers
vec3_t vec;
CParticle src;
int pal = 238; // nice color for tracers
if( !start || !end ) return;
@ -1087,7 +1088,7 @@ void CTempEnts::TracerEffect( const Vector &start, const Vector &end )
src.velocity[2] = 6000.0f * vec[2];
// 0 is a quake particle
g_engfuncs.pEfxAPI->R_AllocParticle( &src, 0, PARTICLE_STRETCH );
g_pParticles->AddParticle( &src, 0, FPART_STRETCH );
}
void CTempEnts::WeaponFlash( edict_t *pEnt, int iAttachment )

View File

@ -9,7 +9,8 @@
//-----------------------------------------------------------------------------
// Purpose: implementation for temp entities
//-----------------------------------------------------------------------------
#include "tempents.h"
#include "te_shared.h"
#include "tmpent_def.h"
#include "effects_api.h"
#define MAX_TEMP_ENTITIES 500

View File

@ -8,6 +8,7 @@
#include "studio_event.h"
#include "effects_api.h"
#include "pm_movevars.h"
#include "r_particle.h"
#include "r_tempents.h"
#include "ev_hldm.h"
#include "r_beams.h"
@ -15,355 +16,6 @@
#define MAX_CHANNELS 4 // hl1 and hl2 supported 4 channels for messges
/*
=================
CL_ExplosionParticles
=================
*/
void CL_ExplosionParticles( const Vector pos )
{
cparticle_t src;
int flags;
if( !CVAR_GET_FLOAT( "cl_particles" ))
return;
flags = (PARTICLE_STRETCH|PARTICLE_BOUNCE|PARTICLE_FRICTION);
for( int i = 0; i < 384; i++ )
{
src.origin.x = pos.x + RANDOM_LONG( -16, 16 );
src.origin.y = pos.y + RANDOM_LONG( -16, 16 );
src.origin.z = pos.z + RANDOM_LONG( -16, 16 );
src.velocity.x = RANDOM_LONG( -256, 256 );
src.velocity.y = RANDOM_LONG( -256, 256 );
src.velocity.z = RANDOM_LONG( -256, 256 );
src.accel.x = src.accel.y = 0;
src.accel.z = -60 + RANDOM_FLOAT( -30, 30 );
src.color = Vector( 1, 1, 1 );
src.colorVelocity = Vector( 0, 0, 0 );
src.alpha = 1.0;
src.alphaVelocity = -3.0;
src.radius = 0.5 + RANDOM_FLOAT( -0.2, 0.2 );
src.radiusVelocity = 0;
src.length = 8 + RANDOM_FLOAT( -4, 4 );
src.lengthVelocity = 8 + RANDOM_FLOAT( -4, 4 );
src.rotation = 0;
src.bounceFactor = 0.2;
if( !g_engfuncs.pEfxAPI->R_AllocParticle( &src, gHUD.m_hSparks, flags ))
return;
}
// smoke
flags = PARTICLE_VERTEXLIGHT;
for( i = 0; i < 5; i++ )
{
src.origin.x = pos.x + RANDOM_FLOAT( -10, 10 );
src.origin.y = pos.y + RANDOM_FLOAT( -10, 10 );
src.origin.z = pos.z + RANDOM_FLOAT( -10, 10 );
src.velocity.x = RANDOM_FLOAT( -10, 10 );
src.velocity.y = RANDOM_FLOAT( -10, 10 );
src.velocity.z = RANDOM_FLOAT( -10, 10 ) + RANDOM_FLOAT( -5, 5 ) + 25;
src.accel = Vector( 0, 0, 0 );
src.color = Vector( 0, 0, 0 );
src.colorVelocity = Vector( 0.75, 0.75, 0.75 );
src.alpha = 0.5;
src.alphaVelocity = RANDOM_FLOAT( -0.1, -0.2 );
src.radius = 30 + RANDOM_FLOAT( -15, 15 );
src.radiusVelocity = 15 + RANDOM_FLOAT( -7.5, 7.5 );
src.length = 1;
src.lengthVelocity = 0;
src.rotation = RANDOM_LONG( 0, 360 );
if( !g_engfuncs.pEfxAPI->R_AllocParticle( &src, gHUD.m_hSmoke, flags ))
return;
}
}
/*
=================
CL_BubbleParticles
=================
*/
void CL_BubbleParticles( const Vector org, int count, float magnitude )
{
cparticle_t src;
int i;
if( !CVAR_GET_FLOAT( "cl_particles" ))
return;
for( i = 0; i < count; i++ )
{
src.origin.x = org[0] + RANDOM_FLOAT( -magnitude, magnitude );
src.origin.y = org[1] + RANDOM_FLOAT( -magnitude, magnitude );
src.origin.z = org[2] + RANDOM_FLOAT( -magnitude, magnitude );
src.velocity.x = RANDOM_FLOAT( -5, 5 );
src.velocity.y = RANDOM_FLOAT( -5, 5 );
src.velocity.z = RANDOM_FLOAT( -5, 5 ) + (25 + RANDOM_FLOAT( -5, 5 ));
src.accel = Vector( 0, 0, 0 );
src.color = Vector( 1, 1, 1 );
src.colorVelocity = Vector( 0, 0, 0 );
src.alpha = 1.0;
src.alphaVelocity = -(0.4 + RANDOM_FLOAT( 0, 0.2 ));
src.radius = 1 + RANDOM_FLOAT( -0.5, 0.5 );
src.radiusVelocity = 0;
src.length = 1;
src.lengthVelocity = 0;
src.rotation = 0;
if( !g_engfuncs.pEfxAPI->R_AllocParticle( &src, gHUD.m_hBubble, PARTICLE_UNDERWATER ))
return;
}
}
/*
=================
CL_BulletParticles
=================
*/
void CL_SparkParticles( const Vector org, const Vector dir )
{
cparticle_t src;
int i, flags;
// sparks
flags = (PARTICLE_STRETCH|PARTICLE_BOUNCE|PARTICLE_FRICTION);
for( i = 0; i < 16; i++ )
{
src.origin.x = org[0] + dir[0] * 2 + RANDOM_FLOAT( -1, 1 );
src.origin.y = org[1] + dir[1] * 2 + RANDOM_FLOAT( -1, 1 );
src.origin.z = org[2] + dir[2] * 2 + RANDOM_FLOAT( -1, 1 );
src.velocity.x = dir[0] * 180 + RANDOM_FLOAT( -60, 60 );
src.velocity.y = dir[1] * 180 + RANDOM_FLOAT( -60, 60 );
src.velocity.z = dir[2] * 180 + RANDOM_FLOAT( -60, 60 );
src.accel.x = src.accel.y = 0;
src.accel.z = -120 + RANDOM_FLOAT( -60, 60 );
src.color = Vector( 1.0, 1.0f, 1.0f );
src.colorVelocity = Vector( 0, 0, 0 );
src.alpha = 1.0;
src.alphaVelocity = -8.0;
src.radius = 0.4 + RANDOM_FLOAT( -0.2, 0.2 );
src.radiusVelocity = 0;
src.length = 8 + RANDOM_FLOAT( -4, 4 );
src.lengthVelocity = 8 + RANDOM_FLOAT( -4, 4 );
src.rotation = 0;
src.bounceFactor = 0.2;
if( !g_engfuncs.pEfxAPI->R_AllocParticle( &src, gHUD.m_hSparks, flags ))
return;
}
}
/*
=================
CL_RicochetSparks
=================
*/
void CL_RicochetSparks( const Vector org, float scale )
{
cparticle_t src;
int i, flags;
// sparks
flags = (PARTICLE_STRETCH|PARTICLE_BOUNCE|PARTICLE_FRICTION);
for( i = 0; i < 16; i++ )
{
src.origin.x = org[0] + RANDOM_FLOAT( -1, 1 );
src.origin.y = org[1] + RANDOM_FLOAT( -1, 1 );
src.origin.z = org[2] + RANDOM_FLOAT( -1, 1 );
src.velocity.x = RANDOM_FLOAT( -60, 60 );
src.velocity.y = RANDOM_FLOAT( -60, 60 );
src.velocity.z = RANDOM_FLOAT( -60, 60 );
src.accel.x = src.accel.y = 0;
src.accel.z = -120 + RANDOM_FLOAT( -60, 60 );
src.color = Vector( 1.0, 1.0f, 1.0f );
src.colorVelocity = Vector( 0, 0, 0 );
src.alpha = 1.0;
src.alphaVelocity = -8.0;
src.radius = scale + RANDOM_FLOAT( -0.2, 0.2 );
src.radiusVelocity = 0;
src.length = scale + RANDOM_FLOAT( -0.2, 0.2 );
src.lengthVelocity = scale + RANDOM_FLOAT( -0.2, 0.2 );
src.rotation = 0;
src.bounceFactor = 0.2;
if( !g_engfuncs.pEfxAPI->R_AllocParticle( &src, gHUD.m_hSparks, flags ))
return;
}
}
void CL_SmokeParticles( const Vector pos, int count )
{
cparticle_t src;
int i, flags;
if( !CVAR_GET_FLOAT( "cl_particles" ))
return;
// smoke
flags = PARTICLE_VERTEXLIGHT;
for( i = 0; i < count; i++ )
{
src.origin.x = pos.x + RANDOM_FLOAT( -10, 10 );
src.origin.y = pos.y + RANDOM_FLOAT( -10, 10 );
src.origin.z = pos.z + RANDOM_FLOAT( -10, 10 );
src.velocity.x = RANDOM_FLOAT( -10, 10 );
src.velocity.y = RANDOM_FLOAT( -10, 10 );
src.velocity.z = RANDOM_FLOAT( -10, 10 ) + RANDOM_FLOAT( -5, 5 ) + 25;
src.accel = Vector( 0, 0, 0 );
src.color = Vector( 0, 0, 0 );
src.colorVelocity = Vector( 0.75, 0.75, 0.75 );
src.alpha = 0.5;
src.alphaVelocity = RANDOM_FLOAT( -0.1, -0.2 );
src.radius = 30 + RANDOM_FLOAT( -15, 15 );
src.radiusVelocity = 15 + RANDOM_FLOAT( -7.5, 7.5 );
src.length = 1;
src.lengthVelocity = 0;
src.rotation = RANDOM_LONG( 0, 360 );
if( !g_engfuncs.pEfxAPI->R_AllocParticle( &src, gHUD.m_hSmoke, flags ))
return;
}
}
/*
=================
CL_BulletParticles
=================
*/
void CL_BulletParticles( const Vector org, const Vector dir )
{
cparticle_t src;
int flags;
int i, cnt, count;
if( !CVAR_GET_FLOAT( "cl_particles" ))
return;
count = RANDOM_LONG( 3, 8 );
cnt = POINT_CONTENTS( org );
if( cnt == CONTENTS_WATER )
{
CL_BubbleParticles( org, count, 0 );
return;
}
// sparks
flags = (PARTICLE_STRETCH|PARTICLE_BOUNCE|PARTICLE_FRICTION);
for( i = 0; i < count; i++ )
{
src.origin.x = org[0] + dir[0] * 2 + RANDOM_FLOAT( -1, 1 );
src.origin.y = org[1] + dir[1] * 2 + RANDOM_FLOAT( -1, 1 );
src.origin.z = org[2] + dir[2] * 2 + RANDOM_FLOAT( -1, 1 );
src.velocity.x = dir[0] * 180 + RANDOM_FLOAT( -60, 60 );
src.velocity.y = dir[1] * 180 + RANDOM_FLOAT( -60, 60 );
src.velocity.z = dir[2] * 180 + RANDOM_FLOAT( -60, 60 );
src.accel.x = src.accel.y = 0;
src.accel.z = -120 + RANDOM_FLOAT( -60, 60 );
src.color = Vector( 1.0, 1.0f, 1.0f );
src.colorVelocity = Vector( 0, 0, 0 );
src.alpha = 1.0;
src.alphaVelocity = -8.0;
src.radius = 0.4 + RANDOM_FLOAT( -0.2, 0.2 );
src.radiusVelocity = 0;
src.length = 8 + RANDOM_FLOAT( -4, 4 );
src.lengthVelocity = 8 + RANDOM_FLOAT( -4, 4 );
src.rotation = 0;
src.bounceFactor = 0.2;
if( !g_engfuncs.pEfxAPI->R_AllocParticle( &src, gHUD.m_hSparks, flags ))
return;
}
// smoke
flags = PARTICLE_VERTEXLIGHT;
for( i = 0; i < 3; i++ )
{
src.origin.x = org[0] + dir[0] * 5 + RANDOM_FLOAT( -1, 1 );
src.origin.y = org[1] + dir[1] * 5 + RANDOM_FLOAT( -1, 1 );
src.origin.z = org[2] + dir[2] * 5 + RANDOM_FLOAT( -1, 1 );
src.velocity.x = RANDOM_FLOAT( -2.5, 2.5 );
src.velocity.y = RANDOM_FLOAT( -2.5, 2.5 );
src.velocity.z = RANDOM_FLOAT( -2.5, 2.5 ) + (25 + RANDOM_FLOAT( -5, 5 ));
src.accel = Vector( 0, 0, 0 );
src.color = Vector( 0.4, 0.4, 0.4 );
src.colorVelocity = Vector( 0.2, 0.2, 0.2 );
src.alpha = 0.5;
src.alphaVelocity = -(0.4 + RANDOM_FLOAT( 0, 0.2 ));
src.radius = 3 + RANDOM_FLOAT( -1.5, 1.5 );
src.radiusVelocity = 5 + RANDOM_FLOAT( -2.5, 2.5 );
src.length = 1;
src.lengthVelocity = 0;
src.rotation = RANDOM_LONG( 0, 360 );
if( !g_engfuncs.pEfxAPI->R_AllocParticle( &src, gHUD.m_hSmoke, flags ))
return;
}
}
/*
=================
CL_TeleportParticles
creates a particle box
=================
*/
void CL_TeleportParticles( const Vector org )
{
cparticle_t src;
vec3_t dir;
float vel, color;
int x, y, z;
if( !CVAR_GET_FLOAT( "cl_particles" ))
return;
for( x = -16; x <= 16; x += 4 )
{
for( y = -16; y <= 16; y += 4 )
{
for( z = -16; z <= 32; z += 4 )
{
dir = Vector( y*8, x*8, z*8 ).Normalize();
vel = 50 + RANDOM_LONG( 0, 64 );
color = RANDOM_FLOAT( 0.1, 0.3 );
src.origin.x = org[0] + x + RANDOM_LONG( 0, 4 );
src.origin.y = org[1] + y + RANDOM_LONG( 0, 4 );
src.origin.z = org[2] + z + RANDOM_LONG( 0, 4 );
src.velocity[0] = dir[0] * vel;
src.velocity[1] = dir[1] * vel;
src.velocity[2] = dir[2] * vel;
src.accel[0] = 0;
src.accel[1] = 0;
src.accel[2] = -40;
src.color = Vector( color, color, color );
src.colorVelocity = Vector( 0, 0, 0 );
src.alpha = 1.0;
src.alphaVelocity = -1.0 / (0.3 + RANDOM_LONG( 0, 0.16 ));
src.radius = 2;
src.radiusVelocity = 0;
src.length = 1;
src.lengthVelocity = 0;
src.rotation = 0;
if( !g_engfuncs.pEfxAPI->R_AllocParticle( &src, gHUD.m_hGlowParticle, 0 ))
return;
}
}
}
}
void HUD_AddClientMessage( void )
{
static client_textmessage_t gTextMsg[MAX_CHANNELS], *msg;
@ -533,7 +185,7 @@ void TE_ParseGunShot( void )
pos.y = READ_COORD();
pos.z = READ_COORD();
CL_BulletParticles( pos, Vector( 0, 0, -1 ));
g_pParticles->BulletParticles( pos, Vector( 0, 0, -1 ));
if( RANDOM_LONG( 0, 32 ) <= 8 ) // 25% chanse
{
@ -582,7 +234,7 @@ void TE_ParseExplosion( void )
}
if(!( flags & TE_EXPLFLAG_NOPARTICLES ))
CL_ExplosionParticles( pos );
g_pParticles->ExplosionParticles( pos );
if( RANDOM_LONG( 0, 1 ))
g_pTempEnts->PlaceDecal( pos, dir, scale, g_engfuncs.pEfxAPI->CL_DecalIndexFromName( "{scorch1" ));
else g_pTempEnts->PlaceDecal( pos, dir, scale, g_engfuncs.pEfxAPI->CL_DecalIndexFromName( "{scorch2" ));
@ -721,7 +373,7 @@ void TE_ParseSparks( void )
pos.z = READ_COORD();
g_engfuncs.pEfxAPI->CL_FindExplosionPlane( pos, 1.0f, dir );
CL_SparkParticles( pos, dir );
g_pParticles->SparkParticles( pos, dir );
}
/*
@ -739,7 +391,7 @@ void TE_ParseTeleport( void )
pos.y = READ_COORD();
pos.z = READ_COORD();
CL_TeleportParticles( pos );
g_pParticles->TeleportParticles( pos );
}
/*
@ -977,7 +629,7 @@ void HUD_ParseTempEntity( void )
pos.z = READ_COORD();
dir = READ_DIR();
READ_SHORT(); // FIXME: skip entindex
CL_BulletParticles( pos, dir );
g_pParticles->BulletParticles( pos, dir );
g_pTempEnts->PlaceDecal( pos, dir, 2, g_engfuncs.pEfxAPI->CL_DecalIndex( READ_BYTE() ));
if( RANDOM_LONG( 0, 32 ) <= 8 ) // 25% chanse
@ -999,7 +651,7 @@ void HUD_ParseTempEntity( void )
pos.y = READ_COORD();
pos.z = READ_COORD();
radius = READ_BYTE() / 10.0f;
CL_RicochetSparks( pos, radius );
g_pParticles->RicochetSparks( pos, radius );
break;
case TE_ELIGHT:
READ_SHORT(); // skip attachment

View File

@ -5,6 +5,7 @@
#include "extdll.h"
#include "utils.h"
#include "aurora.h"
#include "r_particle.h"
#include "r_weather.h"
#include "r_beams.h"
@ -17,7 +18,11 @@ void HUD_DrawTransparentTriangles( void )
{
R_DrawWeather();
// Aurora particles
g_pParticleSystems->UpdateSystems();
// classic particles
g_pParticles->Update();
}
void HUD_RenderCallback( int fTrans )

View File

@ -582,6 +582,48 @@ void ClearAllFades( void )
memset( gHUD.m_FadeList, 0, sizeof( gHUD.m_FadeList ));
}
/*
====================
RotatePointAroundVector
====================
*/
void RotatePointAroundVector( Vector &dst, const Vector &dir, const Vector &point, float degrees )
{
float t0, t1;
float angle, c, s, d;
Vector vr, vu, vf;
angle = degrees * (M_PI / 180.f);
s = sin( angle );
c = cos( angle );
vf.Init( dir.x, dir.y, dir.z );
vr.Init( vf.z, -vf.x, vf.y );
// find a three vectors
d = DotProduct( vf, vr );
vr = (vr + ( vf * -d )).Normalize();
vu = CrossProduct( vr, vf );
t0 = vr[0] * c + vu[0] * -s;
t1 = vr[0] * s + vu[0] * c;
dst[0] = (t0 * vr[0] + t1 * vu[0] + vf[0] * vf[0]) * point[0]
+ (t0 * vr[1] + t1 * vu[1] + vf[0] * vf[1]) * point[1]
+ (t0 * vr[2] + t1 * vu[2] + vf[0] * vf[2]) * point[2];
t0 = vr[1] * c + vu[1] * -s;
t1 = vr[1] * s + vu[1] * c;
dst[1] = (t0 * vr[0] + t1 * vu[0] + vf[1] * vf[0]) * point[0]
+ (t0 * vr[1] + t1 * vu[1] + vf[1] * vf[1]) * point[1]
+ (t0 * vr[2] + t1 * vu[2] + vf[1] * vf[2]) * point[2];
t0 = vr[2] * c + vu[2] * -s;
t1 = vr[2] * s + vu[2] * c;
dst[2] = (t0 * vr[0] + t1 * vu[0] + vf[2] * vf[0]) * point[0]
+ (t0 * vr[1] + t1 * vu[1] + vf[2] * vf[1]) * point[1]
+ (t0 * vr[2] + t1 * vu[2] + vf[2] * vf[2]) * point[2];
}
/*
====================
UTIL_Probe

View File

@ -184,6 +184,7 @@ extern void UTIL_TraceHull( const Vector &vecStart, const Vector &vecEnd, IGNORE
// misc utilities
extern float UTIL_Probe( const Vector &origin, Vector *vecDirection, float strength );
extern void UTIL_GetForceDirection( const Vector &origin, float magnitude, Vector *resultDirection, float *resultForce );
extern void RotatePointAroundVector( Vector &dst, const Vector &dir, const Vector &point, float degrees );
// drawing stuff
extern client_sprite_t *SPR_GetList( const char *name, int *count );
@ -209,13 +210,12 @@ extern float v_idlescale;
extern int g_weaponselect;
extern int g_iAlive; // indicates alive local client or not
// tempents.c
extern void CL_BulletParticles( const Vector org, const Vector dir );
// input.cpp
extern cvar_t *v_centerspeed;
extern cvar_t *v_centermove;
extern cvar_t *cl_forwardspeed;
extern cvar_t *cl_particlelod;
extern cvar_t *cl_particles;
extern cvar_t *cl_lw;
extern int CL_ButtonBits( int bResetState );

View File

@ -133,14 +133,6 @@ void CHud :: VidInit( void )
// loading error sprite
m_HUD_error = GetSpriteIndex( "error" );
m_hHudError = GetSprite( m_HUD_error );
// loading TE shaders
m_hDefaultParticle = TEX_Load( "textures/particles/default" );
m_hGlowParticle = TEX_Load( "textures/particles/glow" );
m_hDroplet = TEX_Load( "textures/particles/droplet" );
m_hBubble = TEX_Load( "textures/particles/bubble" );
m_hSparks = TEX_Load( "textures/particles/spark" );
m_hSmoke = TEX_Load( "textures/particles/smoke" );
m_Sound.VidInit();
m_Ammo.VidInit();

View File

@ -706,14 +706,6 @@ public:
// error sprite
int m_HUD_error;
HSPRITE m_hHudError;
// some const shaders
HSPRITE m_hDefaultParticle;
HSPRITE m_hGlowParticle;
HSPRITE m_hDroplet;
HSPRITE m_hBubble;
HSPRITE m_hSparks;
HSPRITE m_hSmoke;
void AddHudElem( CHudBase *p );
float GetSensitivity() { return m_flMouseSensitivity; }

View File

@ -18,7 +18,7 @@
#include "extdll.h"
#include "utils.h"
#include "hud.h"
#include "r_particle.h"
#include "aurora.h"
// CHud message handlers
DECLARE_HUDMESSAGE( HUDColor );

View File

@ -47,6 +47,7 @@ void CM_InitBoxHull( void )
box_markbrushes[0] = box_brush;
box_cmodel->type = mod_brush;
box_cmodel->leaf.nummarkfaces = 0;
box_cmodel->leaf.markfaces = NULL;
box_cmodel->leaf.markbrushes = box_markbrushes;

View File

@ -32,7 +32,7 @@ int CM_StudioExtractBbox( dstudiohdr_t *phdr, int sequence, float *mins, float *
dstudioseqdesc_t *pseqdesc;
pseqdesc = (dstudioseqdesc_t *)((byte *)phdr + phdr->seqindex);
if(sequence == -1) return 0;
if( sequence == -1 ) return 0;
VectorCopy( pseqdesc[sequence].bbmin, mins );
VectorCopy( pseqdesc[sequence].bbmax, maxs );

View File

@ -11,13 +11,14 @@
typedef int HSPRITE; // handle to a graphic
typedef struct tempent_s TEMPENTITY;
typedef struct usercmd_s usercmd_t;
typedef struct cparticle_s cparticle_t;
typedef struct particle_s particle_t;
typedef struct skyportal_s skyportal_t;
typedef struct ref_params_s ref_params_t;
typedef struct dstudioevent_s dstudioevent_t;
typedef void (*ENTCALLBACK)( TEMPENTITY *ent );
typedef void (*HITCALLBACK)( TEMPENTITY *ent, TraceResult *ptr );
typedef int (*pfnUserMsgHook)( const char *pszName, int iSize, void *pbuf ); // user message handle
typedef enum { pt_static, pt_grav, pt_slowgrav, pt_fire, pt_explode, pt_explode2, pt_blob, pt_blob2 } ptype_t;
#define SCRINFO_VIRTUALSPACE 1

View File

@ -162,6 +162,8 @@
#define EF_PLANARSHADOW (1<<13) // use fast planarshadow method instead of shadow casters
#define EF_OCCLUSIONTEST (1<<14) // use occlusion test for this entity (e.g. glares)
#define EF_LASERSPOT (1<<15) // tempentity laserspot at attachment #1 from player or npc
#define EF_NOMIRRORS (1<<16) // entity won't reflecting in mirrors
#define EF_ONLYMIRRORS (1<<17) // entity will be drawing only in mirrors
// The explosion effect has some flags to control performance/aesthetic features:
#define TE_EXPLFLAG_NONE 0 // all flags clear makes default Half-Life explosion
@ -366,16 +368,6 @@ typedef enum
#define CL_ACTIVE 2 // draw normal hud
#define CL_PAUSED 3 // pause when active
// built-in particle-system flags
#define PARTICLE_GRAVITY 40 // default particle gravity
#define PARTICLE_BOUNCE (1<<0) // makes a bouncy particle
#define PARTICLE_FRICTION (1<<1)
#define PARTICLE_VERTEXLIGHT (1<<2) // give some ambient light for it
#define PARTICLE_STRETCH (1<<3)
#define PARTICLE_UNDERWATER (1<<4)
#define PARTICLE_INSTANT (1<<5)
// built-in decals flags
#define DECAL_FADEALPHA (1<<0) // fade decal by alpha instead color
#define DECAL_FADEENERGY (1<<1) // fade decal energy balls

View File

@ -5,108 +5,33 @@
#ifndef EFFECTS_API_H
#define EFFECTS_API_H
// temporary entity array
#define TENTPRIORITY_LOW 0
#define TENTPRIORITY_HIGH 1
// TEMPENTITY flags
#define FTENT_NONE 0
#define FTENT_SINEWAVE (1<<0)
#define FTENT_GRAVITY (1<<1)
#define FTENT_ROTATE (1<<2)
#define FTENT_SLOWGRAVITY (1<<3)
#define FTENT_SMOKETRAIL (1<<4)
#define FTENT_COLLIDEWORLD (1<<5)
#define FTENT_FLICKER (1<<6)
#define FTENT_FADEOUT (1<<7)
#define FTENT_SPRANIMATE (1<<8)
#define FTENT_HITSOUND (1<<9)
#define FTENT_SPIRAL (1<<10)
#define FTENT_SPRCYCLE (1<<11)
#define FTENT_COLLIDEALL (1<<12) // will collide with world and slideboxes
#define FTENT_PERSIST (1<<13) // tent is not removed when unable to draw
#define FTENT_COLLIDEKILL (1<<14) // tent is removed upon collision with anything
#define FTENT_PLYRATTACHMENT (1<<15) // tent is attached to a player (owner)
#define FTENT_SPRANIMATELOOP (1<<16) // animating sprite doesn't die when last frame is displayed
#define FTENT_SCALE (1<<17) // an experiment
#define FTENT_SPARKSHOWER (1<<18)
#define FTENT_NOMODEL (1<<19) // sets by engine, never draw (it just triggers other things)
#define FTENT_CLIENTCUSTOM (1<<20) // Must specify callback. Callback function is responsible
// for killing tempent and updating fields
// ( unless other flags specify how to do things )
#define FTENT_WINDBLOWN (1<<21) // This is set when the temp entity is blown by the wind
#define FTENT_NEVERDIE (1<<22) // Don't die as long as die != 0
#define FTENT_BEOCCLUDED (1<<23) // Don't draw if my specified normal's facing away from the view
struct tempent_s
struct particle_s
{
int flags;
byte color; // colorIndex for R_GetPaletteColor
vec3_t org;
vec3_t vel;
float die;
float m_flFrameMax;
float x, y;
vec3_t m_vecVelocity; // tent velocity
vec3_t m_vecAvelocity; // tent avelocity
vec3_t oldorigin; // attachment offset, beam endpoint etc
vec3_t tentOffset; // if attached, client origin + tentOffset = tent origin.
float fadeSpeed;
float bounceFactor;
int startAlpha; // starting fadeout intensity
sound_t hitSound;
byte priority; // 0 - low, 1 - high
short clientIndex; // if attached, this is the index of the client to stick to
// if COLLIDEALL, this is the index of the client to ignore
// TENTS with FTENT_PLYRATTACHMENT MUST set the clientindex!
void *pvEngineData; // private data that alloced and used by engine, freed in client.dll
HITCALLBACK hitcallback;
ENTCALLBACK callback;
TEMPENTITY *next;
// render-dependent fields
model_t modelindex; // index of precached model
vec3_t origin; // tent position
vec3_t angles; // tent angles
float m_flFrameRate; // studio, sprite framerate
float m_flFrame; // studio, sprite current frame
float m_flSpriteScale; // and model scale too
int m_nFlickerFrame; // for keyed dlights
int m_iAttachment; // sprite attachment
int m_iSequence; // studiomodel sequence
vec3_t renderColor; // tempentity rendercolor
byte renderAmt; // actual lpha value
byte renderMode; // fast method to set various effects
byte renderFX; // matched with entity renderfx
byte skin; // studiomodel skin
byte body; // studiomodel body
};
struct cparticle_s
{
vec3_t origin;
vec3_t velocity;
vec3_t accel;
vec3_t color;
vec3_t colorVelocity;
float alpha;
float alphaVelocity;
float radius;
float radiusVelocity;
float length;
float lengthVelocity;
float rotation;
float bounceFactor;
float ramp;
ptype_t type;
};
typedef struct efxapi_s
{
size_t api_size; // must match with sizeof( efxapi_t );
int (*R_AllocParticle)( cparticle_t *src, HSPRITE shader, int flags );
particle_t *(*R_AllocParticle)( void );
void (*R_BlobExplosion)( const float *org );
void (*R_LavaSplash)( const float *org );
void (*R_ParticleExplosion)( const float *org );
void (*R_ParticleExplosion2)( const float *org, int colorStart, int colorLength );
void (*R_RocketTrail)( const float *start, const float *end, int type );
void (*R_RunParticleEffect)( const float *org, const float *dir, int color, int count );
void (*R_TeleportSplash)( const float *org );
void (*R_GetPaletteColor)( int colorIndex, float *outColor );
int (*CL_DecalIndex)( int id );
int (*CL_DecalIndexFromName)( const char *szDecalName );
void (*R_SetDecal)( float *org, float *dir, float *rgba, float rot, float rad, HSPRITE hSpr, int flags );
void (*CL_AllocDLight)( const float *org, float *rgb, float rad, float time, int flags, int key );
void (*CL_AllocDLight)( const float *org, float *rgb, float rad, float lifetime, int flags, int key );
void (*CL_FindExplosionPlane)( const float *origin, float radius, float *result );
void (*R_LightForPoint)( const float *rgflOrigin, float *lightValue );
int (*CL_IsBoxVisible)( const float *mins, const float *maxs );

83
common/tmpent_def.h Normal file
View File

@ -0,0 +1,83 @@
//=======================================================================
// Copyright XashXT Group 2008 ©
// tmpent_def.h - temp entity edict
//=======================================================================
#ifndef TMPENT_DEF_H
#define TMPENT_DEF_H
// TEMPENTITY priority
#define TENTPRIORITY_LOW 0
#define TENTPRIORITY_HIGH 1
// TEMPENTITY flags
#define FTENT_NONE 0
#define FTENT_SINEWAVE (1<<0)
#define FTENT_GRAVITY (1<<1)
#define FTENT_ROTATE (1<<2)
#define FTENT_SLOWGRAVITY (1<<3)
#define FTENT_SMOKETRAIL (1<<4)
#define FTENT_COLLIDEWORLD (1<<5)
#define FTENT_FLICKER (1<<6)
#define FTENT_FADEOUT (1<<7)
#define FTENT_SPRANIMATE (1<<8)
#define FTENT_HITSOUND (1<<9)
#define FTENT_SPIRAL (1<<10)
#define FTENT_SPRCYCLE (1<<11)
#define FTENT_COLLIDEALL (1<<12) // will collide with world and slideboxes
#define FTENT_PERSIST (1<<13) // tent is not removed when unable to draw
#define FTENT_COLLIDEKILL (1<<14) // tent is removed upon collision with anything
#define FTENT_PLYRATTACHMENT (1<<15) // tent is attached to a player (owner)
#define FTENT_SPRANIMATELOOP (1<<16) // animating sprite doesn't die when last frame is displayed
#define FTENT_SCALE (1<<17) // an experiment
#define FTENT_SPARKSHOWER (1<<18)
#define FTENT_NOMODEL (1<<19) // sets by engine, never draw (it just triggers other things)
#define FTENT_CLIENTCUSTOM (1<<20) // Must specify callback. Callback function is responsible
// for killing tempent and updating fields
// ( unless other flags specify how to do things )
#define FTENT_WINDBLOWN (1<<21) // This is set when the temp entity is blown by the wind
#define FTENT_NEVERDIE (1<<22) // Don't die as long as die != 0
#define FTENT_BEOCCLUDED (1<<23) // Don't draw if my specified normal's facing away from the view
struct tempent_s
{
int flags;
float die;
float m_flFrameMax;
float x, y;
vec3_t m_vecVelocity; // tent velocity
vec3_t m_vecAvelocity; // tent avelocity
vec3_t oldorigin; // attachment offset, beam endpoint etc
vec3_t tentOffset; // if attached, client origin + tentOffset = tent origin.
float fadeSpeed;
float bounceFactor;
int startAlpha; // starting fadeout intensity
sound_t hitSound;
byte priority; // 0 - low, 1 - high
short clientIndex; // if attached, this is the index of the client to stick to
// if COLLIDEALL, this is the index of the client to ignore
// TENTS with FTENT_PLYRATTACHMENT MUST set the clientindex!
void *pvEngineData; // private data that alloced and used by engine, freed in client.dll
HITCALLBACK hitcallback;
ENTCALLBACK callback;
TEMPENTITY *next;
// render-dependent fields
model_t modelindex; // index of precached model
vec3_t origin; // tent position
vec3_t angles; // tent angles
float m_flFrameRate; // studio, sprite framerate
float m_flFrame; // studio, sprite current frame
float m_flSpriteScale; // and model scale too
int m_nFlickerFrame; // for keyed dlights
int m_iAttachment; // sprite attachment
int m_iSequence; // studiomodel sequence
vec3_t renderColor; // tempentity rendercolor
byte renderAmt; // actual lpha value
byte renderMode; // fast method to set various effects
byte renderFX; // matched with entity renderfx
byte skin; // studiomodel skin
byte body; // studiomodel body
};
#endif//TMPENT_DEF_H

File diff suppressed because it is too large Load Diff

View File

@ -314,6 +314,9 @@ void CL_AddPacketEntities( frame_t *frame )
ed_type = ent->pvClientData->current.ed_type;
CL_UpdateEntityFields( ent );
if( ent->v.effects & EF_BRIGHTFIELD )
CL_EntityParticles( ent );
if( clgame.dllFuncs.pfnAddVisibleEntity( ent, ed_type ))
{
if( ed_type == ED_PORTAL && !VectorCompare( ent->v.origin, ent->v.oldorigin ))

View File

@ -2417,14 +2417,21 @@ static triapi_t gTriApi =
static efxapi_t gEfxApi =
{
sizeof( efxapi_t ),
pfnAddParticle,
CL_AllocParticle,
CL_BlobExplosion,
CL_LavaSplash,
CL_ParticleExplosion,
CL_ParticleExplosion2,
CL_RocketTrail,
CL_ParticleEffect,
CL_TeleportSplash,
CL_GetPaletteColor,
pfnDecalIndex,
pfnDecalIndexFromName,
pfnAddDecal,
pfnAddDLight,
CL_AddDecal,
CL_AddDLight,
pfnFindExplosionPlane,
pfnLightForPoint,
CL_LightForPoint,
CM_BoxVisible,
pfnCullBox,
CL_AddEntity,

View File

@ -15,9 +15,6 @@ cvar_t *cl_predict;
cvar_t *cl_showfps;
cvar_t *cl_maxfps;
cvar_t *cl_nodelta;
cvar_t *cl_particles;
cvar_t *cl_particlelod;
cvar_t *cl_draw_beams;
cvar_t *cl_crosshair;
cvar_t *cl_shownet;
cvar_t *cl_showmiss;
@ -1023,9 +1020,6 @@ void CL_InitLocal( void )
// register our variables
cl_predict = Cvar_Get( "cl_predict", "1", CVAR_ARCHIVE, "disables client movement prediction" );
cl_maxfps = Cvar_Get( "cl_maxfps", "1000", 0, "maximum client fps" );
cl_particles = Cvar_Get( "cl_particles", "1", CVAR_ARCHIVE, "disables particle effects" );
cl_draw_beams = Cvar_Get( "cl_draw_beams", "1", CVAR_ARCHIVE, "disables beam rendering" );
cl_particlelod = Cvar_Get( "cl_lod_particle", "0", CVAR_ARCHIVE, "enables particle LOD (1, 2, 3)" );
cl_crosshair = Cvar_Get( "crosshair", "1", CVAR_ARCHIVE|CVAR_USERINFO, "show weapon chrosshair" );
cl_nodelta = Cvar_Get ("cl_nodelta", "0", 0, "disable delta-compression for usercommnds" );
@ -1152,7 +1146,6 @@ void CL_Frame( int time )
S_Update( &cl.refdef );
// advance local effects for next frame
CL_RunDLights ();
CL_RunLightStyles ();
SCR_RunCinematic();

View File

@ -263,6 +263,7 @@ void CL_ParseParticles( sizebuf_t *msg )
count = MSG_ReadByte( msg );
color = MSG_ReadByte( msg );
if( count == 255 ) count = 1024;
CL_ParticleEffect( org, dir, color, count );
}

View File

@ -6,9 +6,7 @@
#include "common.h"
#include "client.h"
#include "effects_api.h"
#include "triangle_api.h"
#include "beam_def.h"
#include "const.h"
#include "tmpent_def.h"
/*
==============================================================
@ -54,3 +52,40 @@ int CL_AddTempEntity( TEMPENTITY *pTemp, shader_t customShader )
// let the render reject entity without model
return re->AddTmpEntity( pTemp, ED_TEMPENTITY, customShader );
}
/*
================
CL_TestEntities
if cl_testentities is set, create 32 player models
================
*/
void CL_TestEntities( void )
{
int i, j;
float f, r;
edict_t ent, *pl;
if( !cl_testentities->integer )
return;
pl = CL_GetLocalPlayer();
Mem_Set( &ent, 0, sizeof( edict_t ));
V_ClearScene();
for( i = 0; i < 32; i++ )
{
r = 64 * ((i%4) - 1.5 );
f = 64 * (i/4) + 128;
for( j = 0; j < 3; j++ )
ent.v.origin[j] = cl.refdef.vieworg[j]+cl.refdef.forward[j] * f + cl.refdef.right[j] * r;
ent.v.scale = 1.0f;
ent.serialnumber = pl->serialnumber;
ent.v.controller[0] = ent.v.controller[1] = 90.0f;
ent.v.controller[2] = ent.v.controller[3] = 180.0f;
ent.v.modelindex = pl->v.modelindex;
re->AddRefEntity( &ent, ED_NORMAL, -1 );
}
}

View File

@ -354,9 +354,6 @@ extern cvar_t *cl_font;
extern cvar_t *cl_nodelta;
extern cvar_t *cl_crosshair;
extern cvar_t *cl_showmiss;
extern cvar_t *cl_particles;
extern cvar_t *cl_particlelod;
extern cvar_t *cl_draw_beams;
extern cvar_t *cl_testentities;
extern cvar_t *cl_testlights;
extern cvar_t *cl_testflashlight;
@ -372,20 +369,14 @@ extern cvar_t *con_font;
bool CL_CheckOrDownloadFile( const char *filename );
//=================================================
void CL_TeleportSplash( vec3_t org );
int CL_ParseEntityBits( sizebuf_t *msg, uint *bits );
void CL_ParseFrame( sizebuf_t *msg );
void CL_ParseTempEnts( sizebuf_t *msg );
void CL_ParseConfigString( sizebuf_t *msg );
void CL_SetLightstyle (int i);
void CL_RunParticles (void);
void CL_RunDLights (void);
void CL_RunLightStyles (void);
void CL_SetLightstyle( int i );
void CL_RunLightStyles( void );
void CL_AddEntities (void);
void CL_AddDLights (void);
void CL_AddLightStyles (void);
void CL_AddEntities( void );
void CL_AddDLights( void );
void CL_AddLightStyles( void );
//=================================================
@ -564,13 +555,19 @@ void CL_AddDecals( void );
void CL_ClearEffects( void );
void CL_TestLights( void );
void CL_TestEntities( void );
void CL_LocalMuzzleFlash( void );
particle_t *CL_AllocParticle( void );
void CL_EntityParticles( edict_t *ent );
void CL_LavaSplash( const vec3_t org );
void CL_BlobExplosion( const vec3_t org );
void CL_TeleportSplash( const vec3_t org );
void CL_ParticleExplosion( const vec3_t org );
void CL_RocketTrail( const vec3_t start, const vec3_t end, int type );
void CL_ParticleExplosion2( const vec3_t org, int colorStart, int colorLength );
void CL_GetPaletteColor( int colorIndex, vec3_t outColor );
void CL_FindExplosionPlane( const vec3_t origin, float radius, vec3_t result );
void pfnLightForPoint( const vec3_t point, vec3_t ambientLight );
bool pfnAddParticle( cparticle_t *src, HSPRITE shader, int flags );
void pfnAddDecal( float *org, float *dir, float *rgba, float rot, float rad, HSPRITE hSpr, int flags );
void pfnAddDLight( const float *org, const float *rgb, float radius, float time, int flags, int key );
void CL_LightForPoint( const vec3_t point, vec3_t ambientLight );
void CL_AddDecal( float *org, float *dir, float *rgba, float rot, float rad, HSPRITE hSpr, int flags );
void CL_AddDLight( const float *org, const float *rgb, float radius, float time, int flags, int key );
void CL_ParticleEffect( const vec3_t org, const vec3_t dir, int color, int count ); // q1 legacy
void CL_SpawnStaticDecal( vec3_t origin, int decalIndex, int entityIndex, int modelIndex );
void CL_QueueEvent( int flags, int index, float delay, event_args_t *args );

View File

@ -330,11 +330,12 @@ void SV_PrepWorldFrame( void )
edict_t *ent;
int i;
for( i = 0; i < svgame.globals->numEntities; i++ )
for( i = 1; i < svgame.globals->numEntities; i++ )
{
ent = EDICT_NUM( i );
if( ent->free ) continue;
ent->pvServerData->s.ed_flags = 0;
ent->v.effects &= ~EF_MUZZLEFLASH;
}
}

View File

@ -264,6 +264,9 @@ bool SV_StepDirection( edict_t *ent, float yaw, float dist, int iMode )
vec3_t move, oldorigin;
float delta;
ent->v.ideal_yaw = yaw;
pfnChangeYaw( ent );
yaw = yaw * M_PI*2 / 360;
VectorSet( move, com.cos( yaw ) * dist, com.sin( yaw ) * dist, 0.0f );
VectorCopy( ent->v.origin, oldorigin );

View File

@ -14,7 +14,6 @@
#include "defaults.h"
#include "shake.h"
#include "basebeams.h"
#include "tempents.h"
void SFX_Explode( short model, Vector origin, float scale, int flags = 0 );
void SFX_Trail( int entindex, short model, Vector color = Vector(200, 200, 200), float life = 30);

View File

@ -9,7 +9,7 @@
#include <string.h>
#include "tempents.h"
#include "te_shared.h"
#include "shake.h"
#ifndef ACTIVITY_H

View File

@ -271,7 +271,7 @@ void CBaseAnimating :: SetBones( float (*data)[3], int datasize )
::SetBones( GET_MODEL_PTR( ENT(pev) ), data, datasize );
}
int CBaseAnimating :: ExtractBbox( int sequence, float *mins, float *maxs )
int CBaseAnimating :: ExtractBbox( int sequence, Vector &mins, Vector &maxs )
{
return ::ExtractBbox( GET_MODEL_PTR( ENT(pev) ), sequence, mins, maxs );
}

View File

@ -39,9 +39,7 @@
#include "enginecallback.h"
#endif
extern globalvars_t *gpGlobals;
int ExtractBbox( void *pmodel, int sequence, float *mins, float *maxs )
int ExtractBbox( void *pmodel, int sequence, Vector &mins, Vector &maxs )
{
dstudiohdr_t *pstudiohdr;
@ -122,7 +120,7 @@ int LookupActivityHeaviest( void *pmodel, entvars_t *pev, int activity )
return seq;
}
void GetEyePosition ( void *pmodel, float *vecEyePosition )
void GetEyePosition ( void *pmodel, Vector &vecEyePosition )
{
dstudiohdr_t *pstudiohdr;

View File

@ -1,52 +1,52 @@
/***
*
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
*
* This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved.
*
* Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC.
*
****/
#ifndef ANIMATION_H
#define ANIMATION_H
#define ACTIVITY_NOT_AVAILABLE -1
#ifndef MONSTEREVENT_H
#include "monsterevent.h"
#endif
extern int IsSoundEvent( int eventNumber );
int LookupActivity( void *pmodel, entvars_t *pev, int activity );
int LookupActivityHeaviest( void *pmodel, entvars_t *pev, int activity );
int LookupSequence( void *pmodel, const char *label );
void GetSequenceInfo( void *pmodel, entvars_t *pev, float *pflFrameRate, float *pflGroundSpeed );
int GetSequenceFlags( void *pmodel, entvars_t *pev );
int LookupAnimationEvents( void *pmodel, entvars_t *pev, float flStart, float flEnd );
float SetController( void *pmodel, entvars_t *pev, int iController, float flValue );
float SetBlending( void *pmodel, entvars_t *pev, int iBlender, float flValue );
void GetEyePosition( void *pmodel, float *vecEyePosition );
void SequencePrecache( void *pmodel, const char *pSequenceName );
int FindTransition( void *pmodel, int iEndingAnim, int iGoalAnim, int *piDir );
void SetBodygroup( void *pmodel, entvars_t *pev, int iGroup, int iValue );
int GetBodygroup( void *pmodel, entvars_t *pev, int iGroup );
//LRC
void SetBones( void *pmodel, float (*data)[3], int datasize );
int GetBoneCount( void *pmodel );
int GetSequenceFrames( void *pmodel, entvars_t *pev ); //LRC
int GetAnimationEvent( void *pmodel, entvars_t *pev, MonsterEvent_t *pMonsterEvent, float flStart, float flEnd, int index );
int ExtractBbox( void *pmodel, int sequence, float *mins, float *maxs );
// From /engine/studio.h
#define STUDIO_LOOPING 0x0001
#endif //ANIMATION_H
/***
*
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
*
* This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved.
*
* Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC.
*
****/
#ifndef ANIMATION_H
#define ANIMATION_H
#define ACTIVITY_NOT_AVAILABLE -1
#ifndef MONSTEREVENT_H
#include "monsterevent.h"
#endif
extern int IsSoundEvent( int eventNumber );
int LookupActivity( void *pmodel, entvars_t *pev, int activity );
int LookupActivityHeaviest( void *pmodel, entvars_t *pev, int activity );
int LookupSequence( void *pmodel, const char *label );
void GetSequenceInfo( void *pmodel, entvars_t *pev, float *pflFrameRate, float *pflGroundSpeed );
int GetSequenceFlags( void *pmodel, entvars_t *pev );
int LookupAnimationEvents( void *pmodel, entvars_t *pev, float flStart, float flEnd );
float SetController( void *pmodel, entvars_t *pev, int iController, float flValue );
float SetBlending( void *pmodel, entvars_t *pev, int iBlender, float flValue );
void GetEyePosition( void *pmodel, Vector &vecEyePosition );
void SequencePrecache( void *pmodel, const char *pSequenceName );
int FindTransition( void *pmodel, int iEndingAnim, int iGoalAnim, int *piDir );
void SetBodygroup( void *pmodel, entvars_t *pev, int iGroup, int iValue );
int GetBodygroup( void *pmodel, entvars_t *pev, int iGroup );
//LRC
void SetBones( void *pmodel, float (*data)[3], int datasize );
int GetBoneCount( void *pmodel );
int GetSequenceFrames( void *pmodel, entvars_t *pev ); //LRC
int GetAnimationEvent( void *pmodel, entvars_t *pev, MonsterEvent_t *pMonsterEvent, float flStart, float flEnd, int index );
int ExtractBbox( void *pmodel, int sequence, Vector &mins, Vector &maxs );
// From /engine/studio.h
#define STUDIO_LOOPING 0x0001
#endif //ANIMATION_H

View File

@ -36,7 +36,7 @@ public:
int GetBoneCount( void );
void SetBones( float (*data)[3], int datasize );
int ExtractBbox( int sequence, float *mins, float *maxs );
int ExtractBbox( int sequence, Vector &mins, Vector &maxs );
void SetSequenceBox( void );
// animation needs

View File

@ -1,327 +1,327 @@
/***
*
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
*
* This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved.
*
* Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC.
*
****/
/*
===== monsters.cpp ========================================================
Monster-related utility code
*/
#include "extdll.h"
#include "util.h"
#include "cbase.h"
#include "animation.h"
#include "saverestore.h"
TYPEDESCRIPTION CBaseAnimating::m_SaveData[] =
{
DEFINE_FIELD( CBaseMonster, m_flFrameRate, FIELD_FLOAT ),
DEFINE_FIELD( CBaseMonster, m_flGroundSpeed, FIELD_FLOAT ),
DEFINE_FIELD( CBaseMonster, m_flLastEventCheck, FIELD_TIME ),
DEFINE_FIELD( CBaseMonster, m_fSequenceFinished, FIELD_BOOLEAN ),
DEFINE_FIELD( CBaseMonster, m_fSequenceLoops, FIELD_BOOLEAN ),
};
IMPLEMENT_SAVERESTORE( CBaseAnimating, CBaseDelay );
//=========================================================
// StudioFrameAdvance - advance the animation frame up to the current time
// if an flInterval is passed in, only advance animation that number of seconds
//=========================================================
float CBaseAnimating :: StudioFrameAdvance ( float flInterval )
{
if (flInterval == 0.0)
{
flInterval = (gpGlobals->time - pev->animtime);
if (flInterval <= 0.001)
{
pev->animtime = gpGlobals->time;
return 0.0;
}
}
if (! pev->animtime)
flInterval = 0.0;
pev->frame += flInterval * m_flFrameRate * pev->framerate;
pev->animtime = gpGlobals->time;
if (pev->frame < 0.0 || pev->frame >= 256.0)
{
if (m_fSequenceLoops)
pev->frame -= (int)(pev->frame / 256.0) * 256.0;
else
pev->frame = (pev->frame < 0.0) ? 0 : 255;
m_fSequenceFinished = TRUE; // just in case it wasn't caught in GetEvents
}
return flInterval;
}
//=========================================================
// LookupActivity
//=========================================================
int CBaseAnimating :: LookupActivity ( int activity )
{
ASSERT( activity != 0 );
void *pmodel = GET_MODEL_PTR( ENT(pev) );
return ::LookupActivity( pmodel, pev, activity );
}
//=========================================================
// LookupActivityHeaviest
//
// Get activity with highest 'weight'
//
//=========================================================
int CBaseAnimating :: LookupActivityHeaviest ( int activity )
{
void *pmodel = GET_MODEL_PTR( ENT(pev) );
return ::LookupActivityHeaviest( pmodel, pev, activity );
}
//=========================================================
//=========================================================
int CBaseAnimating :: LookupSequence ( const char *label )
{
void *pmodel = GET_MODEL_PTR( ENT(pev) );
return ::LookupSequence( pmodel, label );
}
//=========================================================
//=========================================================
void CBaseAnimating :: ResetSequenceInfo ( )
{
void *pmodel = GET_MODEL_PTR( ENT(pev) );
GetSequenceInfo( pmodel, pev, &m_flFrameRate, &m_flGroundSpeed );
m_fSequenceLoops = ((GetSequenceFlags() & STUDIO_LOOPING) != 0);
pev->animtime = gpGlobals->time;
pev->framerate = 1.0;
m_fSequenceFinished = FALSE;
m_flLastEventCheck = gpGlobals->time;
}
//=========================================================
//=========================================================
BOOL CBaseAnimating :: GetSequenceFlags( )
{
void *pmodel = GET_MODEL_PTR( ENT(pev) );
return ::GetSequenceFlags( pmodel, pev );
}
//=========================================================
// DispatchAnimEvents
//=========================================================
void CBaseAnimating :: DispatchAnimEvents ( float flInterval )
{
MonsterEvent_t event;
void *pmodel = GET_MODEL_PTR( ENT(pev) );
if ( !pmodel )
{
ALERT( at_aiconsole, "Gibbed monster is thinking!\n" );
return;
}
// FIXME: I have to do this or some events get missed, and this is probably causing the problem below
flInterval = 0.1;
// FIX: this still sometimes hits events twice
float flStart = pev->frame + (m_flLastEventCheck - pev->animtime) * m_flFrameRate * pev->framerate;
float flEnd = pev->frame + flInterval * m_flFrameRate * pev->framerate;
m_flLastEventCheck = pev->animtime + flInterval;
m_fSequenceFinished = FALSE;
if (flEnd >= 256 || flEnd <= 0.0)
m_fSequenceFinished = TRUE;
int index = 0;
while ( (index = GetAnimationEvent( pmodel, pev, &event, flStart, flEnd, index ) ) != 0 )
{
HandleAnimEvent( &event );
}
}
//=========================================================
//=========================================================
float CBaseAnimating :: SetBoneController ( int iController, float flValue )
{
void *pmodel = GET_MODEL_PTR( ENT(pev) );
return SetController( pmodel, pev, iController, flValue );
}
//=========================================================
//=========================================================
void CBaseAnimating :: InitBoneControllers ( void )
{
void *pmodel = GET_MODEL_PTR( ENT(pev) );
SetController( pmodel, pev, 0, 0.0 );
SetController( pmodel, pev, 1, 0.0 );
SetController( pmodel, pev, 2, 0.0 );
SetController( pmodel, pev, 3, 0.0 );
}
//=========================================================
//=========================================================
float CBaseAnimating :: SetBlending ( int iBlender, float flValue )
{
void *pmodel = GET_MODEL_PTR( ENT(pev) );
return ::SetBlending( pmodel, pev, iBlender, flValue );
}
//=========================================================
//=========================================================
void CBaseAnimating :: GetBonePosition ( int iBone, Vector &origin, Vector &angles )
{
GET_BONE_POSITION( ENT(pev), iBone, origin, angles );
}
//=========================================================
//=========================================================
void CBaseAnimating :: GetAttachment ( int iAttachment, Vector &origin, Vector &angles )
{
GET_ATTACHMENT( ENT(pev), iAttachment, origin, angles );
}
//=========================================================
//=========================================================
int CBaseAnimating :: FindTransition( int iEndingSequence, int iGoalSequence, int *piDir )
{
void *pmodel = GET_MODEL_PTR( ENT(pev) );
if (piDir == NULL)
{
int iDir;
int sequence = ::FindTransition( pmodel, iEndingSequence, iGoalSequence, &iDir );
if (iDir != 1)
return -1;
else
return sequence;
}
return ::FindTransition( pmodel, iEndingSequence, iGoalSequence, piDir );
}
//=========================================================
//=========================================================
void CBaseAnimating :: GetAutomovement( Vector &origin, Vector &angles, float flInterval )
{
}
void CBaseAnimating :: SetBodygroup( int iGroup, int iValue )
{
::SetBodygroup( GET_MODEL_PTR( ENT(pev) ), pev, iGroup, iValue );
}
int CBaseAnimating :: GetBodygroup( int iGroup )
{
return ::GetBodygroup( GET_MODEL_PTR( ENT(pev) ), pev, iGroup );
}
int CBaseAnimating :: GetBoneCount( void )
{
return ::GetBoneCount( GET_MODEL_PTR(ENT(pev)) );
}
void CBaseAnimating :: SetBones( float (*data)[3], int datasize )
{
::SetBones( GET_MODEL_PTR( ENT(pev) ), data, datasize );
}
int CBaseAnimating :: ExtractBbox( int sequence, float *mins, float *maxs )
{
return ::ExtractBbox( GET_MODEL_PTR( ENT(pev) ), sequence, mins, maxs );
}
//=========================================================
//=========================================================
void CBaseAnimating :: SetSequenceBox( void )
{
Vector mins, maxs;
// Get sequence bbox
if ( ExtractBbox( pev->sequence, mins, maxs ) )
{
// expand box for rotation
// find min / max for rotations
float yaw = pev->angles.y * (M_PI / 180.0);
Vector xvector, yvector;
xvector.x = cos(yaw);
xvector.y = sin(yaw);
yvector.x = -sin(yaw);
yvector.y = cos(yaw);
Vector bounds[2];
bounds[0] = mins;
bounds[1] = maxs;
Vector rmin( 9999, 9999, 9999 );
Vector rmax( -9999, -9999, -9999 );
Vector base, transformed;
for (int i = 0; i <= 1; i++ )
{
base.x = bounds[i].x;
for ( int j = 0; j <= 1; j++ )
{
base.y = bounds[j].y;
for ( int k = 0; k <= 1; k++ )
{
base.z = bounds[k].z;
// transform the point
transformed.x = xvector.x*base.x + yvector.x*base.y;
transformed.y = xvector.y*base.x + yvector.y*base.y;
transformed.z = base.z;
if (transformed.x < rmin.x)
rmin.x = transformed.x;
if (transformed.x > rmax.x)
rmax.x = transformed.x;
if (transformed.y < rmin.y)
rmin.y = transformed.y;
if (transformed.y > rmax.y)
rmax.y = transformed.y;
if (transformed.z < rmin.z)
rmin.z = transformed.z;
if (transformed.z > rmax.z)
rmax.z = transformed.z;
}
}
}
rmin.z = 0;
rmax.z = rmin.z + 1;
UTIL_SetSize( pev, rmin, rmax );
}
}
/***
*
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
*
* This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved.
*
* Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC.
*
****/
/*
===== monsters.cpp ========================================================
Monster-related utility code
*/
#include "extdll.h"
#include "util.h"
#include "cbase.h"
#include "animation.h"
#include "saverestore.h"
TYPEDESCRIPTION CBaseAnimating::m_SaveData[] =
{
DEFINE_FIELD( CBaseMonster, m_flFrameRate, FIELD_FLOAT ),
DEFINE_FIELD( CBaseMonster, m_flGroundSpeed, FIELD_FLOAT ),
DEFINE_FIELD( CBaseMonster, m_flLastEventCheck, FIELD_TIME ),
DEFINE_FIELD( CBaseMonster, m_fSequenceFinished, FIELD_BOOLEAN ),
DEFINE_FIELD( CBaseMonster, m_fSequenceLoops, FIELD_BOOLEAN ),
};
IMPLEMENT_SAVERESTORE( CBaseAnimating, CBaseDelay );
//=========================================================
// StudioFrameAdvance - advance the animation frame up to the current time
// if an flInterval is passed in, only advance animation that number of seconds
//=========================================================
float CBaseAnimating :: StudioFrameAdvance ( float flInterval )
{
if (flInterval == 0.0)
{
flInterval = (gpGlobals->time - pev->animtime);
if (flInterval <= 0.001)
{
pev->animtime = gpGlobals->time;
return 0.0;
}
}
if (! pev->animtime)
flInterval = 0.0;
pev->frame += flInterval * m_flFrameRate * pev->framerate;
pev->animtime = gpGlobals->time;
if (pev->frame < 0.0 || pev->frame >= 256.0)
{
if (m_fSequenceLoops)
pev->frame -= (int)(pev->frame / 256.0) * 256.0;
else
pev->frame = (pev->frame < 0.0) ? 0 : 255;
m_fSequenceFinished = TRUE; // just in case it wasn't caught in GetEvents
}
return flInterval;
}
//=========================================================
// LookupActivity
//=========================================================
int CBaseAnimating :: LookupActivity ( int activity )
{
ASSERT( activity != 0 );
void *pmodel = GET_MODEL_PTR( ENT(pev) );
return ::LookupActivity( pmodel, pev, activity );
}
//=========================================================
// LookupActivityHeaviest
//
// Get activity with highest 'weight'
//
//=========================================================
int CBaseAnimating :: LookupActivityHeaviest ( int activity )
{
void *pmodel = GET_MODEL_PTR( ENT(pev) );
return ::LookupActivityHeaviest( pmodel, pev, activity );
}
//=========================================================
//=========================================================
int CBaseAnimating :: LookupSequence ( const char *label )
{
void *pmodel = GET_MODEL_PTR( ENT(pev) );
return ::LookupSequence( pmodel, label );
}
//=========================================================
//=========================================================
void CBaseAnimating :: ResetSequenceInfo ( )
{
void *pmodel = GET_MODEL_PTR( ENT(pev) );
GetSequenceInfo( pmodel, pev, &m_flFrameRate, &m_flGroundSpeed );
m_fSequenceLoops = ((GetSequenceFlags() & STUDIO_LOOPING) != 0);
pev->animtime = gpGlobals->time;
pev->framerate = 1.0;
m_fSequenceFinished = FALSE;
m_flLastEventCheck = gpGlobals->time;
}
//=========================================================
//=========================================================
BOOL CBaseAnimating :: GetSequenceFlags( )
{
void *pmodel = GET_MODEL_PTR( ENT(pev) );
return ::GetSequenceFlags( pmodel, pev );
}
//=========================================================
// DispatchAnimEvents
//=========================================================
void CBaseAnimating :: DispatchAnimEvents ( float flInterval )
{
MonsterEvent_t event;
void *pmodel = GET_MODEL_PTR( ENT(pev) );
if ( !pmodel )
{
ALERT( at_aiconsole, "Gibbed monster is thinking!\n" );
return;
}
// FIXME: I have to do this or some events get missed, and this is probably causing the problem below
flInterval = 0.1;
// FIX: this still sometimes hits events twice
float flStart = pev->frame + (m_flLastEventCheck - pev->animtime) * m_flFrameRate * pev->framerate;
float flEnd = pev->frame + flInterval * m_flFrameRate * pev->framerate;
m_flLastEventCheck = pev->animtime + flInterval;
m_fSequenceFinished = FALSE;
if (flEnd >= 256 || flEnd <= 0.0)
m_fSequenceFinished = TRUE;
int index = 0;
while ( (index = GetAnimationEvent( pmodel, pev, &event, flStart, flEnd, index ) ) != 0 )
{
HandleAnimEvent( &event );
}
}
//=========================================================
//=========================================================
float CBaseAnimating :: SetBoneController ( int iController, float flValue )
{
void *pmodel = GET_MODEL_PTR( ENT(pev) );
return SetController( pmodel, pev, iController, flValue );
}
//=========================================================
//=========================================================
void CBaseAnimating :: InitBoneControllers ( void )
{
void *pmodel = GET_MODEL_PTR( ENT(pev) );
SetController( pmodel, pev, 0, 0.0 );
SetController( pmodel, pev, 1, 0.0 );
SetController( pmodel, pev, 2, 0.0 );
SetController( pmodel, pev, 3, 0.0 );
}
//=========================================================
//=========================================================
float CBaseAnimating :: SetBlending ( int iBlender, float flValue )
{
void *pmodel = GET_MODEL_PTR( ENT(pev) );
return ::SetBlending( pmodel, pev, iBlender, flValue );
}
//=========================================================
//=========================================================
void CBaseAnimating :: GetBonePosition ( int iBone, Vector &origin, Vector &angles )
{
GET_BONE_POSITION( ENT(pev), iBone, origin, angles );
}
//=========================================================
//=========================================================
void CBaseAnimating :: GetAttachment ( int iAttachment, Vector &origin, Vector &angles )
{
GET_ATTACHMENT( ENT(pev), iAttachment, origin, angles );
}
//=========================================================
//=========================================================
int CBaseAnimating :: FindTransition( int iEndingSequence, int iGoalSequence, int *piDir )
{
void *pmodel = GET_MODEL_PTR( ENT(pev) );
if (piDir == NULL)
{
int iDir;
int sequence = ::FindTransition( pmodel, iEndingSequence, iGoalSequence, &iDir );
if (iDir != 1)
return -1;
else
return sequence;
}
return ::FindTransition( pmodel, iEndingSequence, iGoalSequence, piDir );
}
//=========================================================
//=========================================================
void CBaseAnimating :: GetAutomovement( Vector &origin, Vector &angles, float flInterval )
{
}
void CBaseAnimating :: SetBodygroup( int iGroup, int iValue )
{
::SetBodygroup( GET_MODEL_PTR( ENT(pev) ), pev, iGroup, iValue );
}
int CBaseAnimating :: GetBodygroup( int iGroup )
{
return ::GetBodygroup( GET_MODEL_PTR( ENT(pev) ), pev, iGroup );
}
int CBaseAnimating :: GetBoneCount( void )
{
return ::GetBoneCount( GET_MODEL_PTR(ENT(pev)) );
}
void CBaseAnimating :: SetBones( float (*data)[3], int datasize )
{
::SetBones( GET_MODEL_PTR( ENT(pev) ), data, datasize );
}
int CBaseAnimating :: ExtractBbox( int sequence, Vector &mins, Vector &maxs )
{
return ::ExtractBbox( GET_MODEL_PTR( ENT(pev) ), sequence, mins, maxs );
}
//=========================================================
//=========================================================
void CBaseAnimating :: SetSequenceBox( void )
{
Vector mins, maxs;
// Get sequence bbox
if ( ExtractBbox( pev->sequence, mins, maxs ) )
{
// expand box for rotation
// find min / max for rotations
float yaw = pev->angles.y * (M_PI / 180.0);
Vector xvector, yvector;
xvector.x = cos(yaw);
xvector.y = sin(yaw);
yvector.x = -sin(yaw);
yvector.y = cos(yaw);
Vector bounds[2];
bounds[0] = mins;
bounds[1] = maxs;
Vector rmin( 9999, 9999, 9999 );
Vector rmax( -9999, -9999, -9999 );
Vector base, transformed;
for (int i = 0; i <= 1; i++ )
{
base.x = bounds[i].x;
for ( int j = 0; j <= 1; j++ )
{
base.y = bounds[j].y;
for ( int k = 0; k <= 1; k++ )
{
base.z = bounds[k].z;
// transform the point
transformed.x = xvector.x*base.x + yvector.x*base.y;
transformed.y = xvector.y*base.x + yvector.y*base.y;
transformed.z = base.z;
if (transformed.x < rmin.x)
rmin.x = transformed.x;
if (transformed.x > rmax.x)
rmax.x = transformed.x;
if (transformed.y < rmin.y)
rmin.y = transformed.y;
if (transformed.y > rmax.y)
rmax.y = transformed.y;
if (transformed.z < rmin.z)
rmin.z = transformed.z;
if (transformed.z > rmax.z)
rmax.z = transformed.z;
}
}
}
rmin.z = 0;
rmax.z = rmin.z + 1;
UTIL_SetSize( pev, rmin, rmax );
}
}

View File

@ -38,10 +38,7 @@ typedef unsigned char byte;
#include "scriptevent.h"
#endif
extern globalvars_t *gpGlobals;
int ExtractBbox( void *pmodel, int sequence, float *mins, float *maxs )
int ExtractBbox( void *pmodel, int sequence, Vector &mins, Vector &maxs )
{
dstudiohdr_t *pstudiohdr;
@ -122,7 +119,7 @@ int LookupActivityHeaviest( void *pmodel, entvars_t *pev, int activity )
return seq;
}
void GetEyePosition ( void *pmodel, float *vecEyePosition )
void GetEyePosition ( void *pmodel, Vector &vecEyePosition )
{
dstudiohdr_t *pstudiohdr;

View File

@ -29,7 +29,7 @@ int GetSequenceFlags( void *pmodel, entvars_t *pev );
int LookupAnimationEvents( void *pmodel, entvars_t *pev, float flStart, float flEnd );
float SetController( void *pmodel, entvars_t *pev, int iController, float flValue );
float SetBlending( void *pmodel, entvars_t *pev, int iBlender, float flValue );
void GetEyePosition( void *pmodel, float *vecEyePosition );
void GetEyePosition( void *pmodel, Vector &vecEyePosition );
void SequencePrecache( void *pmodel, const char *pSequenceName );
int FindTransition( void *pmodel, int iEndingAnim, int iGoalAnim, int *piDir );
void SetBodygroup( void *pmodel, entvars_t *pev, int iGroup, int iValue );
@ -41,7 +41,7 @@ int GetBoneCount( void *pmodel );
int GetSequenceFrames( void *pmodel, entvars_t *pev ); //LRC
int GetAnimationEvent( void *pmodel, entvars_t *pev, MonsterEvent_t *pMonsterEvent, float flStart, float flEnd, int index );
int ExtractBbox( void *pmodel, int sequence, float *mins, float *maxs );
int ExtractBbox( void *pmodel, int sequence, Vector &mins, Vector &maxs );
// From /common/ref_studio.h
#define STUDIO_LOOPING 0x0001

View File

@ -612,7 +612,7 @@ public:
int GetBoneCount( void );
void SetBones( float (*data)[3], int datasize );
int ExtractBbox( int sequence, float *mins, float *maxs );
int ExtractBbox( int sequence, Vector &mins, Vector &maxs );
void SetSequenceBox( void );
// animation needs

View File

@ -2130,7 +2130,7 @@ void CBaseMonster :: StartMonster ( void )
//LRC- there are perfectly good reasons for making a monster stuck, so it shouldn't always be an error.
if (!WALK_MOVE ( ENT(pev), 0, 0, WALKMOVE_NORMAL ) && !FBitSet( pev->spawnflags, SF_MONSTER_NO_YELLOW_BLOBS))
{
ALERT(at_debug, "%s \"%s\" stuck in wall--level design error", STRING(pev->classname), STRING(pev->targetname));
ALERT(at_debug, "%s \"%s\" stuck in wall--level design error\n", STRING(pev->classname), STRING(pev->targetname));
pev->effects = EF_BRIGHTFIELD;
}
}

View File

@ -62,7 +62,7 @@ void CBaseMonster :: SetState ( MONSTERSTATE State )
void CBaseMonster :: RunAI ( void )
{
// to test model's eye height
//UTIL_ParticleEffect ( pev->origin + pev->view_ofs, g_vecZero, 255, 10 );
// UTIL_ParticleEffect ( pev->origin + pev->view_ofs, g_vecZero, 255, 10 );
// IDLE sound permitted in ALERT state is because monsters were silent in ALERT state. Only play IDLE sound in IDLE state
// once we have sounds for that state.

View File

@ -218,7 +218,6 @@ int PRECACHE_PARTICLE( char* s )
if( !stricmp( token, "sprite" ))
{
token = COM_ParseToken( &pfile );
ALERT( at_console, "aurora precache sprite: %s\n", token );
PRECACHE_MODEL( token );
}
token = COM_ParseToken( &pfile );

View File

@ -20,7 +20,7 @@
#include <string.h>
#include "tempents.h"
#include "te_shared.h"
#include "shake.h"
#include "game_shared.h"
#include "activity.h"

View File

@ -50,7 +50,5 @@ Beta 13.02.10
24. revision server physic
25. revision monster moving
26. get rid of fakemirror stuff in spirit OK
27. rewrite engine particle system
27. rewrite engine particle system OK
28. rewrite engine decal system

View File

@ -214,7 +214,7 @@ tristate_t triState;
static void Tri_DrawPolygon( void )
{
ref_shader_t *shader;
static int oldframe;
static int i, oldframe;
if( tri_caps[TRI_SHADER] )
shader = &r_shaders[triState.currentShader];
@ -227,6 +227,13 @@ static void Tri_DrawPolygon( void )
tri_mesh.normalsArray = tri_normal;
else tri_mesh.normalsArray = NULL; // no normals
if( triState.numColor == 1 )
{
// global color for all vertexes
for( i = 0; i < triState.numVertex - 1; i++ )
Vector4Copy( tri_colors[0], tri_colors[i+1] );
}
tri_mesh.xyzArray = tri_vertex;
tri_mesh.stArray = tri_coords;
tri_mesh.colorsArray[0] = tri_colors;
@ -256,7 +263,8 @@ static void Tri_DrawPolygon( void )
triState.features |= MF_NOCULL;
// upload video right before rendering
if( shader->flags & SHADER_VIDEOMAP ) R_UploadCinematicShader( shader );
if( shader->flags & SHADER_VIDEOMAP )
R_UploadCinematicShader( shader );
R_PushMesh( &tri_mesh, triState.features );
if( oldframe != glState.draw_frame )
@ -406,6 +414,7 @@ void Tri_Vertex3f( const float x, const float y, const float z )
tri_vertex[triState.numVertex][0] = x;
tri_vertex[triState.numVertex][1] = y;
tri_vertex[triState.numVertex][2] = z;
tri_vertex[triState.numVertex][3] = 1;
triState.numVertex++;
@ -416,10 +425,10 @@ void Tri_Vertex3f( const float x, const float y, const float z )
void Tri_Color4ub( const byte r, const byte g, const byte b, const byte a )
{
tri_colors[triState.numVertex][0] = r;
tri_colors[triState.numVertex][1] = g;
tri_colors[triState.numVertex][2] = b;
tri_colors[triState.numVertex][3] = a;
tri_colors[triState.numColor][0] = r;
tri_colors[triState.numColor][1] = g;
tri_colors[triState.numColor][2] = b;
tri_colors[triState.numColor][3] = a;
triState.numColor++;
}
@ -429,6 +438,7 @@ void Tri_Normal3f( const float x, const float y, const float z )
tri_normal[triState.numVertex][0] = x;
tri_normal[triState.numVertex][1] = y;
tri_normal[triState.numVertex][2] = z;
tri_normal[triState.numVertex][3] = 1;
}
void Tri_TexCoord2f( const float u, const float v )
@ -503,6 +513,7 @@ void Tri_RenderCallback( int fTrans )
tri_mbuffer.infokey = -1;
tri_mbuffer.shaderkey = 0;
triState.numColor = 0;
ri.DrawTriangles( fTrans );

View File

@ -437,8 +437,8 @@ dynamic:
anyDlights = true;
}
add = 1.0 - (dist / (dl->intensity + radius));
dist2 = add * 0.5 / dist;
add = 1.0f - (dist / (dl->intensity + radius));
dist2 = add * 0.5f / dist;
for( i = 0; i < 3; i++ )
{
dot = dl->color[i] * add;

View File

@ -742,8 +742,9 @@ msurface_t *R_TransformedTraceLine( trace_t *tr, const vec3_t start, const vec3_
void R_SpriteInit( void );
mspriteframe_t *R_GetSpriteFrame( ref_model_t *pModel, int frame, float yawAngle );
bool R_DrawSpriteModel( const meshbuffer_t *mb );
void R_DrawSpriteModel( const meshbuffer_t *mb );
bool R_SpriteOccluded( ref_entity_t *e );
bool R_CullSpriteModel( ref_entity_t *e );
//
// r_studio.c

View File

@ -24,6 +24,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <stdio.h> // sscanf
#include "r_local.h"
#include "clgame_api.h"
#include "tmpent_def.h"
#include "effects_api.h"
#include "mathlib.h"
#include "matrix_lib.h"
@ -307,10 +308,10 @@ R_LightForPoint
*/
void R_LightForPoint( const vec3_t point, vec3_t ambientLight )
{
vec4_t ambient;
vec4_t ambient, diffuse;
vec3_t dir;
R_LightForOrigin( point, dir, ambient, NULL, 64.0f );
R_LightForOrigin( point, dir, ambient, diffuse, 256.0f );
VectorCopy( ambient, ambientLight );
}
@ -1377,7 +1378,7 @@ static void R_CullEntities( void )
culled = R_CullBrushModel( e );
break;
case mod_sprite:
culled = false;
culled = R_CullSpriteModel( e );
break;
default: break;
}
@ -2483,7 +2484,7 @@ bool R_AddEntityToScene( edict_t *pRefEntity, int ed_type, shader_t customShader
refent = &r_entities[r_numEntities];
if( pRefEntity->v.effects & EF_NODRAW )
if( pRefEntity->v.effects & EF_NODRAW && ed_type != ED_PORTAL )
return true; // done
// filter ents
@ -2526,6 +2527,9 @@ bool R_AddEntityToScene( edict_t *pRefEntity, int ed_type, shader_t customShader
refent->parent = NULL;
refent->prev = NULL;
if( pRefEntity->v.rendermode == kRenderGlow && !pRefEntity->v.renderfx )
refent->flags |= EF_OCCLUSIONTEST;
// setup custom shader
if( customShader >= 0 && customShader < MAX_SHADERS && (shader = &r_shaders[customShader]))
refent->customShader = shader;

View File

@ -642,7 +642,6 @@ void R_DrawMeshes( void )
int i;
meshbuffer_t *meshbuf;
Tri_RenderCallback( false );
RI.previousentity = NULL;
if( RI.meshlist->num_opaque_meshes )
{
@ -651,9 +650,8 @@ void R_DrawMeshes( void )
R_BatchMeshBuffer( meshbuf, meshbuf+1 );
R_BatchMeshBuffer( meshbuf, NULL );
}
Tri_RenderCallback( false );
Tri_RenderCallback( true );
if( RI.meshlist->num_translucent_meshes )
{
meshbuf = RI.meshlist->meshbuffer_translucent;
@ -661,6 +659,7 @@ void R_DrawMeshes( void )
R_BatchMeshBuffer( meshbuf, meshbuf + 1 );
R_BatchMeshBuffer( meshbuf, NULL );
}
Tri_RenderCallback( true );
R_LoadIdentity();
}

View File

@ -22,6 +22,8 @@ string sp_name;
ref_shader_t **frames = NULL;
cvar_t *r_sprite_lerping;
uint tex_flags = 0;
vec3_t sprite_mins, sprite_maxs;
float sprite_radius;
/*
====================
@ -489,14 +491,13 @@ static float R_SpriteGlowBlend( ref_entity_t *e )
float dist = R_GlowSightDistance( e->origin );
float brightness;
if( dist <= 0 )
return false; // occluded
if( e->renderfx == kRenderFxNoDissipation )
{
return (float)e->renderamt * (1.0f/255.0f);
}
if( dist <= 0 ) return 0.0f; // occluded
// UNDONE: Tweak these magic numbers (19000 - falloff & 200 - sprite size)
brightness = 19000.0 / (dist * dist);
brightness = bound( 0.05f, brightness, 1.0f );
@ -536,16 +537,28 @@ bool R_SpriteOccluded( ref_entity_t *e )
R_DrawSpriteModel
=================
*/
bool R_DrawSpriteModel( const meshbuffer_t *mb )
void R_DrawSpriteModel( const meshbuffer_t *mb )
{
ref_entity_t *e;
mspriteframe_t *frame, *oldframe;
msprite_t *psprite;
ref_entity_t *e = RI.currententity;
ref_model_t *model = e->model;
ref_model_t *model;
float lerp = 1.0f, ilerp;
meshbuffer_t *rb = (meshbuffer_t *)mb;
byte renderamt;
MB_NUM2ENTITY( mb->sortkey, e );
model = e->model;
if( OCCLUSION_QUERIES_ENABLED( RI ) && OCCLUSION_TEST_ENTITY( e ))
{
ref_shader_t *shader;
MB_NUM2SHADER( mb->shaderkey, shader );
if( !R_GetOcclusionQueryResultBool( shader->type == 1 ? OQ_PLANARSHADOW : OQ_ENTITY, e - r_entities, true ))
return;
}
psprite = (msprite_t * )model->extradata;
switch( e->rendermode )
@ -615,5 +628,28 @@ bool R_DrawSpriteModel( const meshbuffer_t *mb )
// restore current values (e.g. for right mirror passes)
e->renderamt = renderamt;
}
return true;
}
bool R_CullSpriteModel( ref_entity_t *e )
{
bool frustum, query, clipped;
if( !e->model->extradata )
return true;
if( e->ent_type == ED_VIEWMODEL && r_lefthand->integer >= 2 )
return true;
VectorCopy( e->model->mins, sprite_mins );
VectorCopy( e->model->maxs, sprite_maxs );
sprite_radius = RadiusFromBounds( sprite_mins, sprite_maxs );
clipped = R_CullModel( e, sprite_mins, sprite_maxs, sprite_radius );
frustum = clipped & 1;
if( clipped & 2 ) return true;
query = OCCLUSION_QUERIES_ENABLED( RI ) && OCCLUSION_TEST_ENTITY( e ) ? true : false;
if( !frustum && query ) R_IssueOcclusionQuery( R_GetOcclusionQueryNum( OQ_ENTITY, e - r_entities ), e, sprite_mins, sprite_maxs );
return frustum;
}

View File

@ -8,6 +8,7 @@
#include "mathlib.h"
#include "matrix_lib.h"
#include "clgame_api.h"
#include "tmpent_def.h"
#include "effects_api.h"
#include "const.h"