#include "tr_local.h"
Include dependency graph for tr_sky.c:

Go to the source code of this file.
Defines | |
| #define | HALF_SKY_SUBDIVISIONS (SKY_SUBDIVISIONS/2) |
| #define | MAX_CLIP_VERTS 64 |
| #define | ON_EPSILON 0.1f |
| #define | SKY_SUBDIVISIONS 8 |
| #define | SQR(a) ((a)*(a)) |
Functions | |
| void | AddSkyPolygon (int nump, vec3_t vecs) |
| void | ClearSkyBox (void) |
| void | ClipSkyPolygon (int nump, vec3_t vecs, int stage) |
| void | DrawSkyBox (shader_t *shader) |
| void | DrawSkySide (struct image_s *image, const int mins[2], const int maxs[2]) |
| void | FillCloudBox (const shader_t *shader, int stage) |
| void | FillCloudySkySide (const int mins[2], const int maxs[2], qboolean addIndexes) |
| void | MakeSkyVec (float s, float t, int axis, float outSt[2], vec3_t outXYZ) |
| void | R_BuildCloudData (shaderCommands_t *input) |
| void | R_InitSkyTexCoords (float heightCloud) |
| void | RB_ClipSkyPolygons (shaderCommands_t *input) |
| void | RB_DrawSun (void) |
| void | RB_StageIteratorSky (void) |
Variables | |
| float | s_cloudTexCoords [6][SKY_SUBDIVISIONS+1][SKY_SUBDIVISIONS+1][2] |
| float | s_cloudTexP [6][SKY_SUBDIVISIONS+1][SKY_SUBDIVISIONS+1] |
| vec3_t | s_skyPoints [SKY_SUBDIVISIONS+1][SKY_SUBDIVISIONS+1] |
| float | s_skyTexCoords [SKY_SUBDIVISIONS+1][SKY_SUBDIVISIONS+1][2] |
| vec3_t | sky_clip [6] |
| float | sky_max |
| float | sky_maxs [2][6] |
| float | sky_min |
| float | sky_mins [2][6] |
| int | sky_texorder [6] = {0,2,1,3,4,5} |
|
|
Definition at line 26 of file tr_sky.c. Referenced by DrawSkyBox(), FillCloudBox(), and R_InitSkyTexCoords(). |
|
|
Definition at line 144 of file tr_sky.c. Referenced by ClipSkyPolygon(). |
|
|
|
|
|
|
|
|
Definition at line 637 of file tr_sky.c. Referenced by R_InitSkyTexCoords(). |
|
||||||||||||
|
Definition at line 57 of file tr_sky.c. References fabs(), i, j, s, sky_maxs, sky_mins, t, v, vec3_origin, vec3_t, vecs, VectorAdd, VectorCopy, and vp. Referenced by ClipSkyPolygon(). 00058 {
00059 int i,j;
00060 vec3_t v, av;
00061 float s, t, dv;
00062 int axis;
00063 float *vp;
00064 // s = [0]/[2], t = [1]/[2]
00065 static int vec_to_st[6][3] =
00066 {
00067 {-2,3,1},
00068 {2,3,-1},
00069
00070 {1,3,2},
00071 {-1,3,-2},
00072
00073 {-2,-1,3},
00074 {-2,1,-3}
00075
00076 // {-1,2,3},
00077 // {1,2,-3}
00078 };
00079
00080 // decide which face it maps to
00081 VectorCopy (vec3_origin, v);
00082 for (i=0, vp=vecs ; i<nump ; i++, vp+=3)
00083 {
00084 VectorAdd (vp, v, v);
00085 }
00086 av[0] = fabs(v[0]);
00087 av[1] = fabs(v[1]);
00088 av[2] = fabs(v[2]);
00089 if (av[0] > av[1] && av[0] > av[2])
00090 {
00091 if (v[0] < 0)
00092 axis = 1;
00093 else
00094 axis = 0;
00095 }
00096 else if (av[1] > av[2] && av[1] > av[0])
00097 {
00098 if (v[1] < 0)
00099 axis = 3;
00100 else
00101 axis = 2;
00102 }
00103 else
00104 {
00105 if (v[2] < 0)
00106 axis = 5;
00107 else
00108 axis = 4;
00109 }
00110
00111 // project new texture coords
00112 for (i=0 ; i<nump ; i++, vecs+=3)
00113 {
00114 j = vec_to_st[axis][2];
00115 if (j > 0)
00116 dv = vecs[j - 1];
00117 else
00118 dv = -vecs[-j - 1];
00119 if (dv < 0.001)
00120 continue; // don't divide by zero
00121 j = vec_to_st[axis][0];
00122 if (j < 0)
00123 s = -vecs[-j -1] / dv;
00124 else
00125 s = vecs[j-1] / dv;
00126 j = vec_to_st[axis][1];
00127 if (j < 0)
00128 t = -vecs[-j -1] / dv;
00129 else
00130 t = vecs[j-1] / dv;
00131
00132 if (s < sky_mins[0][axis])
00133 sky_mins[0][axis] = s;
00134 if (t < sky_mins[1][axis])
00135 sky_mins[1][axis] = t;
00136 if (s > sky_maxs[0][axis])
00137 sky_maxs[0][axis] = s;
00138 if (t > sky_maxs[1][axis])
00139 sky_maxs[1][axis] = t;
00140 }
00141 }
|
Here is the call graph for this function:

