diff options
author | Tim Angus <tim@ngus.net> | 2001-08-15 00:39:36 +0000 |
---|---|---|
committer | Tim Angus <tim@ngus.net> | 2001-08-15 00:39:36 +0000 |
commit | 6a0c927855d030620dc2a54a261be7119b771897 (patch) | |
tree | dd33e210b94520f0442428ade104345f110ce4b7 /src | |
parent | 50a3f688230416ba6fd7d9c4d99d14a8871d63ee (diff) |
Added spriter - simple particle engine for mappers
Diffstat (limited to 'src')
-rw-r--r-- | src/cgame/cg_ents.c | 3 | ||||
-rw-r--r-- | src/cgame/cg_local.h | 13 | ||||
-rw-r--r-- | src/cgame/cg_main.c | 11 | ||||
-rw-r--r-- | src/cgame/cg_servercmds.c | 4 | ||||
-rw-r--r-- | src/game/bg_public.h | 8 | ||||
-rw-r--r-- | src/game/g_misc.c | 74 | ||||
-rw-r--r-- | src/game/g_spawn.c | 15 | ||||
-rw-r--r-- | src/game/g_utils.c | 4 | ||||
-rw-r--r-- | src/game/q_shared.h | 1 |
9 files changed, 109 insertions, 24 deletions
diff --git a/src/cgame/cg_ents.c b/src/cgame/cg_ents.c index 62920756..d145f387 100644 --- a/src/cgame/cg_ents.c +++ b/src/cgame/cg_ents.c @@ -953,6 +953,9 @@ static void CG_AddCEntity( centity_t *cent ) { case ET_GRAPPLE: CG_Grapple( cent ); break; + case ET_SPRITER: + CG_Spriter( cent ); + break; } } diff --git a/src/cgame/cg_local.h b/src/cgame/cg_local.h index 0a672504..9f701bc8 100644 --- a/src/cgame/cg_local.h +++ b/src/cgame/cg_local.h @@ -220,6 +220,7 @@ typedef enum { LE_SPRITE_EXPLOSION, LE_FRAGMENT, LE_MOVE_SCALE_FADE, + LE_SPRITER, LE_FALL_SCALE_FADE, LE_FADE_RGB, LE_SCALE_FADE @@ -272,6 +273,12 @@ typedef struct localEntity_s { leBounceSoundType_t leBounceSoundType; refEntity_t refEntity; + + //TA: random stuff for cg_spriter.c + vec3_t acceleration; + float initAlp, finalAlp; + float initRad, finalRad; + qboolean overdraw; } localEntity_t; //====================================================================== @@ -1025,6 +1032,7 @@ typedef struct { // locally derived information from gamestate // qhandle_t gameModels[MAX_MODELS]; + qhandle_t gameShaders[MAX_SHADERS]; sfxHandle_t gameSounds[MAX_SOUNDS]; int numInlineModels; @@ -1328,6 +1336,11 @@ void CG_Buildable( centity_t *cent ); void CG_InitBuildables( ); // +// cg_spriter.c +// +void CG_Spriter( centity_t *cent ); + +// // cg_predict.c // void CG_BuildSolidList( void ); diff --git a/src/cgame/cg_main.c b/src/cgame/cg_main.c index 2cdc9149..35a6022b 100644 --- a/src/cgame/cg_main.c +++ b/src/cgame/cg_main.c @@ -907,6 +907,17 @@ static void CG_RegisterGraphics( void ) { cgs.gameModels[i] = trap_R_RegisterModel( modelName ); } + // register all the server specified shaders + for (i=1 ; i<MAX_SHADERS ; i++) { + const char *shaderName; + + shaderName = CG_ConfigString( CS_SHADERS+i ); + if ( !shaderName[0] ) { + break; + } + cgs.gameShaders[i] = trap_R_RegisterShader( shaderName ); + } + CG_ClearParticles (); } diff --git a/src/cgame/cg_servercmds.c b/src/cgame/cg_servercmds.c index ed0a7956..65e09cd5 100644 --- a/src/cgame/cg_servercmds.c +++ b/src/cgame/cg_servercmds.c @@ -314,7 +314,9 @@ static void CG_ConfigStringModified( void ) { cg.intermissionStarted = atoi( str ); } else if ( num >= CS_MODELS && num < CS_MODELS+MAX_MODELS ) { cgs.gameModels[ num-CS_MODELS ] = trap_R_RegisterModel( str ); - } else if ( num >= CS_SOUNDS && num < CS_SOUNDS+MAX_MODELS ) { + } else if ( num >= CS_SHADERS && num < CS_SHADERS+MAX_SHADERS ) { + cgs.gameShaders[ num-CS_SHADERS ] = trap_R_RegisterShader( str ); + } else if ( num >= CS_SOUNDS && num < CS_SOUNDS+MAX_SOUNDS ) { if ( str[0] != '*' ) { // player specific sounds don't register here cgs.gameSounds[ num-CS_SOUNDS] = trap_S_RegisterSound( str, qfalse ); } diff --git a/src/game/bg_public.h b/src/game/bg_public.h index 6205bc2e..da4f09ea 100644 --- a/src/game/bg_public.h +++ b/src/game/bg_public.h @@ -98,12 +98,13 @@ #define CS_MODELS 33 #define CS_SOUNDS (CS_MODELS+MAX_MODELS) -#define CS_PLAYERS (CS_SOUNDS+MAX_SOUNDS) +#define CS_SHADERS (CS_SOUNDS+MAX_SOUNDS) +#define CS_PLAYERS (CS_SHADERS+MAX_SHADERS) #define CS_PRECACHES (CS_PLAYERS+MAX_CLIENTS) #define CS_LOCATIONS (CS_PRECACHES+MAX_CLIENTS) -#define CS_PARTICLES (CS_LOCATIONS+MAX_LOCATIONS) +/*#define CS_PARTICLES (CS_LOCATIONS+MAX_LOCATIONS) TA: never used?!*/ -#define CS_MAX (CS_PARTICLES+MAX_LOCATIONS) +#define CS_MAX (CS_LOCATIONS+MAX_LOCATIONS) #if (CS_MAX) > MAX_CONFIGSTRINGS #error overflow: (CS_MAX) > MAX_CONFIGSTRINGS @@ -1003,6 +1004,7 @@ typedef enum { ET_TORCH, //TA: torch type ET_CORPSE, + ET_SPRITER, ET_EVENTS // any of the EV_* events can be added freestanding // by setting eType to ET_EVENTS + eventNum diff --git a/src/game/g_misc.c b/src/game/g_misc.c index a874d5b0..870b5144 100644 --- a/src/game/g_misc.c +++ b/src/game/g_misc.c @@ -70,24 +70,6 @@ void SP_light( gentity_t *self ) { G_FreeEntity( self ); } -//TA: position/colour/intensity calculating function -void ShineTorch( gentity_t *self ) -{ - vec3_t origin, angles; - - VectorCopy( self->parent->s.pos.trBase, origin ); - VectorCopy( self->parent->s.apos.trBase, angles ); - - G_SetOrigin( self, origin ); - - VectorCopy( angles, self->s.apos.trBase ); - - //so we can use the predicted values client side if available - self->s.clientNum = self->parent->s.number; - - trap_LinkEntity( self ); -} - /* @@ -356,3 +338,59 @@ void SP_shooter_grenade( gentity_t *ent ) { //InitShooter( ent, WP_GRENADE_LAUNCHER); } +/* +====================================================================== + + NEAT EFFECTS AND STUFF FOR TREMULOUS + +====================================================================== +*/ + +//TA: position/colour/intensity calculating function +void ShineTorch( gentity_t *self ) +{ + vec3_t origin, angles; + + VectorCopy( self->parent->s.pos.trBase, origin ); + VectorCopy( self->parent->s.apos.trBase, angles ); + + G_SetOrigin( self, origin ); + + VectorCopy( angles, self->s.apos.trBase ); + + //so we can use the predicted values client side if available + self->s.clientNum = self->parent->s.number; + + trap_LinkEntity( self ); +} + +void SP_spriter( gentity_t *self ) +{ + vec3_t accel; + + G_SetOrigin( self, self->s.origin ); + + VectorCopy( self->acceleration, self->s.origin2 ); + + self->s.time = (int)self->speed; + self->s.time2 = (int)self->wait; + self->s.powerups = (int)self->random; + self->s.angles2[ 0 ] = self->physicsBounce; + + self->s.modelindex = self->pos1[ 0 ]; + self->s.modelindex2 = self->pos1[ 1 ]; + + self->s.legsAnim = self->pos2[ 0 ]; + self->s.torsoAnim = self->pos2[ 1 ]; + + if( self->count > 0 ) + self->s.angles2[ 1 ] = ( 1000 / self->count ); + else + self->s.angles2[ 1 ] = 1000; + + self->s.weapon = G_ShaderIndex( self->targetShaderName ); + + self->s.eType = ET_SPRITER; + + trap_LinkEntity( self ); +} diff --git a/src/game/g_spawn.c b/src/game/g_spawn.c index 8f74a4ee..37dbc82e 100644 --- a/src/game/g_spawn.c +++ b/src/game/g_spawn.c @@ -118,6 +118,12 @@ field_t fields[] = { {"dmg", FOFS(damage), F_INT}, {"angles", FOFS(s.angles), F_VECTOR}, {"angle", FOFS(s.angles), F_ANGLEHACK}, + //TA + {"bounce", FOFS(physicsBounce), F_FLOAT}, + {"alpha", FOFS(pos1), F_VECTOR}, + {"radius", FOFS(pos2), F_VECTOR}, + {"acceleration", FOFS(acceleration), F_VECTOR}, + //TA {"targetShaderName", FOFS(targetShaderName), F_LSTRING}, {"targetShaderNewName", FOFS(targetShaderNewName), F_LSTRING}, @@ -135,8 +141,8 @@ void SP_info_player_deathmatch (gentity_t *ent); void SP_info_player_intermission (gentity_t *ent); //TA: extra bits -void SP_info_droid_intermission (gentity_t *ent); -void SP_info_human_intermission (gentity_t *ent); +void SP_info_droid_intermission( gentity_t *ent ); +void SP_info_human_intermission( gentity_t *ent ); void SP_info_firstplace(gentity_t *ent); void SP_info_secondplace(gentity_t *ent); @@ -195,6 +201,9 @@ void SP_team_CTF_blueplayer( gentity_t *ent ); void SP_team_CTF_redspawn( gentity_t *ent ); void SP_team_CTF_bluespawn( gentity_t *ent ); +//TA: +void SP_spriter( gentity_t *ent ); + spawn_t spawns[] = { // info entities don't do anything at all, but provide positional // information for things controlled by other processes @@ -266,6 +275,8 @@ spawn_t spawns[] = { {"team_CTF_redspawn", SP_team_CTF_redspawn}, {"team_CTF_bluespawn", SP_team_CTF_bluespawn}, + {"spriter", SP_spriter}, + {0, 0} }; diff --git a/src/game/g_utils.c b/src/game/g_utils.c index 07d0adf4..d13b9356 100644 --- a/src/game/g_utils.c +++ b/src/game/g_utils.c @@ -117,6 +117,10 @@ int G_FindConfigstringIndex( char *name, int start, int max, qboolean create ) { return i; } +//TA: added ShaderIndex +int G_ShaderIndex( char *name ) { + return G_FindConfigstringIndex (name, CS_SHADERS, MAX_SHADERS, qtrue); +} int G_ModelIndex( char *name ) { return G_FindConfigstringIndex (name, CS_MODELS, MAX_MODELS, qtrue); diff --git a/src/game/q_shared.h b/src/game/q_shared.h index b5fd5889..153ce970 100644 --- a/src/game/q_shared.h +++ b/src/game/q_shared.h @@ -1102,6 +1102,7 @@ typedef enum { #define MAX_MODELS 256 // these are sent over the net as 8 bits #define MAX_SOUNDS 256 // so they cannot be blindly increased +#define MAX_SHADERS 256 //TA: should be in bg_public.h #define MAX_CONFIGSTRINGS 1024 |