Home | Namespaces | Hierarchy | Alphabetical List | Class list | Files | Namespace Members | Class members | File members
Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes
render::Camera Class Reference

A viewpoint from which the scene will be rendered. More...

#include <Camera.h>

Inheritance diagram for render::Camera:
scene::Node engine::Object

List of all members.

Public Member Functions

 Camera ()
 Camera (const std::string &name)
f32 getAspectRatio ()
 Retrieves the current aspect ratio.
SceneDetailLevel getDetailLevel ()
 Retrieves the level of detail that the camera will render.
f32 getFarClipDistance ()
 Retrieves the distance from the camera to the far clipping plane.
f32 getFOV ()
 Retrieves the cameras Y-dimension Field Of View (FOV).
FrustumgetFrustum () const
 get the frustum of this camera.
f32 getNearClipDistance ()
 Sets the position of the near clipping plane.
const core::matrix4getProjectionMatrix ()
const core::matrix4getProjectionMatrixRS ()
 Gets the projection matrix for this frustum adjusted for the current rendersystem specifics.
ProjectionType getProjectionType ()
 Retrieves info on the type of projection used (orthographic or perspective).
const core::matrix4getViewMatrix ()
 Gets the view matrix for this camera.
void lookAt (const core::vector3d &targetPoint)
void lookAt (f32 x, f32 y, f32 z)
void rotate (const core::quaternion &q, scene::TransformSpace relativeTo=scene::TS_LOCAL)
void rotate (const f32 &degrees, const core::vector3d &axis, scene::TransformSpace relativeTo=scene::TS_LOCAL)
void rotateX (f32 degrees, scene::TransformSpace relativeTo=scene::TS_LOCAL)
void rotateY (f32 degrees, scene::TransformSpace relativeTo=scene::TS_LOCAL)
void rotateZ (f32 degrees, scene::TransformSpace relativeTo=scene::TS_LOCAL)
void setAspectRatio (f32 ratio)
void setDetailLevel (SceneDetailLevel sd)
 Sets the level of rendering detail required from this camera.
void setDirection (f32 x, f32 y, f32 z)
void setDirection (const core::vector3d &vec)
 Sets the camera's direction vector.
void setFarClipDistance (f32 farDist)
 Sets the distance to the far clipping plane.
void setFixedUpAxis (bool useFixed, const core::vector3d &fixedAxis=core::vector3d::UNIT_Y)
void setFOV (f32 fov)
void setNearClipDistance (f32 nearDist)
void setProjectionType (ProjectionType pt)
 Sets the type of projection to use (orthographic or perspective). Default is perspective.
 ~Camera ()

Protected Member Functions

void initProperties ()
void updateFrustum ()
void updateImpl (f32 elapsedTime)
void updateProjection ()
void updateView ()

Protected Attributes

f32 mAspect
f32 mFarDist
bool mFixedUp
core::vector3d mFixedUpAxis
f32 mFOV
FrustummFrustum
bool mModifiedProjection
bool mModifiedView
f32 mNearDist
core::matrix4 mProjMatrix
core::matrix4 mProjMatrixRS
ProjectionType mProjType
SceneDetailLevel mSceneDetail
core::matrix4 mViewMatrix

Static Protected Attributes

static u32 msNextGeneratedCameraIndex = 0

Detailed Description

A viewpoint from which the scene will be rendered.

K_Game renders scenes from a camera viewpoint into a buffer of some sort, normally a window or a texture (a subclass of RenderTarget). K_Game cameras support both perspective projection (the default, meaning objects get smaller the further away they are) and orthographic projection (blueprint-style, no decrease in size with distance). In addition, more than one camera can point at a single render target if required, each rendering to a subset of the target, allowing split screen and picture-in-picture views. Cameras maintain their own aspect ratios, field of view, and frustum, and project co-ordinates into a space measured from -1 to 1 in x and y, and 0 to 1 in z. At render time, the camera will be rendering to a Viewport which will translate these parametric co-ordinates into real screen co-ordinates. Obviously it is advisable that the viewport has the same aspect ratio as the camera to avoid distortion (unless you want it!).


