Main Page | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

tr_surface.c File Reference

#include "tr_local.h"

Include dependency graph for tr_surface.c:

Include dependency graph

Go to the source code of this file.

Defines

#define NUM_BEAM_SEGS   6

Functions

void DoRailCore (const vec3_t start, const vec3_t end, const vec3_t up, float len, float spanWidth)
void DoRailDiscs (int numSegs, const vec3_t start, const vec3_t dir, const vec3_t right, const vec3_t up)
void LerpMeshVertexes (md3Surface_t *surf, float backlerp)
float LodErrorForVolume (vec3_t local, float radius)
void RB_AddQuadStamp (vec3_t origin, vec3_t left, vec3_t up, byte *color)
void RB_AddQuadStampExt (vec3_t origin, vec3_t left, vec3_t up, byte *color, float s1, float t1, float s2, float t2)
void RB_CheckOverflow (int verts, int indexes)
void RB_SurfaceAxis (void)
void RB_SurfaceBad (surfaceType_t *surfType)
void RB_SurfaceBeam (void)
void RB_SurfaceDisplayList (srfDisplayList_t *surf)
void RB_SurfaceEntity (surfaceType_t *surfType)
void RB_SurfaceFace (srfSurfaceFace_t *surf)
void RB_SurfaceFlare (srfFlare_t *surf)
void RB_SurfaceGrid (srfGridMesh_t *cv)
void RB_SurfaceLightningBolt (void)
void RB_SurfaceMesh (md3Surface_t *surface)
void RB_SurfacePolychain (srfPoly_t *p)
void RB_SurfaceRailCore (void)
void RB_SurfaceRailRings (void)
void RB_SurfaceSkip (void *surf)
void RB_SurfaceSprite (void)
void RB_SurfaceTriangles (srfTriangles_t *srf)
void VectorArrayNormalize (vec4_t *normals, unsigned int count)

Variables

void(* rb_surfaceTable [SF_NUM_SURFACE_TYPES])(void *)


Define Documentation

#define NUM_BEAM_SEGS   6
 

Referenced by RB_SurfaceBeam().


Function Documentation

void DoRailCore const vec3_t  start,
const vec3_t  end,
const vec3_t  up,
float  len,
float  spanWidth
[static]
 

Definition at line 338 of file tr_surface.c.

References backEnd, backEndState_t::currentEntity, trRefEntity_t::e, shaderCommands_s::indexes, shaderCommands_s::numIndexes, shaderCommands_s::numVertexes, refEntity_t::shaderRGBA, t, tess, shaderCommands_s::texCoords, up, VectorMA, shaderCommands_s::vertexColors, and shaderCommands_s::xyz.

Referenced by RB_SurfaceLightningBolt(), and RB_SurfaceRailCore().

00339 {
00340     float       spanWidth2;
00341     int         vbase;
00342     float       t = len / 256.0f;
00343 
00344     vbase = tess.numVertexes;
00345 
00346     spanWidth2 = -spanWidth;
00347 
00348     // FIXME: use quad stamp?
00349     VectorMA( start, spanWidth, up, tess.xyz[tess.numVertexes] );
00350     tess.texCoords[tess.numVertexes][0][0] = 0;
00351     tess.texCoords[tess.numVertexes][0][1] = 0;
00352     tess.vertexColors[tess.numVertexes][0] = backEnd.currentEntity->e.shaderRGBA[0] * 0.25;
00353     tess.vertexColors[tess.numVertexes][1] = backEnd.currentEntity->e.shaderRGBA[1] * 0.25;
00354     tess.vertexColors[tess.numVertexes][2] = backEnd.currentEntity->e.shaderRGBA[2] * 0.25;
00355     tess.numVertexes++;
00356 
00357     VectorMA( start, spanWidth2, up, tess.xyz[tess.numVertexes] );
00358     tess.texCoords[tess.numVertexes][0][0] = 0;
00359     tess.texCoords[tess.numVertexes][0][1] = 1;
00360     tess.vertexColors[tess.numVertexes][0] = backEnd.currentEntity->e.shaderRGBA[0];
00361     tess.vertexColors[tess.numVertexes][1] = backEnd.currentEntity->e.shaderRGBA[1];
00362     tess.vertexColors[tess.numVertexes][2] = backEnd.currentEntity->e.shaderRGBA[2];
00363     tess.numVertexes++;
00364 
00365     VectorMA( end, spanWidth, up, tess.xyz[tess.numVertexes] );
00366 
00367     tess.texCoords[tess.numVertexes][0][0] = t;
00368     tess.texCoords[tess.numVertexes][0][1] = 0;
00369     tess.vertexColors[tess.numVertexes][0] = backEnd.currentEntity->e.shaderRGBA[0];
00370     tess.vertexColors[tess.numVertexes][1] = backEnd.currentEntity->e.shaderRGBA[1];
00371     tess.vertexColors[tess.numVertexes][2] = backEnd.currentEntity->e.shaderRGBA[2];
00372     tess.numVertexes++;
00373 
00374     VectorMA( end, spanWidth2, up, tess.xyz[tess.numVertexes] );
00375     tess.texCoords[tess.numVertexes][0][0] = t;
00376     tess.texCoords[tess.numVertexes][0][1] = 1;
00377     tess.vertexColors[tess.numVertexes][0] = backEnd.currentEntity->e.shaderRGBA[0];
00378     tess.vertexColors[tess.numVertexes][1] = backEnd.currentEntity->e.shaderRGBA[1];
00379     tess.vertexColors[tess.numVertexes][2] = backEnd.currentEntity->e.shaderRGBA[2];
00380     tess.numVertexes++;
00381 
00382     tess.indexes[tess.numIndexes++] = vbase;
00383     tess.indexes[tess.numIndexes++] = vbase + 1;
00384     tess.indexes[tess.numIndexes++] = vbase + 2;
00385 
00386     tess.indexes[tess.numIndexes++] = vbase + 2;
00387     tess.indexes[tess.numIndexes++] = vbase + 1;
00388     tess.indexes[tess.numIndexes++] = vbase + 3;
00389 }

