2018-10-07 03:42:33 +00:00
|
|
|
#pragma once
|
2016-03-10 03:47:37 +00:00
|
|
|
|
2019-09-22 21:52:05 +00:00
|
|
|
#include <memory>
|
|
|
|
#include "Runtime/GuiSys/CGuiWidget.hpp"
|
2016-03-10 03:47:37 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
namespace urde {
|
2017-01-22 01:40:12 +00:00
|
|
|
class CSimplePool;
|
2016-03-10 03:47:37 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
class CGuiCamera : public CGuiWidget {
|
2016-03-12 04:58:56 +00:00
|
|
|
public:
|
2018-12-08 05:30:43 +00:00
|
|
|
enum class EProjection { Perspective, Orthographic };
|
|
|
|
struct SProjection {
|
|
|
|
union {
|
|
|
|
struct {
|
|
|
|
float xbc_left;
|
|
|
|
float xc0_right;
|
|
|
|
float xc4_top;
|
|
|
|
float xc8_bottom;
|
|
|
|
float xcc_znear;
|
|
|
|
float xd0_zfar;
|
|
|
|
};
|
|
|
|
struct {
|
|
|
|
float xbc_fov;
|
|
|
|
float xc0_aspect;
|
|
|
|
float xc4_znear;
|
|
|
|
float xc8_zfar;
|
|
|
|
};
|
2016-03-16 03:37:51 +00:00
|
|
|
};
|
2018-12-08 05:30:43 +00:00
|
|
|
SProjection(float left, float right, float top, float bottom, float znear, float zfar)
|
|
|
|
: xbc_left(left), xc0_right(right), xc4_top(top), xc8_bottom(bottom), xcc_znear(znear), xd0_zfar(zfar) {}
|
|
|
|
SProjection(float fov, float aspect, float znear, float zfar)
|
|
|
|
: xbc_fov(fov), xc0_aspect(aspect), xc4_znear(znear), xc8_zfar(zfar) {}
|
|
|
|
};
|
|
|
|
|
2017-05-21 16:01:04 +00:00
|
|
|
private:
|
2018-12-08 05:30:43 +00:00
|
|
|
EProjection xb8_projtype;
|
|
|
|
SProjection m_proj;
|
|
|
|
|
2016-03-12 04:58:56 +00:00
|
|
|
public:
|
2018-12-08 05:30:43 +00:00
|
|
|
CGuiCamera(const CGuiWidgetParms& parms, float left, float right, float top, float bottom, float znear, float zfar);
|
|
|
|
CGuiCamera(const CGuiWidgetParms& parms, float fov, float aspect, float znear, float zfar);
|
2019-08-09 12:45:18 +00:00
|
|
|
FourCC GetWidgetTypeID() const override { return FOURCC('CAMR'); }
|
2017-01-29 03:58:16 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
static std::shared_ptr<CGuiWidget> Create(CGuiFrame* frame, CInputStream& in, CSimplePool* sp);
|
2016-03-16 03:37:51 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
zeus::CVector3f ConvertToScreenSpace(const zeus::CVector3f& vec) const;
|
|
|
|
const SProjection& GetProjection() const { return m_proj; }
|
|
|
|
void SetFov(float fov) { m_proj.xbc_fov = fov; }
|
2019-08-09 12:45:18 +00:00
|
|
|
void Draw(const CGuiWidgetDrawParms& parms) const override;
|
2017-01-22 01:40:12 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
std::shared_ptr<CGuiCamera> shared_from_this() {
|
|
|
|
return std::static_pointer_cast<CGuiCamera>(CGuiObject::shared_from_this());
|
|
|
|
}
|
2016-03-12 04:58:56 +00:00
|
|
|
};
|
2016-03-10 03:47:37 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
} // namespace urde
|