BsCamera.h 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. #pragma once
  4. #include "BsCorePrerequisites.h"
  5. #include "BsIReflectable.h"
  6. #include "BsMatrix4.h"
  7. #include "BsVector3.h"
  8. #include "BsVector2.h"
  9. #include "BsVector2I.h"
  10. #include "BsAABox.h"
  11. #include "BsQuaternion.h"
  12. #include "BsRay.h"
  13. #include "BsCoreObject.h"
  14. #include "BsConvexVolume.h"
  15. #include "BsPostProcessSettings.h"
  16. namespace bs
  17. {
  18. /** @addtogroup Renderer-Internal
  19. * @{
  20. */
  21. /** Signals which portion of a Camera is dirty. */
  22. enum class CameraDirtyFlag
  23. {
  24. Transform = 1<<0,
  25. Everything = 1<<1,
  26. PostProcess = 1<<2
  27. };
  28. /** Flags that describe a camera. */
  29. enum class CameraFlag
  30. {
  31. /**
  32. * This flag is a signal to the renderer that his camera will only render overlays and doesn't require depth
  33. * buffer or multi-sampled render targets. Such cameras will not render any scene objects. This can improve
  34. * performance and memory usage.
  35. */
  36. Overlay = 1 << 0,
  37. /**
  38. * High dynamic range allows light intensity to be more correctly recorded when rendering by allowing for a larger
  39. * range of values. The stored light is then converted into visible color range using exposure and a tone mapping
  40. * operator.
  41. */
  42. HDR = 1 << 1,
  43. /**
  44. * Specify that no lighting should be applied to scene objects and everything should be rendered using their
  45. * albedo texture.
  46. */
  47. NoLighting = 1 << 2
  48. };
  49. typedef Flags<CameraFlag> CameraFlags;
  50. BS_FLAGS_OPERATORS(CameraFlag);
  51. /** @} */
  52. /** @addtogroup Implementation
  53. * @{
  54. */
  55. /**
  56. * Camera determines how is world geometry projected onto a 2D surface. You may position and orient it in space, set
  57. * options like aspect ratio and field or view and it outputs view and projection matrices required for rendering.
  58. *
  59. * This class contains funcionality common to both core and non-core versions of the camera.
  60. */
  61. class BS_CORE_EXPORT CameraBase
  62. {
  63. public:
  64. virtual ~CameraBase() { }
  65. /**
  66. * Sets the camera horizontal field of view. This determines how wide the camera viewing angle is along the
  67. * horizontal axis. Vertical FOV is calculated from the horizontal FOV and the aspect ratio.
  68. */
  69. virtual void setHorzFOV(const Radian& fovy);
  70. /** Retrieves the camera horizontal field of view. */
  71. virtual const Radian& getHorzFOV() const;
  72. /**
  73. * Sets the distance from the frustum to the near clipping plane. Anything closer than the near clipping plane will
  74. * not be rendered. Decreasing this value decreases depth buffer precision.
  75. */
  76. virtual void setNearClipDistance(float nearDist);
  77. /**
  78. * Retrieves the distance from the frustum to the near clipping plane. Anything closer than the near clipping plane
  79. * will not be rendered. Decreasing this value decreases depth buffer precision.
  80. */
  81. virtual float getNearClipDistance() const;
  82. /**
  83. * Sets the distance from the frustum to the far clipping plane. Anything farther than the far clipping plane will
  84. * not be rendered. Increasing this value decreases depth buffer precision.
  85. */
  86. virtual void setFarClipDistance(float farDist);
  87. /**
  88. * Retrieves the distance from the frustum to the far clipping plane. Anything farther than the far clipping plane
  89. * will not be rendered. Increasing this value decreases depth buffer precision.
  90. */
  91. virtual float getFarClipDistance() const;
  92. /** Sets the current viewport aspect ratio (width / height). */
  93. virtual void setAspectRatio(float ratio);
  94. /** Returns current viewport aspect ratio (width / height). */
  95. virtual float getAspectRatio() const;
  96. /** Sets camera world space position. */
  97. virtual void setPosition(const Vector3& position);
  98. /** Retrieves camera world space position. */
  99. virtual Vector3 getPosition() const { return mPosition; }
  100. /** Sets should the camera be rendered to or not. */
  101. void setIsActive(bool active) { mIsActive = active; _markCoreDirty(); }
  102. /** Gets whether the camera be rendered to or not. */
  103. bool getIsActive() const { return mIsActive; }
  104. /**
  105. * Gets the Z (forward) axis of the object, in world space.
  106. *
  107. * @return Forward axis of the object.
  108. */
  109. Vector3 getForward() const { return getRotation().rotate(-Vector3::UNIT_Z); }
  110. /** Sets camera world space rotation. */
  111. virtual void setRotation(const Quaternion& rotation);
  112. /** Retrieves camera world space rotation. */
  113. virtual Quaternion getRotation() const { return mRotation; }
  114. /** Manually set the extents of the frustum that will be used when calculating the projection matrix. This will
  115. * prevents extents for being automatically calculated from aspect and near plane so it is up to the caller to keep
  116. * these values accurate.
  117. *
  118. * @param[in] left The position where the left clip plane intersect the near clip plane, in view space.
  119. * @param[in] right The position where the right clip plane intersect the near clip plane, in view space.
  120. * @param[in] top The position where the top clip plane intersect the near clip plane, in view space.
  121. * @param[in] bottom The position where the bottom clip plane intersect the near clip plane, in view space.
  122. */
  123. virtual void setFrustumExtents(float left, float right, float top, float bottom);
  124. /**
  125. * Resets frustum extents so they are automatically derived from other values. This is only relevant if you have
  126. * previously set custom extents.
  127. */
  128. virtual void resetFrustumExtents();
  129. /** Returns the extents of the frustum in view space at the near plane. */
  130. virtual void getFrustumExtents(float& outleft, float& outright, float& outtop, float& outbottom) const;
  131. /**
  132. * Returns the standard projection matrix that determines how are 3D points projected to two dimensions. The layout
  133. * of this matrix depends on currently used render system.
  134. *
  135. * @note
  136. * You should use this matrix when sending the matrix to the render system to make sure everything works
  137. * consistently when other render systems are used.
  138. */
  139. virtual const Matrix4& getProjectionMatrixRS() const;
  140. /**
  141. * Returns the inverse of the render-system specific projection matrix.
  142. *
  143. * @see getProjectionMatrixRS
  144. */
  145. virtual const Matrix4& getProjectionMatrixRSInv() const;
  146. /**
  147. * Returns the standard projection matrix that determines how are 3D points projected to two dimensions. Returned
  148. * matrix is standard following right-hand rules and depth range of [-1, 1].
  149. *
  150. * @note
  151. * Different render systems will expect different projection matrix layouts, in which case use
  152. * getProjectionMatrixRS().
  153. */
  154. virtual const Matrix4& getProjectionMatrix() const;
  155. /**
  156. * Returns the inverse of the projection matrix.
  157. *
  158. * @see getProjectionMatrix
  159. */
  160. virtual const Matrix4& getProjectionMatrixInv() const;
  161. /** Gets the camera view matrix. Used for positioning/orienting the camera. */
  162. virtual const Matrix4& getViewMatrix() const;
  163. /**
  164. * Returns the inverse of the view matrix.
  165. *
  166. * @see getViewMatrix
  167. */
  168. virtual const Matrix4& getViewMatrixInv() const;
  169. /**
  170. * Sets whether the camera should use the custom view matrix. When this is enabled camera will no longer calculate
  171. * its view matrix based on position/orientation and caller will be resonsible to keep the view matrix up to date.
  172. */
  173. virtual void setCustomViewMatrix(bool enable, const Matrix4& viewMatrix = Matrix4::IDENTITY);
  174. /** Returns true if a custom view matrix is used. */
  175. virtual bool isCustomViewMatrixEnabled() const { return mCustomViewMatrix; }
  176. /**
  177. * Sets whether the camera should use the custom projection matrix. When this is enabled camera will no longer
  178. * calculate its projection matrix based on field of view, aspect and other parameters and caller will be resonsible
  179. * to keep the projection matrix up to date.
  180. */
  181. virtual void setCustomProjectionMatrix(bool enable, const Matrix4& projectionMatrix = Matrix4::IDENTITY);
  182. /** Returns true if a custom projection matrix is used. */
  183. virtual bool isCustomProjectionMatrixEnabled() const { return mCustomProjMatrix; }
  184. /** Returns a convex volume representing the visible area of the camera, in local space. */
  185. virtual const ConvexVolume& getFrustum() const;
  186. /** Returns a convex volume representing the visible area of the camera, in world space. */
  187. virtual ConvexVolume getWorldFrustum() const;
  188. /** Returns the bounding of the frustum. */
  189. const AABox& getBoundingBox() const;
  190. /**
  191. * Sets the type of projection used by the camera. Projection type controls how is 3D geometry projected onto a
  192. * 2D plane.
  193. */
  194. virtual void setProjectionType(ProjectionType pt);
  195. /**
  196. * Returns the type of projection used by the camera. Projection type controls how is 3D geometry projected onto a
  197. * 2D plane.
  198. */
  199. virtual ProjectionType getProjectionType() const;
  200. /**
  201. * Sets the orthographic window height, for use with orthographic rendering only.
  202. *
  203. * @param[in] w Width of the window in world units.
  204. * @param[in] h Height of the window in world units.
  205. *
  206. * @note
  207. * Calling this method will recalculate the aspect ratio, use setOrthoWindowHeight() or setOrthoWindowWidth() alone
  208. * if you wish to preserve the aspect ratio but just fit one or other dimension to a particular size.
  209. */
  210. virtual void setOrthoWindow(float w, float h);
  211. /**
  212. * Sets the orthographic window height, for use with orthographic rendering only.
  213. *
  214. * @param[in] h Height of the window in world units.
  215. *
  216. * @note The width of the window will be calculated from the aspect ratio.
  217. */
  218. virtual void setOrthoWindowHeight(float h);
  219. /**
  220. * Sets the orthographic window width, for use with orthographic rendering only.
  221. *
  222. * @param[in] w Width of the window in world units.
  223. *
  224. * @note The height of the window will be calculated from the aspect ratio.
  225. */
  226. virtual void setOrthoWindowWidth(float w);
  227. /** Gets the orthographic window width in world units, for use with orthographic rendering only. */
  228. virtual float getOrthoWindowHeight() const;
  229. /**
  230. * Gets the orthographic window width in world units, for use with orthographic rendering only.
  231. *
  232. * @note This is calculated from the orthographic height and the aspect ratio.
  233. */
  234. virtual float getOrthoWindowWidth() const;
  235. /**
  236. * Gets a priority that determines in which orders the cameras are rendered. This only applies to cameras rendering
  237. * to the same render target.
  238. */
  239. INT32 getPriority() const { return mPriority; }
  240. /**
  241. * Sets a priority that determines in which orders the cameras are rendered. This only applies to cameras rendering
  242. * to the same render target.
  243. *
  244. * @param[in] priority The priority. Higher value means the camera will be rendered sooner.
  245. */
  246. void setPriority(INT32 priority) { mPriority = priority; _markCoreDirty(); }
  247. /** Retrieves layer bitfield that is used when determining which object should the camera render. */
  248. UINT64 getLayers() const { return mLayers; }
  249. /** Sets layer bitfield that is used when determining which object should the camera render. */
  250. void setLayers(UINT64 layers) { mLayers = layers; _markCoreDirty(); }
  251. /** Returns number of samples if the camera uses multiple samples per pixel. */
  252. UINT32 getMSAACount() const { return mMSAA; }
  253. /**
  254. * Enables or disables multi-sampled anti-aliasing. Set to zero or one to disable, or to the required number of
  255. * samples to enable.
  256. */
  257. void setMSAACount(UINT32 count) { mMSAA = count; _markCoreDirty(); }
  258. /** Returns settings that are used for controling post-process operations like tonemapping. */
  259. const SPtr<PostProcessSettings>& getPostProcessSettings() const { return mPPSettings; }
  260. /** Sets settings that are used for controling post-process operations like tonemapping. */
  261. void setPostProcessSettings(const SPtr<PostProcessSettings>& settings) { mPPSettings = settings; _markCoreDirty(CameraDirtyFlag::PostProcess); }
  262. /** Retrieves flags that define the camera. */
  263. CameraFlags getFlags() const { return mCameraFlags; }
  264. /** Enables or disables flags that define the camera's behaviour. */
  265. void setFlag(const CameraFlag& flag, bool enable);
  266. /**
  267. * Converts a point in world space to screen coordinates (in pixels corresponding to the render target attached to
  268. * the camera).
  269. */
  270. Vector2I worldToScreenPoint(const Vector3& worldPoint) const;
  271. /** Converts a point in world space to normalized device coordinates (in [-1, 1] range). */
  272. Vector2 worldToNdcPoint(const Vector3& worldPoint) const;
  273. /** Converts a point in world space to point relative to camera's coordinate system (view space). */
  274. Vector3 worldToViewPoint(const Vector3& worldPoint) const;
  275. /**
  276. * Converts a point in screen space (pixels corresponding to render target attached to the camera) to a point in
  277. * world space.
  278. *
  279. * @param[in] screenPoint Point to transform.
  280. * @param[in] depth Depth to place the world point at, in world coordinates. The depth is applied to the
  281. * vector going from camera origin to the point on the near plane.
  282. */
  283. Vector3 screenToWorldPoint(const Vector2I& screenPoint, float depth = 0.5f) const;
  284. /**
  285. * Converts a point in screen space (pixels corresponding to render target attached to the camera) to a point in
  286. * world space.
  287. *
  288. * @param[in] screenPoint Point to transform.
  289. * @param[in] deviceDepth Depth to place the world point at, in normalized device coordinates.
  290. */
  291. Vector3 screenToWorldPointDeviceDepth(const Vector2I& screenPoint, float deviceDepth = 0.5f) const;
  292. /**
  293. * Converts a point in screen space (pixels corresponding to render target attached to the camera) to a point
  294. * relative to camera's coordinate system (view space).
  295. *
  296. * @param[in] screenPoint Point to transform.
  297. * @param[in] depth Depth to place the world point at. The depth is applied to the vector going from camera
  298. * origin to the point on the near plane.
  299. */
  300. Vector3 screenToViewPoint(const Vector2I& screenPoint, float depth = 0.5f) const;
  301. /**
  302. * Converts a point in screen space (pixels corresponding to render target attached to the camera) to normalized
  303. * device coordinates (in [-1, 1] range).
  304. */
  305. Vector2 screenToNdcPoint(const Vector2I& screenPoint) const;
  306. /** Converts a point relative to camera's coordinate system (view space) into a point in world space. */
  307. Vector3 viewToWorldPoint(const Vector3& viewPoint) const;
  308. /**
  309. * Converts a point relative to camera's coordinate system (view space) into a point in screen space (pixels
  310. * corresponding to render target attached to the camera).
  311. */
  312. Vector2I viewToScreenPoint(const Vector3& viewPoint) const;
  313. /**
  314. * Converts a point relative to camera's coordinate system (view space) into normalized device coordinates
  315. * (in [-1, 1] range).
  316. */
  317. Vector2 viewToNdcPoint(const Vector3& viewPoint) const;
  318. /**
  319. * Converts a point in normalized device coordinates ([-1, 1] range) to a point in world space.
  320. *
  321. * @param[in] ndcPoint Point to transform.
  322. * @param[in] depth Depth to place the world point at. The depth is applied to the vector going from camera
  323. * origin to the point on the near plane.
  324. */
  325. Vector3 ndcToWorldPoint(const Vector2& ndcPoint, float depth = 0.5f) const;
  326. /**
  327. * Converts a point in normalized device coordinates ([-1, 1] range) to a point relative to camera's coordinate system
  328. * (view space).
  329. *
  330. * @param[in] ndcPoint Point to transform.
  331. * @param[in] depth Depth to place the world point at. The depth is applied to the vector going from camera
  332. * origin to the point on the near plane.
  333. */
  334. Vector3 ndcToViewPoint(const Vector2& ndcPoint, float depth = 0.5f) const;
  335. /**
  336. * Converts a point in normalized device coordinates ([-1, 1] range) to a point in screen space (pixels corresponding
  337. * to render target attached to the camera).
  338. */
  339. Vector2I ndcToScreenPoint(const Vector2& ndcPoint) const;
  340. /**
  341. * Converts a point in screen space (pixels corresponding to render target attached to the camera) to a ray in world
  342. * space originating at the selected point on the camera near plane.
  343. */
  344. Ray screenPointToRay(const Vector2I& screenPoint) const;
  345. /** Projects a point from view to normalized device space. */
  346. Vector3 projectPoint(const Vector3& point) const;
  347. /** Un-projects a point in normalized device space to view space. */
  348. Vector3 unprojectPoint(const Vector3& point) const;
  349. static const float INFINITE_FAR_PLANE_ADJUST; /**< Small constant used to reduce far plane projection to avoid inaccuracies. */
  350. protected:
  351. CameraBase();
  352. /** Calculate projection parameters that are used when constructing the projection matrix. */
  353. virtual void calcProjectionParameters(float& left, float& right, float& bottom, float& top) const;
  354. /** Recalculate frustum if dirty. */
  355. virtual void updateFrustum() const;
  356. /** Recalculate frustum planes if dirty. */
  357. virtual void updateFrustumPlanes() const;
  358. /**
  359. * Update view matrix from parent position/orientation.
  360. *
  361. * @note Does nothing when custom view matrix is set.
  362. */
  363. virtual void updateView() const;
  364. /** Checks if the frustum requires updating. */
  365. virtual bool isFrustumOutOfDate() const;
  366. /** Notify camera that the frustum requires to be updated. */
  367. virtual void invalidateFrustum() const;
  368. /** Returns a rectangle that defines the viewport position and size, in pixels. */
  369. virtual Rect2I getViewportRect() const = 0;
  370. /**
  371. * Marks the simulation thread object as dirty and notifies the system its data should be synced with its core
  372. * thread counterpart.
  373. */
  374. virtual void _markCoreDirty(CameraDirtyFlag flag = CameraDirtyFlag::Everything) { }
  375. protected:
  376. UINT64 mLayers; /**< Bitfield that can be used for filtering what objects the camera sees. */
  377. CameraFlags mCameraFlags; /**< Flags that further determine type of camera. */
  378. Vector3 mPosition; /**< World space position. */
  379. Quaternion mRotation; /**< World space rotation. */
  380. bool mIsActive; /**< Is camera being rendered to. */
  381. ProjectionType mProjType; /**< Type of camera projection. */
  382. Radian mHorzFOV; /**< Horizontal field of view represents how wide is the camera angle. */
  383. float mFarDist; /**< Clip any objects further than this. Larger value decreases depth precision at smaller depths. */
  384. float mNearDist; /**< Clip any objects close than this. Smaller value decreases depth precision at larger depths. */
  385. float mAspect; /**< Width/height viewport ratio. */
  386. float mOrthoHeight; /**< Height in world units used for orthographic cameras. */
  387. INT32 mPriority; /**< Determines in what order will the camera be rendered. Higher priority means the camera will be rendered sooner. */
  388. bool mCustomViewMatrix; /**< Is custom view matrix set. */
  389. bool mCustomProjMatrix; /**< Is custom projection matrix set. */
  390. UINT8 mMSAA; /**< Number of samples to render the scene with. */
  391. SPtr<PostProcessSettings> mPPSettings; /**< Settings used to control post-process operations. */
  392. bool mFrustumExtentsManuallySet; /**< Are frustum extents manually set. */
  393. mutable Matrix4 mProjMatrixRS; /**< Cached render-system specific projection matrix. */
  394. mutable Matrix4 mProjMatrix; /**< Cached projection matrix that determines how are 3D points projected to a 2D viewport. */
  395. mutable Matrix4 mViewMatrix; /**< Cached view matrix that determines camera position/orientation. */
  396. mutable Matrix4 mProjMatrixRSInv;
  397. mutable Matrix4 mProjMatrixInv;
  398. mutable Matrix4 mViewMatrixInv;
  399. mutable ConvexVolume mFrustum; /**< Main clipping planes describing cameras visible area. */
  400. mutable bool mRecalcFrustum : 1; /**< Should frustum be recalculated. */
  401. mutable bool mRecalcFrustumPlanes : 1; /**< Should frustum planes be recalculated. */
  402. mutable bool mRecalcView : 1; /**< Should view matrix be recalculated. */
  403. mutable float mLeft, mRight, mTop, mBottom; /**< Frustum extents. */
  404. mutable AABox mBoundingBox; /**< Frustum bounding box. */
  405. };
  406. /** @} */
  407. /** @addtogroup Renderer-Engine-Internal
  408. * @{
  409. */
  410. /** @copydoc CameraBase */
  411. class BS_CORE_EXPORT Camera : public IReflectable, public CoreObject, public CameraBase
  412. {
  413. public:
  414. /** Returns the viewport used by the camera. */
  415. SPtr<Viewport> getViewport() const { return mViewport; }
  416. /**
  417. * Determines whether this is the main application camera. Main camera controls the final render surface that is
  418. * displayed to the user.
  419. */
  420. bool isMain() const { return mMain; }
  421. /**
  422. * Marks or unmarks this camera as the main application camera. Main camera controls the final render surface that
  423. * is displayed to the user.
  424. */
  425. void setMain(bool main) { mMain = main; }
  426. /** Retrieves an implementation of a camera handler usable only from the core thread. */
  427. SPtr<ct::Camera> getCore() const;
  428. /** Creates a new camera that renders to the specified portion of the provided render target. */
  429. static SPtr<Camera> create(SPtr<RenderTarget> target = nullptr,
  430. float left = 0.0f, float top = 0.0f, float width = 1.0f, float height = 1.0f);
  431. /** @name Internal
  432. * @{
  433. */
  434. /** Returns the hash value that can be used to identify if the internal data needs an update. */
  435. UINT32 _getLastModifiedHash() const { return mLastUpdateHash; }
  436. /** Sets the hash value that can be used to identify if the internal data needs an update. */
  437. void _setLastModifiedHash(UINT32 hash) { mLastUpdateHash = hash; }
  438. /** @} */
  439. protected:
  440. Camera(SPtr<RenderTarget> target = nullptr,
  441. float left = 0.0f, float top = 0.0f, float width = 1.0f, float height = 1.0f);
  442. /** @copydoc CameraBase */
  443. Rect2I getViewportRect() const override;
  444. /** @copydoc CoreObject::createCore */
  445. SPtr<ct::CoreObject> createCore() const override;
  446. /** @copydoc CameraBase::_markCoreDirty */
  447. void _markCoreDirty(CameraDirtyFlag flag = CameraDirtyFlag::Everything) override;
  448. /** @copydoc CoreObject::syncToCore */
  449. CoreSyncData syncToCore(FrameAlloc* allocator) override;
  450. /** @copydoc CoreObject::getCoreDependencies */
  451. void getCoreDependencies(Vector<CoreObject*>& dependencies) override;
  452. /** Creates a new camera without initializing it. */
  453. static SPtr<Camera> createEmpty();
  454. SPtr<Viewport> mViewport; /**< Viewport that describes 2D rendering surface. */
  455. bool mMain;
  456. UINT32 mLastUpdateHash;
  457. /************************************************************************/
  458. /* RTTI */
  459. /************************************************************************/
  460. public:
  461. friend class CameraRTTI;
  462. static RTTITypeBase* getRTTIStatic();
  463. RTTITypeBase* getRTTI() const override;
  464. };
  465. namespace ct
  466. {
  467. /** @copydoc CameraBase */
  468. class BS_CORE_EXPORT Camera : public CoreObject, public CameraBase
  469. {
  470. public:
  471. ~Camera();
  472. /** Returns the viewport used by the camera. */
  473. SPtr<Viewport> getViewport() const { return mViewport; }
  474. protected:
  475. friend class bs::Camera;
  476. Camera(SPtr<RenderTarget> target = nullptr,
  477. float left = 0.0f, float top = 0.0f, float width = 1.0f, float height = 1.0f);
  478. Camera(const SPtr<Viewport>& viewport);
  479. /** @copydoc CoreObject::initialize */
  480. void initialize() override;
  481. /** @copydoc CameraBase */
  482. Rect2I getViewportRect() const override;
  483. /** @copydoc CoreObject::syncToCore */
  484. void syncToCore(const CoreSyncData& data) override;
  485. SPtr<Viewport> mViewport;
  486. };
  487. }
  488. /** @} */
  489. }