void DoRailDiscs int  numSegs,
const vec3_t  start,
const vec3_t  dir,
const vec3_t  right,
const vec3_t  up
[static]
 

Definition at line 391 of file tr_surface.c.

References backEnd, c, cos(), backEndState_t::currentEntity, DEG2RAD, trRefEntity_t::e, i, shaderCommands_s::indexes, cvar_s::integer, j, shaderCommands_s::numIndexes, shaderCommands_s::numVertexes, r_railWidth, RB_CHECKOVERFLOW, right, s, refEntity_t::shaderRGBA, sin(), tess, shaderCommands_s::texCoords, up, v, vec3_t, VectorAdd, VectorCopy, shaderCommands_s::vertexColors, and shaderCommands_s::xyz.

Referenced by RB_SurfaceRailRings().

00392 {
00393     int i;
00394     vec3_t  pos[4];
00395     vec3_t  v;
00396     int     spanWidth = r_railWidth->integer;
00397     float c, s;
00398     float       scale;
00399 
00400     if ( numSegs > 1 )
00401         numSegs--;
00402     if ( !numSegs )
00403         return;
00404 
00405     scale = 0.25;
00406 
00407     for ( i = 0; i < 4; i++ )
00408     {
00409         c = cos( DEG2RAD( 45 + i * 90 ) );
00410         s = sin( DEG2RAD( 45 + i * 90 ) );
00411         v[0] = ( right[0] * c + up[0] * s ) * scale * spanWidth;
00412         v[1] = ( right[1] * c + up[1] * s ) * scale * spanWidth;
00413         v[2] = ( right[2] * c + up[2] * s ) * scale * spanWidth;
00414         VectorAdd( start, v, pos[i] );
00415 
00416         if ( numSegs > 1 )
00417         {
00418             // offset by 1 segment if we're doing a long distance shot
00419             VectorAdd( pos[i], dir, pos[i] );
00420         }
00421     }
00422 
00423     for ( i = 0; i < numSegs; i++ )
00424     {
00425         int j;
00426 
00427         RB_CHECKOVERFLOW( 4, 6 );
00428 
00429         for ( j = 0; j < 4; j++ )
00430         {
00431             VectorCopy( pos[j], tess.xyz[tess.numVertexes] );
00432             tess.texCoords[tess.numVertexes][0][0] = ( j < 2 );
00433             tess.texCoords[tess.numVertexes][0][1] = ( j && j != 3 );
00434             tess.vertexColors[tess.numVertexes][0] = backEnd.currentEntity->e.shaderRGBA[0];
00435             tess.vertexColors[tess.numVertexes][1] = backEnd.currentEntity->e.shaderRGBA[1];
00436             tess.vertexColors[tess.numVertexes][2] = backEnd.currentEntity->e.shaderRGBA[2];
00437             tess.numVertexes++;
00438 
00439             VectorAdd( pos[j], dir, pos[j] );
00440         }
00441 
00442         tess.indexes[tess.numIndexes++] = tess.numVertexes - 4 + 0;
00443         tess.indexes[tess.numIndexes++] = tess.numVertexes - 4 + 1;
00444         tess.indexes[tess.numIndexes++] = tess.numVertexes - 4 + 3;
00445         tess.indexes[tess.numIndexes++] = tess.numVertexes - 4 + 3;
00446         tess.indexes[tess.numIndexes++] = tess.numVertexes - 4 + 1;
00447         tess.indexes[tess.numIndexes++] = tess.numVertexes - 4 + 2;
00448     }
00449 }

Here is the call graph for this function:

