CmCamera.h 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639
  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. Copyright (c) 2000-2011 Torus Knot Software Ltd
  7. Permission is hereby granted, free of charge, to any person obtaining a copy
  8. of this software and associated documentation files (the "Software"), to deal
  9. in the Software without restriction, including without limitation the rights
  10. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  11. copies of the Software, and to permit persons to whom the Software is
  12. furnished to do so, subject to the following conditions:
  13. The above copyright notice and this permission notice shall be included in
  14. all copies or substantial portions of the Software.
  15. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  21. THE SOFTWARE.
  22. -----------------------------------------------------------------------------
  23. */
  24. #ifndef __Camera_H__
  25. #define __Camera_H__
  26. // Default options
  27. #include "CmPrerequisites.h"
  28. #include "CmString.h"
  29. // Matrices & Vectors
  30. #include "CmMatrix4.h"
  31. #include "CmVector3.h"
  32. #include "CmVector2.h"
  33. #include "CmAxisAlignedBox.h"
  34. #include "CmVertexIndexData.h"
  35. #include "CmPlane.h"
  36. #include "CmQuaternion.h"
  37. #include "CmCommon.h"
  38. #include "CmRay.h"
  39. #include "CmComponent.h"
  40. namespace CamelotEngine {
  41. /** Specifies perspective (realistic) or orthographic (architectural) projection.
  42. */
  43. enum ProjectionType
  44. {
  45. PT_ORTHOGRAPHIC,
  46. PT_PERSPECTIVE
  47. };
  48. /** Worldspace clipping planes.
  49. */
  50. enum FrustumPlane
  51. {
  52. FRUSTUM_PLANE_NEAR = 0,
  53. FRUSTUM_PLANE_FAR = 1,
  54. FRUSTUM_PLANE_LEFT = 2,
  55. FRUSTUM_PLANE_RIGHT = 3,
  56. FRUSTUM_PLANE_TOP = 4,
  57. FRUSTUM_PLANE_BOTTOM = 5
  58. };
  59. /** \addtogroup Core
  60. * @{
  61. */
  62. /** \addtogroup Scene
  63. * @{
  64. */
  65. /** A viewpoint from which the scene will be rendered.
  66. @remarks
  67. OGRE renders scenes from a camera viewpoint into a buffer of
  68. some sort, normally a window or a texture (a subclass of
  69. RenderTarget). OGRE cameras support both perspective projection (the default,
  70. meaning objects get smaller the further away they are) and
  71. orthographic projection (blueprint-style, no decrease in size
  72. with distance). Each camera carries with it a style of rendering,
  73. e.g. full textured, flat shaded, wireframe), field of view,
  74. rendering distances etc, allowing you to use OGRE to create
  75. complex multi-window views if required. In addition, more than
  76. one camera can point at a single render target if required,
  77. each rendering to a subset of the target, allowing split screen
  78. and picture-in-picture views.
  79. @par
  80. Cameras maintain their own aspect ratios, field of view, and frustum,
  81. and project co-ordinates into a space measured from -1 to 1 in x and y,
  82. and 0 to 1 in z. At render time, the camera will be rendering to a
  83. Viewport which will translate these parametric co-ordinates into real screen
  84. co-ordinates. Obviously it is advisable that the viewport has the same
  85. aspect ratio as the camera to avoid distortion (unless you want it!).
  86. @par
  87. Note that a Camera can be attached to a SceneNode, using the method
  88. SceneNode::attachObject. If this is done the Camera will combine it's own
  89. position/orientation settings with it's parent SceneNode.
  90. This is useful for implementing more complex Camera / object
  91. relationships i.e. having a camera attached to a world object.
  92. */
  93. class CM_EXPORT Camera : public Component
  94. {
  95. protected:
  96. /// Orthographic or perspective?
  97. ProjectionType mProjType;
  98. /// y-direction field-of-view (default 45)
  99. Radian mFOVy;
  100. /// Far clip distance - default 10000
  101. float mFarDist;
  102. /// Near clip distance - default 100
  103. float mNearDist;
  104. /// x/y viewport ratio - default 1.3333
  105. float mAspect;
  106. /// Ortho height size (world units)
  107. float mOrthoHeight;
  108. /// Off-axis frustum center offset - default (0.0, 0.0)
  109. Vector2 mFrustumOffset;
  110. /// Focal length of frustum (for stereo rendering, defaults to 1.0)
  111. float mFocalLength;
  112. /// The 6 main clipping planes
  113. mutable Plane mFrustumPlanes[6];
  114. /// Stored versions of parent orientation / position
  115. mutable Quaternion mLastParentOrientation;
  116. mutable Vector3 mLastParentPosition;
  117. /// Pre-calced projection matrix for the specific render system
  118. mutable Matrix4 mProjMatrixRS;
  119. /// Pre-calced standard projection matrix but with render system depth range
  120. mutable Matrix4 mProjMatrixRSDepth;
  121. /// Pre-calced standard projection matrix
  122. mutable Matrix4 mProjMatrix;
  123. /// Pre-calced view matrix
  124. mutable Matrix4 mViewMatrix;
  125. /// Something's changed in the frustum shape?
  126. mutable bool mRecalcFrustum;
  127. /// Something re the frustum planes has changed
  128. mutable bool mRecalcFrustumPlanes;
  129. /// Something re the world space corners has changed
  130. mutable bool mRecalcWorldSpaceCorners;
  131. /// Something re the vertex data has changed
  132. mutable bool mRecalcVertexData;
  133. /// Are we using a custom view matrix?
  134. bool mCustomViewMatrix;
  135. /// Are we using a custom projection matrix?
  136. bool mCustomProjMatrix;
  137. /// Have the frustum extents been manually set?
  138. bool mFrustumExtentsManuallySet;
  139. /// Frustum extents
  140. mutable float mLeft, mRight, mTop, mBottom;
  141. // Internal functions for calcs
  142. virtual void calcProjectionParameters(float& left, float& right, float& bottom, float& top) const;
  143. /// Update frustum if out of date
  144. virtual void updateFrustum(void) const;
  145. /// Implementation of updateFrustum (called if out of date)
  146. virtual void updateFrustumImpl(void) const;
  147. virtual void updateFrustumPlanes(void) const;
  148. /// Implementation of updateFrustumPlanes (called if out of date)
  149. virtual void updateFrustumPlanesImpl(void) const;
  150. virtual void updateWorldSpaceCorners(void) const;
  151. /// Implementation of updateWorldSpaceCorners (called if out of date)
  152. virtual void updateWorldSpaceCornersImpl(void) const;
  153. virtual void updateVertexData(void) const;
  154. virtual void updateView(void) const;
  155. virtual bool isFrustumOutOfDate(void) const;
  156. /// Signal to update frustum information.
  157. virtual void invalidateFrustum(void) const;
  158. mutable AxisAlignedBox mBoundingBox;
  159. mutable VertexData mVertexData;
  160. mutable Vector3 mWorldSpaceCorners[8];
  161. public:
  162. /** Sets the Y-dimension Field Of View (FOV) of the frustum.
  163. @remarks
  164. Field Of View (FOV) is the angle made between the frustum's position, and the edges
  165. of the 'screen' onto which the scene is projected. High values (90+ degrees) result in a wide-angle,
  166. fish-eye kind of view, low values (30- degrees) in a stretched, telescopic kind of view. Typical values
  167. are between 45 and 60 degrees.
  168. @par
  169. This value represents the VERTICAL field-of-view. The horizontal field of view is calculated from
  170. this depending on the dimensions of the viewport (they will only be the same if the viewport is square).
  171. @note
  172. Setting the FOV overrides the value supplied for frustum::setNearClipPlane.
  173. */
  174. virtual void setFOVy(const Radian& fovy);
  175. /** Retrieves the frustums Y-dimension Field Of View (FOV).
  176. */
  177. virtual const Radian& getFOVy(void) const;
  178. /** Sets the position of the near clipping plane.
  179. @remarks
  180. The position of the near clipping plane is the distance from the frustums position to the screen
  181. on which the world is projected. The near plane distance, combined with the field-of-view and the
  182. aspect ratio, determines the size of the viewport through which the world is viewed (in world
  183. co-ordinates). Note that this world viewport is different to a screen viewport, which has it's
  184. dimensions expressed in pixels. The frustums viewport should have the same aspect ratio as the
  185. screen viewport it renders into to avoid distortion.
  186. @param
  187. near The distance to the near clipping plane from the frustum in world coordinates.
  188. */
  189. virtual void setNearClipDistance(float nearDist);
  190. /** Sets the position of the near clipping plane.
  191. */
  192. virtual float getNearClipDistance(void) const;
  193. /** Sets the distance to the far clipping plane.
  194. @remarks
  195. The view frustum is a pyramid created from the frustum position and the edges of the viewport.
  196. This method sets the distance for the far end of that pyramid.
  197. Different applications need different values: e.g. a flight sim
  198. needs a much further far clipping plane than a first-person
  199. shooter. An important point here is that the larger the ratio
  200. between near and far clipping planes, the lower the accuracy of
  201. the Z-buffer used to depth-cue pixels. This is because the
  202. Z-range is limited to the size of the Z buffer (16 or 32-bit)
  203. and the max values must be spread over the gap between near and
  204. far clip planes. As it happens, you can affect the accuracy far
  205. more by altering the near distance rather than the far distance,
  206. but keep this in mind.
  207. @param
  208. far The distance to the far clipping plane from the frustum in
  209. world coordinates.If you specify 0, this means an infinite view
  210. distance which is useful especially when projecting shadows; but
  211. be careful not to use a near distance too close.
  212. */
  213. virtual void setFarClipDistance(float farDist);
  214. /** Retrieves the distance from the frustum to the far clipping plane.
  215. */
  216. virtual float getFarClipDistance(void) const;
  217. /** Sets the aspect ratio for the frustum viewport.
  218. @remarks
  219. The ratio between the x and y dimensions of the rectangular area visible through the frustum
  220. is known as aspect ratio: aspect = width / height .
  221. @par
  222. The default for most fullscreen windows is 1.3333 - this is also assumed by Ogre unless you
  223. use this method to state otherwise.
  224. */
  225. virtual void setAspectRatio(float ratio);
  226. /** Retreives the current aspect ratio.
  227. */
  228. virtual float getAspectRatio(void) const;
  229. /** Sets frustum offsets, used in stereo rendering.
  230. @remarks
  231. You can set both horizontal and vertical plane offsets of "eye"; in
  232. stereo rendering frustum is moved in horizontal plane. To be able to
  233. render from two "eyes" you'll need two cameras rendering on two
  234. RenderTargets.
  235. @par
  236. The frustum offsets is in world coordinates, and default to (0, 0) - no offsets.
  237. @param
  238. offset The horizontal and vertical plane offsets.
  239. */
  240. virtual void setFrustumOffset(const Vector2& offset);
  241. /** Sets frustum offsets, used in stereo rendering.
  242. @remarks
  243. You can set both horizontal and vertical plane offsets of "eye"; in
  244. stereo rendering frustum is moved in horizontal plane. To be able to
  245. render from two "eyes" you'll need two cameras rendering on two
  246. RenderTargets.
  247. @par
  248. The frustum offsets is in world coordinates, and default to (0, 0) - no offsets.
  249. @param
  250. horizontal The horizontal plane offset.
  251. @param
  252. vertical The vertical plane offset.
  253. */
  254. virtual void setFrustumOffset(float horizontal = 0.0, float vertical = 0.0);
  255. /** Retrieves the frustum offsets.
  256. */
  257. virtual const Vector2& getFrustumOffset() const;
  258. /** Sets frustum focal length (used in stereo rendering).
  259. @param
  260. focalLength The distance to the focal plane from the frustum in world coordinates.
  261. */
  262. virtual void setFocalLength(float focalLength = 1.0);
  263. /** Returns focal length of frustum.
  264. */
  265. virtual float getFocalLength() const;
  266. /** Manually set the extents of the frustum.
  267. @param left, right, top, bottom The position where the side clip planes intersect
  268. the near clip plane, in eye space
  269. */
  270. virtual void setFrustumExtents(float left, float right, float top, float bottom);
  271. /** Reset the frustum extents to be automatically derived from other params. */
  272. virtual void resetFrustumExtents();
  273. /** Get the extents of the frustum in view space. */
  274. virtual void getFrustumExtents(float& outleft, float& outright, float& outtop, float& outbottom) const;
  275. /** Gets the projection matrix for this frustum adjusted for the current
  276. rendersystem specifics (may be right or left-handed, depth range
  277. may vary).
  278. @remarks
  279. This method retrieves the rendering-API dependent version of the projection
  280. matrix. If you want a 'typical' projection matrix then use
  281. getProjectionMatrix.
  282. */
  283. virtual const Matrix4& getProjectionMatrixRS(void) const;
  284. /** Gets the depth-adjusted projection matrix for the current rendersystem,
  285. but one which still conforms to right-hand rules.
  286. @remarks
  287. This differs from the rendering-API dependent getProjectionMatrix
  288. in that it always returns a right-handed projection matrix result
  289. no matter what rendering API is being used - this is required for
  290. vertex and fragment programs for example. However, the resulting depth
  291. range may still vary between render systems since D3D uses [0,1] and
  292. GL uses [-1,1], and the range must be kept the same between programmable
  293. and fixed-function pipelines.
  294. */
  295. virtual const Matrix4& getProjectionMatrixWithRSDepth(void) const;
  296. /** Gets the normal projection matrix for this frustum, ie the
  297. projection matrix which conforms to standard right-handed rules and
  298. uses depth range [-1,+1].
  299. @remarks
  300. This differs from the rendering-API dependent getProjectionMatrixRS
  301. in that it always returns a right-handed projection matrix with depth
  302. range [-1,+1], result no matter what rendering API is being used - this
  303. is required for some uniform algebra for example.
  304. */
  305. virtual const Matrix4& getProjectionMatrix(void) const;
  306. /** Gets the view matrix for this frustum. Mainly for use by OGRE internally.
  307. */
  308. virtual const Matrix4& getViewMatrix(void) const;
  309. /** Set whether to use a custom view matrix on this frustum.
  310. @remarks
  311. This is an advanced method which allows you to manually set
  312. the view matrix on this frustum, rather than having it calculate
  313. itself based on it's position and orientation.
  314. @note
  315. After enabling a custom view matrix, the frustum will no longer
  316. update on its own based on position / orientation changes. You
  317. are completely responsible for keeping the view matrix up to date.
  318. The custom matrix will be returned from getViewMatrix.
  319. @param enable If true, the custom view matrix passed as the second
  320. parameter will be used in preference to an auto calculated one. If
  321. false, the frustum will revert to auto calculating the view matrix.
  322. @param viewMatrix The custom view matrix to use, the matrix must be an
  323. affine matrix.
  324. @see Frustum::setCustomProjectionMatrix, Matrix4::isAffine
  325. */
  326. virtual void setCustomViewMatrix(bool enable,
  327. const Matrix4& viewMatrix = Matrix4::IDENTITY);
  328. /// Returns whether a custom view matrix is in use
  329. virtual bool isCustomViewMatrixEnabled(void) const
  330. { return mCustomViewMatrix; }
  331. /** Set whether to use a custom projection matrix on this frustum.
  332. @remarks
  333. This is an advanced method which allows you to manually set
  334. the projection matrix on this frustum, rather than having it
  335. calculate itself based on it's position and orientation.
  336. @note
  337. After enabling a custom projection matrix, the frustum will no
  338. longer update on its own based on field of view and near / far
  339. distance changes. You are completely responsible for keeping the
  340. projection matrix up to date if those values change. The custom
  341. matrix will be returned from getProjectionMatrix and derivative
  342. functions.
  343. @param enable If true, the custom projection matrix passed as the
  344. second parameter will be used in preference to an auto calculated
  345. one. If false, the frustum will revert to auto calculating the
  346. projection matrix.
  347. @param projectionMatrix The custom view matrix to use
  348. @see Frustum::setCustomViewMatrix
  349. */
  350. virtual void setCustomProjectionMatrix(bool enable,
  351. const Matrix4& projectionMatrix = Matrix4::IDENTITY);
  352. /// Returns whether a custom projection matrix is in use
  353. virtual bool isCustomProjectionMatrixEnabled(void) const
  354. { return mCustomProjMatrix; }
  355. /** Retrieves the clipping planes of the frustum (world space).
  356. @remarks
  357. The clipping planes are ordered as declared in enumerate constants FrustumPlane.
  358. */
  359. virtual const Plane* getFrustumPlanes(void) const;
  360. /** Retrieves a specified plane of the frustum (world space).
  361. @remarks
  362. Gets a reference to one of the planes which make up the frustum frustum, e.g. for clipping purposes.
  363. */
  364. virtual const Plane& getFrustumPlane( unsigned short plane ) const;
  365. /** Tests whether the given container is visible in the Frustum.
  366. @param
  367. bound Bounding box to be checked (world space)
  368. @param
  369. culledBy Optional pointer to an int which will be filled by the plane number which culled
  370. the box if the result was false;
  371. @returns
  372. If the box was visible, true is returned.
  373. @par
  374. Otherwise, false is returned.
  375. */
  376. virtual bool isVisible(const AxisAlignedBox& bound, FrustumPlane* culledBy = 0) const;
  377. /** Tests whether the given container is visible in the Frustum.
  378. @param
  379. bound Bounding sphere to be checked (world space)
  380. @param
  381. culledBy Optional pointer to an int which will be filled by the plane number which culled
  382. the box if the result was false;
  383. @returns
  384. If the sphere was visible, true is returned.
  385. @par
  386. Otherwise, false is returned.
  387. */
  388. virtual bool isVisible(const Sphere& bound, FrustumPlane* culledBy = 0) const;
  389. /** Tests whether the given vertex is visible in the Frustum.
  390. @param
  391. vert Vertex to be checked (world space)
  392. @param
  393. culledBy Optional pointer to an int which will be filled by the plane number which culled
  394. the box if the result was false;
  395. @returns
  396. If the box was visible, true is returned.
  397. @par
  398. Otherwise, false is returned.
  399. */
  400. virtual bool isVisible(const Vector3& vert, FrustumPlane* culledBy = 0) const;
  401. /** Overridden from MovableObject */
  402. const AxisAlignedBox& getBoundingBox(void) const;
  403. /** Overridden from MovableObject */
  404. float getBoundingRadius(void) const;
  405. /** Gets the world space corners of the frustum.
  406. @remarks
  407. The corners are ordered as follows: top-right near,
  408. top-left near, bottom-left near, bottom-right near,
  409. top-right far, top-left far, bottom-left far, bottom-right far.
  410. */
  411. virtual const Vector3* getWorldSpaceCorners(void) const;
  412. /** Sets the type of projection to use (orthographic or perspective). Default is perspective.
  413. */
  414. virtual void setProjectionType(ProjectionType pt);
  415. /** Retrieves info on the type of projection used (orthographic or perspective).
  416. */
  417. virtual ProjectionType getProjectionType(void) const;
  418. /** Sets the orthographic window settings, for use with orthographic rendering only.
  419. @note Calling this method will recalculate the aspect ratio, use
  420. setOrthoWindowHeight or setOrthoWindowWidth alone if you wish to
  421. preserve the aspect ratio but just fit one or other dimension to a
  422. particular size.
  423. @param w, h The dimensions of the view window in world units
  424. */
  425. virtual void setOrthoWindow(float w, float h);
  426. /** Sets the orthographic window height, for use with orthographic rendering only.
  427. @note The width of the window will be calculated from the aspect ratio.
  428. @param h The height of the view window in world units
  429. */
  430. virtual void setOrthoWindowHeight(float h);
  431. /** Sets the orthographic window width, for use with orthographic rendering only.
  432. @note The height of the window will be calculated from the aspect ratio.
  433. @param w The width of the view window in world units
  434. */
  435. virtual void setOrthoWindowWidth(float w);
  436. /** Gets the orthographic window height, for use with orthographic rendering only.
  437. */
  438. virtual float getOrthoWindowHeight() const;
  439. /** Gets the orthographic window width, for use with orthographic rendering only.
  440. @note This is calculated from the orthographic height and the aspect ratio
  441. */
  442. virtual float getOrthoWindowWidth() const;
  443. /** Project a sphere onto the near plane and get the bounding rectangle.
  444. @param sphere The world-space sphere to project
  445. @param radius Radius of the sphere
  446. @param left, top, right, bottom Pointers to destination values, these
  447. will be completed with the normalised device coordinates (in the
  448. range {-1,1})
  449. @returns true if the sphere was projected to a subset of the near plane,
  450. false if the entire near plane was contained
  451. */
  452. virtual bool projectSphere(const Sphere& sphere,
  453. float* left, float* top, float* right, float* bottom) const;
  454. /// Small constant used to reduce far plane projection to avoid inaccuracies
  455. static const float INFINITE_FAR_PLANE_ADJUST;
  456. protected:
  457. /// Rendering type
  458. PolygonMode mSceneDetail;
  459. /** Viewing window.
  460. @remarks
  461. Generalize camera class for the case, when viewing frustum doesn't cover all viewport.
  462. */
  463. float mWLeft, mWTop, mWRight, mWBottom;
  464. /// Is viewing window used.
  465. bool mWindowSet;
  466. /// Windowed viewport clip planes
  467. mutable vector<Plane>::type mWindowClipPlanes;
  468. // Was viewing window changed.
  469. mutable bool mRecalcWindow;
  470. /** Whether aspect ratio will automatically be recalculated
  471. when a viewport changes its size
  472. */
  473. bool mAutoAspectRatio;
  474. /// Whether or not the rendering distance of objects should take effect for this camera
  475. bool mUseRenderingDistance;
  476. Viewport* mViewport;
  477. /** Do actual window setting, using parameters set in SetWindow call
  478. @remarks
  479. The method will called on demand.
  480. */
  481. void setWindowImpl(void) const;
  482. /** Helper function for forwardIntersect that intersects rays with canonical plane */
  483. vector<Vector4>::type getRayForwardIntersect(const Vector3& anchor, const Vector3 *dir, float planeOffset) const;
  484. public:
  485. /** Standard constructor.
  486. */
  487. Camera(GameObjectPtr parent);
  488. /** Standard destructor.
  489. */
  490. virtual ~Camera();
  491. void init(RenderTarget* target = nullptr,
  492. float left = 0.0f, float top = 0.0f,
  493. float width = 1.0f, float height = 1.0f,
  494. int ZOrder = 0);
  495. Viewport* getViewport() { return mViewport; }
  496. /** Sets the level of rendering detail required from this camera.
  497. @remarks
  498. Each camera is set to render at full detail by default, that is
  499. with full texturing, lighting etc. This method lets you change
  500. that behaviour, allowing you to make the camera just render a
  501. wireframe view, for example.
  502. */
  503. void setPolygonMode(PolygonMode sd);
  504. /** Retrieves the level of detail that the camera will render.
  505. */
  506. PolygonMode getPolygonMode(void) const;
  507. /** Tells the Camera to contact the SceneManager to render from it's viewpoint.
  508. @param vp The viewport to render to
  509. @param includeOverlays Whether or not any overlay objects should be included
  510. */
  511. void _renderScene(Viewport *vp, bool includeOverlays);
  512. /** Gets a world space ray as cast from the camera through a viewport position.
  513. @param screenx, screeny The x and y position at which the ray should intersect the viewport,
  514. in normalised screen coordinates [0,1]
  515. */
  516. Ray getCameraToViewportRay(float screenx, float screeny) const;
  517. /** Gets a world space ray as cast from the camera through a viewport position.
  518. @param screenx, screeny The x and y position at which the ray should intersect the viewport,
  519. in normalised screen coordinates [0,1]
  520. @param outRay Ray instance to populate with result
  521. */
  522. void getCameraToViewportRay(float screenx, float screeny, Ray* outRay) const;
  523. /** Sets the viewing window inside of viewport.
  524. @remarks
  525. This method can be used to set a subset of the viewport as the rendering
  526. target.
  527. @param Left Relative to Viewport - 0 corresponds to left edge, 1 - to right edge (default - 0).
  528. @param Top Relative to Viewport - 0 corresponds to top edge, 1 - to bottom edge (default - 0).
  529. @param Right Relative to Viewport - 0 corresponds to left edge, 1 - to right edge (default - 1).
  530. @param Bottom Relative to Viewport - 0 corresponds to top edge, 1 - to bottom edge (default - 1).
  531. */
  532. virtual void setWindow (float Left, float Top, float Right, float Bottom);
  533. /// Cancel view window.
  534. virtual void resetWindow (void);
  535. /// Returns if a viewport window is being used
  536. virtual bool isWindowSet(void) const { return mWindowSet; }
  537. /// Gets the window clip planes, only applicable if isWindowSet == true
  538. const vector<Plane>::type& getWindowPlanes(void) const;
  539. /** If set to true a viewport that owns this frustum will be able to
  540. recalculate the aspect ratio whenever the frustum is resized.
  541. @remarks
  542. You should set this to true only if the frustum / camera is used by
  543. one viewport at the same time. Otherwise the aspect ratio for other
  544. viewports may be wrong.
  545. */
  546. void setAutoAspectRatio(bool autoratio);
  547. /** Retrieves if AutoAspectRatio is currently set or not
  548. */
  549. bool getAutoAspectRatio(void) const;
  550. /** Forward projects frustum rays to find forward intersection with plane.
  551. @remarks
  552. Forward projection may lead to intersections at infinity.
  553. */
  554. void forwardIntersect(const Plane& worldPlane, vector<Vector4>::type* intersect3d) const;
  555. /************************************************************************/
  556. /* RTTI */
  557. /************************************************************************/
  558. public:
  559. friend class CameraRTTI;
  560. static RTTITypeBase* getRTTIStatic();
  561. virtual RTTITypeBase* getRTTI() const;
  562. protected:
  563. Camera() {} // Serialization only
  564. };
  565. /** @} */
  566. /** @} */
  567. } // namespace CamelotEngine
  568. #endif