Loading...
Searching...
No Matches
camera.h
Go to the documentation of this file.
#ifndef BALL_VIEW_RENDERING_CAMERA_H
#define BALL_VIEW_RENDERING_CAMERA_H
#ifndef BALL_COMMON_GLOBAL_H
#include <BALL/COMMON/global.h>
#endif
#ifndef BALL_MATHS_VECTOR3_H
#include <BALL/MATHS/vector3.h>
#endif
#ifndef BALL_MATHS_QUATERNION_H
#include <BALL/MATHS/quaternion.h>
#endif
namespace BALL
{
namespace VIEW
{
class BALL_VIEW_EXPORT Camera
{
public:
enum ProjectionMode
{
PERSPECTIVE = 0,
ORTHOGRAPHIC
};
Camera();
Camera(const Camera& camera);
Camera(const Vector3& view_point, const Vector3& look_at, const Vector3& look_up_vector, const ProjectionMode& mode = PERSPECTIVE);
virtual ~Camera(){}
Camera& operator = (const Camera& camera);
void moveRight(float translation)
{ view_point_ += right_vector_*translation; look_at_ += right_vector_*translation; }
void moveUp(float translation)
{ view_point_ += look_up_vector_*translation; look_at_ += look_up_vector_*translation; }
void moveForward(float translation)
{
Vector3 normal_view_vector(view_vector_);
normal_view_vector.normalize();
view_point_ += normal_view_vector*translation;
look_at_ += normal_view_vector*translation;
}
const Vector3& getViewPoint() const
{ return view_point_;}
void setViewPoint(const Vector3& view_point)
{ view_point_ = view_point; calculateVectors_();}
const Vector3& getLookAtPosition() const
{ return look_at_;}
void setLookAtPosition(const Vector3& look_at)
{ look_at_ = look_at; calculateVectors_();}
const Vector3& getLookUpVector() const
{ return look_up_vector_;}
void setLookUpVector(const Vector3& look_up_vector)
{ look_up_vector_ = look_up_vector; calculateVectors_();}
void rotateAboutView(float degree);
float getDistance() const
{ return view_point_.getDistance(look_at_);}
Vector3 getViewVector() const
{ return view_vector_;}
Vector3 getRightVector() const
{ return right_vector_;}
void translate(const Vector3& v);
Vector3 convertCameraToSceneCoordinates(const Vector3& v);
void rotate(const Quaternion& q, const Vector3& origin);
void rotate(const Matrix4x4& mat, const Vector3& origin);
virtual void clear()
{ *this = Camera();}
void setProjectionMode(ProjectionMode const& mode)
{ projection_mode_ = mode; }
ProjectionMode getProjectionMode() const
{ return projection_mode_; }
String toString() const;
bool readFromString(const String& data);
bool operator == (const Camera& camera) const;
bool operator < (const Camera& camera) const;
virtual void dump(std::ostream& s = std::cout, Size depth = 0) const;
protected:
//_
void calculateVectors_();
//_
Vector3 view_point_;
//_
Vector3 look_at_;
//_
Vector3 look_up_vector_;
/*_ The viewing vector.
Stored only for better performance in the scene.
*/
Vector3 view_vector_;
/*_ The orthogonal vector to the viewing vector, which is showing to the right.
Stored only for better performance in the scene.
*/
Vector3 right_vector_;
/* The projection mode used by this camera.
*/
ProjectionMode projection_mode_;
};
} // namespace VIEW
} // namespace BALL
#endif //BALL_VIEW_RENDERING_CAMERA_H
global.h
BALL_VIEW_EXPORT
#define BALL_VIEW_EXPORT
Definition COMMON/global.h:52
BALL::String
Definition string.h:57
BALL::TVector3::normalize
TVector3 & normalize()
Definition vector3.h:770
BALL::VIEW::Camera::view_vector_
Vector3 view_vector_
Definition camera.h:179
BALL::VIEW::Camera::dump
virtual void dump(std::ostream &s=std::cout, Size depth=0) const
BALL::VIEW::Camera::translate
void translate(const Vector3 &v)
Translate the view point and the point the camera is looking to by a given vector.
BALL::VIEW::Camera::toString
String toString() const
BALL::VIEW::Camera::look_at_
Vector3 look_at_
Definition camera.h:171
BALL::VIEW::Camera::Camera
Camera()
Constructor.
BALL::VIEW::Camera::setLookAtPosition
void setLookAtPosition(const Vector3 &look_at)
Set the direction of the camera.
Definition camera.h:86
BALL::VIEW::Camera::getViewPoint
const Vector3 & getViewPoint() const
Get the position of the camera.
Definition camera.h:74
BALL::VIEW::Camera::moveForward
void moveForward(float translation)
Move the camera along the view vector.
Definition camera.h:65
BALL::VIEW::Camera::Camera
Camera(const Vector3 &view_point, const Vector3 &look_at, const Vector3 &look_up_vector, const ProjectionMode &mode=PERSPECTIVE)
BALL::VIEW::Camera::Camera
Camera(const Camera &camera)
Copy Constructor.
BALL::VIEW::Camera::getLookAtPosition
const Vector3 & getLookAtPosition() const
Get the direction of the camera.
Definition camera.h:82
BALL::VIEW::Camera::right_vector_
Vector3 right_vector_
Definition camera.h:184
BALL::VIEW::Camera::getRightVector
Vector3 getRightVector() const
Get an vector orthogonal to the viewing vector and showing to the right.
Definition camera.h:109
BALL::VIEW::Camera::moveUp
void moveUp(float translation)
Move the camera along the up vector.
Definition camera.h:61
BALL::VIEW::Camera::convertCameraToSceneCoordinates
Vector3 convertCameraToSceneCoordinates(const Vector3 &v)
Convert the given vector from camera system to cartesian coordinates.
BALL::VIEW::Camera::setProjectionMode
void setProjectionMode(ProjectionMode const &mode)
Set the projection mode.
Definition camera.h:129
BALL::VIEW::Camera::rotateAboutView
void rotateAboutView(float degree)
Rotate up and right around the view vector.
BALL::VIEW::Camera::getProjectionMode
ProjectionMode getProjectionMode() const
Get the projection mode.
Definition camera.h:133
BALL::VIEW::Camera::ProjectionMode
ProjectionMode
Enumeration of different projection modes.
Definition camera.h:28
BALL::VIEW::Camera::ORTHOGRAPHIC
@ ORTHOGRAPHIC
Definition camera.h:30
BALL::VIEW::Camera::PERSPECTIVE
@ PERSPECTIVE
Definition camera.h:29
BALL::VIEW::Camera::calculateVectors_
void calculateVectors_()
BALL::VIEW::Camera::~Camera
virtual ~Camera()
Destructor.
Definition camera.h:46
BALL::VIEW::Camera::getDistance
float getDistance() const
Get the distance between the view point and the look at point.
Definition camera.h:101
BALL::VIEW::Camera::rotate
void rotate(const Matrix4x4 &mat, const Vector3 &origin)
Rotate the camera.
BALL::VIEW::Camera::view_point_
Vector3 view_point_
Definition camera.h:168
BALL::VIEW::Camera::getViewVector
Vector3 getViewVector() const
Get the view vector.
Definition camera.h:105
BALL::VIEW::Camera::getLookUpVector
const Vector3 & getLookUpVector() const
Get the look up vector.
Definition camera.h:90
BALL::VIEW::Camera::clear
virtual void clear()
Reset Camera to standard values.
Definition camera.h:125
BALL::VIEW::Camera::setLookUpVector
void setLookUpVector(const Vector3 &look_up_vector)
Set the look up vector and compute the new right vector.
Definition camera.h:94
BALL::VIEW::Camera::setViewPoint
void setViewPoint(const Vector3 &view_point)
Set the position of the camera.
Definition camera.h:78
BALL::VIEW::Camera::moveRight
void moveRight(float translation)
Move the camera along the right vector.
Definition camera.h:57
BALL::VIEW::Camera::readFromString
bool readFromString(const String &data)
BALL::VIEW::Camera::projection_mode_
ProjectionMode projection_mode_
Definition camera.h:188
BALL::VIEW::Camera::look_up_vector_
Vector3 look_up_vector_
Definition camera.h:174
BALL::VIEW::Camera::rotate
void rotate(const Quaternion &q, const Vector3 &origin)
Rotate the camera.
BALL::Matrix4x4
TMatrix4x4< float > Matrix4x4
Definition matrix44.h:2184
BALL::VIEW
Definition constraints.h:35
BALL
Definition constants.h:13
BALL::Size
BALL_SIZE_TYPE Size
Definition COMMON/global.h:114
BALL::Vector3
TVector3< float > Vector3
Definition vector3.h:1084
BALL::Quaternion
TQuaternion< float > Quaternion
Definition quaternion.h:626
quaternion.h
vector3.h