commit e21591fe9a5cd90bad40638713aeb2335c24a00c Author: devhc Date: Wed Jul 13 00:37:26 2011 +0200 shape functionality, extended range marker functionality diff --git a/src/cgame/cg_drawtools.c b/src/cgame/cg_drawtools.c index 323488e..d818c07 100644 --- a/src/cgame/cg_drawtools.c +++ b/src/cgame/cg_drawtools.c @@ -504,6 +504,72 @@ void CG_DrawSphericalCone( const vec3_t tip, const vec3_t rotation, float radius /* ================ +CG_DrawAxisAlignedBox +================ +*/ +void CG_DrawAxisAlignedBox( const vec3_t mins, const vec3_t maxs, + int customShader, const float *shaderRGBA ) +{ + refEntity_t re; + memset( &re, 0, sizeof( re ) ); + + re.reType = RT_MODEL; + re.hModel = cgs.media.cubeModel; + re.customShader = customShader; + re.renderfx = RF_NOSHADOW; + if( shaderRGBA != NULL ) + { + VectorScale( shaderRGBA, 255, re.shaderRGBA ); + re.shaderRGBA[ 3 ] = 255 * shaderRGBA[ 3 ]; + } + + VectorAdd( mins, maxs, re.origin ); + VectorScale( re.origin, 0.5f, re.origin ); + + VectorSet( re.axis[ 0 ], ( maxs[ 0 ] - mins[ 0 ] ) * 0.01f, 0, 0 ); + VectorSet( re.axis[ 1 ], 0, ( maxs[ 1 ] - mins[ 1 ] ) * 0.01f, 0 ); + VectorSet( re.axis[ 2 ], 0, 0, ( maxs[ 2 ] - mins[ 2 ] ) * 0.01f ); + re.nonNormalizedAxes = qtrue; + + trap_R_AddRefEntityToScene( &re ); +} + +/* +================ +CG_DrawCone +================ +*/ +void CG_DrawCone( const vec3_t tip, const vec3_t rotation, float baseRadius, + float height, int customShader, const float *shaderRGBA ) +{ + refEntity_t re; + memset( &re, 0, sizeof( re ) ); + + re.reType = RT_MODEL; + re.hModel = cgs.media.coneModel; + re.customShader = customShader; + re.renderfx = RF_NOSHADOW; + if( shaderRGBA != NULL ) + { + VectorScale( shaderRGBA, 255, re.shaderRGBA ); + re.shaderRGBA[ 3 ] = 255 * shaderRGBA[ 3 ]; + } + + VectorCopy( tip, re.origin ); + + baseRadius *= 0.01f; + height *= 0.01f; + AnglesToAxis( rotation, re.axis ); + VectorScale( re.axis[ 0 ], height, re.axis[ 0 ] ); + VectorScale( re.axis[ 1 ], baseRadius, re.axis[ 1 ] ); + VectorScale( re.axis[ 2 ], baseRadius, re.axis[ 2 ] ); + re.nonNormalizedAxes = qtrue; + + trap_R_AddRefEntityToScene( &re ); +} + +/* +================ CG_DrawRangeMarker ================ */ @@ -526,6 +592,8 @@ void CG_DrawRangeMarker( int rmType, const vec3_t origin, const float *angles, f CG_DrawSphericalCone( origin, angles, range, qfalse, pcsh, rgba ); else if( rmType == 2 ) CG_DrawSphericalCone( origin, angles, range, qtrue, pcsh, rgba ); + else if( rmType == 3 ) + CG_DrawAxisAlignedBox( origin, angles, pcsh, rgba ); } if( drawIntersection || drawFrontline ) @@ -574,6 +642,28 @@ void CG_DrawRangeMarker( int rmType, const vec3_t origin, const float *angles, f CG_DrawSphericalCone( tip, angles, range + r, t2, mbsh->b2, NULL ); CG_DrawSphericalCone( tip, angles, range + r, t2, mbsh->f1, NULL ); } + else if( rmType == 3 ) + { + vec3_t delta, mins, maxs; + + VectorSet( delta, lineThickness, lineThickness, lineThickness ); + VectorScale( delta, 0.5f, delta ); + + VectorAdd( origin, delta, mins ); + VectorSubtract( angles, delta, maxs ); + if( mins[ 0 ] < maxs[ 0 ] && mins[ 1 ] < maxs[ 1 ] && mins[ 2 ] < maxs[ 2 ] ) + { + if( drawIntersection ) + CG_DrawAxisAlignedBox( mins, maxs, mbsh->b1, NULL ); + CG_DrawAxisAlignedBox( mins, maxs, mbsh->f2, NULL ); + } + + VectorSubtract( origin, delta, mins ); + VectorAdd( angles, delta, maxs ); + if( drawIntersection ) + CG_DrawAxisAlignedBox( mins, maxs, mbsh->b2, NULL ); + CG_DrawAxisAlignedBox( mins, maxs, mbsh->f1, NULL ); + } bshs = &cg.binaryShaderSettings[ cg.numBinaryShadersUsed ]; VectorScale( rgb, 255 * lineOpacity, bshs->color ); diff --git a/src/cgame/cg_ents.c b/src/cgame/cg_ents.c index 2137966..a08e918 100644 --- a/src/cgame/cg_ents.c +++ b/src/cgame/cg_ents.c @@ -1001,6 +1001,63 @@ void CG_RangeMarker( centity_t *cent ) /* +================ +CG_Shape +================ +*/ +void CG_Shape( centity_t *cent ) +{ + int rmType; + const float *origin, *angles; + float radius, height; + vec4_t rgba; + int shaderIndex; + int customShader; + + rmType = cent->currentState.modelindex; + origin = cent->lerpOrigin; + angles = cent->lerpAngles; + radius = cent->currentState.origin[ 0 ]; + height = cent->currentState.origin[ 1 ]; + rgba[ 0 ] = cent->currentState.torsoAnim / 255.0f; + rgba[ 1 ] = cent->currentState.weaponAnim / 255.0f; + rgba[ 2 ] = cent->currentState.legsAnim / 255.0f; + rgba[ 3 ] = cent->currentState.weapon / 255.0f; + shaderIndex = cent->currentState.modelindex2; + + if( shaderIndex == MAX_GAME_SHADERS ) + { + qboolean drawS, drawI, drawF; + float so, lo, th; + + if( CG_GetRangeMarkerPreferences( &drawS, &drawI, &drawF, &so, &lo, &th ) ) + { + VectorScale( rgba, rgba[ 3 ], rgba ); + CG_DrawRangeMarker( rmType, origin, angles, radius, drawS, drawI, drawF, rgba, so, lo, th ); + } + + return; + } + + if( shaderIndex > 0 && shaderIndex < MAX_GAME_SHADERS ) + customShader = cgs.gameShaders[ shaderIndex ]; + else + customShader = 0; + + if( rmType == 0 ) + CG_DrawSphere( origin, radius, customShader, rgba ); + else if( rmType == 1 ) + CG_DrawSphericalCone( origin, angles, radius, qfalse, customShader, rgba ); + else if( rmType == 2 ) + CG_DrawSphericalCone( origin, angles, radius, qtrue, customShader, rgba ); + else if( rmType == 3 ) + CG_DrawAxisAlignedBox( origin, angles, customShader, rgba ); + else if( rmType == 4 ) + CG_DrawCone( origin, angles, radius, height, customShader, rgba ); +} + + +/* =============== CG_CEntityPVSEnter @@ -1128,6 +1185,10 @@ static void CG_AddCEntity( centity_t *cent ) CG_Beam( cent ); break; + case ET_SHAPE: + CG_Shape( cent ); + break; + case ET_PORTAL: CG_Portal( cent ); break; diff --git a/src/cgame/cg_local.h b/src/cgame/cg_local.h index 74eb7d4..b70d0e4 100644 --- a/src/cgame/cg_local.h +++ b/src/cgame/cg_local.h @@ -1216,6 +1216,8 @@ typedef struct qhandle_t sphereModel; qhandle_t sphericalCone64Model; qhandle_t sphericalCone240Model; + qhandle_t cubeModel; + qhandle_t coneModel; qhandle_t plainColorShader; qhandle_t binaryAlpha1Shader; @@ -1669,6 +1671,10 @@ char CG_GetColorCharForHealth( int clientnum ); void CG_DrawSphere( const vec3_t center, float radius, int customShader, const float *shaderRGBA ); void CG_DrawSphericalCone( const vec3_t tip, const vec3_t rotation, float radius, qboolean a240, int customShader, const float *shaderRGBA ); +void CG_DrawAxisAlignedBox( const vec3_t mins, const vec3_t maxs, + int customShader, const float *shaderRGBA ); +void CG_DrawCone( const vec3_t tip, const vec3_t rotation, float baseRadius, + float height, int customShader, const float *shaderRGBA ); void CG_DrawRangeMarker( int rmType, const vec3_t origin, const float *angles, float range, qboolean drawSurface, qboolean drawIntersection, qboolean drawFrontline, const vec3_t rgb, float surfaceOpacity, float lineOpacity, float lineThickness ); diff --git a/src/cgame/cg_main.c b/src/cgame/cg_main.c index d3976f3..e652cb5 100644 --- a/src/cgame/cg_main.c +++ b/src/cgame/cg_main.c @@ -944,6 +944,8 @@ static void CG_RegisterGraphics( void ) cgs.media.sphereModel = trap_R_RegisterModel( "models/generic/sphere" ); cgs.media.sphericalCone64Model = trap_R_RegisterModel( "models/generic/sphericalCone64" ); cgs.media.sphericalCone240Model = trap_R_RegisterModel( "models/generic/sphericalCone240" ); + cgs.media.cubeModel = trap_R_RegisterModel( "models/au12/cube" ); + cgs.media.coneModel = trap_R_RegisterModel( "models/au12/cone" ); cgs.media.plainColorShader = trap_R_RegisterShader( "gfx/plainColor" ); cgs.media.binaryAlpha1Shader = trap_R_RegisterShader( "gfx/binary/alpha1" ); diff --git a/src/game/bg_public.h b/src/game/bg_public.h index 0896fc1..98ec459 100644 --- a/src/game/bg_public.h +++ b/src/game/bg_public.h @@ -1191,6 +1191,7 @@ typedef enum ET_MISSILE, ET_MOVER, ET_BEAM, + ET_SHAPE, ET_PORTAL, ET_SPEAKER, ET_PUSH_TRIGGER, diff --git a/src/game/g_svcmds.c b/src/game/g_svcmds.c index f6832c4..8aa4a5e 100644 --- a/src/game/g_svcmds.c +++ b/src/game/g_svcmds.c @@ -73,6 +73,9 @@ void Svcmd_EntityList_f( void ) case ET_BEAM: G_Printf( "ET_BEAM " ); break; + case ET_SHAPE: + G_Printf( "ET_SHAPE " ); + break; case ET_PORTAL: G_Printf( "ET_PORTAL " ); break;