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

Function DrawStars

Descent3/terrainrender.cpp:1953–2025  ·  view source on GitHub ↗

Draws our pretty stars

Source from the content-addressed store, hash-verified

1951
1952// Draws our pretty stars
1953void DrawStars(matrix *vorient) {
1954 rend_SetLighting(LS_NONE);
1955 rend_SetTextureType(TT_FLAT);
1956 rend_SetOverlayType(OT_NONE);
1957 rend_SetColorModel(CM_MONO);
1958 rend_SetAlphaType(AT_VERTEX);
1959 rend_SetZBufferState(0);
1960 g3_SetFarClipZ(6000000);
1961 vector tempvec;
1962 if (Rendering_main_view && Terrain_sky.flags & TF_ROTATE_STARS && Terrain_sky.rotate_rate > 0) {
1963 matrix mat;
1964 vm_AnglesToMatrix(&mat, 0, Terrain_sky.rotate_rate * Frametime * (65536.0 / 360.0), 0);
1965 vm_Orthogonalize(&mat);
1966 for (int i = 0; i < MAX_STARS; i++) {
1967 vm_MatrixMulVector(&tempvec, &Terrain_sky.star_vectors[i], &mat);
1968 Terrain_sky.star_vectors[i] = tempvec;
1969 }
1970 }
1971 for (int i = 0; i < MAX_STARS; i++) {
1972 g3Point starpnt, lastpnt;
1973 vector streak_vec;
1974 float mag;
1975 // Rotate star
1976 tempvec = Terrain_sky.star_vectors[i];
1977 vm_MatrixMulVector(&starpnt.p3_vec, &tempvec, vorient);
1978 starpnt.p3_flags = PF_RGBA;
1979 // Get streaking line from last frame
1980 if (Rendering_main_view) {
1981 streak_vec = Last_frame_stars[i] - starpnt.p3_vec;
1982 mag = vm_GetMagnitudeFast(&streak_vec);
1983 } else {
1984 mag = 0.0f;
1985 }
1986
1987 if (Rendering_main_view && mag > 9000.0) {
1988 streak_vec /= mag;
1989 float norm = (mag / 90000);
1990 if (norm > 1)
1991 norm = 1.0;
1992 float revnorm = 1.0 - (norm * 4);
1993 if (revnorm < 0)
1994 revnorm = 0;
1995 float color_norm = (.6 + (revnorm * .4));
1996
1997 lastpnt.p3_vec = starpnt.p3_vec + ((norm * .75 * 90000) * streak_vec);
1998 lastpnt.p3_flags = PF_RGBA;
1999 lastpnt.p3_a = 0;
2000 starpnt.p3_a = color_norm;
2001
2002 g3_CodePoint(&starpnt);
2003 g3_CodePoint(&lastpnt);
2004 rend_SetFlatColor(Terrain_sky.star_color[i]);
2005 g3_DrawSpecialLine(&starpnt, &lastpnt);
2006 } else {
2007 starpnt.p3_flags = PF_RGBA;
2008 if (!g3_CodePoint(&starpnt)) // only draw if this point is on screen
2009 {
2010 starpnt.p3_a = 1.0;

Callers 1

DrawSkyFunction · 0.85

Calls 15

g3_SetFarClipZFunction · 0.85
g3_CodePointFunction · 0.85
g3_DrawSpecialLineFunction · 0.85
g3_ProjectPointFunction · 0.85
rend_SetLightingFunction · 0.50
rend_SetTextureTypeFunction · 0.50
rend_SetOverlayTypeFunction · 0.50
rend_SetColorModelFunction · 0.50
rend_SetAlphaTypeFunction · 0.50
rend_SetZBufferStateFunction · 0.50
vm_AnglesToMatrixFunction · 0.50
vm_OrthogonalizeFunction · 0.50

Tested by

no test coverage detected