NAP
cameracomponent.h
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2  * License, v. 2.0. If a copy of the MPL was not distributed with this
3  * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4 
5 #pragma once
6 
7 // External Includes
8 #include <glm/glm.hpp>
9 #include <component.h>
10 #include <utility/dllexport.h>
11 #include <renderwindow.h>
12 #include <rect.h>
13 
14 namespace nap
15 {
16  // Forward declares
17  class CameraComponentInstance;
18 
19 
23  class NAPAPI CameraComponent : public Component
24  {
25  RTTI_ENABLE(Component)
26  DECLARE_COMPONENT(CameraComponent, CameraComponentInstance)
27  public:
31  virtual void getDependentComponents(std::vector<rtti::TypeInfo>& components) const override;
32  };
33 
34 
39  {
40  RTTI_ENABLE(ComponentInstance)
41  public:
42  // Default constructor
44 
49  virtual const glm::mat4& getProjectionMatrix() const = 0;
50 
55  virtual const glm::mat4 getViewMatrix() const = 0;
56 
63  virtual void setRenderTargetSize(const glm::ivec2& size) { mRenderTargetSize = size; }
64 
74  glm::vec3 screenToWorld(const glm::vec3& screenPos, const math::Rect& viewport);
75 
82  glm::vec3 worldToScreen(const glm::vec3& worldPos, const math::Rect& viewport);
83 
91  glm::vec3 rayFromScreen(const glm::vec2& screenPos, const math::Rect& viewport);
92 
96  const glm::ivec2& getRenderTargetSize() const { return mRenderTargetSize; }
97 
101  virtual float getNearClippingPlane() const = 0;
102 
106  virtual float getFarClippingPlane() const = 0;
107 
114  virtual const glm::mat4& getRenderProjectionMatrix() const = 0;
115 
116  private:
117  glm::ivec2 mRenderTargetSize = { 1, 1 }; // The size of the render target we're rendering to
118  };
119 }
nap::CameraComponentInstance
Definition: cameracomponent.h:38
nap::CameraComponentInstance::setRenderTargetSize
virtual void setRenderTargetSize(const glm::ivec2 &size)
Definition: cameracomponent.h:63
nap::math::Rect
Definition: rect.h:19
nap::CameraComponent
Definition: cameracomponent.h:23
nap::EntityInstance
Definition: entity.h:34
nap::ComponentInstance
Definition: component.h:43
nap::Component
Definition: component.h:151
nap
Definition: templateapp.h:17
nap::CameraComponentInstance::getRenderTargetSize
const glm::ivec2 & getRenderTargetSize() const
Definition: cameracomponent.h:96