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

Function DrawSphere

Descent3/fireball.cpp:2153–2232  ·  view source on GitHub ↗

TODO: MTS: not used? Draws a sphere with the appropriate texture. If texture=-1, then uses rgb as colors

Source from the content-addressed store, hash-verified

2151// TODO: MTS: not used?
2152// Draws a sphere with the appropriate texture. If texture=-1, then uses rgb as colors
2153void DrawSphere(vector *pos, float r, float g, float b, float alpha, float size, int texture, uint8_t saturate) {
2154 static vector sphere_vecs[16][16];
2155 static int first = 1;
2156 g3Point sphere_points[16][16], *pntlist[4], draw_points[4];
2157 int bm_handle = -1;
2158 ddgr_color color = GR_RGB(r * 255, g * 255, b * 255);
2159
2160 int i, t;
2161
2162 if (size < 0)
2163 return;
2164 if (first) {
2165 first = 0;
2166 // Create a unit sphere
2167 int increment = 65536 / 16;
2168 for (i = 0; i < 16; i++) {
2169 for (t = 0; t < 16; t++) {
2170 matrix tempm;
2171 angle pitch, heading;
2172 pitch = i * increment;
2173 heading = t * increment;
2174
2175 vm_AnglesToMatrix(&tempm, pitch, heading, 0);
2176 sphere_vecs[i][t] = tempm.fvec;
2177 }
2178 }
2179 }
2180 rend_SetZBufferWriteMask(0);
2181 draw_points[0].p3_u = 0;
2182 draw_points[0].p3_v = 0;
2183 draw_points[1].p3_u = 1.0 + ((ps_rand() % 100) / 500.0);
2184 draw_points[1].p3_v = 0;
2185 draw_points[2].p3_u = 1.0 + ((ps_rand() % 100) / 500.0);
2186 draw_points[2].p3_v = 1.0 + ((ps_rand() % 100) / 500.0);
2187 draw_points[3].p3_u = 0;
2188 draw_points[3].p3_v = 1.0 + ((ps_rand() % 100) / 500.0);
2189
2190 if (texture == -1) {
2191 rend_SetTextureType(TT_FLAT);
2192 rend_SetOverlayType(OT_NONE);
2193 rend_SetColorModel(CM_RGB);
2194 rend_SetLighting(LS_NONE);
2195 rend_SetFlatColor(color);
2196 rend_SetAlphaType(AT_CONSTANT);
2197 rend_SetAlphaValue(alpha * 255.0);
2198 } else {
2199 rend_SetTextureType(TT_LINEAR);
2200 rend_SetOverlayType(OT_NONE);
2201 rend_SetColorModel(CM_MONO);
2202 rend_SetLighting(LS_NONE);
2203 rend_SetAlphaType(AT_SATURATE_TEXTURE);
2204 rend_SetAlphaValue(alpha * 255.0);
2205 bm_handle = GetTextureBitmap(texture, 0);
2206 }
2207
2208 for (i = 0; i < 16; i++) {
2209 for (t = 0; t < 16; t++) {
2210 vector temp_vec = *pos + (sphere_vecs[i][t] * size);

Callers

nothing calls this directly

Calls 15

ps_randFunction · 0.85
GetTextureBitmapFunction · 0.85
g3_RotatePointFunction · 0.85
g3_CodePointFunction · 0.85
g3_CheckAndDrawPolyFunction · 0.85
GR_RGBFunction · 0.50
vm_AnglesToMatrixFunction · 0.50
rend_SetZBufferWriteMaskFunction · 0.50
rend_SetTextureTypeFunction · 0.50
rend_SetOverlayTypeFunction · 0.50
rend_SetColorModelFunction · 0.50
rend_SetLightingFunction · 0.50

Tested by

no test coverage detected