|
|
@@ -2,6 +2,7 @@
|
|
|
#define PERSPECTIVE_CAMERA_H
|
|
|
|
|
|
#include "Camera.h"
|
|
|
+#include "cln/Collision.h"
|
|
|
|
|
|
|
|
|
/// @todo
|
|
|
@@ -10,8 +11,6 @@ class PerspectiveCamera: public Camera
|
|
|
public:
|
|
|
PerspectiveCamera(Scene& scene, ulong flags, SceneNode* parent);
|
|
|
|
|
|
- void init(const char*) {}
|
|
|
-
|
|
|
/// @name Accessors
|
|
|
/// @{
|
|
|
float getFovX() const
|
|
|
@@ -27,11 +26,29 @@ class PerspectiveCamera: public Camera
|
|
|
void setFovY(float fovy);
|
|
|
/// @}
|
|
|
|
|
|
+ void moveUpdate()
|
|
|
+ {
|
|
|
+ Camera::moveUpdate();
|
|
|
+ wspaceCShape =
|
|
|
+ lspaceCShape.getCollisionShapeType(getWorldTransform());
|
|
|
+ }
|
|
|
+
|
|
|
+ /// @copydoc SceneNode::getVisibilityCollisionShapeWorldSpace
|
|
|
+ const CollisionShape* getVisibilityCollisionShapeWorldSpace() const
|
|
|
+ {
|
|
|
+ return &wspaceCShape;
|
|
|
+ }
|
|
|
+
|
|
|
+ void init(const char*)
|
|
|
+ {}
|
|
|
+
|
|
|
void setAll(float fovx, float fovy, float znear, float zfar);
|
|
|
|
|
|
private:
|
|
|
/// @name Data
|
|
|
/// @{
|
|
|
+ PerspectiveCameraShape lspaceCShape;
|
|
|
+ PerspectiveCameraShape wspaceCShape;
|
|
|
|
|
|
/// fovX is the angle in the y axis (imagine the cam positioned in
|
|
|
/// the default OGL pos) Note that fovX > fovY (most of the time) and
|
|
|
@@ -46,8 +63,17 @@ class PerspectiveCamera: public Camera
|
|
|
/// Implements Camera::calcProjectionMatrix
|
|
|
void calcProjectionMatrix();
|
|
|
|
|
|
- /// Implements Camera::getExtremePoints
|
|
|
- void getExtremePoints(Vec3* pointsArr, uint& pointsNum) const;
|
|
|
+ /// Update:
|
|
|
+ /// - The projection matrix
|
|
|
+ /// - The planes
|
|
|
+ /// - The collision shape
|
|
|
+ void updateLocals()
|
|
|
+ {
|
|
|
+ calcProjectionMatrix();
|
|
|
+ calcLSpaceFrustumPlanes();
|
|
|
+ lspaceCShape.setAll(fovX, fovY, zNear, zFar,
|
|
|
+ Transform::getIdentity());
|
|
|
+ }
|
|
|
};
|
|
|
|
|
|
|
|
|
@@ -62,8 +88,7 @@ inline PerspectiveCamera::PerspectiveCamera(Scene& scene, ulong flags,
|
|
|
inline void PerspectiveCamera::setFovX(float fovx_)
|
|
|
{
|
|
|
fovX = fovx_;
|
|
|
- calcProjectionMatrix();
|
|
|
- calcLSpaceFrustumPlanes();
|
|
|
+ update();
|
|
|
}
|
|
|
|
|
|
|