Draws a bitmap on a specific plane. Also does rotation. Angle of rotation is passed as 'rot_angle'
| 352 | |
| 353 | // Draws a bitmap on a specific plane. Also does rotation. Angle of rotation is passed as 'rot_angle' |
| 354 | void 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 |
no test coverage detected