OgreCamera.h
Go to the documentation of this file.
/*
-----------------------------------------------------------------------------
This source file is part of OGRE
(Object-oriented Graphics Rendering Engine)
For the latest info, see http://www.ogre3d.org
Copyright (c) 2000-2013 Torus Knot Software Ltd
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-----------------------------------------------------------------------------
*/
#ifndef __Camera_H__
#define __Camera_H__
// Default options
#include "OgrePrerequisites.h"
#include "OgreString.h"
#include "OgreMovableObject.h"
// Matrices & Vectors
#include "OgreMatrix4.h"
#include "OgreVector3.h"
#include "OgrePlane.h"
#include "OgreQuaternion.h"
#include "OgreCommon.h"
#include "OgreFrustum.h"
#include "OgreRay.h"
#include "OgrePlaneBoundedVolume.h"
#include "OgreHeaderPrefix.h"
namespace Ogre {
class _OgreExport Camera : public Frustum
{
public:
class _OgreExport Listener
{
public:
Listener() {}
virtual ~Listener() {}
virtual void cameraPreRenderScene(Camera* cam)
{ (void)cam; }
virtual void cameraPostRenderScene(Camera* cam)
{ (void)cam; }
virtual void cameraDestroyed(Camera* cam)
{ (void)cam; }
};
protected:
SceneManager *mSceneMgr;
Quaternion mOrientation;
Vector3 mPosition;
mutable Quaternion mDerivedOrientation;
mutable Vector3 mDerivedPosition;
mutable Quaternion mRealOrientation;
mutable Vector3 mRealPosition;
bool mYawFixed;
Vector3 mYawFixedAxis;
PolygonMode mSceneDetail;
unsigned int mVisFacesLastRender;
unsigned int mVisBatchesLastRender;
static String msMovableType;
SceneNode* mAutoTrackTarget;
Vector3 mAutoTrackOffset;
Real mSceneLodFactor;
Real mSceneLodFactorInv;
Real mWLeft, mWTop, mWRight, mWBottom;
bool mWindowSet;
mutable vector<Plane>::type mWindowClipPlanes;
mutable bool mRecalcWindow;
Viewport* mLastViewport;
bool mAutoAspectRatio;
Frustum *mCullFrustum;
bool mUseRenderingDistance;
const Camera* mLodCamera;
bool mUseMinPixelSize;
Real mPixelDisplayRatio;
typedef vector<Listener*>::type ListenerList;
ListenerList mListeners;
// Internal functions for calcs
bool isViewOutOfDate(void) const;
void invalidateFrustum(void) const;
void invalidateView(void) const;
virtual void setWindowImpl(void) const;
virtual vector<Vector4>::type getRayForwardIntersect(const Vector3& anchor, const Vector3 *dir, Real planeOffset) const;
public:
Camera( const String& name, SceneManager* sm);
virtual ~Camera();
virtual void addListener(Listener* l);
virtual void removeListener(Listener* l);
SceneManager* getSceneManager(void) const;
void setPolygonMode(PolygonMode sd);
PolygonMode getPolygonMode(void) const;
void setPosition(Real x, Real y, Real z);
void setPosition(const Vector3& vec);
const Vector3& getPosition(void) const;
void move(const Vector3& vec);
void moveRelative(const Vector3& vec);
void setDirection(Real x, Real y, Real z);
void setDirection(const Vector3& vec);
Vector3 getDirection(void) const;
Vector3 getUp(void) const;
Vector3 getRight(void) const;
void lookAt( const Vector3& targetPoint );
void lookAt(Real x, Real y, Real z);
void roll(const Radian& angle);
void yaw(const Radian& angle);
void pitch(const Radian& angle);
void rotate(const Vector3& axis, const Radian& angle);
void rotate(const Quaternion& q);
void setFixedYawAxis( bool useFixed, const Vector3& fixedAxis = Vector3::UNIT_Y );
const Quaternion& getOrientation(void) const;
void setOrientation(const Quaternion& q);
void _renderScene(Viewport *vp, bool includeOverlays);
_OgreExport friend std::ostream& operator<<(std::ostream& o, const Camera& c);
void _notifyRenderedFaces(unsigned int numfaces);
void _notifyRenderedBatches(unsigned int numbatches);
unsigned int _getNumRenderedFaces(void) const;
unsigned int _getNumRenderedBatches(void) const;
const Quaternion& getDerivedOrientation(void) const;
const Vector3& getDerivedPosition(void) const;
Vector3 getDerivedDirection(void) const;
Vector3 getDerivedUp(void) const;
Vector3 getDerivedRight(void) const;
const Quaternion& getRealOrientation(void) const;
const Vector3& getRealPosition(void) const;
Vector3 getRealDirection(void) const;
Vector3 getRealUp(void) const;
Vector3 getRealRight(void) const;
void getWorldTransforms(Matrix4* mat) const;
const String& getMovableType(void) const;
void setAutoTracking(bool enabled, SceneNode* const target = 0,
const Vector3& offset = Vector3::ZERO);
void setLodBias(Real factor = 1.0);
Real getLodBias(void) const;
virtual void setLodCamera(const Camera* lodCam);
virtual const Camera* getLodCamera() const;
Ray getCameraToViewportRay(Real screenx, Real screeny) const;
void getCameraToViewportRay(Real screenx, Real screeny, Ray* outRay) const;
PlaneBoundedVolume getCameraToViewportBoxVolume(Real screenLeft,
Real screenTop, Real screenRight, Real screenBottom, bool includeFarPlane = false);
void getCameraToViewportBoxVolume(Real screenLeft,
Real screenTop, Real screenRight, Real screenBottom,
PlaneBoundedVolume* outVolume, bool includeFarPlane = false);
Real _getLodBiasInverse(void) const;
void _autoTrack(void);
virtual void setWindow (Real left, Real top, Real right, Real bottom);
virtual void resetWindow (void);
virtual bool isWindowSet(void) const { return mWindowSet; }
const vector<Plane>::type& getWindowPlanes(void) const;
Real getBoundingRadius(void) const;
SceneNode* getAutoTrackTarget(void) const { return mAutoTrackTarget; }
const Vector3& getAutoTrackOffset(void) const { return mAutoTrackOffset; }
Viewport* getViewport(void) const {return mLastViewport;}
void _notifyViewport(Viewport* viewport) {mLastViewport = viewport;}
void setAutoAspectRatio(bool autoratio);
bool getAutoAspectRatio(void) const;
void setCullingFrustum(Frustum* frustum) { mCullFrustum = frustum; }
Frustum* getCullingFrustum(void) const { return mCullFrustum; }
virtual void forwardIntersect(const Plane& worldPlane, vector<Vector4>::type* intersect3d) const;
bool isVisible(const AxisAlignedBox& bound, FrustumPlane* culledBy = 0) const;
bool isVisible(const Sphere& bound, FrustumPlane* culledBy = 0) const;
bool isVisible(const Vector3& vert, FrustumPlane* culledBy = 0) const;
const Vector3* getWorldSpaceCorners(void) const;
const Plane& getFrustumPlane( unsigned short plane ) const;
bool projectSphere(const Sphere& sphere,
Real* left, Real* top, Real* right, Real* bottom) const;
Real getNearClipDistance(void) const;
Real getFarClipDistance(void) const;
const Matrix4& getViewMatrix(void) const;
const Matrix4& getViewMatrix(bool ownFrustumOnly) const;
virtual void setUseRenderingDistance(bool use) { mUseRenderingDistance = use; }
virtual bool getUseRenderingDistance(void) const { return mUseRenderingDistance; }
virtual void synchroniseBaseSettingsWith(const Camera* cam);
const Vector3& getPositionForViewUpdate(void) const;
const Quaternion& getOrientationForViewUpdate(void) const;
void setUseMinPixelSize(bool enable) { mUseMinPixelSize = enable; }
bool getUseMinPixelSize() const { return mUseMinPixelSize; }
Real getPixelDisplayRatio() const { return mPixelDisplayRatio; }
};
} // namespace Ogre
#include "OgreHeaderSuffix.h"
#endif // __Camera_H__
Ogre::Camera::mSceneLodFactorInv
Real mSceneLodFactorInv
Inverted scene LOD factor, can be used by Renderables to adjust their LOD.
Definition: OgreCamera.h:153
Ogre::Camera::mRecalcWindow
bool mRecalcWindow
Was viewing window changed.
Definition: OgreCamera.h:166
Ogre::Camera::Listener::cameraPostRenderScene
virtual void cameraPostRenderScene(Camera *cam)
Called after the scene has been rendered with this camera.
Definition: OgreCamera.h:102
Ogre::Camera::getCullingFrustum
Frustum * getCullingFrustum(void) const
Returns the custom culling frustum in use.
Definition: OgreCamera.h:593
Ogre::Camera::mPixelDisplayRatio
Real mPixelDisplayRatio
Definition: OgreCamera.h:183
Ogre::Camera::getUseRenderingDistance
virtual bool getUseRenderingDistance(void) const
Get whether this camera should use the &#39;rendering distance&#39; on objects to exclude distant objects fro...
Definition: OgreCamera.h:638
Ogre::Camera::ListenerList
vector< Listener * >::type ListenerList
Definition: OgreCamera.h:185
Ogre::Camera::mCullFrustum
Frustum * mCullFrustum
Custom culling frustum.
Definition: OgreCamera.h:174
Ogre::Camera::mOrientation
Quaternion mOrientation
Camera orientation, quaternion style.
Definition: OgreCamera.h:115
OgreQuaternion.h
OgreVector3.h
_OgreExport
#define _OgreExport
Definition: OgrePlatform.h:257
Ogre::Camera::setUseRenderingDistance
virtual void setUseRenderingDistance(bool use)
Set whether this camera should use the &#39;rendering distance&#39; on objects to exclude distant objects fro...
Definition: OgreCamera.h:634
Ogre::Camera::Listener::~Listener
virtual ~Listener()
Definition: OgreCamera.h:95
Ogre::Camera::mVisFacesLastRender
unsigned int mVisFacesLastRender
Stored number of visible faces in the last render.
Definition: OgreCamera.h:137
OgreMovableObject.h
Ogre::PlaneBoundedVolume
Represents a convex volume bounded by planes.
Definition: OgrePlaneBoundedVolume.h:49
Ogre::Quaternion
Implementation of a Quaternion, i.e.
Definition: OgreQuaternion.h:57
Ogre::Sphere
A sphere primitive, mostly used for bounds checking.
Definition: OgreSphere.h:51
OgrePlane.h
Ogre::Camera::mAutoAspectRatio
bool mAutoAspectRatio
Whether aspect ratio will automatically be recalculated when a viewport changes its size...
Definition: OgreCamera.h:172
Ogre::Camera::mWindowSet
bool mWindowSet
Is viewing window used.
Definition: OgreCamera.h:162
Ogre::Real
float Real
Software floating point type.
Definition: OgrePrerequisites.h:70
Ogre::Camera::mSceneMgr
SceneManager * mSceneMgr
Scene manager responsible for the scene.
Definition: OgreCamera.h:112
Ogre::Camera::getUseMinPixelSize
bool getUseMinPixelSize() const
Returns whether to use min display size calculations.
Definition: OgreCamera.h:661
OgreString.h
Ogre::Camera::mDerivedPosition
Vector3 mDerivedPosition
Definition: OgreCamera.h:122
Ogre::Camera::mDerivedOrientation
Quaternion mDerivedOrientation
Derived orientation/position of the camera, including reflection.
Definition: OgreCamera.h:121
Ogre::Camera::mRealPosition
Vector3 mRealPosition
Definition: OgreCamera.h:126
Ogre::Camera::mWTop
Real mWTop
Definition: OgreCamera.h:160
Ogre::SceneNode
Class representing a node in the scene graph.
Definition: OgreSceneNode.h:58
Ogre::Camera::isWindowSet
virtual bool isWindowSet(void) const
Returns if a viewport window is being used.
Definition: OgreCamera.h:547
Ogre::Viewport
An abstraction of a viewport, i.e.
Definition: OgreViewport.h:57
Ogre::Camera::Listener::Listener
Listener()
Definition: OgreCamera.h:94
Ogre::Plane
Defines a plane in 3D space.
Definition: OgrePlane.h:61
Ogre::Camera::mUseRenderingDistance
bool mUseRenderingDistance
Whether or not the rendering distance of objects should take effect for this camera.
Definition: OgreCamera.h:176
Ogre::Camera::getAutoTrackTarget
SceneNode * getAutoTrackTarget(void) const
Get the auto tracking target for this camera, if any.
Definition: OgreCamera.h:554
Ogre::Camera::getPixelDisplayRatio
Real getPixelDisplayRatio() const
Returns an estimated ratio between a pixel and the display area it represents.
Definition: OgreCamera.h:673
Ogre::Camera::mAutoTrackOffset
Vector3 mAutoTrackOffset
Tracking offset for fine tuning.
Definition: OgreCamera.h:148
OgreCommon.h
Ogre::Camera::_notifyViewport
void _notifyViewport(Viewport *viewport)
Notifies this camera that a viewport is using it.
Definition: OgreCamera.h:565
Ogre::Matrix4
Class encapsulating a standard 4x4 homogeneous matrix.
Definition: OgreMatrix4.h:78
Ogre::Vector3
Standard 3-dimensional vector.
Definition: OgreVector3.h:51
OgrePlaneBoundedVolume.h
OgrePrerequisites.h
Ogre::Camera::mYawFixedAxis
Vector3 mYawFixedAxis
Fixed axis to yaw around.
Definition: OgreCamera.h:131
Ogre::Camera::mYawFixed
bool mYawFixed
Whether to yaw around a fixed axis.
Definition: OgreCamera.h:129
Ogre::operator<<
std::ostream & operator<<(std::ostream &o, const TRect< T > &r)
Definition: OgreCommon.h:636
Ogre::Camera::Listener::cameraDestroyed
virtual void cameraDestroyed(Camera *cam)
Called when the camera is being destroyed.
Definition: OgreCamera.h:106
Ogre::Camera::mVisBatchesLastRender
unsigned int mVisBatchesLastRender
Stored number of visible batches in the last render.
Definition: OgreCamera.h:140
OgreMatrix4.h
Ogre::String
_StringBase String
Definition: OgrePrerequisites.h:439
Ogre::Camera::mRealOrientation
Quaternion mRealOrientation
Real world orientation/position of the camera.
Definition: OgreCamera.h:125
Ogre::Camera::mSceneLodFactor
Real mSceneLodFactor
Scene LOD factor used to adjust overall LOD.
Definition: OgreCamera.h:151
Ogre::Camera::mAutoTrackTarget
SceneNode * mAutoTrackTarget
SceneNode which this Camera will automatically track.
Definition: OgreCamera.h:146
Ogre::Camera::mUseMinPixelSize
bool mUseMinPixelSize
Whether or not the minimum display size of objects should take effect for this camera.
Definition: OgreCamera.h:181
Ogre::Camera::mPosition
Vector3 mPosition
Camera position - default (0,0,0)
Definition: OgreCamera.h:118
Ogre::Camera::mSceneDetail
PolygonMode mSceneDetail
Rendering type.
Definition: OgreCamera.h:134
Ogre::Camera
A viewpoint from which the scene will be rendered.
Definition: OgreCamera.h:86
Ogre::Vector3::UNIT_Y
static const Vector3 UNIT_Y
Definition: OgreVector3.h:802
OgreHeaderSuffix.h
OgreRay.h
Ogre
Definition: OgreAndroidLogListener.h:34
Ogre::FrustumPlane
FrustumPlane
Worldspace clipping planes.
Definition: OgreFrustum.h:71
Ogre::Camera::mLastViewport
Viewport * mLastViewport
The last viewport to be added using this camera.
Definition: OgreCamera.h:168
OgreFrustum.h
Ogre::vector
Definition: OgrePrerequisites.h:491
Ogre::Camera::getAutoTrackOffset
const Vector3 & getAutoTrackOffset(void) const
Get the auto tracking offset for this camera, if it is auto tracking.
Definition: OgreCamera.h:556
OgreHeaderPrefix.h
Ogre::Camera::mListeners
ListenerList mListeners
Definition: OgreCamera.h:186
Ogre::Camera::setUseMinPixelSize
void setUseMinPixelSize(bool enable)
Sets whether to use min display size calculations.
Definition: OgreCamera.h:657
Ogre::Camera::mLodCamera
const Camera * mLodCamera
Camera to use for LOD calculation.
Definition: OgreCamera.h:178
Ogre::Camera::getViewport
Viewport * getViewport(void) const
Get the last viewport which was attached to this camera.
Definition: OgreCamera.h:563
Ogre::PolygonMode
PolygonMode
The polygon mode to use when rasterising.
Definition: OgreCommon.h:179
Ogre::Camera::msMovableType
static String msMovableType
Shared class-level name for Movable type.
Definition: OgreCamera.h:143
Ogre::Frustum
A frustum represents a pyramid, capped at the near and far end which is used to represent either a vi...
Definition: OgreFrustum.h:85
Ogre::Camera::mWindowClipPlanes
vector< Plane >::type mWindowClipPlanes
Windowed viewport clip planes.
Definition: OgreCamera.h:164
Ogre::Camera::setCullingFrustum
void setCullingFrustum(Frustum *frustum)
Tells the camera to use a separate Frustum instance to perform culling.
Definition: OgreCamera.h:591
Ogre::Camera::Listener
Listener interface so you can be notified of Camera events.
Definition: OgreCamera.h:91
Ogre::AxisAlignedBox
A 3D box aligned with the x/y/z axes.
Definition: OgreAxisAlignedBox.h:54
Ogre::SceneManager
Manages the organisation and rendering of a &#39;scene&#39; i.e.
Definition: OgreSceneManager.h:143
Ogre::Ray
Representation of a ray in space, i.e.
Definition: OgreRay.h:46
Ogre::Camera::Listener::cameraPreRenderScene
virtual void cameraPreRenderScene(Camera *cam)
Called prior to the scene being rendered with this camera.
Definition: OgreCamera.h:98
Ogre::Radian
Wrapper class which indicates a given angle value is in Radians.
Definition: OgreMath.h:47
Ogre::Vector3::ZERO
static const Vector3 ZERO
Definition: OgreVector3.h:800

Copyright © 2012 Torus Knot Software Ltd
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.