mirror of https://github.com/AxioDL/metaforce.git
GX implementation of CHudRadarInterface
This commit is contained in:
parent
2503872065
commit
a0d5c5c285
|
@ -61,12 +61,15 @@ const std::array<zeus::CMatrix3f, 6> CGraphics::skCubeBasisMats{{
|
||||||
static EStreamFlags sStreamFlags;
|
static EStreamFlags sStreamFlags;
|
||||||
static GX::Primitive sStreamPrimitive;
|
static GX::Primitive sStreamPrimitive;
|
||||||
static u32 sVerticesCount;
|
static u32 sVerticesCount;
|
||||||
|
static zeus::CColor sQueuedColor;
|
||||||
// Originally writes directly to GX FIFO
|
// Originally writes directly to GX FIFO
|
||||||
struct StreamVertex {
|
struct StreamVertex {
|
||||||
zeus::CColor color;
|
zeus::CColor color;
|
||||||
zeus::CVector2f texCoord;
|
zeus::CVector2f texCoord;
|
||||||
zeus::CVector3f normal;
|
zeus::CVector3f normal;
|
||||||
zeus::CVector3f vertex;
|
zeus::CVector3f vertex;
|
||||||
|
constexpr StreamVertex(const zeus::CColor& color) : color(color) {}
|
||||||
|
constexpr StreamVertex(const StreamVertex&) = default;
|
||||||
};
|
};
|
||||||
static std::vector<StreamVertex> sQueuedVertices;
|
static std::vector<StreamVertex> sQueuedVertices;
|
||||||
|
|
||||||
|
@ -530,7 +533,7 @@ void CGraphics::SetTevOp(ERglTevStage stage, const CTevCombiners::CTevPass& pass
|
||||||
void CGraphics::StreamBegin(GX::Primitive primitive) {
|
void CGraphics::StreamBegin(GX::Primitive primitive) {
|
||||||
// Originally ResetVertexDataStream(true);
|
// Originally ResetVertexDataStream(true);
|
||||||
sQueuedVertices.clear();
|
sQueuedVertices.clear();
|
||||||
sQueuedVertices.emplace_back();
|
sQueuedVertices.emplace_back(sQueuedColor);
|
||||||
sVerticesCount = 0;
|
sVerticesCount = 0;
|
||||||
// End
|
// End
|
||||||
sStreamFlags = EStreamFlagBits::fHasColor;
|
sStreamFlags = EStreamFlagBits::fHasColor;
|
||||||
|
@ -543,7 +546,11 @@ void CGraphics::StreamNormal(const zeus::CVector3f& nrm) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGraphics::StreamColor(const zeus::CColor& color) {
|
void CGraphics::StreamColor(const zeus::CColor& color) {
|
||||||
|
if (sStreamFlags) {
|
||||||
sQueuedVertices.back().color = color;
|
sQueuedVertices.back().color = color;
|
||||||
|
} else {
|
||||||
|
sQueuedColor = color;
|
||||||
|
}
|
||||||
sStreamFlags |= EStreamFlagBits::fHasColor;
|
sStreamFlags |= EStreamFlagBits::fHasColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,19 +26,19 @@ CHudRadarInterface::CHudRadarInterface(CGuiFrame& baseHud, CStateManager& stateM
|
||||||
x40_BaseWidget_RadarStuff->SetColor(g_tweakGuiColors->GetRadarStuffColor());
|
x40_BaseWidget_RadarStuff->SetColor(g_tweakGuiColors->GetRadarStuffColor());
|
||||||
}
|
}
|
||||||
|
|
||||||
void CHudRadarInterface::DoDrawRadarPaint(const zeus::CVector3f& translate, float radius, const zeus::CColor& color) {
|
void CHudRadarInterface::DoDrawRadarPaint(float radius) {
|
||||||
radius *= 4.f;
|
radius *= 4.f;
|
||||||
|
|
||||||
CRadarPaintShader::Instance& inst = m_paintInsts.emplace_back();
|
CGraphics::StreamBegin(GX::TRIANGLESTRIP);
|
||||||
inst.pos[0] = translate + zeus::CVector3f(-radius, 0.f, radius);
|
CGraphics::StreamTexcoord(0.f, 1.f);
|
||||||
inst.uv[0].assign(0.f, 1.f);
|
CGraphics::StreamVertex(-radius, 0.f, radius);
|
||||||
inst.pos[1] = translate + zeus::CVector3f(-radius, 0.f, -radius);
|
CGraphics::StreamTexcoord(0.f, 0.f);
|
||||||
inst.uv[1].assign(0.f, 0.f);
|
CGraphics::StreamVertex(-radius, 0.f, -radius);
|
||||||
inst.pos[2] = translate + zeus::CVector3f(radius, 0.f, radius);
|
CGraphics::StreamTexcoord(1.f, 1.f);
|
||||||
inst.uv[2].assign(1.f, 1.f);
|
CGraphics::StreamVertex(radius, 0.f, radius);
|
||||||
inst.pos[3] = translate + zeus::CVector3f(radius, 0.f, -radius);
|
CGraphics::StreamTexcoord(1.f, 0.f);
|
||||||
inst.uv[3].assign(1.f, 0.f);
|
CGraphics::StreamVertex(radius, 0.f, -radius);
|
||||||
inst.color = color;
|
CGraphics::StreamEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CHudRadarInterface::DrawRadarPaint(const zeus::CVector3f& enemyPos, float radius, float alpha,
|
void CHudRadarInterface::DrawRadarPaint(const zeus::CVector3f& enemyPos, float radius, float alpha,
|
||||||
|
@ -55,10 +55,15 @@ void CHudRadarInterface::DrawRadarPaint(const zeus::CVector3f& enemyPos, float r
|
||||||
}
|
}
|
||||||
|
|
||||||
const zeus::CVector2f scopeScaled = playerToEnemy * parms.x70_scopeScalar;
|
const zeus::CVector2f scopeScaled = playerToEnemy * parms.x70_scopeScalar;
|
||||||
|
g_Renderer->SetModelMatrix(
|
||||||
|
parms.x3c_postTranslate *
|
||||||
|
zeus::CTransform::Translate(parms.xc_preTranslate * zeus::CVector3f(scopeScaled.x(), 0.f, scopeScaled.y())));
|
||||||
|
|
||||||
zeus::CColor color = g_tweakGuiColors->GetRadarEnemyPaintColor();
|
zeus::CColor color = g_tweakGuiColors->GetRadarEnemyPaintColor();
|
||||||
color.a() *= alpha;
|
color.a() *= alpha;
|
||||||
color.a() *= parms.x74_alpha;
|
color.a() *= parms.x74_alpha;
|
||||||
DoDrawRadarPaint(parms.xc_preTranslate * zeus::CVector3f(scopeScaled.x(), 0.f, scopeScaled.y()), radius, color);
|
CGraphics::StreamColor(color);
|
||||||
|
DoDrawRadarPaint(radius);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CHudRadarInterface::SetIsVisibleGame(bool v) {
|
void CHudRadarInterface::SetIsVisibleGame(bool v) {
|
||||||
|
@ -115,13 +120,17 @@ void CHudRadarInterface::Draw(const CStateManager& mgr, float alpha) {
|
||||||
drawParms.x3c_postTranslate = x40_BaseWidget_RadarStuff->GetWorldTransform();
|
drawParms.x3c_postTranslate = x40_BaseWidget_RadarStuff->GetWorldTransform();
|
||||||
const float enemyRadius = g_tweakGui->GetRadarEnemyPaintRadius();
|
const float enemyRadius = g_tweakGui->GetRadarEnemyPaintRadius();
|
||||||
|
|
||||||
m_paintInsts.clear();
|
|
||||||
x44_camera->Draw(CGuiWidgetDrawParms{0.f, zeus::CVector3f{}});
|
x44_camera->Draw(CGuiWidgetDrawParms{0.f, zeus::CVector3f{}});
|
||||||
CGraphics::SetModelMatrix(drawParms.x3c_postTranslate);
|
|
||||||
|
|
||||||
|
g_Renderer->SetModelMatrix(drawParms.x3c_postTranslate);
|
||||||
|
g_Renderer->SetBlendMode_AdditiveAlpha();
|
||||||
|
x0_txtrRadarPaint->Load(GX::TEXMAP0, EClampMode::Repeat);
|
||||||
|
CGraphics::SetTevOp(ERglTevStage::Stage0, CTevCombiners::sTevPass805a5ebc);
|
||||||
|
g_Renderer->SetDepthReadWrite(false, false);
|
||||||
zeus::CColor playerColor = g_tweakGuiColors->GetRadarPlayerPaintColor();
|
zeus::CColor playerColor = g_tweakGuiColors->GetRadarPlayerPaintColor();
|
||||||
playerColor.a() *= alpha;
|
playerColor.a() *= alpha;
|
||||||
DoDrawRadarPaint(zeus::skZero3f, g_tweakGui->GetRadarPlayerPaintRadius(), playerColor);
|
CGraphics::StreamColor(playerColor);
|
||||||
|
DoDrawRadarPaint(g_tweakGui->GetRadarPlayerPaintRadius());
|
||||||
|
|
||||||
const zeus::CAABox radarBounds(
|
const zeus::CAABox radarBounds(
|
||||||
player.GetTranslation().x() - drawParms.x78_xyRadius, player.GetTranslation().y() - drawParms.x78_xyRadius,
|
player.GetTranslation().x() - drawParms.x78_xyRadius, player.GetTranslation().y() - drawParms.x78_xyRadius,
|
||||||
|
@ -156,7 +165,7 @@ void CHudRadarInterface::Draw(const CStateManager& mgr, float alpha) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_paintShader.draw(m_paintInsts, x0_txtrRadarPaint.GetObj());
|
g_Renderer->SetDepthReadWrite(true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace metaforce
|
} // namespace metaforce
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
|
|
||||||
#include "Runtime/CToken.hpp"
|
#include "Runtime/CToken.hpp"
|
||||||
#include "Runtime/Graphics/CTexture.hpp"
|
#include "Runtime/Graphics/CTexture.hpp"
|
||||||
#include "Runtime/Graphics/Shaders/CRadarPaintShader.hpp"
|
|
||||||
|
|
||||||
#include <zeus/CTransform.hpp>
|
#include <zeus/CTransform.hpp>
|
||||||
#include <zeus/CVector3f.hpp>
|
#include <zeus/CVector3f.hpp>
|
||||||
|
@ -33,9 +32,8 @@ class CHudRadarInterface {
|
||||||
bool x3c_25_visibleDebug : 1 = true;
|
bool x3c_25_visibleDebug : 1 = true;
|
||||||
CGuiWidget* x40_BaseWidget_RadarStuff;
|
CGuiWidget* x40_BaseWidget_RadarStuff;
|
||||||
CGuiCamera* x44_camera;
|
CGuiCamera* x44_camera;
|
||||||
CRadarPaintShader m_paintShader;
|
|
||||||
std::vector<CRadarPaintShader::Instance> m_paintInsts;
|
void DoDrawRadarPaint(float radius);
|
||||||
void DoDrawRadarPaint(const zeus::CVector3f& translate, float radius, const zeus::CColor& color);
|
|
||||||
void DrawRadarPaint(const zeus::CVector3f& enemyPos, float radius, float alpha, const SRadarPaintDrawParms& parms);
|
void DrawRadarPaint(const zeus::CVector3f& enemyPos, float radius, float alpha, const SRadarPaintDrawParms& parms);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
Loading…
Reference in New Issue