| 436 | } |
| 437 | |
| 438 | void xModelRender2D(const xModelInstance& model, const basic_rect<F32>& r, const xVec3& from, |
| 439 | const xVec3& to) |
| 440 | { |
| 441 | if (r.w <= 0.0f || r.h <= 0.0f || r.x + r.w < 0.0f || r.x > 1.0f || r.y + r.h < 0.0f || |
| 442 | r.y > 1.0f) |
| 443 | { |
| 444 | return; |
| 445 | } |
| 446 | |
| 447 | RwCamera* camera = RwCameraGetCurrentCamera(); |
| 448 | RwFrame* frame = RwCameraGetFrame(camera); |
| 449 | RwMatrix* cammat = RwFrameGetLTM(frame); |
| 450 | |
| 451 | xMat4x3 objmat, shearmat, temp1, temp2; |
| 452 | xMat3x3LookAt(&objmat, &to, &from); |
| 453 | xMat3x3Transpose(&objmat, &objmat); |
| 454 | objmat.pos.x = 0.0f; |
| 455 | objmat.pos.y = 0.0f; |
| 456 | objmat.pos.z = xVec3Dist(&to, &from); |
| 457 | objmat.flags = 0; |
| 458 | |
| 459 | const RwV2d* camvw = RwCameraGetViewWindow(camera); |
| 460 | F32 viewscale = camvw->x * r.w * 2.0f; |
| 461 | F32 shearX = camvw->x * -(r.x * 2.0f + r.w - 1.0f); |
| 462 | F32 shearY = camvw->y * -(r.y * 2.0f + r.h - 1.0f); |
| 463 | |
| 464 | shearmat.right.x = viewscale; |
| 465 | shearmat.right.y = 0.0f; |
| 466 | shearmat.right.z = 0.0f; |
| 467 | shearmat.up.x = 0.0f; |
| 468 | shearmat.up.y = viewscale; |
| 469 | shearmat.up.z = 0.0f; |
| 470 | shearmat.at.x = shearX; |
| 471 | shearmat.at.y = shearY; |
| 472 | shearmat.at.z = 1.0f; |
| 473 | shearmat.pos.x = 0.0f; |
| 474 | shearmat.pos.y = 0.0f; |
| 475 | shearmat.pos.z = 0.0f; |
| 476 | shearmat.flags = 0; |
| 477 | |
| 478 | xMat4x3Mul(&temp1, &objmat, &shearmat); |
| 479 | xMat4x3Mul(&temp2, &temp1, (xMat4x3*)cammat); |
| 480 | xMat4x3Mul(&objmat, (xMat4x3*)model.Mat, &temp2); |
| 481 | |
| 482 | temp1 = *(xMat4x3*)model.Mat; |
| 483 | *model.Mat = *(RwMatrix*)&objmat; |
| 484 | |
| 485 | iModelRender(model.Data, model.Mat); |
| 486 | |
| 487 | *model.Mat = *(RwMatrix*)&temp1; |
| 488 | } |
| 489 | |
| 490 | static RwCamera* CameraCreate(S32 a, S32 b, S32 c) |
| 491 | { |
no test coverage detected