Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

Teddy::Scenes::Camera Class Reference

Camera. More...

#include <Camera.h>

Inheritance diagram for Teddy::Scenes::Camera:

Inheritance graph
[legend]
Collaboration diagram for Teddy::Scenes::Camera:

Collaboration graph
[legend]
List of all members.

Public Methods

 Camera (const std::string &name, Teddy::Scenes::Scene *scene)
 Camera constructor. More...

Teddy::Models::Model * pick (Teddy::PhysicalComponents::Projection *p, const Teddy::Maths::TVector2< int > &pos)
virtual void projectScene (Teddy::PhysicalComponents::Projection *p)
 Draw the scene as seen from the camera. More...

void setMirrorX (const bool mirror_x)
void setNearFar (const float near_clip, const float far_clip)
double getNear ()
double getFar ()
void setFov (const float fov)
 Set field of vision. More...

float getFov () const
 Return field of vision. More...

void modFov (const float mod)
void setScene (Teddy::Scenes::Scene *scene)
 Set Scene for camera. More...

Scene * getScene () const
 Return Scene of camera. More...

void updatePlanes ()
 Calculate view frustum planes. More...

bool cull (const Teddy::Models::Model &mi)
Teddy::Maths::Matrix getFrustumMatrix (const float left, const float right, const float bottom, const float top, const float nearval, const float farval) const
 Calculate frustum matrix. More...

Teddy::Maths::Matrix getPerspectiveMatrix (const float fovy, const float aspect, const float zNear, const float zFar) const
 Calculate perspective projection matrix. More...

Teddy::Maths::Matrix getPickMatrix (const Teddy::Maths::TVector2< int > &pos, const Teddy::Maths::TVector2< int > &size, const Teddy::Maths::TRect< int > &viewport) const
Teddy::Maths::TVector4< float > projectVector (const Teddy::Maths::TVector4< float > &v) const
void doProjection (Teddy::PhysicalComponents::Projection *p, const bool load_matrix=true)
 Calculate and apply perpective camera projection. More...

void doCamera (Teddy::PhysicalComponents::Projection *p, const bool load_matrix=true)
 Calculate and apply camera projection according to Projection. More...

void doObjectMatrix (Teddy::PhysicalComponents::Projection *p, const Teddy::Maths::Matrix &m, const bool load_matrix=true)
void pushObjectMatrix ()
void popObjectMatrix ()
void updateFrustum ()
bool cullPoint (const Teddy::Maths::TVector< float > &v) const
bool cullSphere (const Teddy::Maths::TVector< float > &v, const float radius) const
bool cullAABox (const Teddy::Maths::TVector< float > &pos, const Teddy::Maths::TVector< float > &size)

Protected Attributes

Teddy::Scenes::Scene * scene
 Scene to draw. More...

Teddy::PhysicalComponents::Projection * active_projection
 Last active projection where to draw. More...

Teddy::Maths::Matrix to_screen_s_matrix
 To screen space -matrix. More...

Teddy::Maths::Matrix view_matrix
 Current/latest view matrix. More...

Teddy::Maths::Matrix projection_matrix
 Current/latest projection matrix. More...

Teddy::Maths::Matrix model_view_matrix [MSD]
 ModelView Matrix stack. More...

Teddy::Maths::TRect< int > rect
Teddy::Maths::Plane view_plane [6]
 Camera view volume planes for clipping. More...

int model_view_matrix_sp
 ModelView Matrix stack pointer. More...

double near_clip
 Near clip plane z. More...

double far_clip
 Far clip plane z. More...

double fov
 Field of vision. More...

float frustum [6][4]
bool mirror_x
 Mirror X. More...

bool projection_dirty
 Projection needs to be redone? More...


Detailed Description

Camera.

Warning:
Starfield is not working
Cull method needs checking, it does not work with picking
Todo:
docs

GL_EXT_ cull_vertex

Definition at line 60 of file Camera.h.


Constructor & Destructor Documentation

Teddy::Scenes::Camera::Camera (  const std::string &    name,
Teddy::Scenes::Scene *    scene
) 
 

Camera constructor.

Parameters:
name  Name for the Camera
scene  Scene which to view through this Camera

Definition at line 50 of file Camera.cpp.

References active_projection, mirror_x, model_view_matrix, model_view_matrix_sp, MSD, and projection_dirty.


