BsCamera.h 23 KB

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