|
|
Definition at line 246 of file tr_sky.c. References i, sky_maxs, and sky_mins. Referenced by RB_ClipSkyPolygons(). 00246 {
00247 int i;
00248
00249 for (i=0 ; i<6 ; i++) {
00250 sky_mins[0][i] = sky_mins[1][i] = 9999;
00251 sky_maxs[0][i] = sky_maxs[1][i] = -9999;
00252 }
00253 }
|
|
||||||||||||||||
|
Definition at line 150 of file tr_sky.c. References AddSkyPolygon(), d, DotProduct, e, ERR_DROP, i, j, MAX_CLIP_VERTS, qboolean, ri, SIDE_BACK, SIDE_FRONT, SIDE_ON, sky_clip, v, vec3_t, vecs, and VectorCopy. Referenced by RB_ClipSkyPolygons(). 00151 {
00152 float *norm;
00153 float *v;
00154 qboolean front, back;
00155 float d, e;
00156 float dists[MAX_CLIP_VERTS];
00157 int sides[MAX_CLIP_VERTS];
00158 vec3_t newv[2][MAX_CLIP_VERTS];
00159 int newc[2];
00160 int i, j;
00161
00162 if (nump > MAX_CLIP_VERTS-2)
00163 ri.Error (ERR_DROP, "ClipSkyPolygon: MAX_CLIP_VERTS");
00164 if (stage == 6)
00165 { // fully clipped, so draw it
00166 AddSkyPolygon (nump, vecs);
00167 return;
00168 }
00169
00170 front = back = qfalse;
00171 norm = sky_clip[stage];
00172 for (i=0, v = vecs ; i<nump ; i++, v+=3)
00173 {
00174 d = DotProduct (v, norm);
00175 if (d > ON_EPSILON)
00176 {
00177 front = qtrue;
00178 sides[i] = SIDE_FRONT;
00179 }
00180 else if (d < -ON_EPSILON)
00181 {
00182 back = qtrue;
00183 sides[i] = SIDE_BACK;
00184 }
00185 else
00186 sides[i] = SIDE_ON;
00187 dists[i] = d;
00188 }
00189
00190 if (!front || !back)
00191 { // not clipped
00192 ClipSkyPolygon (nump, vecs, stage+1);
00193 return;
00194 }
00195
00196 // clip it
00197 sides[i] = sides[0];
00198 dists[i] = dists[0];
00199 VectorCopy (vecs, (vecs+(i*3)) );
00200 newc[0] = newc[1] = 0;
00201
00202 for (i=0, v = vecs ; i<nump ; i++, v+=3)
00203 {
00204 switch (sides[i])
00205 {
00206 case SIDE_FRONT:
00207 VectorCopy (v, newv[0][newc[0]]);
00208 newc[0]++;
00209 break;
00210 case SIDE_BACK:
00211 VectorCopy (v, newv[1][newc[1]]);
00212 newc[1]++;
00213 break;
00214 case SIDE_ON:
00215 VectorCopy (v, newv[0][newc[0]]);
00216 newc[0]++;
00217 VectorCopy (v, newv[1][newc[1]]);
00218 newc[1]++;
00219 break;
00220 }
00221
00222 if (sides[i] == SIDE_ON || sides[i+1] == SIDE_ON || sides[i+1] == sides[i])
00223 continue;
00224
00225 d = dists[i] / (dists[i] - dists[i+1]);
00226 for (j=0 ; j<3 ; j++)
00227 {
00228 e = v[j] + d*(v[j+3] - v[j]);
00229 newv[0][newc[0]][j] = e;
00230 newv[1][newc[1]][j] = e;
00231 }
00232 newc[0]++;
00233 newc[1]++;
00234 }
00235
00236 // continue
00237 ClipSkyPolygon (newc[0], newv[0][0], stage+1);
00238 ClipSkyPolygon (newc[1], newv[1][0], stage+1);
00239 }
|
Here is the call graph for this function:

|
|
Definition at line 387 of file tr_sky.c. References ceil(), Com_Memset(), DrawSkySide(), floor(), HALF_SKY_SUBDIVISIONS, i, MakeSkyVec(), skyParms_t::outerbox, s, s_skyPoints, s_skyTexCoords, shader_t, shader_s::sky, sky_max, sky_maxs, sky_min, sky_mins, sky_texorder, and t. Referenced by RB_StageIteratorSky(). 00388 {
00389 int i;
00390
00391 sky_min = 0;
00392 sky_max = 1;
00393
00394 Com_Memset( s_skyTexCoords, 0, sizeof( s_skyTexCoords ) );
00395
00396 for (i=0 ; i<6 ; i++)
00397 {
00398 int sky_mins_subd[2], sky_maxs_subd[2];
00399 int s, t;
00400
00401 sky_mins[0][i] = floor( sky_mins[0][i] * HALF_SKY_SUBDIVISIONS ) / HALF_SKY_SUBDIVISIONS;
00402 sky_mins[1][i] = floor( sky_mins[1][i] * HALF_SKY_SUBDIVISIONS ) / HALF_SKY_SUBDIVISIONS;
00403 sky_maxs[0][i] = ceil( sky_maxs[0][i] * HALF_SKY_SUBDIVISIONS ) / HALF_SKY_SUBDIVISIONS;
00404 sky_maxs[1][i] = ceil( sky_maxs[1][i] * HALF_SKY_SUBDIVISIONS ) / HALF_SKY_SUBDIVISIONS;
00405
00406 if ( ( sky_mins[0][i] >= sky_maxs[0][i] ) ||
00407 ( sky_mins[1][i] >= sky_maxs[1][i] ) )
00408 {
00409 continue;
00410 }
00411
00412 sky_mins_subd[0] = sky_mins[0][i] * HALF_SKY_SUBDIVISIONS;
00413 sky_mins_subd[1] = sky_mins[1][i] * HALF_SKY_SUBDIVISIONS;
00414 sky_maxs_subd[0] = sky_maxs[0][i] * HALF_SKY_SUBDIVISIONS;
00415 sky_maxs_subd[1] = sky_maxs[1][i] * HALF_SKY_SUBDIVISIONS;
00416
00417 if ( sky_mins_subd[0] < -HALF_SKY_SUBDIVISIONS )
00418 sky_mins_subd[0] = -HALF_SKY_SUBDIVISIONS;
00419 else if ( sky_mins_subd[0] > HALF_SKY_SUBDIVISIONS )
00420 sky_mins_subd[0] = HALF_SKY_SUBDIVISIONS;
00421 if ( sky_mins_subd[1] < -HALF_SKY_SUBDIVISIONS )
00422 sky_mins_subd[1] = -HALF_SKY_SUBDIVISIONS;
00423 else if ( sky_mins_subd[1] > HALF_SKY_SUBDIVISIONS )
00424 sky_mins_subd[1] = HALF_SKY_SUBDIVISIONS;
00425
00426 if ( sky_maxs_subd[0] < -HALF_SKY_SUBDIVISIONS )
00427 sky_maxs_subd[0] = -HALF_SKY_SUBDIVISIONS;
00428 else if ( sky_maxs_subd[0] > HALF_SKY_SUBDIVISIONS )
00429 sky_maxs_subd[0] = HALF_SKY_SUBDIVISIONS;
00430 if ( sky_maxs_subd[1] < -HALF_SKY_SUBDIVISIONS )
00431 sky_maxs_subd[1] = -HALF_SKY_SUBDIVISIONS;
00432 else if ( sky_maxs_subd[1] > HALF_SKY_SUBDIVISIONS )
00433 sky_maxs_subd[1] = HALF_SKY_SUBDIVISIONS;
00434
00435 //
00436 // iterate through the subdivisions
00437 //
00438 for ( t = sky_mins_subd[1]+HALF_SKY_SUBDIVISIONS; t <= sky_maxs_subd[1]+HALF_SKY_SUBDIVISIONS; t++ )
00439 {
00440 for ( s = sky_mins_subd[0]+HALF_SKY_SUBDIVISIONS; s <= sky_maxs_subd[0]+HALF_SKY_SUBDIVISIONS; s++ )
00441 {
00442 MakeSkyVec( ( s - HALF_SKY_SUBDIVISIONS ) / ( float ) HALF_SKY_SUBDIVISIONS,
00443 ( t - HALF_SKY_SUBDIVISIONS ) / ( float ) HALF_SKY_SUBDIVISIONS,
00444 i,
00445 s_skyTexCoords[t][s],
00446 s_skyPoints[t][s] );
00447 }
00448 }
00449
00450 DrawSkySide( shader->sky.outerbox[sky_texorder[i]],
00451 sky_mins_subd,
00452 sky_maxs_subd );
00453 }
00454
00455 }
|
Here is the call graph for this function:

