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

Function g3_DrawRotatedBitmap

renderer/HardwareDraw.cpp:299–351  ·  view source on GitHub ↗

Draws a bitmap that has been rotated about its center. Angle of rotation is passed as 'rot_angle'

Source from the content-addressed store, hash-verified

297
298// Draws a bitmap that has been rotated about its center. Angle of rotation is passed as 'rot_angle'
299void g3_DrawRotatedBitmap(vector *pos, angle rot_angle, float width, float height, int bm, int color) {
300 // get the view orientation
301 matrix viewOrient;
302 g3_GetUnscaledMatrix(&viewOrient);
303
304 matrix rot_matrix;
305 vm_AnglesToMatrix(&rot_matrix, 0, 0, rot_angle);
306
307 float w = width;
308 float h = height;
309
310 vector rot_vectors[4];
311 rot_vectors[0].x = -w;
312 rot_vectors[0].y = h;
313
314 rot_vectors[1].x = w;
315 rot_vectors[1].y = h;
316
317 rot_vectors[2].x = w;
318 rot_vectors[2].y = -h;
319
320 rot_vectors[3].x = -w;
321 rot_vectors[3].y = -h;
322
323 g3Point rot_points[8], *pntlist[8];
324 int i;
325 for (i = 0; i < 4; ++i) {
326 vector offset;
327 rot_vectors[i].z = 0.0f;
328 vm_MatrixMulVector(&offset, &rot_vectors[i], &rot_matrix);
329
330 vector cornerPos = *pos + (viewOrient.uvec * offset.y) + (viewOrient.rvec * offset.x);
331 rot_points[i].p3_codes = 0;
332 g3_RotatePoint(&rot_points[i], &cornerPos);
333
334 rot_points[i].p3_flags |= PF_UV | PF_RGBA;
335 rot_points[i].p3_l = 1.0f;
336 rot_points[i].p3_uvl.u = ((i & 1) ^ ((i & 2) >> 1)) ? 1.0f : 0.0f;
337 rot_points[i].p3_uvl.v = (i & 2) ? 1.0f : 0.0f;
338
339 pntlist[i] = &rot_points[i];
340 }
341
342 // And draw!!
343 rend_SetTextureType(TT_LINEAR);
344
345 if (color != -1) {
346 rend_SetLighting(LS_FLAT_GOURAUD);
347 rend_SetFlatColor(color);
348 }
349
350 g3_DrawPoly(4, pntlist, bm);
351}
352
353// Draws a bitmap on a specific plane. Also does rotation. Angle of rotation is passed as 'rot_angle'
354void g3_DrawPlanarRotatedBitmap(vector *pos, vector *norm, angle rot_angle, float width, float height, int bm) {

Callers 8

DrawPlayerDamageDiskFunction · 0.85
DrawLightningFunction · 0.85
DrawFireballObjectFunction · 0.85
DrawBlastRingObjectFunction · 0.85
DrawBlobbyWeaponRingFunction · 0.85
DrawWeaponObjectFunction · 0.85
DrawVisRainDropFunction · 0.85
DrawVisEffectFunction · 0.85

Calls 8

g3_GetUnscaledMatrixFunction · 0.85
g3_RotatePointFunction · 0.85
g3_DrawPolyFunction · 0.85
rend_SetTextureTypeFunction · 0.70
rend_SetLightingFunction · 0.70
rend_SetFlatColorFunction · 0.70
vm_AnglesToMatrixFunction · 0.50
vm_MatrixMulVectorFunction · 0.50

Tested by

no test coverage detected