MCPcopy Create free account
hub / github.com/BohemiaInteractive/CWR / DrawTankDirection

Method DrawTankDirection

engine/Poseidon/UI/InGame/InGameUIDraw.cpp:628–752  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

626}
627
628void InGameUI::DrawTankDirection(const Camera& camera)
629{
630 if (_tankPos >= 1)
631 {
632 return;
633 }
634 AIUnit* unit = GWorld->FocusOn();
635 PoseidonAssert(unit);
636 EntityAI* veh = unit->GetVehicle();
637
638 float tankLeft = tankX;
639
640 const int w = GLOB_ENGINE->Width2D();
641 const int h = GLOB_ENGINE->Height2D();
642
643 Matrix4Val camInvTransform = camera.GetInvTransform();
644 Vector3 dirHull(VRotate, camInvTransform, veh->Direction());
645 Vector3 dirTurret(VRotate, camInvTransform, veh->GetWeaponDirection(0));
646 Vector3 dirObsTurret(VRotate, camInvTransform, veh->GetEyeDirection());
647
648 Matrix4 mrot(MZero);
649 Matrix4 mtrans1 = Matrix4(MTranslation, Vector3(-0.5, 0, -0.5));
650 Matrix4 mtrans2 = Matrix4(MTranslation, Vector3(0.5, 0, 0.5));
651
652 Draw2DPars pars;
653 pars.spec = NoZBuf | IsAlpha | IsAlphaFog | ClampU | ClampV;
654
655 // Rect2D rect(tankLeft * w, tankY * h, tankW * w, tankH * h);
656
657 const float size = 0.67;
658
659 Rect2DPixel rect(w * (tankLeft + tankW * 0.5 - tankW * size * 0.5), h * (tankY + tankH * 0.5 - tankH * size * 0.5),
660 tankW * w * size, tankH * h * size);
661
662#define v000 VZero
663#define v001 VForward
664#define v100 VAside
665#define v101 Vector3(1, 0, 1)
666
667 mrot.SetUpAndDirection(VUp, dirHull);
668 Matrix4 m = mtrans2 * mrot * mtrans1;
669 Vector3 uv = m.FastTransform(v000);
670 pars.uTR = uv[2];
671 pars.vTR = uv[0];
672 uv = m.FastTransform(v001);
673 pars.uTL = uv[2];
674 pars.vTL = uv[0];
675 uv = m.FastTransform(v100);
676 pars.uBR = uv[2];
677 pars.vBR = uv[0];
678 uv = m.FastTransform(v101);
679 pars.uBL = uv[2];
680 pars.vBL = uv[0];
681
682 // draw all hull components
683 pars.SetColor(ColorFromHit(veh->GetHitForDisplay(0)));
684 pars.mip = GEngine->TextBank()->UseMipmap(_imageHull, 0, 0);
685 GEngine->Draw2D(pars, rect, rect);

Callers

nothing calls this directly

Calls 15

FocusOnMethod · 0.80
Vector3Class · 0.50
GetVehicleMethod · 0.45
Width2DMethod · 0.45
Height2DMethod · 0.45
GetInvTransformMethod · 0.45
DirectionMethod · 0.45
GetWeaponDirectionMethod · 0.45
GetEyeDirectionMethod · 0.45
SetUpAndDirectionMethod · 0.45
FastTransformMethod · 0.45
SetColorMethod · 0.45

Tested by

no test coverage detected