|
||||||||||||||||
|
Definition at line 364 of file tr_sky.c. References GL_Bind(), qglBegin, qglEnd, qglTexCoord2fv, qglVertex3fv, s, s_skyPoints, s_skyTexCoords, and t. Referenced by DrawSkyBox(). 00365 {
00366 int s, t;
00367
00368 GL_Bind( image );
00369
00370 for ( t = mins[1]+HALF_SKY_SUBDIVISIONS; t < maxs[1]+HALF_SKY_SUBDIVISIONS; t++ )
00371 {
00372 qglBegin( GL_TRIANGLE_STRIP );
00373
00374 for ( s = mins[0]+HALF_SKY_SUBDIVISIONS; s <= maxs[0]+HALF_SKY_SUBDIVISIONS; s++ )
00375 {
00376 qglTexCoord2fv( s_skyTexCoords[t][s] );
00377 qglVertex3fv( s_skyPoints[t][s] );
00378
00379 qglTexCoord2fv( s_skyTexCoords[t+1][s] );
00380 qglVertex3fv( s_skyPoints[t+1][s] );
00381 }
00382
00383 qglEnd();
00384 }
00385 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 507 of file tr_sky.c. References ceil(), FillCloudySkySide(), floor(), HALF_SKY_SUBDIVISIONS, i, MakeSkyVec(), myftol, NULL, s, s_cloudTexCoords, s_skyPoints, s_skyTexCoords, shader_t, sky_maxs, sky_mins, and t. Referenced by R_BuildCloudData(). 00508 {
00509 int i;
00510
00511 for ( i =0; i < 6; i++ )
00512 {
00513 int sky_mins_subd[2], sky_maxs_subd[2];
00514 int s, t;
00515 float MIN_T;
00516
00517 if ( 1 ) // FIXME? shader->sky.fullClouds )
00518 {
00519 MIN_T = -HALF_SKY_SUBDIVISIONS;
00520
00521 // still don't want to draw the bottom, even if fullClouds
00522 if ( i == 5 )
00523 continue;
00524 }
00525 else
00526 {
00527 switch( i )
00528 {
00529 case 0:
00530 case 1:
00531 case 2:
00532 case 3:
00533 MIN_T = -1;
00534 break;
00535 case 5:
00536 // don't draw clouds beneath you
00537 continue;
00538 case 4: // top
00539 default:
00540 MIN_T = -HALF_SKY_SUBDIVISIONS;
00541 break;
00542 }
00543 }
00544
00545 sky_mins[0][i] = floor( sky_mins[0][i] * HALF_SKY_SUBDIVISIONS ) / HALF_SKY_SUBDIVISIONS;
00546 sky_mins[1][i] = floor( sky_mins[1][i] * HALF_SKY_SUBDIVISIONS ) / HALF_SKY_SUBDIVISIONS;
00547 sky_maxs[0][i] = ceil( sky_maxs[0][i] * HALF_SKY_SUBDIVISIONS ) / HALF_SKY_SUBDIVISIONS;
00548 sky_maxs[1][i] = ceil( sky_maxs[1][i] * HALF_SKY_SUBDIVISIONS ) / HALF_SKY_SUBDIVISIONS;
00549
00550 if ( ( sky_mins[0][i] >= sky_maxs[0][i] ) ||
00551 ( sky_mins[1][i] >= sky_maxs[1][i] ) )
00552 {
00553 continue;
00554 }
00555
00556 sky_mins_subd[0] = myftol( sky_mins[0][i] * HALF_SKY_SUBDIVISIONS );
00557 sky_mins_subd[1] = myftol( sky_mins[1][i] * HALF_SKY_SUBDIVISIONS );
00558 sky_maxs_subd[0] = myftol( sky_maxs[0][i] * HALF_SKY_SUBDIVISIONS );
00559 sky_maxs_subd[1] = myftol( sky_maxs[1][i] * HALF_SKY_SUBDIVISIONS );
00560
00561 if ( sky_mins_subd[0] < -HALF_SKY_SUBDIVISIONS )
00562 sky_mins_subd[0] = -HALF_SKY_SUBDIVISIONS;
00563 else if ( sky_mins_subd[0] > HALF_SKY_SUBDIVISIONS )
00564 sky_mins_subd[0] = HALF_SKY_SUBDIVISIONS;
00565 if ( sky_mins_subd[1] < MIN_T )
00566 sky_mins_subd[1] = MIN_T;
00567 else if ( sky_mins_subd[1] > HALF_SKY_SUBDIVISIONS )
00568 sky_mins_subd[1] = HALF_SKY_SUBDIVISIONS;
00569
00570 if ( sky_maxs_subd[0] < -HALF_SKY_SUBDIVISIONS )
00571 sky_maxs_subd[0] = -HALF_SKY_SUBDIVISIONS;
00572 else if ( sky_maxs_subd[0] > HALF_SKY_SUBDIVISIONS )
00573 sky_maxs_subd[0] = HALF_SKY_SUBDIVISIONS;
00574 if ( sky_maxs_subd[1] < MIN_T )
00575 sky_maxs_subd[1] = MIN_T;
00576 else if ( sky_maxs_subd[1] > HALF_SKY_SUBDIVISIONS )
00577 sky_maxs_subd[1] = HALF_SKY_SUBDIVISIONS;
00578
00579 //
00580 // iterate through the subdivisions
00581 //
00582 for ( t = sky_mins_subd[1]+HALF_SKY_SUBDIVISIONS; t <= sky_maxs_subd[1]+HALF_SKY_SUBDIVISIONS; t++ )
00583 {
00584 for ( s = sky_mins_subd[0]+HALF_SKY_SUBDIVISIONS; s <= sky_maxs_subd[0]+HALF_SKY_SUBDIVISIONS; s++ )
00585 {
00586 MakeSkyVec( ( s - HALF_SKY_SUBDIVISIONS ) / ( float ) HALF_SKY_SUBDIVISIONS,
00587 ( t - HALF_SKY_SUBDIVISIONS ) / ( float ) HALF_SKY_SUBDIVISIONS,
00588 i,
00589 NULL,
00590 s_skyPoints[t][s] );
00591
00592 s_skyTexCoords[t][s][0] = s_cloudTexCoords[i][t][s][0];
00593 s_skyTexCoords[t][s][1] = s_cloudTexCoords[i][t][s][1];
00594 }
00595 }
00596
00597 // only add indexes for first stage
00598 FillCloudySkySide( sky_mins_subd, sky_maxs_subd, ( stage == 0 ) );
00599 }
00600 }
|
Here is the call graph for this function:

|
||||||||||||||||
|
Definition at line 457 of file tr_sky.c. References backEnd, ERR_DROP, shaderCommands_s::indexes, shaderCommands_s::numIndexes, shaderCommands_s::numVertexes, viewParms_t::or, orientationr_t::origin, ri, s, s_skyPoints, s_skyTexCoords, t, tess, shaderCommands_s::texCoords, VectorAdd, backEndState_t::viewParms, and shaderCommands_s::xyz. Referenced by FillCloudBox(). 00458 {
00459 int s, t;
00460 int vertexStart = tess.numVertexes;
00461 int tHeight, sWidth;
00462
00463 tHeight = maxs[1] - mins[1] + 1;
00464 sWidth = maxs[0] - mins[0] + 1;
00465
00466 for ( t = mins[1]+HALF_SKY_SUBDIVISIONS; t <= maxs[1]+HALF_SKY_SUBDIVISIONS; t++ )
00467 {
00468 for ( s = mins[0]+HALF_SKY_SUBDIVISIONS; s <= maxs[0]+HALF_SKY_SUBDIVISIONS; s++ )
00469 {
00470 VectorAdd( s_skyPoints[t][s], backEnd.viewParms.or.origin, tess.xyz[tess.numVertexes] );
00471 tess.texCoords[tess.numVertexes][0][0] = s_skyTexCoords[t][s][0];
00472 tess.texCoords[tess.numVertexes][0][1] = s_skyTexCoords[t][s][1];
00473
00474 tess.numVertexes++;
00475
00476 if ( tess.numVertexes >= SHADER_MAX_VERTEXES )
00477 {
00478 ri.Error( ERR_DROP, "SHADER_MAX_VERTEXES hit in FillCloudySkySide()\n" );
00479 }
00480 }
00481 }
00482
00483 // only add indexes for one pass, otherwise it would draw multiple times for each pass
00484 if ( addIndexes ) {
00485 for ( t = 0; t < tHeight-1; t++ )
00486 {
00487 for ( s = 0; s < sWidth-1; s++ )
00488 {
00489 tess.indexes[tess.numIndexes] = vertexStart + s + t * ( sWidth );
00490 tess.numIndexes++;
00491 tess.indexes[tess.numIndexes] = vertexStart + s + ( t + 1 ) * ( sWidth );
00492 tess.numIndexes++;
00493 tess.indexes[tess.numIndexes] = vertexStart + s + 1 + t * ( sWidth );
00494 tess.numIndexes++;
00495
00496 tess.indexes[tess.numIndexes] = vertexStart + s + ( t + 1 ) * ( sWidth );
00497 tess.numIndexes++;
00498 tess.indexes[tess.numIndexes] = vertexStart + s + 1 + ( t + 1 ) * ( sWidth );
00499 tess.numIndexes++;
00500 tess.indexes[tess.numIndexes] = vertexStart + s + 1 + t * ( sWidth );
00501 tess.numIndexes++;
00502 }
00503 }
00504 }
00505 }
|
|
||||||||||||||||||||||||
|
Definition at line 292 of file tr_sky.c. References b, backEnd, j, k, s, t, vec3_t, backEndState_t::viewParms, and viewParms_t::zFar. Referenced by DrawSkyBox(), FillCloudBox(), and R_InitSkyTexCoords(). 00293 {
00294 // 1 = s, 2 = t, 3 = 2048
00295 static int st_to_vec[6][3] =
00296 {
00297 {3,-1,2},
00298 {-3,1,2},
00299
00300 {1,3,2},
00301 {-1,-3,2},
00302
00303 {-2,-1,3}, // 0 degrees yaw, look straight up
00304 {2,-1,-3} // look straight down
00305 };
00306
00307 vec3_t b;
00308 int j, k;
00309 float boxSize;
00310
00311 boxSize = backEnd.viewParms.zFar / 1.75; // div sqrt(3)
00312 b[0] = s*boxSize;
00313 b[1] = t*boxSize;
00314 b[2] = boxSize;
00315
00316 for (j=0 ; j<3 ; j++)
00317 {
00318 k = st_to_vec[axis][j];
00319 if (k < 0)
00320 {
00321 outXYZ[j] = -b[-k - 1];
00322 }
00323 else
00324 {
00325 outXYZ[j] = b[k - 1];
00326 }
00327 }
00328
00329 // avoid bilerp seam
00330 s = (s+1)*0.5;
00331 t = (t+1)*0.5;
00332 if (s < sky_min)
00333 {
00334 s = sky_min;
00335 }
00336 else if (s > sky_max)
00337 {
00338 s = sky_max;
00339 }
00340
00341 if (t < sky_min)
00342 {
00343 t = sky_min;
00344 }
00345 else if (t > sky_max)
00346 {
00347 t = sky_max;
00348 }
00349
00350 t = 1.0 - t;
00351
00352
00353 if ( outSt )
00354 {
00355 outSt[0] = s;
00356 outSt[1] = t;
00357 }
00358 }
|
|
|
Definition at line 605 of file tr_sky.c. References assert, skyParms_t::cloudHeight, FillCloudBox(), i, input, shader_s::isSky, shaderCommands_s::numIndexes, shaderCommands_s::numVertexes, shaderCommands_s::shader, shader_t, shaderCommands_t, shader_s::sky, sky_max, sky_min, tess, and shaderCommands_s::xstages. Referenced by RB_StageIteratorSky(). 00606 {
00607 int i;
00608 shader_t *shader;
00609
00610 shader = input->shader;
00611
00612 assert( shader->isSky );
00613
00614 sky_min = 1.0 / 256.0f; // FIXME: not correct?
00615 sky_max = 255.0 / 256.0f;
00616
00617 // set up for drawing
00618 tess.numIndexes = 0;
00619 tess.numVertexes = 0;
00620
00621 if ( input->shader->sky.cloudHeight )
00622 {
00623 for ( i = 0; i < MAX_SHADER_STAGES; i++ )
00624 {
00625 if ( !tess.xstages[i] ) {
00626 break;
00627 }
00628 FillCloudBox( input->shader, i );
00629 }
00630 }
00631 }
|
Here is the call graph for this function:

|
|
Definition at line 638 of file tr_sky.c. References backEnd, DotProduct, HALF_SKY_SUBDIVISIONS, i, MakeSkyVec(), NULL, p, Q_acos(), s, s_cloudTexCoords, s_cloudTexP, SQR, sqrt(), t, v, vec3_t, VectorNormalize(), VectorScale, backEndState_t::viewParms, and viewParms_t::zFar. Referenced by ParseSkyParms(). 00639 {
00640 int i, s, t;
00641 float radiusWorld = 4096;
00642 float p;
00643 float sRad, tRad;
00644 vec3_t skyVec;
00645 vec3_t v;
00646
00647 // init zfar so MakeSkyVec works even though
00648 // a world hasn't been bounded
00649 backEnd.viewParms.zFar = 1024;
00650
00651 for ( i = 0; i < 6; i++ )
00652 {
00653 for ( t = 0; t <= SKY_SUBDIVISIONS; t++ )
00654 {
00655 for ( s = 0; s <= SKY_SUBDIVISIONS; s++ )
00656 {
00657 // compute vector from view origin to sky side integral point
00658 MakeSkyVec( ( s - HALF_SKY_SUBDIVISIONS ) / ( float ) HALF_SKY_SUBDIVISIONS,
00659 ( t - HALF_SKY_SUBDIVISIONS ) / ( float ) HALF_SKY_SUBDIVISIONS,
00660 i,
00661 NULL,
00662 skyVec );
00663
00664 // compute parametric value 'p' that intersects with cloud layer
00665 p = ( 1.0f / ( 2 * DotProduct( skyVec, skyVec ) ) ) *
00666 ( -2 * skyVec[2] * radiusWorld +
00667 2 * sqrt( SQR( skyVec[2] ) * SQR( radiusWorld ) +
00668 2 * SQR( skyVec[0] ) * radiusWorld * heightCloud +
00669 SQR( skyVec[0] ) * SQR( heightCloud ) +
00670 2 * SQR( skyVec[1] ) * radiusWorld * heightCloud +
00671 SQR( skyVec[1] ) * SQR( heightCloud ) +
00672 2 * SQR( skyVec[2] ) * radiusWorld * heightCloud +
00673 SQR( skyVec[2] ) * SQR( heightCloud ) ) );
00674
00675 s_cloudTexP[i][t][s] = p;
00676
00677 // compute intersection point based on p
00678 VectorScale( skyVec, p, v );
00679 v[2] += radiusWorld;
00680
00681 // compute vector from world origin to intersection point 'v'
00682 VectorNormalize( v );
00683
00684 sRad = Q_acos( v[0] );
00685 tRad = Q_acos( v[1] );
00686
00687 s_cloudTexCoords[i][t][s][0] = sRad;
00688 s_cloudTexCoords[i][t][s][1] = tRad;
00689 }
00690 }
00691 }
00692 }
|
Here is the call graph for this function:

|
|
Definition at line 260 of file tr_sky.c. References backEnd, ClearSkyBox(), ClipSkyPolygon(), i, shaderCommands_s::indexes, input, j, shaderCommands_s::numIndexes, viewParms_t::or, orientationr_t::origin, p, shaderCommands_t, vec3_t, VectorSubtract, backEndState_t::viewParms, and shaderCommands_s::xyz. Referenced by RB_StageIteratorSky(). 00261 {
00262 vec3_t p[5]; // need one extra point for clipping
00263 int i, j;
00264
00265 ClearSkyBox();
00266
00267 for ( i = 0; i < input->numIndexes; i += 3 )
00268 {
00269 for (j = 0 ; j < 3 ; j++)
00270 {
00271 VectorSubtract( input->xyz[input->indexes[i+j]],
00272 backEnd.viewParms.or.origin,
00273 p[j] );
00274 }
00275 ClipSkyPolygon( 3, p[0], 0 );
00276 }
00277 }
|
Here is the call graph for this function:

|
Here is the call graph for this function:

|
|
Definition at line 798 of file tr_sky.c. References backEnd, trGlobals_t::defaultImage, DrawSkyBox(), GL_State(), trGlobals_t::identityLight, cvar_s::integer, viewParms_t::or, orientationr_t::origin, skyParms_t::outerbox, qglColor3f, qglDepthRange, qglPopMatrix, qglPushMatrix, qglTranslatef, R_BuildCloudData(), r_fastsky, r_showsky, RB_ClipSkyPolygons(), RB_StageIteratorGeneric(), shaderCommands_s::shader, shader_s::sky, backEndState_t::skyRenderedThisView, tess, tr, and backEndState_t::viewParms. 00798 {
00799 if ( r_fastsky->integer ) {
00800 return;
00801 }
00802
00803 // go through all the polygons and project them onto
00804 // the sky box to see which blocks on each side need
00805 // to be drawn
00806 RB_ClipSkyPolygons( &tess );
00807
00808 // r_showsky will let all the sky blocks be drawn in
00809 // front of everything to allow developers to see how
00810 // much sky is getting sucked in
00811 if ( r_showsky->integer ) {
00812 qglDepthRange( 0.0, 0.0 );
00813 } else {
00814 qglDepthRange( 1.0, 1.0 );
00815 }
00816
00817 // draw the outer skybox
00818 if ( tess.shader->sky.outerbox[0] && tess.shader->sky.outerbox[0] != tr.defaultImage ) {
00819 qglColor3f( tr.identityLight, tr.identityLight, tr.identityLight );
00820
00821 qglPushMatrix ();
00822 GL_State( 0 );
00823 qglTranslatef (backEnd.viewParms.or.origin[0], backEnd.viewParms.or.origin[1], backEnd.viewParms.or.origin[2]);
00824
00825 DrawSkyBox( tess.shader );
00826
00827 qglPopMatrix();
00828 }
00829
00830 // generate the vertexes for all the clouds, which will be drawn
00831 // by the generic shader routine
00832 R_BuildCloudData( &tess );
00833
00834 RB_StageIteratorGeneric();
00835
00836 // draw the inner skybox
00837
00838
00839 // back to normal depth range
00840 qglDepthRange( 0.0, 1.0 );
00841
00842 // note that sky was drawn so we will draw a sun later
00843 backEnd.skyRenderedThisView = qtrue;
00844 }
|
Here is the call graph for this function:

|
|
Definition at line 28 of file tr_sky.c. Referenced by FillCloudBox(), and R_InitSkyTexCoords(). |
|
|
Definition at line 29 of file tr_sky.c. Referenced by R_InitSkyTexCoords(). |
|
|
Definition at line 361 of file tr_sky.c. Referenced by DrawSkyBox(), DrawSkySide(), FillCloudBox(), and FillCloudySkySide(). |
|
|
Definition at line 362 of file tr_sky.c. Referenced by DrawSkyBox(), DrawSkySide(), FillCloudBox(), and FillCloudySkySide(). |
|
|
Initial value:
{
{1,1,0},
{1,-1,0},
{0,-1,1},
{0,1,1},
{1,0,1},
{-1,0,1}
}
Definition at line 39 of file tr_sky.c. Referenced by ClipSkyPolygon(). |
|
|
Definition at line 50 of file tr_sky.c. Referenced by DrawSkyBox(), and R_BuildCloudData(). |
|
|
Definition at line 49 of file tr_sky.c. Referenced by AddSkyPolygon(), ClearSkyBox(), DrawSkyBox(), and FillCloudBox(). |
|
|
Definition at line 50 of file tr_sky.c. Referenced by DrawSkyBox(), and R_BuildCloudData(). |
|
|
Definition at line 49 of file tr_sky.c. Referenced by AddSkyPolygon(), ClearSkyBox(), DrawSkyBox(), and FillCloudBox(). |
|
|
Definition at line 360 of file tr_sky.c. Referenced by DrawSkyBox(). |
1.3.9.1