From 15740faf9fe9fe4be08965098bbf2947e096aeeb Mon Sep 17 00:00:00 2001 From: chai Date: Wed, 14 Aug 2019 22:50:43 +0800 Subject: +Unity Runtime code --- Runtime/Camera/Projector.h | 74 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 Runtime/Camera/Projector.h (limited to 'Runtime/Camera/Projector.h') diff --git a/Runtime/Camera/Projector.h b/Runtime/Camera/Projector.h new file mode 100644 index 0000000..f805e1e --- /dev/null +++ b/Runtime/Camera/Projector.h @@ -0,0 +1,74 @@ +#ifndef PROJECTOR_H +#define PROJECTOR_H + +#include "Runtime/GameCode/Behaviour.h" +#include "Renderable.h" +#include "Runtime/Math/Matrix4x4.h" + +namespace Unity { class Material; } +struct CullResults; +struct ProjectorRenderSettings; + +class Projector : public Behaviour, Renderable { +public: + Projector (); + + REGISTER_DERIVED_CLASS (Projector, Behaviour) + DECLARE_OBJECT_SERIALIZE (Projector) + + Projector (MemLabelId label, ObjectCreationMode mode); + + // Renderable + virtual void RenderRenderable (const CullResults& cullResults); + + virtual void AddToManager (); + virtual void RemoveFromManager (); + + virtual void Reset(); + virtual void CheckConsistency (); + + void SetNearClipPlane (float inNear) { m_NearClipPlane = inNear; SetDirty(); } + float GetNearClipPlane () const { return m_NearClipPlane; } + + void SetFarClipPlane (float farPlane) { m_FarClipPlane = farPlane; SetDirty(); } + float GetFarClipPlane () const { return m_FarClipPlane; } + + void SetFieldOfView (float angle) { m_FieldOfView = angle; SetDirty(); } + float GetFieldOfView () const { return m_FieldOfView; } + + void SetAspectRatio (float aspect) { m_AspectRatio = aspect; SetDirty(); } + float GetAspectRatio () const { return m_AspectRatio; } + + void SetOrthographic (bool isOrtho) { m_Orthographic = isOrtho; SetDirty(); } + bool GetOrthographic () const { return m_Orthographic; } + + void SetOrthographicSize (float size) { m_OrthographicSize = size; SetDirty(); } + float GetOrthographicSize () const { return m_OrthographicSize; } + + PPtr GetMaterial () const { return m_Material; } + void SetMaterial (PPtr material) { m_Material = material; } + + int GetIgnoreLayers () { return m_IgnoreLayers.m_Bits; } + void SetIgnoreLayers(int layers) { m_IgnoreLayers.m_Bits = layers; SetDirty(); } + + Matrix4x4f GetProjectorToPerspectiveMatrix() const; + static void InitializeClass(); + static void CleanupClass() { } + +private: + + void SetupProjectorSettings (Material* material, ProjectorRenderSettings& settings); + Matrix4x4f CalculateProjectionMatrix() const; + + float m_NearClipPlane; + float m_FarClipPlane; + float m_FieldOfView; + float m_AspectRatio; + bool m_Orthographic; + float m_OrthographicSize; + + BitField m_IgnoreLayers; + PPtr m_Material; ///< Custom material to apply. If set it overrides, texture & blend mode settings +}; + +#endif -- cgit v1.1-26-g67d0