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

Function g3_DrawPlanarRotatedBitmap

renderer/HardwareDraw.cpp:354–410  ·  view source on GitHub ↗

Draws a bitmap on a specific plane. Also does rotation. Angle of rotation is passed as 'rot_angle'

Source from the content-addressed store, hash-verified

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) {
355 matrix rot_matrix;
356 vm_VectorToMatrix(&rot_matrix, norm, NULL, NULL);
357 vm_TransposeMatrix(&rot_matrix);
358
359 matrix twist_matrix;
360 vm_AnglesToMatrix(&twist_matrix, 0, 0, rot_angle);
361
362 float w = width;
363 float h = height;
364
365 vector rot_vectors[4];
366 rot_vectors[0] = (twist_matrix.rvec * -w);
367 rot_vectors[0] += (twist_matrix.uvec * h);
368
369 rot_vectors[1] = (twist_matrix.rvec * w);
370 rot_vectors[1] += (twist_matrix.uvec * h);
371
372 rot_vectors[2] = (twist_matrix.rvec * w);
373 rot_vectors[2] -= (twist_matrix.uvec * h);
374
375 rot_vectors[3] = (twist_matrix.rvec * -w);
376 rot_vectors[3] -= (twist_matrix.uvec * h);
377
378 int i;
379 for (i = 0; i < 4; ++i) {
380 vector temp_vec = rot_vectors[i];
381 vm_MatrixMulVector(&rot_vectors[i], &temp_vec, &rot_matrix);
382 }
383
384 g3Point rot_points[8], *pntlist[8];
385 for (i = 0; i < 4; ++i) {
386 rot_vectors[i] += *pos;
387
388 g3_RotatePoint(&rot_points[i], &rot_vectors[i]);
389 rot_points[i].p3_flags |= PF_UV | PF_L;
390 rot_points[i].p3_l = 1.0f;
391
392 pntlist[i] = &rot_points[i];
393 }
394
395 rot_points[0].p3_u = 0.0f;
396 rot_points[0].p3_v = 0.0f;
397
398 rot_points[1].p3_u = 1.0f;
399 rot_points[1].p3_v = 0.0f;
400
401 rot_points[2].p3_u = 1.0f;
402 rot_points[2].p3_v = 1.0f;
403
404 rot_points[3].p3_u = 0.0f;
405 rot_points[3].p3_v = 1.0f;
406
407 // And draw!!
408 rend_SetTextureType(TT_LINEAR);
409 g3_DrawPoly(4, pntlist, bm);
410}
411

Callers 6

DrawPlayerInvulSphereFunction · 0.85
DrawSkyFunction · 0.85
DrawWeaponObjectFunction · 0.85
DrawVisRainDropFunction · 0.85
DrawVisMassDriverEffectFunction · 0.85
DrawVisEffectFunction · 0.85

Calls 7

g3_RotatePointFunction · 0.85
g3_DrawPolyFunction · 0.85
rend_SetTextureTypeFunction · 0.70
vm_VectorToMatrixFunction · 0.50
vm_TransposeMatrixFunction · 0.50
vm_AnglesToMatrixFunction · 0.50
vm_MatrixMulVectorFunction · 0.50

Tested by

no test coverage detected