void LerpMeshVertexes md3Surface_t surf,
float  backlerp
[static]
 

Definition at line 610 of file tr_surface.c.

References backEnd, byte, backEndState_t::currentEntity, trRefEntity_t::e, refEntity_t::frame, FUNCTABLE_SIZE, MD3_XYZ_SCALE, shaderCommands_s::normal, shaderCommands_s::numVertexes, md3Surface_t::numVerts, md3Surface_t::ofsXyzNormals, refEntity_t::oldframe, trGlobals_t::sinTable, tess, tr, vec3_t, VectorArrayNormalize(), shaderCommands_s::xyz, and zero().

Referenced by RB_SurfaceMesh().

00611 {
00612     short   *oldXyz, *newXyz, *oldNormals, *newNormals;
00613     float   *outXyz, *outNormal;
00614     float   oldXyzScale, newXyzScale;
00615     float   oldNormalScale, newNormalScale;
00616     int     vertNum;
00617     unsigned lat, lng;
00618     int     numVerts;
00619 
00620     outXyz = tess.xyz[tess.numVertexes];
00621     outNormal = tess.normal[tess.numVertexes];
00622 
00623     newXyz = (short *)((byte *)surf + surf->ofsXyzNormals)
00624         + (backEnd.currentEntity->e.frame * surf->numVerts * 4);
00625     newNormals = newXyz + 3;
00626 
00627     newXyzScale = MD3_XYZ_SCALE * (1.0 - backlerp);
00628     newNormalScale = 1.0 - backlerp;
00629 
00630     numVerts = surf->numVerts;
00631 
00632     if ( backlerp == 0 ) {
00633 #if idppc_altivec
00634         vector signed short newNormalsVec0;
00635         vector signed short newNormalsVec1;
00636         vector signed int newNormalsIntVec;
00637         vector float newNormalsFloatVec;
00638         vector float newXyzScaleVec;
00639         vector unsigned char newNormalsLoadPermute;
00640         vector unsigned char newNormalsStorePermute;
00641         vector float zero;
00642         
00643         newNormalsStorePermute = vec_lvsl(0,(float *)&newXyzScaleVec);
00644         newXyzScaleVec = *(vector float *)&newXyzScale;
00645         newXyzScaleVec = vec_perm(newXyzScaleVec,newXyzScaleVec,newNormalsStorePermute);
00646         newXyzScaleVec = vec_splat(newXyzScaleVec,0);       
00647         newNormalsLoadPermute = vec_lvsl(0,newXyz);
00648         newNormalsStorePermute = vec_lvsr(0,outXyz);
00649         zero = (vector float)vec_splat_s8(0);
00650         //
00651         // just copy the vertexes
00652         //
00653         for (vertNum=0 ; vertNum < numVerts ; vertNum++,
00654             newXyz += 4, newNormals += 4,
00655             outXyz += 4, outNormal += 4) 
00656         {
00657             newNormalsLoadPermute = vec_lvsl(0,newXyz);
00658             newNormalsStorePermute = vec_lvsr(0,outXyz);
00659             newNormalsVec0 = vec_ld(0,newXyz);
00660             newNormalsVec1 = vec_ld(16,newXyz);
00661             newNormalsVec0 = vec_perm(newNormalsVec0,newNormalsVec1,newNormalsLoadPermute);
00662             newNormalsIntVec = vec_unpackh(newNormalsVec0);
00663             newNormalsFloatVec = vec_ctf(newNormalsIntVec,0);
00664             newNormalsFloatVec = vec_madd(newNormalsFloatVec,newXyzScaleVec,zero);
00665             newNormalsFloatVec = vec_perm(newNormalsFloatVec,newNormalsFloatVec,newNormalsStorePermute);
00666             //outXyz[0] = newXyz[0] * newXyzScale;
00667             //outXyz[1] = newXyz[1] * newXyzScale;
00668             //outXyz[2] = newXyz[2] * newXyzScale;
00669 
00670             lat = ( newNormals[0] >> 8 ) & 0xff;
00671             lng = ( newNormals[0] & 0xff );
00672             lat *= (FUNCTABLE_SIZE/256);
00673             lng *= (FUNCTABLE_SIZE/256);
00674 
00675             // decode X as cos( lat ) * sin( long )
00676             // decode Y as sin( lat ) * sin( long )
00677             // decode Z as cos( long )
00678 
00679             outNormal[0] = tr.sinTable[(lat+(FUNCTABLE_SIZE/4))&FUNCTABLE_MASK] * tr.sinTable[lng];
00680             outNormal[1] = tr.sinTable[lat] * tr.sinTable[lng];
00681             outNormal[2] = tr.sinTable[(lng+(FUNCTABLE_SIZE/4))&FUNCTABLE_MASK];
00682 
00683             vec_ste(newNormalsFloatVec,0,outXyz);
00684             vec_ste(newNormalsFloatVec,4,outXyz);
00685             vec_ste(newNormalsFloatVec,8,outXyz);
00686         }
00687         
00688 #else
00689         //
00690         // just copy the vertexes
00691         //
00692         for (vertNum=0 ; vertNum < numVerts ; vertNum++,
00693             newXyz += 4, newNormals += 4,
00694             outXyz += 4, outNormal += 4) 
00695         {
00696 
00697             outXyz[0] = newXyz[0] * newXyzScale;
00698             outXyz[1] = newXyz[1] * newXyzScale;
00699             outXyz[2] = newXyz[2] * newXyzScale;
00700 
00701             lat = ( newNormals[0] >> 8 ) & 0xff;
00702             lng = ( newNormals[0] & 0xff );
00703             lat *= (FUNCTABLE_SIZE/256);
00704             lng *= (FUNCTABLE_SIZE/256);
00705 
00706             // decode X as cos( lat ) * sin( long )
00707             // decode Y as sin( lat ) * sin( long )
00708             // decode Z as cos( long )
00709 
00710             outNormal[0] = tr.sinTable[(lat+(FUNCTABLE_SIZE/4))&FUNCTABLE_MASK] * tr.sinTable[lng];
00711             outNormal[1] = tr.sinTable[lat] * tr.sinTable[lng];
00712             outNormal[2] = tr.sinTable[(lng+(FUNCTABLE_SIZE/4))&FUNCTABLE_MASK];
00713         }
00714 #endif
00715     } else {
00716         //
00717         // interpolate and copy the vertex and normal
00718         //
00719         oldXyz = (short *)((byte *)surf + surf->ofsXyzNormals)
00720             + (backEnd.currentEntity->e.oldframe * surf->numVerts * 4);
00721         oldNormals = oldXyz + 3;
00722 
00723         oldXyzScale = MD3_XYZ_SCALE * backlerp;
00724         oldNormalScale = backlerp;
00725 
00726         for (vertNum=0 ; vertNum < numVerts ; vertNum++,
00727             oldXyz += 4, newXyz += 4, oldNormals += 4, newNormals += 4,
00728             outXyz += 4, outNormal += 4) 
00729         {
00730             vec3_t uncompressedOldNormal, uncompressedNewNormal;
00731 
00732             // interpolate the xyz
00733             outXyz[0] = oldXyz[0] * oldXyzScale + newXyz[0] * newXyzScale;
00734             outXyz[1] = oldXyz[1] * oldXyzScale + newXyz[1] * newXyzScale;
00735             outXyz[2] = oldXyz[2] * oldXyzScale + newXyz[2] * newXyzScale;
00736 
00737             // FIXME: interpolate lat/long instead?
00738             lat = ( newNormals[0] >> 8 ) & 0xff;
00739             lng = ( newNormals[0] & 0xff );
00740             lat *= 4;
00741             lng *= 4;
00742             uncompressedNewNormal[0] = tr.sinTable[(lat+(FUNCTABLE_SIZE/4))&FUNCTABLE_MASK] * tr.sinTable[lng];
00743             uncompressedNewNormal[1] = tr.sinTable[lat] * tr.sinTable[lng];
00744             uncompressedNewNormal[2] = tr.sinTable[(lng+(FUNCTABLE_SIZE/4))&FUNCTABLE_MASK];
00745 
00746             lat = ( oldNormals[0] >> 8 ) & 0xff;
00747             lng = ( oldNormals[0] & 0xff );
00748             lat *= 4;
00749             lng *= 4;
00750 
00751             uncompressedOldNormal[0] = tr.sinTable[(lat+(FUNCTABLE_SIZE/4))&FUNCTABLE_MASK] * tr.sinTable[lng];
00752             uncompressedOldNormal[1] = tr.sinTable[lat] * tr.sinTable[lng];
00753             uncompressedOldNormal[2] = tr.sinTable[(lng+(FUNCTABLE_SIZE/4))&FUNCTABLE_MASK];
00754 
00755             outNormal[0] = uncompressedOldNormal[0] * oldNormalScale + uncompressedNewNormal[0] * newNormalScale;
00756             outNormal[1] = uncompressedOldNormal[1] * oldNormalScale + uncompressedNewNormal[1] * newNormalScale;
00757             outNormal[2] = uncompressedOldNormal[2] * oldNormalScale + uncompressedNewNormal[2] * newNormalScale;
00758 
00759 //          VectorNormalize (outNormal);
00760         }
00761         VectorArrayNormalize((vec4_t *)tess.normal[tess.numVertexes], numVerts);
00762     }
00763 }

Here is the call graph for this function:

float LodErrorForVolume vec3_t  local,
float  radius
[static]
 

Definition at line 870 of file tr_surface.c.

References orientationr_t::axis, backEnd, d, DotProduct, viewParms_t::or, backEndState_t::or, orientationr_t::origin, r_lodCurveError, cvar_s::value, vec3_t, VectorSubtract, and backEndState_t::viewParms.

Referenced by RB_SurfaceGrid().

00870                                                                 {
00871     vec3_t      world;
00872     float       d;
00873 
00874     // never let it go negative
00875     if ( r_lodCurveError->value < 0 ) {
00876         return 0;
00877     }
00878 
00879     world[0] = local[0] * backEnd.or.axis[0][0] + local[1] * backEnd.or.axis[1][0] + 
00880         local[2] * backEnd.or.axis[2][0] + backEnd.or.origin[0];
00881     world[1] = local[0] * backEnd.or.axis[0][1] + local[1] * backEnd.or.axis[1][1] + 
00882         local[2] * backEnd.or.axis[2][1] + backEnd.or.origin[1];
00883     world[2] = local[0] * backEnd.or.axis[0][2] + local[1] * backEnd.or.axis[1][2] + 
00884         local[2] * backEnd.or.axis[2][2] + backEnd.or.origin[2];
00885 
00886     VectorSubtract( world, backEnd.viewParms.or.origin, world );
00887     d = DotProduct( world, backEnd.viewParms.or.axis[0] );
00888 
00889     if ( d < 0 ) {
00890         d = -d;
00891     }
00892     d -= radius;
00893     if ( d < 1 ) {
00894         d = 1;
00895     }
00896 
00897     return r_lodCurveError->value / d;
00898 }

