MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / DrawSky

Function DrawSky

Descent3/terrainrender.cpp:2027–2178  ·  view source on GitHub ↗

Draw the suns,moons,stars, horizon, etc

Source from the content-addressed store, hash-verified

2025}
2026// Draw the suns,moons,stars, horizon, etc
2027void DrawSky(vector *veye, matrix *vorient) {
2028 int i, t;
2029
2030 vector tempvec;
2031
2032 rend_SetLighting(LS_GOURAUD);
2033 rend_SetZBufferState(0);
2034 rend_SetZBufferWriteMask(0);
2035
2036 // If the sky is rotating, update the horizon vectors accordingly
2037 if (Rendering_main_view && Terrain_sky.flags & TF_ROTATE_SKY && Terrain_sky.rotate_rate > 0) {
2038 matrix mat;
2039 vm_AnglesToMatrix(&mat, 0, Terrain_sky.rotate_rate * Frametime * (65536.0 / 360.0), 0);
2040 vm_Orthogonalize(&mat);
2041 for (i = 0; i < 6; i++) {
2042 for (t = 0; t < MAX_HORIZON_PIECES; t++) {
2043 vector rot_vec;
2044 tempvec = Terrain_sky.horizon_vectors[t][i];
2045 vm_MatrixMulVector(&rot_vec, &tempvec, &mat);
2046 Terrain_sky.horizon_vectors[t][i] = rot_vec;
2047 }
2048 }
2049 }
2050
2051 for (i = 0; i < 6; i++) {
2052 for (t = 0; t < MAX_HORIZON_PIECES; t++) {
2053 tempvec = Terrain_sky.horizon_vectors[t][i];
2054 tempvec.y -= veye->y * 0.5f;
2055 vm_MatrixMulVector(&Temp_sky_vectors[t][i], &tempvec, vorient);
2056
2057 tempvec = Terrain_sky.horizon_vectors[t][i];
2058 tempvec.x += veye->x;
2059 tempvec.z += veye->z;
2060 tempvec.y += veye->y * 0.5f;
2061 Temp_sky_vectors_unrotated[t][i] = tempvec;
2062 }
2063 }
2064 float sr = (float)GR_COLOR_RED(Terrain_sky.sky_color) / 255.0;
2065 float sg = (float)GR_COLOR_GREEN(Terrain_sky.sky_color) / 255.0;
2066 float sb = (float)GR_COLOR_BLUE(Terrain_sky.sky_color) / 255.0;
2067 if (!Terrain_sky.textured) {
2068 DrawGouraudSky();
2069 } else {
2070 DrawTexturedSky();
2071 }
2072
2073 if (Terrain_sky.flags & TF_STARS) {
2074 DrawStars(vorient);
2075 }
2076
2077 if (Terrain_sky.flags & TF_SATELLITES) {
2078 rend_SetWrapType(WT_CLAMP);
2079 rend_SetColorModel(CM_MONO);
2080
2081 // do satellites
2082 for (i = 0; i < Terrain_sky.num_satellites; i++) {
2083 int bm_handle = GetTextureBitmap(Terrain_sky.satellite_texture[i], 0);
2084 vector subvec = Terrain_sky.satellite_vectors[i] - *veye;

Callers 1

RenderTerrainFunction · 0.85

Calls 15

GR_COLOR_REDFunction · 0.85
GR_COLOR_GREENFunction · 0.85
GR_COLOR_BLUEFunction · 0.85
DrawGouraudSkyFunction · 0.85
DrawTexturedSkyFunction · 0.85
DrawStarsFunction · 0.85
GetTextureBitmapFunction · 0.85
vm_NormalizeVectorFunction · 0.85
DrawColoredRingFunction · 0.85
g3_SetTriangulationTestFunction · 0.85
bm_hFunction · 0.85

Tested by

no test coverage detected