Member Function Documentation

bool Teddy::Scenes::Camera::cull (  const Teddy::Models::Model &    mi ) 
 

bool Teddy::Scenes::Camera::cullAABox (  const Teddy::Maths::TVector< float > &    pos,
const Teddy::Maths::TVector< float > &    size
) 
 

bool Teddy::Scenes::Camera::cullPoint (  const Teddy::Maths::TVector< float > &    v )  const
 

bool Teddy::Scenes::Camera::cullSphere (  const Teddy::Maths::TVector< float > &    v,
const float    radius
)  const
 

void Teddy::Scenes::Camera::doCamera (  Teddy::PhysicalComponents::Projection *    p,
const bool    load_matrix = true
) 
 

Calculate and apply camera projection according to Projection.

Parameters:
p  Projection to which this Camera will project it's scene
load_matrix  If true, the camera matrix is loaded to OpenGL
Warning:
This might not be thread safe

Definition at line 96 of file Camera.cpp.

References Teddy::Models::Model::getWorldToLocalMatrix, and view_matrix.

Referenced by projectScene.

void Teddy::Scenes::Camera::doObjectMatrix (  Teddy::PhysicalComponents::Projection *    p,
const Teddy::Maths::Matrix &    m,
const bool    load_matrix = true
) 
 

void Teddy::Scenes::Camera::doProjection (  Teddy::PhysicalComponents::Projection *    p,
const bool    load_matrix = true
) 
 

Calculate and apply perpective camera projection.

Todo:
Optimize: This does not need to be recalculted always

Definition at line 77 of file Camera.cpp.

References far_clip, fov, getPerspectiveMatrix, near_clip, projection_matrix, and updatePlanes.

Referenced by projectScene.

double Teddy::Scenes::Camera::getFar (    ) 
 

Definition at line 190 of file Camera.cpp.

References far_clip.

float Teddy::Scenes::Camera::getFov (    )  const
 

Return field of vision.

Definition at line 207 of file Camera.cpp.

References fov.

Matrix Teddy::Scenes::Camera::getFrustumMatrix (  const float    left,
const float    right,
const float    bottom,
const float    top,
const float    nearval,
const float    farval
)  const
 

Calculate frustum matrix.

Definition at line 258 of file Camera.cpp.

Referenced by getPerspectiveMatrix.

double Teddy::Scenes::Camera::getNear (    ) 
 

Definition at line 185 of file Camera.cpp.

References near_clip.

Matrix Teddy::Scenes::Camera::getPerspectiveMatrix (  const float    fovy,
const float    aspect,
const float    zNear,
const float    zFar
)  const
 

Calculate perspective projection matrix.

Definition at line 281 of file Camera.cpp.

References getFrustumMatrix, and M_PI.

Referenced by doProjection.

Teddy::Maths::Matrix Teddy::Scenes::Camera::getPickMatrix (  const Teddy::Maths::TVector2< int > &    pos,
const Teddy::Maths::TVector2< int > &    size,
const Teddy::Maths::TRect< int > &    viewport
)  const
 

Scene * Teddy::Scenes::Camera::getScene (    )  const
 

Return Scene of camera.

Definition at line 219 of file Camera.cpp.

References scene.

void Teddy::Scenes::Camera::modFov (  const float    mod ) 
 

Definition at line 201 of file Camera.cpp.

References fov.

Teddy::Models::Model* Teddy::Scenes::Camera::pick (  Teddy::PhysicalComponents::Projection *    p,
const Teddy::Maths::TVector2< int > &    pos
) 
 

void Teddy::Scenes::Camera::popObjectMatrix (    ) 
 

Definition at line 112 of file Camera.cpp.

References model_view_matrix_sp.

void Teddy::Scenes::Camera::projectScene (  Teddy::PhysicalComponents::Projection *    p )  [virtual]
 

Draw the scene as seen from the camera.

Definition at line 139 of file Camera.cpp.

References active_projection, doCamera, doProjection, Teddy::Scenes::Scene::draw, IntRect, Teddy::MixIn::Mutex::lock, rect, scene, and Teddy::MixIn::Mutex::unlock.

Teddy::Maths::TVector4<float> Teddy::Scenes::Camera::projectVector (  const Teddy::Maths::TVector4< float > &    v )  const
 