void RB_AddQuadStamp vec3_t  origin,
vec3_t  left,
vec3_t  up,
byte color
 

Definition at line 144 of file tr_surface.c.

References byte, RB_AddQuadStampExt(), and up.

Referenced by AutospriteDeform(), and RB_SurfaceSprite().

00144                                                                            {
00145     RB_AddQuadStampExt( origin, left, up, color, 0, 0, 1, 1 );
00146 }

Here is the call graph for this function:

void RB_AddQuadStampExt vec3_t  origin,
vec3_t  left,
vec3_t  up,
byte color,
float  s1,
float  t1,
float  s2,
float  t2
 

Definition at line 72 of file tr_surface.c.

References orientationr_t::axis, backEnd, byte, shaderCommands_s::indexes, shaderCommands_s::normal, shaderCommands_s::numIndexes, shaderCommands_s::numVertexes, viewParms_t::or, RB_CHECKOVERFLOW, tess, shaderCommands_s::texCoords, up, vec3_origin, vec3_t, VectorSubtract, shaderCommands_s::vertexColors, backEndState_t::viewParms, and shaderCommands_s::xyz.

Referenced by DeformText(), RB_AddQuadStamp(), and RB_SurfaceFlare().

00072                                                                                                                       {
00073     vec3_t      normal;
00074     int         ndx;
00075 
00076     RB_CHECKOVERFLOW( 4, 6 );
00077 
00078     ndx = tess.numVertexes;
00079 
00080     // triangle indexes for a simple quad
00081     tess.indexes[ tess.numIndexes ] = ndx;
00082     tess.indexes[ tess.numIndexes + 1 ] = ndx + 1;
00083     tess.indexes[ tess.numIndexes + 2 ] = ndx + 3;
00084 
00085     tess.indexes[ tess.numIndexes + 3 ] = ndx + 3;
00086     tess.indexes[ tess.numIndexes + 4 ] = ndx + 1;
00087     tess.indexes[ tess.numIndexes + 5 ] = ndx + 2;
00088 
00089     tess.xyz[ndx][0] = origin[0] + left[0] + up[0];
00090     tess.xyz[ndx][1] = origin[1] + left[1] + up[1];
00091     tess.xyz[ndx][2] = origin[2] + left[2] + up[2];
00092 
00093     tess.xyz[ndx+1][0] = origin[0] - left[0] + up[0];
00094     tess.xyz[ndx+1][1] = origin[1] - left[1] + up[1];
00095     tess.xyz[ndx+1][2] = origin[2] - left[2] + up[2];
00096 
00097     tess.xyz[ndx+2][0] = origin[0] - left[0] - up[0];
00098     tess.xyz[ndx+2][1] = origin[1] - left[1] - up[1];
00099     tess.xyz[ndx+2][2] = origin[2] - left[2] - up[2];
00100 
00101     tess.xyz[ndx+3][0] = origin[0] + left[0] - up[0];
00102     tess.xyz[ndx+3][1] = origin[1] + left[1] - up[1];
00103     tess.xyz[ndx+3][2] = origin[2] + left[2] - up[2];
00104 
00105 
00106     // constant normal all the way around
00107     VectorSubtract( vec3_origin, backEnd.viewParms.or.axis[0], normal );
00108 
00109     tess.normal[ndx][0] = tess.normal[ndx+1][0] = tess.normal[ndx+2][0] = tess.normal[ndx+3][0] = normal[0];
00110     tess.normal[ndx][1] = tess.normal[ndx+1][1] = tess.normal[ndx+2][1] = tess.normal[ndx+3][1] = normal[1];
00111     tess.normal[ndx][2] = tess.normal[ndx+1][2] = tess.normal[ndx+2][2] = tess.normal[ndx+3][2] = normal[2];
00112     
00113     // standard square texture coordinates
00114     tess.texCoords[ndx][0][0] = tess.texCoords[ndx][1][0] = s1;
00115     tess.texCoords[ndx][0][1] = tess.texCoords[ndx][1][1] = t1;
00116 
00117     tess.texCoords[ndx+1][0][0] = tess.texCoords[ndx+1][1][0] = s2;
00118     tess.texCoords[ndx+1][0][1] = tess.texCoords[ndx+1][1][1] = t1;
00119 
00120     tess.texCoords[ndx+2][0][0] = tess.texCoords[ndx+2][1][0] = s2;
00121     tess.texCoords[ndx+2][0][1] = tess.texCoords[ndx+2][1][1] = t2;
00122 
00123     tess.texCoords[ndx+3][0][0] = tess.texCoords[ndx+3][1][0] = s1;
00124     tess.texCoords[ndx+3][0][1] = tess.texCoords[ndx+3][1][1] = t2;
00125 
00126     // constant color all the way around
00127     // should this be identity and let the shader specify from entity?
00128     * ( unsigned int * ) &tess.vertexColors[ndx] = 
00129     * ( unsigned int * ) &tess.vertexColors[ndx+1] = 
00130     * ( unsigned int * ) &tess.vertexColors[ndx+2] = 
00131     * ( unsigned int * ) &tess.vertexColors[ndx+3] = 
00132         * ( unsigned int * )color;
00133 
00134 
00135     tess.numVertexes += 4;
00136     tess.numIndexes += 6;
00137 }

