Home | Namespaces | Hierarchy | Alphabetical List | Class list | Files | Namespace Members | Class members | File members |
A viewpoint from which the scene will be rendered. More...
#include <Camera.h>
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). | |
Frustum * | getFrustum () const |
get the frustum of this camera. | |
f32 | getNearClipDistance () |
Sets the position of the near clipping plane. | |
const core::matrix4 & | getProjectionMatrix () |
const core::matrix4 & | getProjectionMatrixRS () |
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::matrix4 & | getViewMatrix () |
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 °rees, 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 |
Frustum * | mFrustum |
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 |
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!).
render::Camera::Camera | ( | ) |
References initProperties(), scene::Node::mNodeType, and scene::NT_CAMERA.
render::Camera::Camera | ( | const std::string & | name | ) |
References initProperties(), scene::Node::mNodeType, and scene::NT_CAMERA.
render::Camera::~Camera | ( | ) |
References mFrustum.
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 |
get the frustum of this camera.
References mFrustum.
Referenced by render::RenderManager::findLightsAffectingFrustum(), and render::RenderManager::findVisibleRenderables().
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] |
Reimplemented from scene::Node.
References mAspect, mFarDist, mFixedUp, mFixedUpAxis, mFOV, mFrustum, mModifiedProjection, mModifiedView, mNearDist, mProjMatrix, mProjMatrixRS, mProjType, mSceneDetail, mViewMatrix, render::PT_PERSPECTIVE, render::SDL_TEXTURED, core::vector3d::UNIT_Y, and core::matrix4::ZERO.
Referenced by Camera().
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.
targetPoint | A vector specifying the look at point. |
References scene::Node::mPosition, and setDirection().
Referenced by lookAt().
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.
x,y,z | Co-ordinates of the point to look at. |
References lookAt().
void render::Camera::rotate | ( | const core::quaternion & | q, |
scene::TransformSpace | relativeTo = scene::TS_LOCAL |
||
) | [virtual] |
Reimplemented from scene::Node.
References scene::Node::getAbsoluteOrientation(), core::quaternion::getInverse(), scene::Node::mModifiedAbsoluteTransform, scene::Node::mOrientation, scene::TS_LOCAL, scene::TS_PARENT, and scene::TS_WORLD.
Referenced by rotate(), rotateX(), rotateY(), and rotateZ().
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] |
Reimplemented from scene::Node.
References scene::Node::mOrientation, rotate(), and core::vector3d::UNIT_X.
void render::Camera::rotateY | ( | f32 | degrees, |
scene::TransformSpace | relativeTo = scene::TS_LOCAL |
||
) | [virtual] |
Reimplemented from scene::Node.
References mFixedUp, mFixedUpAxis, scene::Node::mOrientation, rotate(), and core::vector3d::UNIT_Y.
void render::Camera::rotateZ | ( | f32 | degrees, |
scene::TransformSpace | relativeTo = scene::TS_LOCAL |
||
) | [virtual] |
Reimplemented from scene::Node.
References scene::Node::mOrientation, rotate(), and core::vector3d::UNIT_Z.
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 | ) |
Sets the camera's direction vector.
References core::vector3d::crossProduct(), core::vector3d::dotProduct(), core::quaternion::fromAngleAxis(), core::quaternion::fromRotationMatrix(), core::quaternion::IDENTITY, mFixedUp, mFixedUpAxis, scene::Node::mModifiedAbsoluteTransform, scene::Node::mOrientation, core::vector3d::normalize(), core::vector3d::ORIGIN_3D, core::PI, core::sqrt(), core::vector3d::UNIT_X, core::vector3d::UNIT_Y, core::vector3d::UNIT_Z, updateView(), core::quaternion::W, core::quaternion::X, core::vector3d::X, core::quaternion::Y, core::vector3d::Y, core::quaternion::Z, and core::vector3d::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.
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.
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] |
References render::Frustum::buildViewFrustum(), mAspect, mFarDist, mFOV, mFrustum, mNearDist, mProjMatrix, mProjType, and mViewMatrix.
Referenced by updateImpl().
void render::Camera::updateImpl | ( | f32 | elapsedTime | ) | [protected, virtual] |
Reimplemented from scene::Node.
References scene::Node::mModifiedAbsoluteTransform, mModifiedView, updateFrustum(), updateProjection(), and updateView().
void render::Camera::updateProjection | ( | ) | [protected] |
References core::matrix4::buildProjectionMatrixInfinitePerspectiveFov(), core::matrix4::buildProjectionMatrixOrtho(), core::matrix4::buildProjectionMatrixPerspectiveFov(), render::RenderManager::convertProjectionMatrix(), core::DEGTORAD, render::RenderManager::getInstance(), mAspect, mFarDist, mFOV, mModifiedProjection, mNearDist, mProjMatrix, mProjMatrixRS, mProjType, render::PT_ORTHOGRAPHIC, render::PT_PERSPECTIVE, and core::sin().
Referenced by updateImpl().
void render::Camera::updateView | ( | ) | [protected] |
f32 render::Camera::mAspect [protected] |
Referenced by getAspectRatio(), initProperties(), setAspectRatio(), updateFrustum(), and updateProjection().
f32 render::Camera::mFarDist [protected] |
Referenced by getFarClipDistance(), initProperties(), setFarClipDistance(), updateFrustum(), and updateProjection().
bool render::Camera::mFixedUp [protected] |
Referenced by initProperties(), rotateY(), setDirection(), and setFixedUpAxis().
core::vector3d render::Camera::mFixedUpAxis [protected] |
Referenced by initProperties(), rotateY(), setDirection(), and setFixedUpAxis().
f32 render::Camera::mFOV [protected] |
Referenced by getFOV(), initProperties(), setFOV(), updateFrustum(), and updateProjection().
Frustum* render::Camera::mFrustum [protected] |
Referenced by getFrustum(), initProperties(), updateFrustum(), and ~Camera().
bool render::Camera::mModifiedProjection [protected] |
Referenced by initProperties(), setAspectRatio(), setFOV(), setNearClipDistance(), setProjectionType(), and updateProjection().
bool render::Camera::mModifiedView [protected] |
Referenced by initProperties(), updateImpl(), and updateView().
f32 render::Camera::mNearDist [protected] |
Referenced by getNearClipDistance(), initProperties(), setNearClipDistance(), updateFrustum(), and updateProjection().
core::matrix4 render::Camera::mProjMatrix [protected] |
Referenced by getProjectionMatrix(), initProperties(), updateFrustum(), and updateProjection().
core::matrix4 render::Camera::mProjMatrixRS [protected] |
Referenced by getProjectionMatrixRS(), initProperties(), and updateProjection().
ProjectionType render::Camera::mProjType [protected] |
Referenced by getProjectionType(), initProperties(), setProjectionType(), updateFrustum(), and updateProjection().
SceneDetailLevel render::Camera::mSceneDetail [protected] |
Referenced by getDetailLevel(), initProperties(), and setDetailLevel().
u32 render::Camera::msNextGeneratedCameraIndex = 0 [static, protected] |
core::matrix4 render::Camera::mViewMatrix [protected] |
Referenced by getViewMatrix(), initProperties(), updateFrustum(), and updateView().
The KG Game Engine
Documentation © 2006-2011 by Kat'Oun. Generated on Sat Jul 2 2011 00:50:08 by
Doxygen
(1.7.4)
|