MCPcopy Create free account
hub / github.com/bfbbdecomp/bfbb / xModelRender2D

Function xModelRender2D

src/SB/Core/x/xModel.cpp:438–488  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

436}
437
438void 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
490static RwCamera* CameraCreate(S32 a, S32 b, S32 c)
491{

Callers 6

render_tag_modelFunction · 0.70
render_one_modelFunction · 0.70
render_modelFunction · 0.50
RenderMethod · 0.50
render_model_2dFunction · 0.50
zUI_RenderFunction · 0.50

Calls 5

xMat3x3LookAtFunction · 0.85
xVec3DistFunction · 0.85
xMat4x3MulFunction · 0.85
xMat3x3TransposeFunction · 0.70
iModelRenderFunction · 0.50

Tested by

no test coverage detected