void RB_CheckOverflow int  verts,
int  indexes
 

Definition at line 48 of file tr_surface.c.

References ERR_DROP, shaderCommands_s::fogNum, shaderCommands_s::numIndexes, shaderCommands_s::numVertexes, RB_BeginSurface(), RB_EndSurface(), ri, shaderCommands_s::shader, SHADER_MAX_INDEXES, SHADER_MAX_VERTEXES, and tess.

Referenced by RB_SurfaceAnim().

00048                                                 {
00049     if (tess.numVertexes + verts < SHADER_MAX_VERTEXES
00050         && tess.numIndexes + indexes < SHADER_MAX_INDEXES) {
00051         return;
00052     }
00053 
00054     RB_EndSurface();
00055 
00056     if ( verts >= SHADER_MAX_VERTEXES ) {
00057         ri.Error(ERR_DROP, "RB_CheckOverflow: verts > MAX (%d > %d)", verts, SHADER_MAX_VERTEXES );
00058     }
00059     if ( indexes >= SHADER_MAX_INDEXES ) {
00060         ri.Error(ERR_DROP, "RB_CheckOverflow: indices > MAX (%d > %d)", indexes, SHADER_MAX_INDEXES );
00061     }
00062 
00063     RB_BeginSurface(tess.shader, tess.fogNum );
00064 }

Here is the call graph for this function:

void RB_SurfaceAxis void   ) 
 

Definition at line 1074 of file tr_surface.c.

References GL_Bind(), qglBegin, qglColor3f, qglEnd, qglLineWidth, qglVertex3f, tr, and trGlobals_t::whiteImage.

Referenced by RB_SurfaceEntity().

01074                             {
01075     GL_Bind( tr.whiteImage );
01076     qglLineWidth( 3 );
01077     qglBegin( GL_LINES );
01078     qglColor3f( 1,0,0 );
01079     qglVertex3f( 0,0,0 );
01080     qglVertex3f( 16,0,0 );
01081     qglColor3f( 0,1,0 );
01082     qglVertex3f( 0,0,0 );
01083     qglVertex3f( 0,16,0 );
01084     qglColor3f( 0,0,1 );
01085     qglVertex3f( 0,0,0 );
01086     qglVertex3f( 0,0,16 );
01087     qglEnd();
01088     qglLineWidth( 1 );
01089 }

Here is the call graph for this function:

void RB_SurfaceBad surfaceType_t surfType  ) 
 

Definition at line 1124 of file tr_surface.c.

References PRINT_ALL, and ri.

01124                                               {
01125     ri.Printf( PRINT_ALL, "Bad surface tesselated.\n" );
01126 }

void RB_SurfaceBeam void   ) 
 

Definition at line 284 of file tr_surface.c.