Constructor & Destructor Documentation

render::Camera::Camera ( )
render::Camera::Camera ( const std::string &  name)
render::Camera::~Camera ( )

References mFrustum.


Member Function Documentation

f32 render::Camera::getAspectRatio ( )

Retrieves the current aspect ratio.

References mAspect.

SceneDetailLevel render::Camera::getDetailLevel ( )

Retrieves the level of detail that the camera will render.

References mSceneDetail.

f32 render::Camera::getFarClipDistance ( )

Retrieves the distance from the camera to the far clipping plane.

References mFarDist.

f32 render::Camera::getFOV ( )

Retrieves the cameras Y-dimension Field Of View (FOV).

References mFOV.

Frustum * render::Camera::getFrustum ( ) const
f32 render::Camera::getNearClipDistance ( )

Sets the position of the near clipping plane.

References mNearDist.

Referenced by render::RenderManager::renderSingleOverlay(), and render::RenderManager::renderVisibleOverlays().

const core::matrix4 & render::Camera::getProjectionMatrix ( )

Gets the projection matrix for this camera. The projection matrix which conforms to standard right-handed rules and uses depth range [-1,+1].

References mProjMatrix.

const core::matrix4 & render::Camera::getProjectionMatrixRS ( )

Gets the projection matrix for this frustum adjusted for the current rendersystem specifics.

References mProjMatrixRS.

Referenced by render::ShaderParamData::getProjectionMatrix(), and render::RenderManager::render().

ProjectionType render::Camera::getProjectionType ( )

Retrieves info on the type of projection used (orthographic or perspective).

References mProjType.

const core::matrix4 & render::Camera::getViewMatrix ( )

Gets the view matrix for this camera.

References mViewMatrix.

Referenced by render::ShaderParamData::getViewMatrix(), and render::RenderManager::render().

void render::Camera::initProperties ( ) [protected]
void render::Camera::lookAt ( const core::vector3d targetPoint)

Points the camera at a location in world-space. This is a helper method to automatically generate the direction vector for the camera, based on it's current position and the supplied look-at point.

Parameters:
targetPointA vector specifying the look at point.

References scene::Node::mPosition, and setDirection().

Referenced by lookAt().

void render::Camera::lookAt ( f32  x,
f32  y,
f32  z 
)

Points the camera at a location in world-space. This is a helper method to automatically generate the direction vector for the camera, based on it's current position and the supplied look-at point.

Parameters:
x,y,zCo-ordinates of the point to look at.

References lookAt().

void render::Camera::rotate ( const core::quaternion q,
scene::TransformSpace  relativeTo = scene::TS_LOCAL 
) [virtual]
void render::Camera::rotate ( const f32 degrees,
const core::vector3d axis,
scene::TransformSpace  relativeTo = scene::TS_LOCAL 
) [virtual]

Reimplemented from scene::Node.

References core::quaternion::fromDegreeAxis(), and rotate().

void render::Camera::rotateX ( f32  degrees,
scene::TransformSpace  relativeTo = scene::TS_LOCAL 
) [virtual]
void render::Camera::rotateY ( f32  degrees,
scene::TransformSpace  relativeTo = scene::TS_LOCAL 
) [virtual]
void render::Camera::rotateZ ( f32  degrees,
scene::TransformSpace  relativeTo = scene::TS_LOCAL 
) [virtual]
void render::Camera::setAspectRatio ( f32  ratio)

Sets the aspect ratio for the camera viewport. The ratio between the x and y dimensions of the rectangular area visible through the camera is known as aspect ratio: aspect = width / height . The default for most fullscreen windows is 1.3333 - this is also assumed by Ogre unless you use this method to state otherwise.

References mAspect, and mModifiedProjection.

Referenced by render::Viewport::updateDimensions().

void render::Camera::setDetailLevel ( SceneDetailLevel  sd)

Sets the level of rendering detail required from this camera.

Each camera is set to render at full detail by default, that is with full texturing, lighting etc. This method lets you change that behavior, allowing you to make the camera just render a wireframe view, for example.

References mSceneDetail.

void render::Camera::setDirection ( const core::vector3d vec)
void render::Camera::setDirection ( f32  x,
f32  y,
f32  z 
)

Sets the camera's direction vector. The autoGenerateUp parameter determines whether the 'up' vector for the camera will automatically be recalculated based on the current 'up' vector (i.e. the roll will remain the same). Change to false if you know the up hasn't changed (e.g. a yaw).

Referenced by lookAt().

void render::Camera::setFarClipDistance ( f32  farDist)

Sets the distance to the far clipping plane.

The view frustum is a pyramid created from the camera position and the edges of the viewport. This frustum does not extend to infinity - it is cropped near to the camera and there is a far plane beyond which nothing is displayed. This method sets the distance for the far plane. Different applications need different values: e.g. a flight sim needs a much further far clipping plane than a first-person shooter. An important point here is that the larger the gap between near and far clipping planes, the lower the accuracy of the Z-buffer used to depth-cue pixels. This is because the Z-range is limited to the size of the Z buffer (16 or 32-bit) and the max values must be spread over the gap between near and far clip planes. The bigger the range, the more the Z values will be approximated which can cause artifacts when lots of objects are close together in the Z-plane. So make sure you clip as close to the camera as you can - don't set a huge value for the sake of it.

Parameters:
farDist,:The distance to the far clipping plane from the camera in world coordinates.

References mFarDist.

void render::Camera::setFixedUpAxis ( bool  useFixed,
const core::vector3d fixedAxis = core::vector3d::UNIT_Y 
)

References mFixedUp, and mFixedUpAxis.

void render::Camera::setFOV ( f32  fov)

Sets the Y-dimension Field Of View (FOV) of the camera. Field Of View (FOV) is the angle made between the camera's position, and the left & right edges of the 'screen' onto which the scene is projected. High values (90+) result in a wide-angle, fish-eye kind of view, low values (30-) in a stretched, telescopic kind of view. Typical values are between 45 and 60.
This value represents the HORIZONTAL field-of-view. The vertical field of view is calculated from this depending on the dimensions of the viewport (they will only be the same if the viewport is square).

References mFOV, and mModifiedProjection.

void render::Camera::setNearClipDistance ( f32  nearDist)

Sets the position of the near clipping plane. The position of the near clipping plane is the distance from the cameras position to the screen on which the world is projected. The near plane distance, combined with the field-of-view and the aspect ratio, determines the size of the viewport through which the world is viewed (in world co-ordinates). Note that this world viewport is different to a screen viewport, which has it's dimensions expressed in pixels. The cameras viewport should have the same aspect ratio as the screen viewport it renders into to avoid distortion.

Parameters:
nearDist,:The distance to the near clipping plane from the camera in world coordinates.

References mModifiedProjection, and mNearDist.

void render::Camera::setProjectionType ( ProjectionType  pt)

Sets the type of projection to use (orthographic or perspective). Default is perspective.

References mModifiedProjection, and mProjType.

void render::Camera::updateFrustum ( ) [protected]
void render::Camera::updateImpl ( f32  elapsedTime) [protected, virtual]
void render::Camera::updateProjection ( ) [protected]
void render::Camera::updateView ( ) [protected]

Member Data Documentation

bool render::Camera::mFixedUp [protected]

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

The KG Game Engine
The KG Game Engine Documentation © 2006-2011 by Kat'Oun. Generated on Sat Jul 2 2011 00:50:08 by Doxygen (1.7.4)