|
@@ -1,45 +1,14 @@
|
|
|
#pragma once
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "BsPrerequisites.h"
|
|
#include "BsPrerequisites.h"
|
|
|
-#include "BsMatrix4.h"
|
|
|
|
|
-#include "BsVector3.h"
|
|
|
|
|
-#include "BsVector2.h"
|
|
|
|
|
-#include "BsAABox.h"
|
|
|
|
|
-#include "BsVertexData.h"
|
|
|
|
|
-#include "BsPlane.h"
|
|
|
|
|
-#include "BsQuaternion.h"
|
|
|
|
|
-#include "BsRay.h"
|
|
|
|
|
|
|
+#include "BsCameraHandler.h"
|
|
|
#include "BsComponent.h"
|
|
#include "BsComponent.h"
|
|
|
-#include "BsCameraProxy.h"
|
|
|
|
|
-#include "BsConvexVolume.h"
|
|
|
|
|
|
|
+#include "BsViewport.h"
|
|
|
|
|
|
|
|
namespace BansheeEngine
|
|
namespace BansheeEngine
|
|
|
{
|
|
{
|
|
|
/**
|
|
/**
|
|
|
- * @brief Specified projection type to use by the camera.
|
|
|
|
|
- */
|
|
|
|
|
- enum ProjectionType
|
|
|
|
|
- {
|
|
|
|
|
- PT_ORTHOGRAPHIC,
|
|
|
|
|
- PT_PERSPECTIVE
|
|
|
|
|
- };
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * @brief Clip planes that form the camera frustum (visible area).
|
|
|
|
|
- */
|
|
|
|
|
- enum FrustumPlane
|
|
|
|
|
- {
|
|
|
|
|
- FRUSTUM_PLANE_NEAR = 0,
|
|
|
|
|
- FRUSTUM_PLANE_FAR = 1,
|
|
|
|
|
- FRUSTUM_PLANE_LEFT = 2,
|
|
|
|
|
- FRUSTUM_PLANE_RIGHT = 3,
|
|
|
|
|
- FRUSTUM_PLANE_TOP = 4,
|
|
|
|
|
- FRUSTUM_PLANE_BOTTOM = 5
|
|
|
|
|
- };
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * @brief Camera determines how is world geometry projected onto a 2D surface. You may
|
|
|
|
|
- * position and orient it in space, and set other options like aspect ratio and field or view.
|
|
|
|
|
|
|
+ * @copydoc CameraHandler
|
|
|
*/
|
|
*/
|
|
|
class BS_EXPORT Camera : public Component
|
|
class BS_EXPORT Camera : public Component
|
|
|
{
|
|
{
|
|
@@ -50,435 +19,305 @@ namespace BansheeEngine
|
|
|
virtual ~Camera();
|
|
virtual ~Camera();
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * @brief Returns the viewport used by the camera.
|
|
|
|
|
- */
|
|
|
|
|
- ViewportPtr getViewport() const { return mViewport; }
|
|
|
|
|
|
|
+ * @copydoc CameraHandler::getViewport
|
|
|
|
|
+ */
|
|
|
|
|
+ ViewportPtr getViewport() const { return mInternal.getViewport(); }
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * @brief Sets the camera horizontal field of view. This determines how wide the camera
|
|
|
|
|
- * viewing angle is along the horizontal axis. Vertical FOV is calculated from the
|
|
|
|
|
- * horizontal FOV and the aspect.
|
|
|
|
|
|
|
+ * @copydoc CameraHandler::setHorzFOV
|
|
|
*/
|
|
*/
|
|
|
- virtual void setHorzFOV(const Radian& fovy);
|
|
|
|
|
|
|
+ virtual void setHorzFOV(const Radian& fovy) { mInternal.setHorzFOV(fovy); }
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * @brief Retrieves the camera horizontal field of view.
|
|
|
|
|
|
|
+ * @copydoc CameraHandler::getHorzFOV
|
|
|
*/
|
|
*/
|
|
|
- virtual const Radian& getHorzFOV() const;
|
|
|
|
|
|
|
+ virtual const Radian& getHorzFOV() const { return mInternal.getHorzFOV(); }
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * @brief Sets the distance from the frustum to the near clipping plane. Anything
|
|
|
|
|
- * closer than the near clipping plane will not be rendered. Decreasing this value
|
|
|
|
|
- * decreases depth buffer precision.
|
|
|
|
|
|
|
+ * @copydoc CameraHandler::setNearClipDistance
|
|
|
*/
|
|
*/
|
|
|
- virtual void setNearClipDistance(float nearDist);
|
|
|
|
|
|
|
+ virtual void setNearClipDistance(float nearDist) { mInternal.setNearClipDistance(nearDist); }
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * @brief Retrieves the distance from the frustum to the near clipping plane. Anything
|
|
|
|
|
- * closer than the near clipping plane will not be rendered. Decreasing this value
|
|
|
|
|
- * decreases depth buffer precision.
|
|
|
|
|
|
|
+ * @copydoc CameraHandler::getNearClipDistance
|
|
|
*/
|
|
*/
|
|
|
- virtual float getNearClipDistance() const;
|
|
|
|
|
|
|
+ virtual float getNearClipDistance() const { return mInternal.getNearClipDistance(); }
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * @brief Sets the distance from the frustum to the far clipping plane. Anything
|
|
|
|
|
- * farther than the far clipping plane will not be rendered. Increasing this value
|
|
|
|
|
- * decreases depth buffer precision.
|
|
|
|
|
|
|
+ * @copydoc CameraHandler::setFarClipDistance
|
|
|
*/
|
|
*/
|
|
|
- virtual void setFarClipDistance(float farDist);
|
|
|
|
|
|
|
+ virtual void setFarClipDistance(float farDist) { mInternal.setFarClipDistance(farDist); }
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * @brief Retrieves the distance from the frustum to the far clipping plane. Anything
|
|
|
|
|
- * farther than the far clipping plane will not be rendered. Increasing this value
|
|
|
|
|
- * decreases depth buffer precision.
|
|
|
|
|
|
|
+ * @copydoc CameraHandler::getFarClipDistance
|
|
|
*/
|
|
*/
|
|
|
- virtual float getFarClipDistance() const;
|
|
|
|
|
|
|
+ virtual float getFarClipDistance() const { return mInternal.getFarClipDistance(); }
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * @brief Sets the current viewport aspect ratio (width / height).
|
|
|
|
|
|
|
+ * @copydoc CameraHandler::setAspectRatio
|
|
|
*/
|
|
*/
|
|
|
- virtual void setAspectRatio(float ratio);
|
|
|
|
|
|
|
+ virtual void setAspectRatio(float ratio) { mInternal.setAspectRatio(ratio); }
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * @brief Returns current viewport aspect ratio (width / height).
|
|
|
|
|
|
|
+ * @copydoc CameraHandler::getAspectRatio
|
|
|
*/
|
|
*/
|
|
|
- virtual float getAspectRatio() const;
|
|
|
|
|
-
|
|
|
|
|
- /** @brief Manually set the extents of the frustum that will be used when calculating the
|
|
|
|
|
- * projection matrix. This will prevents extents for being automatically calculated
|
|
|
|
|
- * from aspect and near plane so it is up to the caller to keep these values
|
|
|
|
|
- * accurate.
|
|
|
|
|
- *
|
|
|
|
|
- * @param left The position where the left clip plane intersect the near clip plane, in view space.
|
|
|
|
|
- * @param right The position where the right clip plane intersect the near clip plane, in view space.
|
|
|
|
|
- * @param top The position where the top clip plane intersect the near clip plane, in view space.
|
|
|
|
|
- * @param bottom The position where the bottom clip plane intersect the near clip plane, in view space.
|
|
|
|
|
- */
|
|
|
|
|
- virtual void setFrustumExtents(float left, float right, float top, float bottom);
|
|
|
|
|
|
|
+ virtual float getAspectRatio() const { return mInternal.getAspectRatio(); }
|
|
|
|
|
|
|
|
- /**
|
|
|
|
|
- * @brief Resets frustum extents so they are automatically derived from other values.
|
|
|
|
|
- * This is only relevant if you have previously set custom extents.
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @copydoc CameraHandler::setFrustumExtents
|
|
|
*/
|
|
*/
|
|
|
- virtual void resetFrustumExtents();
|
|
|
|
|
|
|
+ virtual void setFrustumExtents(float left, float right, float top, float bottom)
|
|
|
|
|
+ {
|
|
|
|
|
+ mInternal.setFrustumExtents(left, right, top, bottom);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- /**
|
|
|
|
|
- * @brief Returns the extents of the frustum in view space at the near plane.
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @copydoc CameraHandler::resetFrustumExtents
|
|
|
*/
|
|
*/
|
|
|
- virtual void getFrustumExtents(float& outleft, float& outright, float& outtop, float& outbottom) const;
|
|
|
|
|
|
|
+ virtual void resetFrustumExtents() { mInternal.resetFrustumExtents(); }
|
|
|
|
|
|
|
|
- /**
|
|
|
|
|
- * @brief Returns the standard projection matrix that determines how are 3D points
|
|
|
|
|
- * projected to two dimensions. The layout of this matrix depends on currently
|
|
|
|
|
- * used render system.
|
|
|
|
|
- *
|
|
|
|
|
- * @note You should use this matrix when sending the matrix to the render system to remain
|
|
|
|
|
- * everything works consistently when other render systems are used.
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @copydoc CameraHandler::getFrustumExtents
|
|
|
*/
|
|
*/
|
|
|
- virtual const Matrix4& getProjectionMatrixRS() const;
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * @brief Returns the standard projection matrix that determines how are 3D points
|
|
|
|
|
- * projected to two dimensions. Returned matrix is standard following right-hand
|
|
|
|
|
- * rules and depth range of [-1, 1].
|
|
|
|
|
- *
|
|
|
|
|
- * @note Different render systems will expect different projection matrix layouts, in which
|
|
|
|
|
- * case use getProjectionMatrixRS.
|
|
|
|
|
- */
|
|
|
|
|
- virtual const Matrix4& getProjectionMatrix() const;
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * @brief Gets the camera view matrix. Used for positioning/orienting the camera.
|
|
|
|
|
- */
|
|
|
|
|
- virtual const Matrix4& getViewMatrix() const;
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * @brief Sets whether the camera should use the custom view matrix.
|
|
|
|
|
- * When this is enabled camera will no longer calculate its view matrix
|
|
|
|
|
- * based on position/orientation and caller will be resonsible to keep
|
|
|
|
|
- * the view matrix up to date.
|
|
|
|
|
- */
|
|
|
|
|
- virtual void setCustomViewMatrix(bool enable, const Matrix4& viewMatrix = Matrix4::IDENTITY);
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * @brief Returns true if a custom view matrix is used.
|
|
|
|
|
- */
|
|
|
|
|
- virtual bool isCustomViewMatrixEnabled() const { return mCustomViewMatrix; }
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * @brief Sets whether the camera should use the custom projection matrix.
|
|
|
|
|
- * When this is enabled camera will no longer calculate its projection matrix
|
|
|
|
|
- * based on field of view, aspect and other parameters and caller will be
|
|
|
|
|
- * resonsible to keep the projection matrix up to date.
|
|
|
|
|
- */
|
|
|
|
|
- virtual void setCustomProjectionMatrix(bool enable, const Matrix4& projectionMatrix = Matrix4::IDENTITY);
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * @brief Returns true if a custom projection matrix is used.
|
|
|
|
|
- */
|
|
|
|
|
- virtual bool isCustomProjectionMatrixEnabled() const { return mCustomProjMatrix; }
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * @brief Returns a convex volume representing the visible area of the camera,
|
|
|
|
|
- * in local space.
|
|
|
|
|
- */
|
|
|
|
|
- virtual const ConvexVolume& getFrustum() const;
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * @brief Returns a convex volume representing the visible area of the camera,
|
|
|
|
|
- * in world space.
|
|
|
|
|
- */
|
|
|
|
|
- virtual ConvexVolume getWorldFrustum() const;
|
|
|
|
|
|
|
+ virtual void getFrustumExtents(float& outleft, float& outright, float& outtop, float& outbottom) const
|
|
|
|
|
+ {
|
|
|
|
|
+ mInternal.getFrustumExtents(outleft, outright, outtop, outbottom);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * @brief Returns the bounding of the frustum.
|
|
|
|
|
|
|
+ * @copydoc CameraHandler::getProjectionMatrixRS
|
|
|
*/
|
|
*/
|
|
|
- const AABox& getBoundingBox() const;
|
|
|
|
|
|
|
+ virtual const Matrix4& getProjectionMatrixRS() const { return mInternal.getProjectionMatrixRS(); }
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * @brief Sets the type of projection used by the camera.
|
|
|
|
|
|
|
+ * @copydoc CameraHandler::getProjectionMatrix
|
|
|
*/
|
|
*/
|
|
|
- virtual void setProjectionType(ProjectionType pt);
|
|
|
|
|
|
|
+ virtual const Matrix4& getProjectionMatrix() const { return mInternal.getProjectionMatrix(); }
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * @brief Returns the type of projection used by the camera.
|
|
|
|
|
|
|
+ * @copydoc CameraHandler::getViewMatrix
|
|
|
*/
|
|
*/
|
|
|
- virtual ProjectionType getProjectionType() const;
|
|
|
|
|
|
|
+ virtual const Matrix4& getViewMatrix() const { updateView(); return mInternal.getViewMatrix(); }
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * @brief Sets the orthographic window height, for use with orthographic rendering only.
|
|
|
|
|
- *
|
|
|
|
|
- * @param w Width of the window in world units.
|
|
|
|
|
- * @param h Height of the window in world units.
|
|
|
|
|
- *
|
|
|
|
|
- * @note Calling this method will recalculate the aspect ratio, use setOrthoWindowHeight or
|
|
|
|
|
- * setOrthoWindowWidth alone if you wish to preserve the aspect ratio but just fit one
|
|
|
|
|
- * or other dimension to a particular size.
|
|
|
|
|
|
|
+ * @copydoc CameraHandler::setCustomViewMatrix
|
|
|
*/
|
|
*/
|
|
|
- virtual void setOrthoWindow(float w, float h);
|
|
|
|
|
|
|
+ virtual void setCustomViewMatrix(bool enable, const Matrix4& viewMatrix = Matrix4::IDENTITY)
|
|
|
|
|
+ {
|
|
|
|
|
+ mInternal.setCustomViewMatrix(enable, viewMatrix);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * @brief Sets the orthographic window height, for use with orthographic rendering only.
|
|
|
|
|
- *
|
|
|
|
|
- * @param h Height of the window in world units.
|
|
|
|
|
- *
|
|
|
|
|
- * @note The width of the window will be calculated from the aspect ratio.
|
|
|
|
|
|
|
+ * @copydoc CameraHandler::isCustomViewMatrixEnabled
|
|
|
*/
|
|
*/
|
|
|
- virtual void setOrthoWindowHeight(float h);
|
|
|
|
|
-
|
|
|
|
|
|
|
+ virtual bool isCustomViewMatrixEnabled() const { return mInternal.isCustomViewMatrixEnabled(); }
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
- * @brief Sets the orthographic window width, for use with orthographic rendering only.
|
|
|
|
|
- *
|
|
|
|
|
- * @param w Width of the window in world units.
|
|
|
|
|
- *
|
|
|
|
|
- * @note The height of the window will be calculated from the aspect ratio.
|
|
|
|
|
|
|
+ * @copydoc CameraHandler::setCustomProjectionMatrix
|
|
|
*/
|
|
*/
|
|
|
- virtual void setOrthoWindowWidth(float w);
|
|
|
|
|
|
|
+ virtual void setCustomProjectionMatrix(bool enable, const Matrix4& projectionMatrix = Matrix4::IDENTITY)
|
|
|
|
|
+ {
|
|
|
|
|
+ mInternal.setCustomProjectionMatrix(enable, projectionMatrix);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * @brief Gets the orthographic window width in world units, for use with orthographic rendering only.
|
|
|
|
|
|
|
+ * @copydoc CameraHandler::isCustomProjectionMatrixEnabled
|
|
|
*/
|
|
*/
|
|
|
- virtual float getOrthoWindowHeight() const;
|
|
|
|
|
|
|
+ virtual bool isCustomProjectionMatrixEnabled() const { return mInternal.isCustomProjectionMatrixEnabled(); }
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * @brief Gets the orthographic window width in world units, for use with orthographic rendering only.
|
|
|
|
|
- *
|
|
|
|
|
- * @note This is calculated from the orthographic height and the aspect ratio.
|
|
|
|
|
|
|
+ * @copydoc CameraHandler::getFrustum
|
|
|
*/
|
|
*/
|
|
|
- virtual float getOrthoWindowWidth() const;
|
|
|
|
|
|
|
+ virtual const ConvexVolume& getFrustum() const { return mInternal.getFrustum(); }
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * @brief This option tells the renderer that this camera should ignore any renderable components.
|
|
|
|
|
|
|
+ * @copydoc CameraHandler::getWorldFrustum
|
|
|
*/
|
|
*/
|
|
|
- void setIgnoreSceneRenderables(bool value) { mIgnoreSceneRenderables = true; markCoreDirty(); }
|
|
|
|
|
|
|
+ virtual ConvexVolume getWorldFrustum() const;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * @brief This option tells the renderer that this camera should ignore any renderable components.
|
|
|
|
|
|
|
+ * @copydoc CameraHandler::getBoundingBox
|
|
|
*/
|
|
*/
|
|
|
- bool getIgnoreSceneRenderables() const { return mIgnoreSceneRenderables; }
|
|
|
|
|
|
|
+ const AABox& getBoundingBox() const { return mInternal.getBoundingBox(); }
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * @brief Gets a priority that determines in which orders the cameras are rendered.
|
|
|
|
|
- * This only applies to cameras rendering to the same render target.
|
|
|
|
|
|
|
+ * @copydoc CameraHandler::setProjectionType
|
|
|
*/
|
|
*/
|
|
|
- INT32 getPriority() const { return mPriority; }
|
|
|
|
|
|
|
+ virtual void setProjectionType(ProjectionType pt) { mInternal.setProjectionType(pt); }
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * @brief Sets a priority that determines in which orders the cameras are rendered.
|
|
|
|
|
- * This only applies to cameras rendering to the same render target.
|
|
|
|
|
- *
|
|
|
|
|
- * @param priority The priority. Higher value means the camera will be rendered sooner.
|
|
|
|
|
|
|
+ * @copydoc CameraHandler::getProjectionType
|
|
|
*/
|
|
*/
|
|
|
- void setPriority(INT32 priority) { mPriority = priority; markCoreDirty(); }
|
|
|
|
|
|
|
+ virtual ProjectionType getProjectionType() const { return mInternal.getProjectionType(); }
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * @brief Retrieves layer bitfield that is used when determining which object should the camera render.
|
|
|
|
|
|
|
+ * @copydoc CameraHandler::setOrthoWindow
|
|
|
*/
|
|
*/
|
|
|
- UINT64 getLayers() const { return mLayers; }
|
|
|
|
|
|
|
+ virtual void setOrthoWindow(float w, float h) { mInternal.setOrthoWindow(w, h); }
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * @brief Sets layer bitfield that is used when determining which object should the camera render.
|
|
|
|
|
|
|
+ * @copydoc CameraHandler::setOrthoWindowHeight
|
|
|
*/
|
|
*/
|
|
|
- void setLayers(UINT64 layers) { mLayers = layers; markCoreDirty(); }
|
|
|
|
|
|
|
+ virtual void setOrthoWindowHeight(float h) { mInternal.setOrthoWindowHeight(h); }
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * @brief Converts a point in world space to screen coordinates (in pixels
|
|
|
|
|
- * corresponding to the render target attached to the camera).
|
|
|
|
|
|
|
+ * @copydoc CameraHandler::setOrthoWindowWidth
|
|
|
*/
|
|
*/
|
|
|
- Vector2I worldToScreenPoint(const Vector3& worldPoint) const;
|
|
|
|
|
|
|
+ virtual void setOrthoWindowWidth(float w) { mInternal.setOrthoWindowWidth(w); }
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * @brief Converts a point in world space to normalized clip coordinates
|
|
|
|
|
- * (in [0, 1] range).
|
|
|
|
|
|
|
+ * @copydoc CameraHandler::getOrthoWindowHeight
|
|
|
*/
|
|
*/
|
|
|
- Vector2 worldToClipPoint(const Vector3& worldPoint) const;
|
|
|
|
|
|
|
+ virtual float getOrthoWindowHeight() const { return mInternal.getOrthoWindowHeight(); }
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * @brief Converts a point in world space to point relative to camera's
|
|
|
|
|
- * coordinate system (view space).
|
|
|
|
|
|
|
+ * @copydoc CameraHandler::getOrthoWindowWidth
|
|
|
*/
|
|
*/
|
|
|
- Vector3 worldToViewPoint(const Vector3& worldPoint) const;
|
|
|
|
|
|
|
+ virtual float getOrthoWindowWidth() const { return mInternal.getOrthoWindowWidth(); }
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * @brief Converts a point in screen space (pixels corresponding to
|
|
|
|
|
- * render target attached to the camera) to a point in world space.
|
|
|
|
|
|
|
+ * @copydoc CameraHandler::setIgnoreSceneRenderables
|
|
|
*/
|
|
*/
|
|
|
- Vector3 screenToWorldPoint(const Vector2I& screenPoint) const;
|
|
|
|
|
|
|
+ void setIgnoreSceneRenderables(bool value) { mInternal.setIgnoreSceneRenderables(value); }
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * @brief Converts a point in screen space (pixels corresponding to
|
|
|
|
|
- * render target attached to the camera) to a point relative to
|
|
|
|
|
- * camera's coordinate system (view space).
|
|
|
|
|
|
|
+ * @copydoc CameraHandler::getIgnoreSceneRenderables
|
|
|
*/
|
|
*/
|
|
|
- Vector3 screenToViewPoint(const Vector2I& screenPoint) const;
|
|
|
|
|
|
|
+ bool getIgnoreSceneRenderables() const { return mInternal.getIgnoreSceneRenderables(); }
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * @brief Converts a point in screen space (pixels corresponding to
|
|
|
|
|
- * render target attached to the camera) to normalized clip
|
|
|
|
|
- * coordinates (in [0, 1] range).
|
|
|
|
|
|
|
+ * @copydoc CameraHandler::getPriority
|
|
|
*/
|
|
*/
|
|
|
- Vector2 screenToClipPoint(const Vector2I& screenPoint) const;
|
|
|
|
|
|
|
+ INT32 getPriority() const { return mInternal.getPriority(); }
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * @brief Converts a point relative to camera's coordinate system (view space)
|
|
|
|
|
- * into a point in world space.
|
|
|
|
|
|
|
+ * @copydoc CameraHandler::setPriority
|
|
|
*/
|
|
*/
|
|
|
- Vector3 viewToWorldPoint(const Vector3& viewPoint) const;
|
|
|
|
|
|
|
+ void setPriority(INT32 priority) { mInternal.setPriority(priority); }
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * @brief Converts a point relative to camera's coordinate system (view space)
|
|
|
|
|
- * into a point in screen space (pixels corresponding to render target
|
|
|
|
|
- * attached to the camera.
|
|
|
|
|
|
|
+ * @copydoc CameraHandler::getLayers
|
|
|
*/
|
|
*/
|
|
|
- Vector2I viewToScreenPoint(const Vector3& viewPoint) const;
|
|
|
|
|
|
|
+ UINT64 getLayers() const { return mInternal.getLayers(); }
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * @brief Converts a point relative to camera's coordinate system (view space)
|
|
|
|
|
- * into normalized clip coordinates (in [0, 1] range).
|
|
|
|
|
|
|
+ * @copydoc CameraHandler::setLayers
|
|
|
*/
|
|
*/
|
|
|
- Vector2 viewToClipPoint(const Vector3& viewPoint) const;
|
|
|
|
|
|
|
+ void setLayers(UINT64 layers) { mInternal.setLayers(layers); }
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * @brief Converts a point in normalized clip coordinates ([0, 1] range) to
|
|
|
|
|
- * a point in world space.
|
|
|
|
|
|
|
+ * @copydoc CameraHandler::worldToScreenPoint
|
|
|
*/
|
|
*/
|
|
|
- Vector3 clipToWorldPoint(const Vector2& clipPoint) const;
|
|
|
|
|
|
|
+ Vector2I worldToScreenPoint(const Vector3& worldPoint) const { updateView(); return mInternal.worldToScreenPoint(worldPoint); }
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * @brief Converts a point in normalized clip coordinates ([0, 1] range) to
|
|
|
|
|
- * a point relative to camera's coordinate system (view space).
|
|
|
|
|
|
|
+ * @copydoc CameraHandler::worldToClipPoint
|
|
|
*/
|
|
*/
|
|
|
- Vector3 clipToViewPoint(const Vector2& clipPoint) const;
|
|
|
|
|
|
|
+ Vector2 worldToClipPoint(const Vector3& worldPoint) const { updateView(); return mInternal.worldToClipPoint(worldPoint); }
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * @brief Converts a point in normalized clip coordinates ([0, 1] range) to
|
|
|
|
|
- * a point in screen space (pixels corresponding to render target attached
|
|
|
|
|
- * to the camera)
|
|
|
|
|
|
|
+ * @copydoc CameraHandler::worldToViewPoint
|
|
|
*/
|
|
*/
|
|
|
- Vector2I clipToScreenPoint(const Vector2& clipPoint) const;
|
|
|
|
|
|
|
+ Vector3 worldToViewPoint(const Vector3& worldPoint) const { updateView(); return mInternal.worldToViewPoint(worldPoint); }
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * @brief Converts a point in screen space (pixels corresponding to
|
|
|
|
|
- * render target attached to the camera) to a ray in world space
|
|
|
|
|
- * originating at the selected point on the camera near plane.
|
|
|
|
|
|
|
+ * @copydoc CameraHandler::screenToWorldPoint
|
|
|
*/
|
|
*/
|
|
|
- Ray screenPointToRay(const Vector2I& screenPoint) const;
|
|
|
|
|
|
|
+ Vector3 screenToWorldPoint(const Vector2I& screenPoint) const { updateView(); return mInternal.screenToWorldPoint(screenPoint); }
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * @brief Projects a point from view to clip space.
|
|
|
|
|
|
|
+ * @copydoc CameraHandler::screenToViewPoint
|
|
|
*/
|
|
*/
|
|
|
- Vector3 projectPoint(const Vector3& point) const;
|
|
|
|
|
|
|
+ Vector3 screenToViewPoint(const Vector2I& screenPoint) const { return mInternal.screenToViewPoint(screenPoint); }
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * @brief Un-projects a point in clip space to view space.
|
|
|
|
|
|
|
+ * @copydoc CameraHandler::screenToClipPoint
|
|
|
*/
|
|
*/
|
|
|
- Vector3 unprojectPoint(const Vector3& point) const;
|
|
|
|
|
|
|
+ Vector2 screenToClipPoint(const Vector2I& screenPoint) const { return mInternal.screenToClipPoint(screenPoint); }
|
|
|
|
|
|
|
|
- static const float INFINITE_FAR_PLANE_ADJUST; /**< Small constant used to reduce far plane projection to avoid inaccuracies. */
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @copydoc CameraHandler::viewToWorldPoint
|
|
|
|
|
+ */
|
|
|
|
|
+ Vector3 viewToWorldPoint(const Vector3& viewPoint) const { updateView(); return mInternal.viewToWorldPoint(viewPoint); }
|
|
|
|
|
|
|
|
- /************************************************************************/
|
|
|
|
|
- /* CORE PROXY */
|
|
|
|
|
- /************************************************************************/
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @copydoc CameraHandler::viewToScreenPoint
|
|
|
|
|
+ */
|
|
|
|
|
+ Vector2I viewToScreenPoint(const Vector3& viewPoint) const { return mInternal.viewToScreenPoint(viewPoint); }
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * @brief Checks is the core dirty flag set. This is used by external systems
|
|
|
|
|
- * to know when internal data has changed and core thread potentially needs to be notified.
|
|
|
|
|
|
|
+ * @copydoc CameraHandler::viewToClipPoint
|
|
|
*/
|
|
*/
|
|
|
- bool _isCoreDirty() const { return mCoreDirtyFlags != 0 || mViewport->_isCoreDirty(); }
|
|
|
|
|
|
|
+ Vector2 viewToClipPoint(const Vector3& viewPoint) const { return mInternal.viewToClipPoint(viewPoint); }
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * @brief Marks the core dirty flag as clean.
|
|
|
|
|
|
|
+ * @copydoc CameraHandler::clipToWorldPoint
|
|
|
*/
|
|
*/
|
|
|
- void _markCoreClean() { mCoreDirtyFlags = 0; mViewport->_markCoreClean(); }
|
|
|
|
|
|
|
+ Vector3 clipToWorldPoint(const Vector2& clipPoint) const { updateView(); return mInternal.clipToWorldPoint(clipPoint); }
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * @brief Creates a new core proxy from the currently set options. Core proxies ensure
|
|
|
|
|
- * that the core thread has all the necessary data, while avoiding the need
|
|
|
|
|
- * to manage Camera itself on the core thread.
|
|
|
|
|
- *
|
|
|
|
|
- * @note You generally need to update the core thread with a new proxy whenever core
|
|
|
|
|
- * dirty flag is set.
|
|
|
|
|
|
|
+ * @copydoc CameraHandler::clipToViewPoint
|
|
|
*/
|
|
*/
|
|
|
- CameraProxyPtr _createProxy() const;
|
|
|
|
|
|
|
+ Vector3 clipToViewPoint(const Vector2& clipPoint) const { return mInternal.clipToViewPoint(clipPoint); }
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * @brief Returns the currently active proxy object, if any.
|
|
|
|
|
|
|
+ * @copydoc CameraHandler::clipToScreenPoint
|
|
|
*/
|
|
*/
|
|
|
- CameraProxyPtr _getActiveProxy() const { return mActiveProxy; }
|
|
|
|
|
|
|
+ Vector2I clipToScreenPoint(const Vector2& clipPoint) const { return mInternal.clipToScreenPoint(clipPoint); }
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * @brief Changes the currently active proxy object.
|
|
|
|
|
|
|
+ * @copydoc CameraHandler::screenPointToRay
|
|
|
*/
|
|
*/
|
|
|
- void _setActiveProxy(const CameraProxyPtr& proxy) { mActiveProxy = proxy; }
|
|
|
|
|
|
|
+ Ray screenPointToRay(const Vector2I& screenPoint) const { updateView(); return mInternal.screenPointToRay(screenPoint); }
|
|
|
|
|
|
|
|
- protected:
|
|
|
|
|
/**
|
|
/**
|
|
|
- * @brief Calculate projection parameters that are used when constructing the projection matrix.
|
|
|
|
|
|
|
+ * @copydoc CameraHandler::projectPoint
|
|
|
*/
|
|
*/
|
|
|
- virtual void calcProjectionParameters(float& left, float& right, float& bottom, float& top) const;
|
|
|
|
|
|
|
+ Vector3 projectPoint(const Vector3& point) const { return mInternal.projectPoint(point); }
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * @brief Recalculate frustum if dirty.
|
|
|
|
|
|
|
+ * @copydoc CameraHandler::unprojectPoint
|
|
|
*/
|
|
*/
|
|
|
- virtual void updateFrustum() const;
|
|
|
|
|
|
|
+ Vector3 unprojectPoint(const Vector3& point) const { return mInternal.unprojectPoint(point); }
|
|
|
|
|
+
|
|
|
|
|
+ /************************************************************************/
|
|
|
|
|
+ /* CORE PROXY */
|
|
|
|
|
+ /************************************************************************/
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * @brief Recalculate frustum planes if dirty.
|
|
|
|
|
|
|
+ * @copydoc CameraHandler::_isCoreDirty
|
|
|
*/
|
|
*/
|
|
|
- virtual void updateFrustumPlanes() const;
|
|
|
|
|
|
|
+ bool _isCoreDirty() const { return mInternal._isCoreDirty(); }
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * @brief Update view matrix from parent position/orientation.
|
|
|
|
|
- *
|
|
|
|
|
- * @note Does nothing when custom view matrix is set.
|
|
|
|
|
|
|
+ * @copydoc CameraHandler::_markCoreClean
|
|
|
*/
|
|
*/
|
|
|
- virtual void updateView() const;
|
|
|
|
|
|
|
+ void _markCoreClean() { mInternal._markCoreClean(); }
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * @brief Checks if the frustum requires updating.
|
|
|
|
|
|
|
+ * @copydoc CameraHandler::_createProxy
|
|
|
*/
|
|
*/
|
|
|
- virtual bool isFrustumOutOfDate() const;
|
|
|
|
|
|
|
+ CameraProxyPtr _createProxy() const { updateView(); return mInternal._createProxy(); }
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * @brief Notify camera that the frustum requires to be updated.
|
|
|
|
|
|
|
+ * @copydoc CameraHandler::_getActiveProxy
|
|
|
*/
|
|
*/
|
|
|
- virtual void invalidateFrustum() const;
|
|
|
|
|
|
|
+ CameraProxyPtr _getActiveProxy() const { return mInternal._getActiveProxy(); }
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * @brief Marks the core data as dirty.
|
|
|
|
|
|
|
+ * @copydoc CameraHandler::_setActiveProxy
|
|
|
*/
|
|
*/
|
|
|
- void markCoreDirty() { mCoreDirtyFlags = 0xFFFFFFFF; }
|
|
|
|
|
|
|
+ void _setActiveProxy(const CameraProxyPtr& proxy) { mInternal._setActiveProxy(proxy); }
|
|
|
|
|
|
|
|
protected:
|
|
protected:
|
|
|
- ViewportPtr mViewport; /**< Viewport that describes 2D rendering surface. */
|
|
|
|
|
- UINT64 mLayers; /**< Bitfield that can be used for filtering what objects the camera sees. */
|
|
|
|
|
-
|
|
|
|
|
- ProjectionType mProjType; /**< Type of camera projection. */
|
|
|
|
|
- Radian mHorzFOV; /**< Horizontal field of view represents how wide is the camera angle. */
|
|
|
|
|
- float mFarDist; /**< Clip any objects further than this. Larger value decreases depth precision at smaller depths. */
|
|
|
|
|
- float mNearDist; /**< Clip any objects close than this. Smaller value decreases depth precision at larger depths. */
|
|
|
|
|
- float mAspect; /**< Width/height viewport ratio. */
|
|
|
|
|
- float mOrthoHeight; /**< Height in world units used for orthographic cameras. */
|
|
|
|
|
- INT32 mPriority; /**< Determines in what order will the camera be rendered. Higher priority means the camera will be rendered sooner. */
|
|
|
|
|
-
|
|
|
|
|
- bool mCustomViewMatrix; /**< Is custom view matrix set. */
|
|
|
|
|
- bool mCustomProjMatrix; /**< Is custom projection matrix set. */
|
|
|
|
|
-
|
|
|
|
|
- bool mFrustumExtentsManuallySet; /**< Are frustum extents manually set. */
|
|
|
|
|
- bool mIgnoreSceneRenderables; /**< Should the camera ignore renderable components. */
|
|
|
|
|
-
|
|
|
|
|
- UINT32 mCoreDirtyFlags; /**< True when internal data has changed and core thread wasn't yet informed. */
|
|
|
|
|
- CameraProxyPtr mActiveProxy; /**< Active core proxy if any. */
|
|
|
|
|
-
|
|
|
|
|
- mutable Matrix4 mProjMatrixRS; /**< Cached render-system specific projection matrix. */
|
|
|
|
|
- mutable Matrix4 mProjMatrix; /**< Cached projection matrix that determines how are 3D points projected to a 2D viewport. */
|
|
|
|
|
- mutable Matrix4 mViewMatrix; /**< Cached view matrix that determines camera position/orientation. */
|
|
|
|
|
-
|
|
|
|
|
- mutable ConvexVolume mFrustum; /**< Main clipping planes describing cameras visible area. */
|
|
|
|
|
- mutable bool mRecalcFrustum; /**< Should frustum be recalculated. */
|
|
|
|
|
- mutable bool mRecalcFrustumPlanes; /**< Should frustum planes be recalculated. */
|
|
|
|
|
- mutable float mLeft, mRight, mTop, mBottom; /**< Frustum extents. */
|
|
|
|
|
- mutable AABox mBoundingBox; /**< Frustum bounding box. */
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @brief Checks if the world transform of the camera changed, and if needed updates
|
|
|
|
|
+ * the view matrix.
|
|
|
|
|
+ */
|
|
|
|
|
+ void updateView() const;
|
|
|
|
|
+
|
|
|
|
|
+ mutable CameraHandler mInternal;
|
|
|
|
|
+ mutable UINT32 mLastUpdateHash;
|
|
|
|
|
|
|
|
/************************************************************************/
|
|
/************************************************************************/
|
|
|
/* COMPONENT OVERRIDES */
|
|
/* COMPONENT OVERRIDES */
|