References backEnd, backEndState_t::currentEntity, trRefEntity_t::e, e, GL_Bind(), GL_State(), GLS_DSTBLEND_ONE, GLS_SRCBLEND_ONE, i, NUM_BEAM_SEGS, refEntity_t::oldorigin, refEntity_t::origin, PerpendicularVector(), qglBegin, qglColor3f, qglEnd, qglVertex3fv, RotatePointAroundVector(), tr, vec3_t, VectorAdd, VectorNormalize(), VectorScale, and trGlobals_t::whiteImage.

Referenced by RB_SurfaceEntity().

00285 {
00286 #define NUM_BEAM_SEGS 6
00287     refEntity_t *e;
00288     int i;
00289     vec3_t perpvec;
00290     vec3_t direction, normalized_direction;
00291     vec3_t  start_points[NUM_BEAM_SEGS], end_points[NUM_BEAM_SEGS];
00292     vec3_t oldorigin, origin;
00293 
00294     e = &backEnd.currentEntity->e;
00295 
00296     oldorigin[0] = e->oldorigin[0];
00297     oldorigin[1] = e->oldorigin[1];
00298     oldorigin[2] = e->oldorigin[2];
00299 
00300     origin[0] = e->origin[0];
00301     origin[1] = e->origin[1];
00302     origin[2] = e->origin[2];
00303 
00304     normalized_direction[0] = direction[0] = oldorigin[0] - origin[0];
00305     normalized_direction[1] = direction[1] = oldorigin[1] - origin[1];
00306     normalized_direction[2] = direction[2] = oldorigin[2] - origin[2];
00307 
00308     if ( VectorNormalize( normalized_direction ) == 0 )
00309         return;
00310 
00311     PerpendicularVector( perpvec, normalized_direction );
00312 
00313     VectorScale( perpvec, 4, perpvec );
00314 
00315     for ( i = 0; i < NUM_BEAM_SEGS ; i++ )
00316     {
00317         RotatePointAroundVector( start_points[i], normalized_direction, perpvec, (360.0/NUM_BEAM_SEGS)*i );
00318 //      VectorAdd( start_points[i], origin, start_points[i] );
00319         VectorAdd( start_points[i], direction, end_points[i] );
00320     }
00321 
00322     GL_Bind( tr.whiteImage );
00323 
00324     GL_State( GLS_SRCBLEND_ONE | GLS_DSTBLEND_ONE );
00325 
00326     qglColor3f( 1, 0, 0 );
00327 
00328     qglBegin( GL_TRIANGLE_STRIP );
00329     for ( i = 0; i <= NUM_BEAM_SEGS; i++ ) {
00330         qglVertex3fv( start_points[ i % NUM_BEAM_SEGS] );
00331         qglVertex3fv( end_points[ i % NUM_BEAM_SEGS] );
00332     }
00333     qglEnd();
00334 }

Here is the call graph for this function:

void RB_SurfaceDisplayList srfDisplayList_t surf  ) 
 

Definition at line 1193 of file tr_surface.c.

References srfDisplayList_s::listNum, qglCallList, and srfDisplayList_t.

01193                                                      {
01194     // all apropriate state must be set in RB_BeginSurface
01195     // this isn't implemented yet...
01196     qglCallList( surf->listNum );
01197 }

void RB_SurfaceEntity surfaceType_t surfType  ) 
 

Definition at line 1100 of file tr_surface.c.

References backEnd, backEndState_t::currentEntity, trRefEntity_t::e, RB_SurfaceAxis(), RB_SurfaceBeam(), RB_SurfaceLightningBolt(), RB_SurfaceRailCore(), RB_SurfaceRailRings(), RB_SurfaceSprite(), refEntity_t::reType, RT_BEAM, RT_LIGHTNING, RT_RAIL_CORE, RT_RAIL_RINGS, and RT_SPRITE.

01100                                                  {
01101     switch( backEnd.currentEntity->e.reType ) {
01102     case RT_SPRITE:
01103         RB_SurfaceSprite();
01104         break;
01105     case RT_BEAM:
01106         RB_SurfaceBeam();
01107         break;
01108     case RT_RAIL_CORE:
01109         RB_SurfaceRailCore();
01110         break;
01111     case RT_RAIL_RINGS:
01112         RB_SurfaceRailRings();
01113         break;
01114     case RT_LIGHTNING:
01115         RB_SurfaceLightningBolt();
01116         break;
01117     default:
01118         RB_SurfaceAxis();
01119         break;
01120     }
01121     return;
01122 }

Here is the call graph for this function:

void RB_SurfaceFace srfSurfaceFace_t surf  ) 
 

Definition at line 817 of file tr_surface.c.

