2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-12-09 03:47:43 +00:00

Some initial widget imps

This commit is contained in:
Jack Andersen
2016-03-15 17:37:51 -10:00
parent b3859c4476
commit fcee32f666
13 changed files with 300 additions and 18 deletions

View File

@@ -1,6 +1,7 @@
#include "CGuiCamera.hpp"
#include "CGuiFrame.hpp"
#include "CGuiAnimController.hpp"
#include "Graphics/CGraphics.hpp"
namespace urde
{
@@ -9,15 +10,39 @@ CGuiCamera::CGuiCamera(const CGuiWidgetParms& parms,
float left, float right,
float top, float bottom,
float znear, float zfar)
: CGuiWidget(parms)
{
}
: CGuiWidget(parms),
xfc_left(left), x100_right(right),
x104_top(top), x108_bottom(bottom),
x10c_znear(znear), x110_zfar(zfar)
{}
CGuiCamera::CGuiCamera(const CGuiWidgetParms& parms,
float fov, float aspect,
float znear, float zfar)
: CGuiWidget(parms)
: CGuiWidget(parms),
xfc_fov(fov), x100_aspect(aspect),
x104_znear(znear), x108_zfar(zfar)
{}
zeus::CVector3f CGuiCamera::ConvertToScreenSpace(const zeus::CVector3f& vec) const
{
zeus::CVector3f local = RotateTranslateW2O(vec);
if (local.isZero())
return {-1.f, -1.f, 1.f};
zeus::CMatrix4f mat = CGraphics::CalculatePerspectiveMatrix(xfc_fov, x100_aspect,
x104_znear, x108_zfar);
return mat.multiplyOneOverW(local);
}
void CGuiCamera::Draw(const CGuiWidgetDrawParms& parms) const
{
if (xf8_proj == Projection::Perspective)
CGraphics::SetPerspective(xfc_fov, x100_aspect, x104_znear, x108_zfar);
else
CGraphics::SetOrtho(xfc_left, x100_right, x104_top, x108_bottom, x10c_znear, x110_zfar);
CGraphics::SetViewPointMatrix(x34_worldXF);
CGuiWidget::Draw(parms);
}
CGuiCamera* CGuiCamera::Create(CGuiFrame* frame, CInputStream& in, bool flag)