OgreCamera.h
Go to the documentation of this file.
1 /*
2 -----------------------------------------------------------------------------
3 This source file is part of OGRE
4  (Object-oriented Graphics Rendering Engine)
5 For the latest info, see http://www.ogre3d.org
6 
7 Copyright (c) 2000-2013 Torus Knot Software Ltd
8 
9 Permission is hereby granted, free of charge, to any person obtaining a copy
10 of this software and associated documentation files (the "Software"), to deal
11 in the Software without restriction, including without limitation the rights
12 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 copies of the Software, and to permit persons to whom the Software is
14 furnished to do so, subject to the following conditions:
15 
16 The above copyright notice and this permission notice shall be included in
17 all copies or substantial portions of the Software.
18 
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 THE SOFTWARE.
26 -----------------------------------------------------------------------------
27 */
28 #ifndef __Camera_H__
29 #define __Camera_H__
30 
31 // Default options
32 #include "OgrePrerequisites.h"
33 
34 #include "OgreString.h"
35 #include "OgreMovableObject.h"
36 
37 // Matrices & Vectors
38 #include "OgreMatrix4.h"
39 #include "OgreVector3.h"
40 #include "OgrePlane.h"
41 #include "OgreQuaternion.h"
42 #include "OgreCommon.h"
43 #include "OgreFrustum.h"
44 #include "OgreRay.h"
45 #include "OgrePlaneBoundedVolume.h"
46 #include "OgreHeaderPrefix.h"
47 
48 
49 namespace Ogre {
50 
86  class _OgreExport Camera : public Frustum
87  {
88  public:
92  {
93  public:
94  Listener() {}
95  virtual ~Listener() {}
96 
98  virtual void cameraPreRenderScene(Camera* cam)
99  { (void)cam; }
100 
102  virtual void cameraPostRenderScene(Camera* cam)
103  { (void)cam; }
104 
106  virtual void cameraDestroyed(Camera* cam)
107  { (void)cam; }
108 
109  };
110  protected:
113 
116 
119 
123 
127 
129  bool mYawFixed;
132 
135 
137  unsigned int mVisFacesLastRender;
138 
140  unsigned int mVisBatchesLastRender;
141 
144 
149 
154 
155 
160  Real mWLeft, mWTop, mWRight, mWBottom;
166  mutable bool mRecalcWindow;
179 
184 
187 
188 
189  // Internal functions for calcs
190  bool isViewOutOfDate(void) const;
192  void invalidateFrustum(void) const;
194  void invalidateView(void) const;
195 
196 
201  virtual void setWindowImpl(void) const;
202 
204  virtual vector<Vector4>::type getRayForwardIntersect(const Vector3& anchor, const Vector3 *dir, Real planeOffset) const;
205 
206  public:
209  Camera( const String& name, SceneManager* sm);
210 
213  virtual ~Camera();
214 
216  virtual void addListener(Listener* l);
218  virtual void removeListener(Listener* l);
219 
222  SceneManager* getSceneManager(void) const;
223 
231  void setPolygonMode(PolygonMode sd);
232 
235  PolygonMode getPolygonMode(void) const;
236 
239  void setPosition(Real x, Real y, Real z);
240 
243  void setPosition(const Vector3& vec);
244 
247  const Vector3& getPosition(void) const;
248 
251  void move(const Vector3& vec);
252 
255  void moveRelative(const Vector3& vec);
256 
262  void setDirection(Real x, Real y, Real z);
263 
266  void setDirection(const Vector3& vec);
267 
270  Vector3 getDirection(void) const;
271 
274  Vector3 getUp(void) const;
275 
278  Vector3 getRight(void) const;
279 
288  void lookAt( const Vector3& targetPoint );
301  void lookAt(Real x, Real y, Real z);
302 
305  void roll(const Radian& angle);
306 
309  void yaw(const Radian& angle);
310 
313  void pitch(const Radian& angle);
314 
317  void rotate(const Vector3& axis, const Radian& angle);
318 
321  void rotate(const Quaternion& q);
322 
342  void setFixedYawAxis( bool useFixed, const Vector3& fixedAxis = Vector3::UNIT_Y );
343 
344 
347  const Quaternion& getOrientation(void) const;
348 
351  void setOrientation(const Quaternion& q);
352 
357  void _renderScene(Viewport *vp, bool includeOverlays);
358 
361  _OgreExport friend std::ostream& operator<<(std::ostream& o, const Camera& c);
362 
365  void _notifyRenderedFaces(unsigned int numfaces);
366 
369  void _notifyRenderedBatches(unsigned int numbatches);
370 
373  unsigned int _getNumRenderedFaces(void) const;
374 
377  unsigned int _getNumRenderedBatches(void) const;
378 
381  const Quaternion& getDerivedOrientation(void) const;
384  const Vector3& getDerivedPosition(void) const;
387  Vector3 getDerivedDirection(void) const;
390  Vector3 getDerivedUp(void) const;
393  Vector3 getDerivedRight(void) const;
394 
397  const Quaternion& getRealOrientation(void) const;
400  const Vector3& getRealPosition(void) const;
403  Vector3 getRealDirection(void) const;
406  Vector3 getRealUp(void) const;
409  Vector3 getRealRight(void) const;
410 
412  void getWorldTransforms(Matrix4* mat) const;
413 
415  const String& getMovableType(void) const;
416 
436  void setAutoTracking(bool enabled, SceneNode* const target = 0,
437  const Vector3& offset = Vector3::ZERO);
438 
439 
455  void setLodBias(Real factor = 1.0);
456 
461  Real getLodBias(void) const;
462 
475  virtual void setLodCamera(const Camera* lodCam);
476 
483  virtual const Camera* getLodCamera() const;
484 
485 
490  Ray getCameraToViewportRay(Real screenx, Real screeny) const;
496  void getCameraToViewportRay(Real screenx, Real screeny, Ray* outRay) const;
497 
508  PlaneBoundedVolume getCameraToViewportBoxVolume(Real screenLeft,
509  Real screenTop, Real screenRight, Real screenBottom, bool includeFarPlane = false);
510 
522  void getCameraToViewportBoxVolume(Real screenLeft,
523  Real screenTop, Real screenRight, Real screenBottom,
524  PlaneBoundedVolume* outVolume, bool includeFarPlane = false);
525 
527  Real _getLodBiasInverse(void) const;
528 
529 
531  void _autoTrack(void);
532 
533 
543  virtual void setWindow (Real left, Real top, Real right, Real bottom);
545  virtual void resetWindow (void);
547  virtual bool isWindowSet(void) const { return mWindowSet; }
549  const vector<Plane>::type& getWindowPlanes(void) const;
550 
552  Real getBoundingRadius(void) const;
554  SceneNode* getAutoTrackTarget(void) const { return mAutoTrackTarget; }
556  const Vector3& getAutoTrackOffset(void) const { return mAutoTrackOffset; }
557 
563  Viewport* getViewport(void) const {return mLastViewport;}
565  void _notifyViewport(Viewport* viewport) {mLastViewport = viewport;}
566 
574  void setAutoAspectRatio(bool autoratio);
575 
578  bool getAutoAspectRatio(void) const;
579 
591  void setCullingFrustum(Frustum* frustum) { mCullFrustum = frustum; }
593  Frustum* getCullingFrustum(void) const { return mCullFrustum; }
594 
599  virtual void forwardIntersect(const Plane& worldPlane, vector<Vector4>::type* intersect3d) const;
600 
602  bool isVisible(const AxisAlignedBox& bound, FrustumPlane* culledBy = 0) const;
604  bool isVisible(const Sphere& bound, FrustumPlane* culledBy = 0) const;
606  bool isVisible(const Vector3& vert, FrustumPlane* culledBy = 0) const;
608  const Vector3* getWorldSpaceCorners(void) const;
610  const Plane& getFrustumPlane( unsigned short plane ) const;
612  bool projectSphere(const Sphere& sphere,
613  Real* left, Real* top, Real* right, Real* bottom) const;
615  Real getNearClipDistance(void) const;
617  Real getFarClipDistance(void) const;
619  const Matrix4& getViewMatrix(void) const;
628  const Matrix4& getViewMatrix(bool ownFrustumOnly) const;
634  virtual void setUseRenderingDistance(bool use) { mUseRenderingDistance = use; }
638  virtual bool getUseRenderingDistance(void) const { return mUseRenderingDistance; }
639 
646  virtual void synchroniseBaseSettingsWith(const Camera* cam);
647 
649  const Vector3& getPositionForViewUpdate(void) const;
651  const Quaternion& getOrientationForViewUpdate(void) const;
652 
657  void setUseMinPixelSize(bool enable) { mUseMinPixelSize = enable; }
661  bool getUseMinPixelSize() const { return mUseMinPixelSize; }
662 
673  Real getPixelDisplayRatio() const { return mPixelDisplayRatio; }
674 
675  };
679 } // namespace Ogre
680 
681 #include "OgreHeaderSuffix.h"
682 
683 #endif // __Camera_H__

Copyright © 2012 Torus Knot Software Ltd
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Last modified Wed Oct 23 2013 06:57:23