References backEnd, shaderCommands_s::dlightBits, srfSurfaceFace_t::dlightBits, i, shaderCommands_s::indexes, indices, shader_s::needsNormal, shaderCommands_s::normal, cplane_s::normal, shaderCommands_s::numIndexes, srfSurfaceFace_t::numIndices, srfSurfaceFace_t::numPoints, shaderCommands_s::numVertexes, srfSurfaceFace_t::ofsIndices, srfSurfaceFace_t::plane, srfSurfaceFace_t::points, RB_CHECKOVERFLOW, shaderCommands_s::shader, backEndState_t::smpFrame, tess, shaderCommands_s::texCoords, v, VectorCopy, shaderCommands_s::vertexColors, shaderCommands_s::vertexDlightBits, and shaderCommands_s::xyz.

00817                                               {
00818     int         i;
00819     unsigned    *indices, *tessIndexes;
00820     float       *v;
00821     float       *normal;
00822     int         ndx;
00823     int         Bob;
00824     int         numPoints;
00825     int         dlightBits;
00826 
00827     RB_CHECKOVERFLOW( surf->numPoints, surf->numIndices );
00828 
00829     dlightBits = surf->dlightBits[backEnd.smpFrame];
00830     tess.dlightBits |= dlightBits;
00831 
00832     indices = ( unsigned * ) ( ( ( char  * ) surf ) + surf->ofsIndices );
00833 
00834     Bob = tess.numVertexes;
00835     tessIndexes = tess.indexes + tess.numIndexes;
00836     for ( i = surf->numIndices-1 ; i >= 0  ; i-- ) {
00837         tessIndexes[i] = indices[i] + Bob;
00838     }
00839 
00840     tess.numIndexes += surf->numIndices;
00841 
00842     v = surf->points[0];
00843 
00844     ndx = tess.numVertexes;
00845 
00846     numPoints = surf->numPoints;
00847 
00848     if ( tess.shader->needsNormal ) {
00849         normal = surf->plane.normal;
00850         for ( i = 0, ndx = tess.numVertexes; i < numPoints; i++, ndx++ ) {
00851             VectorCopy( normal, tess.normal[ndx] );
00852         }
00853     }
00854 
00855     for ( i = 0, v = surf->points[0], ndx = tess.numVertexes; i < numPoints; i++, v += VERTEXSIZE, ndx++ ) {
00856         VectorCopy( v, tess.xyz[ndx]);
00857         tess.texCoords[ndx][0][0] = v[3];
00858         tess.texCoords[ndx][0][1] = v[4];
00859         tess.texCoords[ndx][1][0] = v[5];
00860         tess.texCoords[ndx][1][1] = v[6];
00861         * ( unsigned int * ) &tess.vertexColors[ndx] = * ( unsigned int * ) &v[7];
00862         tess.vertexDlightBits[ndx] = dlightBits;
00863     }
00864 
00865 
00866     tess.numVertexes += surf->numPoints;
00867 }

void RB_SurfaceFlare srfFlare_t surf  ) 
 

Definition at line 1168 of file tr_surface.c.

References byte, srfFlare_s::color, srfFlare_s::origin, r_ignore, RB_AddQuadStampExt(), srfFlare_t, up, cvar_s::value, vec3_t, and VectorClear.

01168                                          {
01169 #if 0
01170     vec3_t      left, up;
01171     byte        color[4];
01172 
01173     color[0] = surf->color[0] * 255;
01174     color[1] = surf->color[1] * 255;
01175     color[2] = surf->color[2] * 255;
01176     color[3] = 255;
01177 
01178     VectorClear( left );
01179     VectorClear( up );
01180 
01181     left[0] = r_ignore->value;
01182 
01183     up[1] = r_ignore->value;
01184     
01185     RB_AddQuadStampExt( surf->origin, left, up, color, 0, 0, 1, 1 );
01186 #endif
01187 }

Here is the call graph for this function:

void RB_SurfaceGrid srfGridMesh_t cv  ) 
 

Definition at line 907 of file tr_surface.c.

References backEnd, drawVert_t::color, shaderCommands_s::dlightBits, srfGridMesh_s::dlightBits, shaderCommands_s::fogNum, h(), srfGridMesh_s::height, srfGridMesh_s::heightLodError, i, shaderCommands_s::indexes, j, drawVert_t::lightmap, LodErrorForVolume(), srfGridMesh_s::lodOrigin, srfGridMesh_s::lodRadius, shader_s::needsNormal, drawVert_t::normal, shaderCommands_s::normal, shaderCommands_s::numIndexes, shaderCommands_s::numVertexes, qboolean, RB_BeginSurface(), RB_EndSurface(), rows, shaderCommands_s::shader, SHADER_MAX_INDEXES, SHADER_MAX_VERTEXES, backEndState_t::smpFrame, srfGridMesh_t, drawVert_t::st, tess, shaderCommands_s::texCoords, v1, v2, shaderCommands_s::vertexColors, shaderCommands_s::vertexDlightBits, srfGridMesh_s::verts, w, srfGridMesh_s::width, srfGridMesh_s::widthLodError, drawVert_t::xyz, and shaderCommands_s::xyz.

00907                                          {
00908