tr_surface.c 32 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216
  1. /*
  2. ===========================================================================
  3. Copyright (C) 1999-2005 Id Software, Inc.
  4. This file is part of Quake III Arena source code.
  5. Quake III Arena source code is free software; you can redistribute it
  6. and/or modify it under the terms of the GNU General Public License as
  7. published by the Free Software Foundation; either version 2 of the License,
  8. or (at your option) any later version.
  9. Quake III Arena source code is distributed in the hope that it will be
  10. useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with Foobar; if not, write to the Free Software
  15. Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  16. ===========================================================================
  17. */
  18. // tr_surf.c
  19. #include "tr_local.h"
  20. /*
  21. THIS ENTIRE FILE IS BACK END
  22. backEnd.currentEntity will be valid.
  23. Tess_Begin has already been called for the surface's shader.
  24. The modelview matrix will be set.
  25. It is safe to actually issue drawing commands here if you don't want to
  26. use the shader system.
  27. */
  28. //============================================================================
  29. /*
  30. ==============
  31. RB_CheckOverflow
  32. ==============
  33. */
  34. void RB_CheckOverflow( int verts, int indexes ) {
  35. if (tess.numVertexes + verts < SHADER_MAX_VERTEXES
  36. && tess.numIndexes + indexes < SHADER_MAX_INDEXES) {
  37. return;
  38. }
  39. RB_EndSurface();
  40. if ( verts >= SHADER_MAX_VERTEXES ) {
  41. ri.Error(ERR_DROP, "RB_CheckOverflow: verts > MAX (%d > %d)", verts, SHADER_MAX_VERTEXES );
  42. }
  43. if ( indexes >= SHADER_MAX_INDEXES ) {
  44. ri.Error(ERR_DROP, "RB_CheckOverflow: indices > MAX (%d > %d)", indexes, SHADER_MAX_INDEXES );
  45. }
  46. RB_BeginSurface(tess.shader, tess.fogNum );
  47. }
  48. /*
  49. ==============
  50. RB_AddQuadStampExt
  51. ==============
  52. */
  53. void RB_AddQuadStampExt( vec3_t origin, vec3_t left, vec3_t up, byte *color, float s1, float t1, float s2, float t2 ) {
  54. vec3_t normal;
  55. int ndx;
  56. RB_CHECKOVERFLOW( 4, 6 );
  57. ndx = tess.numVertexes;
  58. // triangle indexes for a simple quad
  59. tess.indexes[ tess.numIndexes ] = ndx;
  60. tess.indexes[ tess.numIndexes + 1 ] = ndx + 1;
  61. tess.indexes[ tess.numIndexes + 2 ] = ndx + 3;
  62. tess.indexes[ tess.numIndexes + 3 ] = ndx + 3;
  63. tess.indexes[ tess.numIndexes + 4 ] = ndx + 1;
  64. tess.indexes[ tess.numIndexes + 5 ] = ndx + 2;
  65. tess.xyz[ndx][0] = origin[0] + left[0] + up[0];
  66. tess.xyz[ndx][1] = origin[1] + left[1] + up[1];
  67. tess.xyz[ndx][2] = origin[2] + left[2] + up[2];
  68. tess.xyz[ndx+1][0] = origin[0] - left[0] + up[0];
  69. tess.xyz[ndx+1][1] = origin[1] - left[1] + up[1];
  70. tess.xyz[ndx+1][2] = origin[2] - left[2] + up[2];
  71. tess.xyz[ndx+2][0] = origin[0] - left[0] - up[0];
  72. tess.xyz[ndx+2][1] = origin[1] - left[1] - up[1];
  73. tess.xyz[ndx+2][2] = origin[2] - left[2] - up[2];
  74. tess.xyz[ndx+3][0] = origin[0] + left[0] - up[0];
  75. tess.xyz[ndx+3][1] = origin[1] + left[1] - up[1];
  76. tess.xyz[ndx+3][2] = origin[2] + left[2] - up[2];
  77. // constant normal all the way around
  78. VectorSubtract( vec3_origin, backEnd.viewParms.or.axis[0], normal );
  79. tess.normal[ndx][0] = tess.normal[ndx+1][0] = tess.normal[ndx+2][0] = tess.normal[ndx+3][0] = normal[0];
  80. tess.normal[ndx][1] = tess.normal[ndx+1][1] = tess.normal[ndx+2][1] = tess.normal[ndx+3][1] = normal[1];
  81. tess.normal[ndx][2] = tess.normal[ndx+1][2] = tess.normal[ndx+2][2] = tess.normal[ndx+3][2] = normal[2];
  82. // standard square texture coordinates
  83. tess.texCoords[ndx][0][0] = tess.texCoords[ndx][1][0] = s1;
  84. tess.texCoords[ndx][0][1] = tess.texCoords[ndx][1][1] = t1;
  85. tess.texCoords[ndx+1][0][0] = tess.texCoords[ndx+1][1][0] = s2;
  86. tess.texCoords[ndx+1][0][1] = tess.texCoords[ndx+1][1][1] = t1;
  87. tess.texCoords[ndx+2][0][0] = tess.texCoords[ndx+2][1][0] = s2;
  88. tess.texCoords[ndx+2][0][1] = tess.texCoords[ndx+2][1][1] = t2;
  89. tess.texCoords[ndx+3][0][0] = tess.texCoords[ndx+3][1][0] = s1;
  90. tess.texCoords[ndx+3][0][1] = tess.texCoords[ndx+3][1][1] = t2;
  91. // constant color all the way around
  92. // should this be identity and let the shader specify from entity?
  93. * ( unsigned int * ) &tess.vertexColors[ndx] =
  94. * ( unsigned int * ) &tess.vertexColors[ndx+1] =
  95. * ( unsigned int * ) &tess.vertexColors[ndx+2] =
  96. * ( unsigned int * ) &tess.vertexColors[ndx+3] =
  97. * ( unsigned int * )color;
  98. tess.numVertexes += 4;
  99. tess.numIndexes += 6;
  100. }
  101. /*
  102. ==============
  103. RB_AddQuadStamp
  104. ==============
  105. */
  106. void RB_AddQuadStamp( vec3_t origin, vec3_t left, vec3_t up, byte *color ) {
  107. RB_AddQuadStampExt( origin, left, up, color, 0, 0, 1, 1 );
  108. }
  109. /*
  110. ==============
  111. RB_SurfaceSprite
  112. ==============
  113. */
  114. static void RB_SurfaceSprite( void ) {
  115. vec3_t left, up;
  116. float radius;
  117. // calculate the xyz locations for the four corners
  118. radius = backEnd.currentEntity->e.radius;
  119. if ( backEnd.currentEntity->e.rotation == 0 ) {
  120. VectorScale( backEnd.viewParms.or.axis[1], radius, left );
  121. VectorScale( backEnd.viewParms.or.axis[2], radius, up );
  122. } else {
  123. float s, c;
  124. float ang;
  125. ang = M_PI * backEnd.currentEntity->e.rotation / 180;
  126. s = sin( ang );
  127. c = cos( ang );
  128. VectorScale( backEnd.viewParms.or.axis[1], c * radius, left );
  129. VectorMA( left, -s * radius, backEnd.viewParms.or.axis[2], left );
  130. VectorScale( backEnd.viewParms.or.axis[2], c * radius, up );
  131. VectorMA( up, s * radius, backEnd.viewParms.or.axis[1], up );
  132. }
  133. if ( backEnd.viewParms.isMirror ) {
  134. VectorSubtract( vec3_origin, left, left );
  135. }
  136. RB_AddQuadStamp( backEnd.currentEntity->e.origin, left, up, backEnd.currentEntity->e.shaderRGBA );
  137. }
  138. /*
  139. =============
  140. RB_SurfacePolychain
  141. =============
  142. */
  143. void RB_SurfacePolychain( srfPoly_t *p ) {
  144. int i;
  145. int numv;
  146. RB_CHECKOVERFLOW( p->numVerts, 3*(p->numVerts - 2) );
  147. // fan triangles into the tess array
  148. numv = tess.numVertexes;
  149. for ( i = 0; i < p->numVerts; i++ ) {
  150. VectorCopy( p->verts[i].xyz, tess.xyz[numv] );
  151. tess.texCoords[numv][0][0] = p->verts[i].st[0];
  152. tess.texCoords[numv][0][1] = p->verts[i].st[1];
  153. *(int *)&tess.vertexColors[numv] = *(int *)p->verts[ i ].modulate;
  154. numv++;
  155. }
  156. // generate fan indexes into the tess array
  157. for ( i = 0; i < p->numVerts-2; i++ ) {
  158. tess.indexes[tess.numIndexes + 0] = tess.numVertexes;
  159. tess.indexes[tess.numIndexes + 1] = tess.numVertexes + i + 1;
  160. tess.indexes[tess.numIndexes + 2] = tess.numVertexes + i + 2;
  161. tess.numIndexes += 3;
  162. }
  163. tess.numVertexes = numv;
  164. }
  165. /*
  166. =============
  167. RB_SurfaceTriangles
  168. =============
  169. */
  170. void RB_SurfaceTriangles( srfTriangles_t *srf ) {
  171. int i;
  172. drawVert_t *dv;
  173. float *xyz, *normal, *texCoords;
  174. byte *color;
  175. int dlightBits;
  176. qboolean needsNormal;
  177. dlightBits = srf->dlightBits[backEnd.smpFrame];
  178. tess.dlightBits |= dlightBits;
  179. RB_CHECKOVERFLOW( srf->numVerts, srf->numIndexes );
  180. for ( i = 0 ; i < srf->numIndexes ; i += 3 ) {
  181. tess.indexes[ tess.numIndexes + i + 0 ] = tess.numVertexes + srf->indexes[ i + 0 ];
  182. tess.indexes[ tess.numIndexes + i + 1 ] = tess.numVertexes + srf->indexes[ i + 1 ];
  183. tess.indexes[ tess.numIndexes + i + 2 ] = tess.numVertexes + srf->indexes[ i + 2 ];
  184. }
  185. tess.numIndexes += srf->numIndexes;
  186. dv = srf->verts;
  187. xyz = tess.xyz[ tess.numVertexes ];
  188. normal = tess.normal[ tess.numVertexes ];
  189. texCoords = tess.texCoords[ tess.numVertexes ][0];
  190. color = tess.vertexColors[ tess.numVertexes ];
  191. needsNormal = tess.shader->needsNormal;
  192. for ( i = 0 ; i < srf->numVerts ; i++, dv++, xyz += 4, normal += 4, texCoords += 4, color += 4 ) {
  193. xyz[0] = dv->xyz[0];
  194. xyz[1] = dv->xyz[1];
  195. xyz[2] = dv->xyz[2];
  196. if ( needsNormal ) {
  197. normal[0] = dv->normal[0];
  198. normal[1] = dv->normal[1];
  199. normal[2] = dv->normal[2];
  200. }
  201. texCoords[0] = dv->st[0];
  202. texCoords[1] = dv->st[1];
  203. texCoords[2] = dv->lightmap[0];
  204. texCoords[3] = dv->lightmap[1];
  205. *(int *)color = *(int *)dv->color;
  206. }
  207. for ( i = 0 ; i < srf->numVerts ; i++ ) {
  208. tess.vertexDlightBits[ tess.numVertexes + i] = dlightBits;
  209. }
  210. tess.numVertexes += srf->numVerts;
  211. }
  212. /*
  213. ==============
  214. RB_SurfaceBeam
  215. ==============
  216. */
  217. void RB_SurfaceBeam( void )
  218. {
  219. #define NUM_BEAM_SEGS 6
  220. refEntity_t *e;
  221. int i;
  222. vec3_t perpvec;
  223. vec3_t direction, normalized_direction;
  224. vec3_t start_points[NUM_BEAM_SEGS], end_points[NUM_BEAM_SEGS];
  225. vec3_t oldorigin, origin;
  226. e = &backEnd.currentEntity->e;
  227. oldorigin[0] = e->oldorigin[0];
  228. oldorigin[1] = e->oldorigin[1];
  229. oldorigin[2] = e->oldorigin[2];
  230. origin[0] = e->origin[0];
  231. origin[1] = e->origin[1];
  232. origin[2] = e->origin[2];
  233. normalized_direction[0] = direction[0] = oldorigin[0] - origin[0];
  234. normalized_direction[1] = direction[1] = oldorigin[1] - origin[1];
  235. normalized_direction[2] = direction[2] = oldorigin[2] - origin[2];
  236. if ( VectorNormalize( normalized_direction ) == 0 )
  237. return;
  238. PerpendicularVector( perpvec, normalized_direction );
  239. VectorScale( perpvec, 4, perpvec );
  240. for ( i = 0; i < NUM_BEAM_SEGS ; i++ )
  241. {
  242. RotatePointAroundVector( start_points[i], normalized_direction, perpvec, (360.0/NUM_BEAM_SEGS)*i );
  243. // VectorAdd( start_points[i], origin, start_points[i] );
  244. VectorAdd( start_points[i], direction, end_points[i] );
  245. }
  246. GL_Bind( tr.whiteImage );
  247. GL_State( GLS_SRCBLEND_ONE | GLS_DSTBLEND_ONE );
  248. qglColor3f( 1, 0, 0 );
  249. qglBegin( GL_TRIANGLE_STRIP );
  250. for ( i = 0; i <= NUM_BEAM_SEGS; i++ ) {
  251. qglVertex3fv( start_points[ i % NUM_BEAM_SEGS] );
  252. qglVertex3fv( end_points[ i % NUM_BEAM_SEGS] );
  253. }
  254. qglEnd();
  255. }
  256. //================================================================================
  257. static void DoRailCore( const vec3_t start, const vec3_t end, const vec3_t up, float len, float spanWidth )
  258. {
  259. float spanWidth2;
  260. int vbase;
  261. float t = len / 256.0f;
  262. vbase = tess.numVertexes;
  263. spanWidth2 = -spanWidth;
  264. // FIXME: use quad stamp?
  265. VectorMA( start, spanWidth, up, tess.xyz[tess.numVertexes] );
  266. tess.texCoords[tess.numVertexes][0][0] = 0;
  267. tess.texCoords[tess.numVertexes][0][1] = 0;
  268. tess.vertexColors[tess.numVertexes][0] = backEnd.currentEntity->e.shaderRGBA[0] * 0.25;
  269. tess.vertexColors[tess.numVertexes][1] = backEnd.currentEntity->e.shaderRGBA[1] * 0.25;
  270. tess.vertexColors[tess.numVertexes][2] = backEnd.currentEntity->e.shaderRGBA[2] * 0.25;
  271. tess.numVertexes++;
  272. VectorMA( start, spanWidth2, up, tess.xyz[tess.numVertexes] );
  273. tess.texCoords[tess.numVertexes][0][0] = 0;
  274. tess.texCoords[tess.numVertexes][0][1] = 1;
  275. tess.vertexColors[tess.numVertexes][0] = backEnd.currentEntity->e.shaderRGBA[0];
  276. tess.vertexColors[tess.numVertexes][1] = backEnd.currentEntity->e.shaderRGBA[1];
  277. tess.vertexColors[tess.numVertexes][2] = backEnd.currentEntity->e.shaderRGBA[2];
  278. tess.numVertexes++;
  279. VectorMA( end, spanWidth, up, tess.xyz[tess.numVertexes] );
  280. tess.texCoords[tess.numVertexes][0][0] = t;
  281. tess.texCoords[tess.numVertexes][0][1] = 0;
  282. tess.vertexColors[tess.numVertexes][0] = backEnd.currentEntity->e.shaderRGBA[0];
  283. tess.vertexColors[tess.numVertexes][1] = backEnd.currentEntity->e.shaderRGBA[1];
  284. tess.vertexColors[tess.numVertexes][2] = backEnd.currentEntity->e.shaderRGBA[2];
  285. tess.numVertexes++;
  286. VectorMA( end, spanWidth2, up, tess.xyz[tess.numVertexes] );
  287. tess.texCoords[tess.numVertexes][0][0] = t;
  288. tess.texCoords[tess.numVertexes][0][1] = 1;
  289. tess.vertexColors[tess.numVertexes][0] = backEnd.currentEntity->e.shaderRGBA[0];
  290. tess.vertexColors[tess.numVertexes][1] = backEnd.currentEntity->e.shaderRGBA[1];
  291. tess.vertexColors[tess.numVertexes][2] = backEnd.currentEntity->e.shaderRGBA[2];
  292. tess.numVertexes++;
  293. tess.indexes[tess.numIndexes++] = vbase;
  294. tess.indexes[tess.numIndexes++] = vbase + 1;
  295. tess.indexes[tess.numIndexes++] = vbase + 2;
  296. tess.indexes[tess.numIndexes++] = vbase + 2;
  297. tess.indexes[tess.numIndexes++] = vbase + 1;
  298. tess.indexes[tess.numIndexes++] = vbase + 3;
  299. }
  300. static void DoRailDiscs( int numSegs, const vec3_t start, const vec3_t dir, const vec3_t right, const vec3_t up )
  301. {
  302. int i;
  303. vec3_t pos[4];
  304. vec3_t v;
  305. int spanWidth = r_railWidth->integer;
  306. float c, s;
  307. float scale;
  308. if ( numSegs > 1 )
  309. numSegs--;
  310. if ( !numSegs )
  311. return;
  312. scale = 0.25;
  313. for ( i = 0; i < 4; i++ )
  314. {
  315. c = cos( DEG2RAD( 45 + i * 90 ) );
  316. s = sin( DEG2RAD( 45 + i * 90 ) );
  317. v[0] = ( right[0] * c + up[0] * s ) * scale * spanWidth;
  318. v[1] = ( right[1] * c + up[1] * s ) * scale * spanWidth;
  319. v[2] = ( right[2] * c + up[2] * s ) * scale * spanWidth;
  320. VectorAdd( start, v, pos[i] );
  321. if ( numSegs > 1 )
  322. {
  323. // offset by 1 segment if we're doing a long distance shot
  324. VectorAdd( pos[i], dir, pos[i] );
  325. }
  326. }
  327. for ( i = 0; i < numSegs; i++ )
  328. {
  329. int j;
  330. RB_CHECKOVERFLOW( 4, 6 );
  331. for ( j = 0; j < 4; j++ )
  332. {
  333. VectorCopy( pos[j], tess.xyz[tess.numVertexes] );
  334. tess.texCoords[tess.numVertexes][0][0] = ( j < 2 );
  335. tess.texCoords[tess.numVertexes][0][1] = ( j && j != 3 );
  336. tess.vertexColors[tess.numVertexes][0] = backEnd.currentEntity->e.shaderRGBA[0];
  337. tess.vertexColors[tess.numVertexes][1] = backEnd.currentEntity->e.shaderRGBA[1];
  338. tess.vertexColors[tess.numVertexes][2] = backEnd.currentEntity->e.shaderRGBA[2];
  339. tess.numVertexes++;
  340. VectorAdd( pos[j], dir, pos[j] );
  341. }
  342. tess.indexes[tess.numIndexes++] = tess.numVertexes - 4 + 0;
  343. tess.indexes[tess.numIndexes++] = tess.numVertexes - 4 + 1;
  344. tess.indexes[tess.numIndexes++] = tess.numVertexes - 4 + 3;
  345. tess.indexes[tess.numIndexes++] = tess.numVertexes - 4 + 3;
  346. tess.indexes[tess.numIndexes++] = tess.numVertexes - 4 + 1;
  347. tess.indexes[tess.numIndexes++] = tess.numVertexes - 4 + 2;
  348. }
  349. }
  350. /*
  351. ** RB_SurfaceRailRinges
  352. */
  353. void RB_SurfaceRailRings( void ) {
  354. refEntity_t *e;
  355. int numSegs;
  356. int len;
  357. vec3_t vec;
  358. vec3_t right, up;
  359. vec3_t start, end;
  360. e = &backEnd.currentEntity->e;
  361. VectorCopy( e->oldorigin, start );
  362. VectorCopy( e->origin, end );
  363. // compute variables
  364. VectorSubtract( end, start, vec );
  365. len = VectorNormalize( vec );
  366. MakeNormalVectors( vec, right, up );
  367. numSegs = ( len ) / r_railSegmentLength->value;
  368. if ( numSegs <= 0 ) {
  369. numSegs = 1;
  370. }
  371. VectorScale( vec, r_railSegmentLength->value, vec );
  372. DoRailDiscs( numSegs, start, vec, right, up );
  373. }
  374. /*
  375. ** RB_SurfaceRailCore
  376. */
  377. void RB_SurfaceRailCore( void ) {
  378. refEntity_t *e;
  379. int len;
  380. vec3_t right;
  381. vec3_t vec;
  382. vec3_t start, end;
  383. vec3_t v1, v2;
  384. e = &backEnd.currentEntity->e;
  385. VectorCopy( e->oldorigin, start );
  386. VectorCopy( e->origin, end );
  387. VectorSubtract( end, start, vec );
  388. len = VectorNormalize( vec );
  389. // compute side vector
  390. VectorSubtract( start, backEnd.viewParms.or.origin, v1 );
  391. VectorNormalize( v1 );
  392. VectorSubtract( end, backEnd.viewParms.or.origin, v2 );
  393. VectorNormalize( v2 );
  394. CrossProduct( v1, v2, right );
  395. VectorNormalize( right );
  396. DoRailCore( start, end, right, len, r_railCoreWidth->integer );
  397. }
  398. /*
  399. ** RB_SurfaceLightningBolt
  400. */
  401. void RB_SurfaceLightningBolt( void ) {
  402. refEntity_t *e;
  403. int len;
  404. vec3_t right;
  405. vec3_t vec;
  406. vec3_t start, end;
  407. vec3_t v1, v2;
  408. int i;
  409. e = &backEnd.currentEntity->e;
  410. VectorCopy( e->oldorigin, end );
  411. VectorCopy( e->origin, start );
  412. // compute variables
  413. VectorSubtract( end, start, vec );
  414. len = VectorNormalize( vec );
  415. // compute side vector
  416. VectorSubtract( start, backEnd.viewParms.or.origin, v1 );
  417. VectorNormalize( v1 );
  418. VectorSubtract( end, backEnd.viewParms.or.origin, v2 );
  419. VectorNormalize( v2 );
  420. CrossProduct( v1, v2, right );
  421. VectorNormalize( right );
  422. for ( i = 0 ; i < 4 ; i++ ) {
  423. vec3_t temp;
  424. DoRailCore( start, end, right, len, 8 );
  425. RotatePointAroundVector( temp, vec, right, 45 );
  426. VectorCopy( temp, right );
  427. }
  428. }
  429. /*
  430. ** VectorArrayNormalize
  431. *
  432. * The inputs to this routing seem to always be close to length = 1.0 (about 0.6 to 2.0)
  433. * This means that we don't have to worry about zero length or enormously long vectors.
  434. */
  435. static void VectorArrayNormalize(vec4_t *normals, unsigned int count)
  436. {
  437. // assert(count);
  438. #if idppc
  439. {
  440. register float half = 0.5;
  441. register float one = 1.0;
  442. float *components = (float *)normals;
  443. // Vanilla PPC code, but since PPC has a reciprocal square root estimate instruction,
  444. // runs *much* faster than calling sqrt(). We'll use a single Newton-Raphson
  445. // refinement step to get a little more precision. This seems to yeild results
  446. // that are correct to 3 decimal places and usually correct to at least 4 (sometimes 5).
  447. // (That is, for the given input range of about 0.6 to 2.0).
  448. do {
  449. float x, y, z;
  450. float B, y0, y1;
  451. x = components[0];
  452. y = components[1];
  453. z = components[2];
  454. components += 4;
  455. B = x*x + y*y + z*z;
  456. #ifdef __GNUC__
  457. asm("frsqrte %0,%1" : "=f" (y0) : "f" (B));
  458. #else
  459. y0 = __frsqrte(B);
  460. #endif
  461. y1 = y0 + half*y0*(one - B*y0*y0);
  462. x = x * y1;
  463. y = y * y1;
  464. components[-4] = x;
  465. z = z * y1;
  466. components[-3] = y;
  467. components[-2] = z;
  468. } while(count--);
  469. }
  470. #else // No assembly version for this architecture, or C_ONLY defined
  471. // given the input, it's safe to call VectorNormalizeFast
  472. while (count--) {
  473. VectorNormalizeFast(normals[0]);
  474. normals++;
  475. }
  476. #endif
  477. }
  478. /*
  479. ** LerpMeshVertexes
  480. */
  481. static void LerpMeshVertexes (md3Surface_t *surf, float backlerp)
  482. {
  483. short *oldXyz, *newXyz, *oldNormals, *newNormals;
  484. float *outXyz, *outNormal;
  485. float oldXyzScale, newXyzScale;
  486. float oldNormalScale, newNormalScale;
  487. int vertNum;
  488. unsigned lat, lng;
  489. int numVerts;
  490. outXyz = tess.xyz[tess.numVertexes];
  491. outNormal = tess.normal[tess.numVertexes];
  492. newXyz = (short *)((byte *)surf + surf->ofsXyzNormals)
  493. + (backEnd.currentEntity->e.frame * surf->numVerts * 4);
  494. newNormals = newXyz + 3;
  495. newXyzScale = MD3_XYZ_SCALE * (1.0 - backlerp);
  496. newNormalScale = 1.0 - backlerp;
  497. numVerts = surf->numVerts;
  498. if ( backlerp == 0 ) {
  499. #if idppc_altivec
  500. vector signed short newNormalsVec0;
  501. vector signed short newNormalsVec1;
  502. vector signed int newNormalsIntVec;
  503. vector float newNormalsFloatVec;
  504. vector float newXyzScaleVec;
  505. vector unsigned char newNormalsLoadPermute;
  506. vector unsigned char newNormalsStorePermute;
  507. vector float zero;
  508. newNormalsStorePermute = vec_lvsl(0,(float *)&newXyzScaleVec);
  509. newXyzScaleVec = *(vector float *)&newXyzScale;
  510. newXyzScaleVec = vec_perm(newXyzScaleVec,newXyzScaleVec,newNormalsStorePermute);
  511. newXyzScaleVec = vec_splat(newXyzScaleVec,0);
  512. newNormalsLoadPermute = vec_lvsl(0,newXyz);
  513. newNormalsStorePermute = vec_lvsr(0,outXyz);
  514. zero = (vector float)vec_splat_s8(0);
  515. //
  516. // just copy the vertexes
  517. //
  518. for (vertNum=0 ; vertNum < numVerts ; vertNum++,
  519. newXyz += 4, newNormals += 4,
  520. outXyz += 4, outNormal += 4)
  521. {
  522. newNormalsLoadPermute = vec_lvsl(0,newXyz);
  523. newNormalsStorePermute = vec_lvsr(0,outXyz);
  524. newNormalsVec0 = vec_ld(0,newXyz);
  525. newNormalsVec1 = vec_ld(16,newXyz);
  526. newNormalsVec0 = vec_perm(newNormalsVec0,newNormalsVec1,newNormalsLoadPermute);
  527. newNormalsIntVec = vec_unpackh(newNormalsVec0);
  528. newNormalsFloatVec = vec_ctf(newNormalsIntVec,0);
  529. newNormalsFloatVec = vec_madd(newNormalsFloatVec,newXyzScaleVec,zero);
  530. newNormalsFloatVec = vec_perm(newNormalsFloatVec,newNormalsFloatVec,newNormalsStorePermute);
  531. //outXyz[0] = newXyz[0] * newXyzScale;
  532. //outXyz[1] = newXyz[1] * newXyzScale;
  533. //outXyz[2] = newXyz[2] * newXyzScale;
  534. lat = ( newNormals[0] >> 8 ) & 0xff;
  535. lng = ( newNormals[0] & 0xff );
  536. lat *= (FUNCTABLE_SIZE/256);
  537. lng *= (FUNCTABLE_SIZE/256);
  538. // decode X as cos( lat ) * sin( long )
  539. // decode Y as sin( lat ) * sin( long )
  540. // decode Z as cos( long )
  541. outNormal[0] = tr.sinTable[(lat+(FUNCTABLE_SIZE/4))&FUNCTABLE_MASK] * tr.sinTable[lng];
  542. outNormal[1] = tr.sinTable[lat] * tr.sinTable[lng];
  543. outNormal[2] = tr.sinTable[(lng+(FUNCTABLE_SIZE/4))&FUNCTABLE_MASK];
  544. vec_ste(newNormalsFloatVec,0,outXyz);
  545. vec_ste(newNormalsFloatVec,4,outXyz);
  546. vec_ste(newNormalsFloatVec,8,outXyz);
  547. }
  548. #else
  549. //
  550. // just copy the vertexes
  551. //
  552. for (vertNum=0 ; vertNum < numVerts ; vertNum++,
  553. newXyz += 4, newNormals += 4,
  554. outXyz += 4, outNormal += 4)
  555. {
  556. outXyz[0] = newXyz[0] * newXyzScale;
  557. outXyz[1] = newXyz[1] * newXyzScale;
  558. outXyz[2] = newXyz[2] * newXyzScale;
  559. lat = ( newNormals[0] >> 8 ) & 0xff;
  560. lng = ( newNormals[0] & 0xff );
  561. lat *= (FUNCTABLE_SIZE/256);
  562. lng *= (FUNCTABLE_SIZE/256);
  563. // decode X as cos( lat ) * sin( long )
  564. // decode Y as sin( lat ) * sin( long )
  565. // decode Z as cos( long )
  566. outNormal[0] = tr.sinTable[(lat+(FUNCTABLE_SIZE/4))&FUNCTABLE_MASK] * tr.sinTable[lng];
  567. outNormal[1] = tr.sinTable[lat] * tr.sinTable[lng];
  568. outNormal[2] = tr.sinTable[(lng+(FUNCTABLE_SIZE/4))&FUNCTABLE_MASK];
  569. }
  570. #endif
  571. } else {
  572. //
  573. // interpolate and copy the vertex and normal
  574. //
  575. oldXyz = (short *)((byte *)surf + surf->ofsXyzNormals)
  576. + (backEnd.currentEntity->e.oldframe * surf->numVerts * 4);
  577. oldNormals = oldXyz + 3;
  578. oldXyzScale = MD3_XYZ_SCALE * backlerp;
  579. oldNormalScale = backlerp;
  580. for (vertNum=0 ; vertNum < numVerts ; vertNum++,
  581. oldXyz += 4, newXyz += 4, oldNormals += 4, newNormals += 4,
  582. outXyz += 4, outNormal += 4)
  583. {
  584. vec3_t uncompressedOldNormal, uncompressedNewNormal;
  585. // interpolate the xyz
  586. outXyz[0] = oldXyz[0] * oldXyzScale + newXyz[0] * newXyzScale;
  587. outXyz[1] = oldXyz[1] * oldXyzScale + newXyz[1] * newXyzScale;
  588. outXyz[2] = oldXyz[2] * oldXyzScale + newXyz[2] * newXyzScale;
  589. // FIXME: interpolate lat/long instead?
  590. lat = ( newNormals[0] >> 8 ) & 0xff;
  591. lng = ( newNormals[0] & 0xff );
  592. lat *= 4;
  593. lng *= 4;
  594. uncompressedNewNormal[0] = tr.sinTable[(lat+(FUNCTABLE_SIZE/4))&FUNCTABLE_MASK] * tr.sinTable[lng];
  595. uncompressedNewNormal[1] = tr.sinTable[lat] * tr.sinTable[lng];
  596. uncompressedNewNormal[2] = tr.sinTable[(lng+(FUNCTABLE_SIZE/4))&FUNCTABLE_MASK];
  597. lat = ( oldNormals[0] >> 8 ) & 0xff;
  598. lng = ( oldNormals[0] & 0xff );
  599. lat *= 4;
  600. lng *= 4;
  601. uncompressedOldNormal[0] = tr.sinTable[(lat+(FUNCTABLE_SIZE/4))&FUNCTABLE_MASK] * tr.sinTable[lng];
  602. uncompressedOldNormal[1] = tr.sinTable[lat] * tr.sinTable[lng];
  603. uncompressedOldNormal[2] = tr.sinTable[(lng+(FUNCTABLE_SIZE/4))&FUNCTABLE_MASK];
  604. outNormal[0] = uncompressedOldNormal[0] * oldNormalScale + uncompressedNewNormal[0] * newNormalScale;
  605. outNormal[1] = uncompressedOldNormal[1] * oldNormalScale + uncompressedNewNormal[1] * newNormalScale;
  606. outNormal[2] = uncompressedOldNormal[2] * oldNormalScale + uncompressedNewNormal[2] * newNormalScale;
  607. // VectorNormalize (outNormal);
  608. }
  609. VectorArrayNormalize((vec4_t *)tess.normal[tess.numVertexes], numVerts);
  610. }
  611. }
  612. /*
  613. =============
  614. RB_SurfaceMesh
  615. =============
  616. */
  617. void RB_SurfaceMesh(md3Surface_t *surface) {
  618. int j;
  619. float backlerp;
  620. int *triangles;
  621. float *texCoords;
  622. int indexes;
  623. int Bob, Doug;
  624. int numVerts;
  625. if ( backEnd.currentEntity->e.oldframe == backEnd.currentEntity->e.frame ) {
  626. backlerp = 0;
  627. } else {
  628. backlerp = backEnd.currentEntity->e.backlerp;
  629. }
  630. RB_CHECKOVERFLOW( surface->numVerts, surface->numTriangles*3 );
  631. LerpMeshVertexes (surface, backlerp);
  632. triangles = (int *) ((byte *)surface + surface->ofsTriangles);
  633. indexes = surface->numTriangles * 3;
  634. Bob = tess.numIndexes;
  635. Doug = tess.numVertexes;
  636. for (j = 0 ; j < indexes ; j++) {
  637. tess.indexes[Bob + j] = Doug + triangles[j];
  638. }
  639. tess.numIndexes += indexes;
  640. texCoords = (float *) ((byte *)surface + surface->ofsSt);
  641. numVerts = surface->numVerts;
  642. for ( j = 0; j < numVerts; j++ ) {
  643. tess.texCoords[Doug + j][0][0] = texCoords[j*2+0];
  644. tess.texCoords[Doug + j][0][1] = texCoords[j*2+1];
  645. // FIXME: fill in lightmapST for completeness?
  646. }
  647. tess.numVertexes += surface->numVerts;
  648. }
  649. /*
  650. ==============
  651. RB_SurfaceFace
  652. ==============
  653. */
  654. void RB_SurfaceFace( srfSurfaceFace_t *surf ) {
  655. int i;
  656. unsigned *indices, *tessIndexes;
  657. float *v;
  658. float *normal;
  659. int ndx;
  660. int Bob;
  661. int numPoints;
  662. int dlightBits;
  663. RB_CHECKOVERFLOW( surf->numPoints, surf->numIndices );
  664. dlightBits = surf->dlightBits[backEnd.smpFrame];
  665. tess.dlightBits |= dlightBits;
  666. indices = ( unsigned * ) ( ( ( char * ) surf ) + surf->ofsIndices );
  667. Bob = tess.numVertexes;
  668. tessIndexes = tess.indexes + tess.numIndexes;
  669. for ( i = surf->numIndices-1 ; i >= 0 ; i-- ) {
  670. tessIndexes[i] = indices[i] + Bob;
  671. }
  672. tess.numIndexes += surf->numIndices;
  673. v = surf->points[0];
  674. ndx = tess.numVertexes;
  675. numPoints = surf->numPoints;
  676. if ( tess.shader->needsNormal ) {
  677. normal = surf->plane.normal;
  678. for ( i = 0, ndx = tess.numVertexes; i < numPoints; i++, ndx++ ) {
  679. VectorCopy( normal, tess.normal[ndx] );
  680. }
  681. }
  682. for ( i = 0, v = surf->points[0], ndx = tess.numVertexes; i < numPoints; i++, v += VERTEXSIZE, ndx++ ) {
  683. VectorCopy( v, tess.xyz[ndx]);
  684. tess.texCoords[ndx][0][0] = v[3];
  685. tess.texCoords[ndx][0][1] = v[4];
  686. tess.texCoords[ndx][1][0] = v[5];
  687. tess.texCoords[ndx][1][1] = v[6];
  688. * ( unsigned int * ) &tess.vertexColors[ndx] = * ( unsigned int * ) &v[7];
  689. tess.vertexDlightBits[ndx] = dlightBits;
  690. }
  691. tess.numVertexes += surf->numPoints;
  692. }
  693. static float LodErrorForVolume( vec3_t local, float radius ) {
  694. vec3_t world;
  695. float d;
  696. // never let it go negative
  697. if ( r_lodCurveError->value < 0 ) {
  698. return 0;
  699. }
  700. world[0] = local[0] * backEnd.or.axis[0][0] + local[1] * backEnd.or.axis[1][0] +
  701. local[2] * backEnd.or.axis[2][0] + backEnd.or.origin[0];
  702. world[1] = local[0] * backEnd.or.axis[0][1] + local[1] * backEnd.or.axis[1][1] +
  703. local[2] * backEnd.or.axis[2][1] + backEnd.or.origin[1];
  704. world[2] = local[0] * backEnd.or.axis[0][2] + local[1] * backEnd.or.axis[1][2] +
  705. local[2] * backEnd.or.axis[2][2] + backEnd.or.origin[2];
  706. VectorSubtract( world, backEnd.viewParms.or.origin, world );
  707. d = DotProduct( world, backEnd.viewParms.or.axis[0] );
  708. if ( d < 0 ) {
  709. d = -d;
  710. }
  711. d -= radius;
  712. if ( d < 1 ) {
  713. d = 1;
  714. }
  715. return r_lodCurveError->value / d;
  716. }
  717. /*
  718. =============
  719. RB_SurfaceGrid
  720. Just copy the grid of points and triangulate
  721. =============
  722. */
  723. void RB_SurfaceGrid( srfGridMesh_t *cv ) {
  724. int i, j;
  725. float *xyz;
  726. float *texCoords;
  727. float *normal;
  728. unsigned char *color;
  729. drawVert_t *dv;
  730. int rows, irows, vrows;
  731. int used;
  732. int widthTable[MAX_GRID_SIZE];
  733. int heightTable[MAX_GRID_SIZE];
  734. float lodError;
  735. int lodWidth, lodHeight;
  736. int numVertexes;
  737. int dlightBits;
  738. int *vDlightBits;
  739. qboolean needsNormal;
  740. dlightBits = cv->dlightBits[backEnd.smpFrame];
  741. tess.dlightBits |= dlightBits;
  742. // determine the allowable discrepance
  743. lodError = LodErrorForVolume( cv->lodOrigin, cv->lodRadius );
  744. // determine which rows and columns of the subdivision
  745. // we are actually going to use
  746. widthTable[0] = 0;
  747. lodWidth = 1;
  748. for ( i = 1 ; i < cv->width-1 ; i++ ) {
  749. if ( cv->widthLodError[i] <= lodError ) {
  750. widthTable[lodWidth] = i;
  751. lodWidth++;
  752. }
  753. }
  754. widthTable[lodWidth] = cv->width-1;
  755. lodWidth++;
  756. heightTable[0] = 0;
  757. lodHeight = 1;
  758. for ( i = 1 ; i < cv->height-1 ; i++ ) {
  759. if ( cv->heightLodError[i] <= lodError ) {
  760. heightTable[lodHeight] = i;
  761. lodHeight++;
  762. }
  763. }
  764. heightTable[lodHeight] = cv->height-1;
  765. lodHeight++;
  766. // very large grids may have more points or indexes than can be fit
  767. // in the tess structure, so we may have to issue it in multiple passes
  768. used = 0;
  769. rows = 0;
  770. while ( used < lodHeight - 1 ) {
  771. // see how many rows of both verts and indexes we can add without overflowing
  772. do {
  773. vrows = ( SHADER_MAX_VERTEXES - tess.numVertexes ) / lodWidth;
  774. irows = ( SHADER_MAX_INDEXES - tess.numIndexes ) / ( lodWidth * 6 );
  775. // if we don't have enough space for at least one strip, flush the buffer
  776. if ( vrows < 2 || irows < 1 ) {
  777. RB_EndSurface();
  778. RB_BeginSurface(tess.shader, tess.fogNum );
  779. } else {
  780. break;
  781. }
  782. } while ( 1 );
  783. rows = irows;
  784. if ( vrows < irows + 1 ) {
  785. rows = vrows - 1;
  786. }
  787. if ( used + rows > lodHeight ) {
  788. rows = lodHeight - used;
  789. }
  790. numVertexes = tess.numVertexes;
  791. xyz = tess.xyz[numVertexes];
  792. normal = tess.normal[numVertexes];
  793. texCoords = tess.texCoords[numVertexes][0];
  794. color = ( unsigned char * ) &tess.vertexColors[numVertexes];
  795. vDlightBits = &tess.vertexDlightBits[numVertexes];
  796. needsNormal = tess.shader->needsNormal;
  797. for ( i = 0 ; i < rows ; i++ ) {
  798. for ( j = 0 ; j < lodWidth ; j++ ) {
  799. dv = cv->verts + heightTable[ used + i ] * cv->width
  800. + widthTable[ j ];
  801. xyz[0] = dv->xyz[0];
  802. xyz[1] = dv->xyz[1];
  803. xyz[2] = dv->xyz[2];
  804. texCoords[0] = dv->st[0];
  805. texCoords[1] = dv->st[1];
  806. texCoords[2] = dv->lightmap[0];
  807. texCoords[3] = dv->lightmap[1];
  808. if ( needsNormal ) {
  809. normal[0] = dv->normal[0];
  810. normal[1] = dv->normal[1];
  811. normal[2] = dv->normal[2];
  812. }
  813. * ( unsigned int * ) color = * ( unsigned int * ) dv->color;
  814. *vDlightBits++ = dlightBits;
  815. xyz += 4;
  816. normal += 4;
  817. texCoords += 4;
  818. color += 4;
  819. }
  820. }
  821. // add the indexes
  822. {
  823. int numIndexes;
  824. int w, h;
  825. h = rows - 1;
  826. w = lodWidth - 1;
  827. numIndexes = tess.numIndexes;
  828. for (i = 0 ; i < h ; i++) {
  829. for (j = 0 ; j < w ; j++) {
  830. int v1, v2, v3, v4;
  831. // vertex order to be reckognized as tristrips
  832. v1 = numVertexes + i*lodWidth + j + 1;
  833. v2 = v1 - 1;
  834. v3 = v2 + lodWidth;
  835. v4 = v3 + 1;
  836. tess.indexes[numIndexes] = v2;
  837. tess.indexes[numIndexes+1] = v3;
  838. tess.indexes[numIndexes+2] = v1;
  839. tess.indexes[numIndexes+3] = v1;
  840. tess.indexes[numIndexes+4] = v3;
  841. tess.indexes[numIndexes+5] = v4;
  842. numIndexes += 6;
  843. }
  844. }
  845. tess.numIndexes = numIndexes;
  846. }
  847. tess.numVertexes += rows * lodWidth;
  848. used += rows - 1;
  849. }
  850. }
  851. /*
  852. ===========================================================================
  853. NULL MODEL
  854. ===========================================================================
  855. */
  856. /*
  857. ===================
  858. RB_SurfaceAxis
  859. Draws x/y/z lines from the origin for orientation debugging
  860. ===================
  861. */
  862. void RB_SurfaceAxis( void ) {
  863. GL_Bind( tr.whiteImage );
  864. qglLineWidth( 3 );
  865. qglBegin( GL_LINES );
  866. qglColor3f( 1,0,0 );
  867. qglVertex3f( 0,0,0 );
  868. qglVertex3f( 16,0,0 );
  869. qglColor3f( 0,1,0 );
  870. qglVertex3f( 0,0,0 );
  871. qglVertex3f( 0,16,0 );
  872. qglColor3f( 0,0,1 );
  873. qglVertex3f( 0,0,0 );
  874. qglVertex3f( 0,0,16 );
  875. qglEnd();
  876. qglLineWidth( 1 );
  877. }
  878. //===========================================================================
  879. /*
  880. ====================
  881. RB_SurfaceEntity
  882. Entities that have a single procedurally generated surface
  883. ====================
  884. */
  885. void RB_SurfaceEntity( surfaceType_t *surfType ) {
  886. switch( backEnd.currentEntity->e.reType ) {
  887. case RT_SPRITE:
  888. RB_SurfaceSprite();
  889. break;
  890. case RT_BEAM:
  891. RB_SurfaceBeam();
  892. break;
  893. case RT_RAIL_CORE:
  894. RB_SurfaceRailCore();
  895. break;
  896. case RT_RAIL_RINGS:
  897. RB_SurfaceRailRings();
  898. break;
  899. case RT_LIGHTNING:
  900. RB_SurfaceLightningBolt();
  901. break;
  902. default:
  903. RB_SurfaceAxis();
  904. break;
  905. }
  906. return;
  907. }
  908. void RB_SurfaceBad( surfaceType_t *surfType ) {
  909. ri.Printf( PRINT_ALL, "Bad surface tesselated.\n" );
  910. }
  911. #if 0
  912. void RB_SurfaceFlare( srfFlare_t *surf ) {
  913. vec3_t left, up;
  914. float radius;
  915. byte color[4];
  916. vec3_t dir;
  917. vec3_t origin;
  918. float d;
  919. // calculate the xyz locations for the four corners
  920. radius = 30;
  921. VectorScale( backEnd.viewParms.or.axis[1], radius, left );
  922. VectorScale( backEnd.viewParms.or.axis[2], radius, up );
  923. if ( backEnd.viewParms.isMirror ) {
  924. VectorSubtract( vec3_origin, left, left );
  925. }
  926. color[0] = color[1] = color[2] = color[3] = 255;
  927. VectorMA( surf->origin, 3, surf->normal, origin );
  928. VectorSubtract( origin, backEnd.viewParms.or.origin, dir );
  929. VectorNormalize( dir );
  930. VectorMA( origin, r_ignore->value, dir, origin );
  931. d = -DotProduct( dir, surf->normal );
  932. if ( d < 0 ) {
  933. return;
  934. }
  935. #if 0
  936. color[0] *= d;
  937. color[1] *= d;
  938. color[2] *= d;
  939. #endif
  940. RB_AddQuadStamp( origin, left, up, color );
  941. }
  942. #else
  943. void RB_SurfaceFlare( srfFlare_t *surf ) {
  944. #if 0
  945. vec3_t left, up;
  946. byte color[4];
  947. color[0] = surf->color[0] * 255;
  948. color[1] = surf->color[1] * 255;
  949. color[2] = surf->color[2] * 255;
  950. color[3] = 255;
  951. VectorClear( left );
  952. VectorClear( up );
  953. left[0] = r_ignore->value;
  954. up[1] = r_ignore->value;
  955. RB_AddQuadStampExt( surf->origin, left, up, color, 0, 0, 1, 1 );
  956. #endif
  957. }
  958. #endif
  959. void RB_SurfaceDisplayList( srfDisplayList_t *surf ) {
  960. // all apropriate state must be set in RB_BeginSurface
  961. // this isn't implemented yet...
  962. qglCallList( surf->listNum );
  963. }
  964. void RB_SurfaceSkip( void *surf ) {
  965. }
  966. void (*rb_surfaceTable[SF_NUM_SURFACE_TYPES])( void *) = {
  967. (void(*)(void*))RB_SurfaceBad, // SF_BAD,
  968. (void(*)(void*))RB_SurfaceSkip, // SF_SKIP,
  969. (void(*)(void*))RB_SurfaceFace, // SF_FACE,
  970. (void(*)(void*))RB_SurfaceGrid, // SF_GRID,
  971. (void(*)(void*))RB_SurfaceTriangles, // SF_TRIANGLES,
  972. (void(*)(void*))RB_SurfacePolychain, // SF_POLY,
  973. (void(*)(void*))RB_SurfaceMesh, // SF_MD3,
  974. (void(*)(void*))RB_SurfaceAnim, // SF_MD4,
  975. (void(*)(void*))RB_SurfaceFlare, // SF_FLARE,
  976. (void(*)(void*))RB_SurfaceEntity, // SF_ENTITY
  977. (void(*)(void*))RB_SurfaceDisplayList // SF_DISPLAY_LIST
  978. };