diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/cgame/cg_buildable.c | 55 | ||||
-rw-r--r-- | src/game/bg_misc.c | 57 | ||||
-rw-r--r-- | src/game/bg_public.h | 3 |
3 files changed, 110 insertions, 5 deletions
diff --git a/src/cgame/cg_buildable.c b/src/cgame/cg_buildable.c index b87483e6..9f4e6661 100644 --- a/src/cgame/cg_buildable.c +++ b/src/cgame/cg_buildable.c @@ -753,6 +753,7 @@ void CG_GhostBuildable( buildable_t buildable ) vec3_t angles, entity_origin; vec3_t mins, maxs; trace_t tr; + float scale; ps = &cg.predictedPlayerState; @@ -778,7 +779,19 @@ void CG_GhostBuildable( buildable_t buildable ) else ent.customShader = cgs.media.redBuildShader; - ent.nonNormalizedAxes = qfalse; + //rescale the model + scale = BG_FindModelScaleForBuildable( buildable ); + + if( scale != 1.0f ) + { + VectorScale( ent.axis[ 0 ], scale, ent.axis[ 0 ] ); + VectorScale( ent.axis[ 1 ], scale, ent.axis[ 1 ] ); + VectorScale( ent.axis[ 2 ], scale, ent.axis[ 2 ] ); + + ent.nonNormalizedAxes = qtrue; + } + else + ent.nonNormalizedAxes = qfalse; // add to refresh list trap_R_AddRefEntityToScene( &ent ); @@ -920,6 +933,7 @@ void CG_Buildable( centity_t *cent ) vec3_t refNormal = { 0.0f, 0.0f, 1.0f }; float rotAngle; buildableTeam_t team = BG_FindTeamForBuildable( es->modelindex ); + float scale; //must be before EF_NODRAW check if( team == BIT_ALIENS ) @@ -957,8 +971,6 @@ void CG_Buildable( centity_t *cent ) ent.hModel = cg_buildables[ es->modelindex ].models[ 0 ]; - ent.nonNormalizedAxes = qfalse; - if( !( es->generic1 & B_SPAWNED_TOGGLEBIT ) ) { sfxHandle_t prebuildSound = cgs.media.humanBuildablePrebuild; @@ -976,6 +988,21 @@ void CG_Buildable( centity_t *cent ) CG_BuildableAnimation( cent, &ent.oldframe, &ent.frame, &ent.backlerp ); + //rescale the model + scale = BG_FindModelScaleForBuildable( es->modelindex ); + + if( scale != 1.0f ) + { + VectorScale( ent.axis[ 0 ], scale, ent.axis[ 0 ] ); + VectorScale( ent.axis[ 1 ], scale, ent.axis[ 1 ] ); + VectorScale( ent.axis[ 2 ], scale, ent.axis[ 2 ] ); + + ent.nonNormalizedAxes = qtrue; + } + else + ent.nonNormalizedAxes = qfalse; + + //add to refresh list trap_R_AddRefEntityToScene( &ent ); @@ -1007,6 +1034,17 @@ void CG_Buildable( centity_t *cent ) turretBarrel.customShader = ent.customShader; + if( scale != 1.0f ) + { + VectorScale( turretBarrel.axis[ 0 ], scale, turretBarrel.axis[ 0 ] ); + VectorScale( turretBarrel.axis[ 1 ], scale, turretBarrel.axis[ 1 ] ); + VectorScale( turretBarrel.axis[ 2 ], scale, turretBarrel.axis[ 2 ] ); + + turretBarrel.nonNormalizedAxes = qtrue; + } + else + turretBarrel.nonNormalizedAxes = qfalse; + trap_R_AddRefEntityToScene( &turretBarrel ); } @@ -1038,6 +1076,17 @@ void CG_Buildable( centity_t *cent ) turretTop.customShader = ent.customShader; + if( scale != 1.0f ) + { + VectorScale( turretTop.axis[ 0 ], scale, turretTop.axis[ 0 ] ); + VectorScale( turretTop.axis[ 1 ], scale, turretTop.axis[ 1 ] ); + VectorScale( turretTop.axis[ 2 ], scale, turretTop.axis[ 2 ] ); + + turretTop.nonNormalizedAxes = qtrue; + } + else + turretTop.nonNormalizedAxes = qfalse; + trap_R_AddRefEntityToScene( &turretTop ); } diff --git a/src/game/bg_misc.c b/src/game/bg_misc.c index f227046f..15361e64 100644 --- a/src/game/bg_misc.c +++ b/src/game/bg_misc.c @@ -32,6 +32,7 @@ buildableAttributes_t bg_buildableList[ ] = "Egg", //char *humanName; "team_alien_spawn", //char *entityName; { "models/buildables/eggpod/eggpod.md3", 0, 0, 0 }, + 1.0f, //float modelScale; { -15, -15, -15 }, //vec3_t mins; { 15, 15, 15 }, //vec3_t maxs; 0.0f, //float zOffset; @@ -66,6 +67,7 @@ buildableAttributes_t bg_buildableList[ ] = "Barricade", //char *humanName; "team_alien_barricade",//char *entityName; { "models/buildables/barricade/barricade.md3", 0, 0, 0 }, + 1.0f, //float modelScale; { -35, -35, -15 }, //vec3_t mins; { 35, 35, 60 }, //vec3_t maxs; 0.0f, //float zOffset; @@ -100,6 +102,7 @@ buildableAttributes_t bg_buildableList[ ] = "Booster", //char *humanName; "team_alien_booster", //char *entityName; { "models/buildables/booster/booster.md3", 0, 0, 0 }, + 1.0f, //float modelScale; { -26, -26, -9 }, //vec3_t mins; { 26, 26, 9 }, //vec3_t maxs; 0.0f, //float zOffset; @@ -134,6 +137,7 @@ buildableAttributes_t bg_buildableList[ ] = "Acid Tube", //char *humanName; "team_alien_acid_tube",//char *entityName; { "models/buildables/acid_tube/acid_tube.md3", 0, 0, 0 }, + 1.0f, //float modelScale; { -25, -25, -25 }, //vec3_t mins; { 25, 25, 25 }, //vec3_t maxs; -15.0f, //float zOffset; @@ -155,7 +159,7 @@ buildableAttributes_t bg_buildableList[ ] = 0, //int turretRange; 0, //int turretFireSpeed; WP_NONE, //weapon_t turretProjType; - 0.707f, //float minNormal; + 0.0f, //float minNormal; qtrue, //qboolean invertNormal; qtrue, //qboolean creepTest; ACIDTUBE_CREEPSIZE, //int creepSize; @@ -168,6 +172,7 @@ buildableAttributes_t bg_buildableList[ ] = "Hive", //char *humanName; "team_alien_hive", //char *entityName; { "models/buildables/acid_tube/acid_tube.md3", 0, 0, 0 }, + 1.0f, //float modelScale; { -35, -35, -25 }, //vec3_t mins; { 35, 35, 25 }, //vec3_t maxs; -15.0f, //float zOffset; @@ -202,6 +207,7 @@ buildableAttributes_t bg_buildableList[ ] = "Trapper", //char *humanName; "team_alien_trapper", //char *entityName; { "models/buildables/trapper/trapper.md3", 0, 0, 0 }, + 1.0f, //float modelScale; { -15, -15, -15 }, //vec3_t mins; { 15, 15, 15 }, //vec3_t maxs; 0.0f, //float zOffset; @@ -236,6 +242,7 @@ buildableAttributes_t bg_buildableList[ ] = "Overmind", //char *humanName; "team_alien_overmind", //char *entityName; { "models/buildables/overmind/overmind.md3", 0, 0, 0 }, + 1.0f, //float modelScale; { -45, -45, -15 }, //vec3_t mins; { 45, 45, 95 }, //vec3_t maxs; 0.0f, //float zOffset; @@ -270,6 +277,7 @@ buildableAttributes_t bg_buildableList[ ] = "Hovel", //char *humanName; "team_alien_hovel", //char *entityName; { "models/buildables/hovel/hovel.md3", 0, 0, 0 }, + 1.0f, //float modelScale; { -50, -50, -20 }, //vec3_t mins; { 50, 50, 20 }, //vec3_t maxs; 0.0f, //float zOffset; @@ -304,6 +312,7 @@ buildableAttributes_t bg_buildableList[ ] = "Telenode", //char *humanName; "team_human_spawn", //char *entityName; { "models/buildables/telenode/telenode.md3", 0, 0, 0 }, + 1.0f, //float modelScale; { -40, -40, -4 }, //vec3_t mins; { 40, 40, 4 }, //vec3_t maxs; 0.0f, //float zOffset; @@ -338,6 +347,7 @@ buildableAttributes_t bg_buildableList[ ] = "Medistation", //char *humanName; "team_human_medistat", //char *entityName; { "models/buildables/medistat/medistat.md3", 0, 0, 0 }, + 1.0f, //float modelScale; { -35, -35, -7 }, //vec3_t mins; { 35, 35, 7 }, //vec3_t maxs; 0.0f, //float zOffset; @@ -374,6 +384,7 @@ buildableAttributes_t bg_buildableList[ ] = { "models/buildables/mgturret/turret_base.md3", "models/buildables/mgturret/turret_barrel.md3", "models/buildables/mgturret/turret_top.md3", 0 }, + 1.0f, //float modelScale; { -25, -25, -20 }, //vec3_t mins; { 25, 25, 20 }, //vec3_t maxs; 0.0f, //float zOffset; @@ -408,6 +419,7 @@ buildableAttributes_t bg_buildableList[ ] = "Tesla Generator", //char *humanName; "team_human_tesla", //char *entityName; { "models/buildables/tesla/tesla.md3", 0, 0, 0 }, + 1.0f, //float modelScale; { -22, -22, -40 }, //vec3_t mins; { 22, 22, 40 }, //vec3_t maxs; 0.0f, //float zOffset; @@ -442,6 +454,7 @@ buildableAttributes_t bg_buildableList[ ] = "Defence Computer", //char *humanName; "team_human_dcc", //char *entityName; { "models/buildables/dcc/dcc.md3", 0, 0, 0 }, + 1.0f, //float modelScale; { -35, -35, -13 }, //vec3_t mins; { 35, 35, 47 }, //vec3_t maxs; 0.0f, //float zOffset; @@ -476,6 +489,7 @@ buildableAttributes_t bg_buildableList[ ] = "Armoury", //char *humanName; "team_human_armoury", //char *entityName; { "models/buildables/arm/arm.md3", 0, 0, 0 }, + 1.0f, //float modelScale; { -40, -40, -13 }, //vec3_t mins; { 40, 40, 50 }, //vec3_t maxs; 0.0f, //float zOffset; @@ -510,6 +524,7 @@ buildableAttributes_t bg_buildableList[ ] = "Reactor", //char *humanName; "team_human_reactor", //char *entityName; { "models/buildables/reactor/reactor.md3", 0, 0, 0 }, + 1.0f, //float modelScale; { -50, -50, -15 }, //vec3_t mins; { 50, 50, 95 }, //vec3_t maxs; 0.0f, //float zOffset; @@ -544,6 +559,7 @@ buildableAttributes_t bg_buildableList[ ] = "Repeater", //char *humanName; "team_human_repeater", //char *entityName; { "models/buildables/repeater/repeater.md3", 0, 0, 0 }, + 1.0f, //float modelScale; { -15, -15, -15 }, //vec3_t mins; { 15, 15, 25 }, //vec3_t maxs; 0.0f, //float zOffset; @@ -698,6 +714,28 @@ char *BG_FindModelsForBuildable( int bclass, int modelNum ) /* ============== +BG_FindModelScaleForBuildable +============== +*/ +float BG_FindModelScaleForBuildable( int bclass ) +{ + int i; + + if( bg_buildableOverrideList[ bclass ].modelScale != 0.0f ) + return bg_buildableOverrideList[ bclass ].modelScale; + + for( i = 0; i < bg_numBuildables; i++ ) + { + if( bg_buildableList[ i ].buildNum == bclass ) + return bg_buildableList[ i ].modelScale; + } + + Com_Printf( S_COLOR_YELLOW "WARNING: fallthrough in BG_FindModelScaleForBuildable( %d )\n", bclass ); + return 1.0f; +} + +/* +============== BG_FindBBoxForBuildable ============== */ @@ -1267,6 +1305,7 @@ static qboolean BG_ParseBuildableFile( const char *filename, buildableAttributeO char *token; char text[ 20000 ]; fileHandle_t f; + float scale; // load the file @@ -1321,6 +1360,21 @@ static qboolean BG_ParseBuildableFile( const char *filename, buildableAttributeO continue; } + else if( !Q_stricmp( token, "modelScale" ) ) + { + token = COM_Parse( &text_p ); + if( !token ) + break; + + scale = atof( token ); + + if( scale < 0.0f ) + scale = 0.0f; + + bao->modelScale = scale; + + continue; + } else if( !Q_stricmp( token, "mins" ) ) { for( i = 0; i <= 2; i++ ) @@ -1356,7 +1410,6 @@ static qboolean BG_ParseBuildableFile( const char *filename, buildableAttributeO break; offset = atof( token ); - offset = 0.0f; bao->zOffset = offset; diff --git a/src/game/bg_public.h b/src/game/bg_public.h index 6bfb8a6b..f72f5791 100644 --- a/src/game/bg_public.h +++ b/src/game/bg_public.h @@ -966,6 +966,7 @@ typedef struct char *entityName; char *models[ MAX_BUILDABLE_MODELS ]; + float modelScale; vec3_t mins; vec3_t maxs; @@ -1012,6 +1013,7 @@ typedef struct { char models[ MAX_BUILDABLE_MODELS ][ MAX_QPATH ]; + float modelScale; vec3_t mins; vec3_t maxs; float zOffset; @@ -1100,6 +1102,7 @@ char *BG_FindNameForBuildable( int bclass ); char *BG_FindHumanNameForBuildable( int bclass ); char *BG_FindEntityNameForBuildable( int bclass ); char *BG_FindModelsForBuildable( int bclass, int modelNum ); +float BG_FindModelScaleForBuildable( int bclass ); void BG_FindBBoxForBuildable( int bclass, vec3_t mins, vec3_t maxs ); float BG_FindZOffsetForBuildable( int pclass ); int BG_FindHealthForBuildable( int bclass ); |