void Teddy::Scenes::Camera::pushObjectMatrix (    ) 
 

Definition at line 107 of file Camera.cpp.

References model_view_matrix_sp.

void Teddy::Scenes::Camera::setFov (  const float    fov ) 
 

Set field of vision.

Definition at line 196 of file Camera.cpp.

References fov.

void Teddy::Scenes::Camera::setMirrorX (  const bool    mirror_x ) 
 

Definition at line 68 of file Camera.cpp.

References Teddy::SysSupport::M_INIT, mirror_x, and Teddy::SysSupport::msg.

void Teddy::Scenes::Camera::setNearFar (  const float    near_clip,
const float    far_clip
) 
 

Definition at line 179 of file Camera.cpp.

References far_clip, and near_clip.

void Teddy::Scenes::Camera::setScene (  Teddy::Scenes::Scene *    scene ) 
 

Set Scene for camera.

Definition at line 213 of file Camera.cpp.

References scene.

void Teddy::Scenes::Camera::updateFrustum (    ) 
 

Definition at line 353 of file Camera.cpp.

References frustum.

void Teddy::Scenes::Camera::updatePlanes (    ) 
 

Calculate view frustum planes.

Definition at line 329 of file Camera.cpp.

References projection_matrix, Teddy::Maths::Matrix::transpose, Vector4, and view_plane.

Referenced by doProjection.


Member Data Documentation

Teddy::PhysicalComponents::Projection* Teddy::Scenes::Camera::active_projection [protected]
 

Last active projection where to draw.

Definition at line 105 of file Camera.h.

Referenced by Camera, and projectScene.

double Teddy::Scenes::Camera::far_clip [protected]
 

Far clip plane z.

Definition at line 114 of file Camera.h.

Referenced by doProjection, getFar, and setNearFar.

double Teddy::Scenes::Camera::fov [protected]
 

Field of vision.

Definition at line 115 of file Camera.h.

Referenced by doProjection, getFov, modFov, and setFov.

float Teddy::Scenes::Camera::frustum[6][4] [protected]
 

Definition at line 116 of file Camera.h.

Referenced by updateFrustum.

bool Teddy::Scenes::Camera::mirror_x [protected]
 

Mirror X.

Definition at line 117 of file Camera.h.

Referenced by Camera, and setMirrorX.

Teddy::Maths::Matrix Teddy::Scenes::Camera::model_view_matrix[MSD] [protected]
 

ModelView Matrix stack.

Definition at line 109 of file Camera.h.

Referenced by Camera.

int Teddy::Scenes::Camera::model_view_matrix_sp [protected]
 

ModelView Matrix stack pointer.

Definition at line 112 of file Camera.h.

Referenced by Camera, popObjectMatrix, and pushObjectMatrix.

double Teddy::Scenes::Camera::near_clip [protected]
 

Near clip plane z.

Definition at line 113 of file Camera.h.

Referenced by doProjection, getNear, and setNearFar.

bool Teddy::Scenes::Camera::projection_dirty [protected]
 

Projection needs to be redone?

Definition at line 118 of file Camera.h.

Referenced by Camera.

Teddy::Maths::Matrix Teddy::Scenes::Camera::projection_matrix [protected]
 

Current/latest projection matrix.

Definition at line 108 of file Camera.h.

Referenced by doProjection, and updatePlanes.

Teddy::Maths::TRect<int> Teddy::Scenes::Camera::rect [protected]
 

Definition at line 110 of file Camera.h.

Referenced by projectScene.

Teddy::Scenes::Scene* Teddy::Scenes::Camera::scene [protected]
 

Scene to draw.

Definition at line 104 of file Camera.h.

Referenced by getScene, projectScene, and setScene.

Teddy::Maths::Matrix Teddy::Scenes::Camera::to_screen_s_matrix [protected]
 

To screen space -matrix.

Definition at line 106 of file Camera.h.

Teddy::Maths::Matrix Teddy::Scenes::Camera::view_matrix [protected]
 

Current/latest view matrix.

Definition at line 107 of file Camera.h.

Referenced by doCamera.

Teddy::Maths::Plane Teddy::Scenes::Camera::view_plane[6] [protected]
 

Camera view volume planes for clipping.

Definition at line 111 of file Camera.h.

Referenced by updatePlanes.


The documentation for this class was generated from the following files: