Coverage Report

Created: 2025-07-18 07:08

/src/ogre/OgreMain/include/OgreCamera.h
Line
Count
Source (jump to first uncovered line)
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-2014 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
// Matrices & Vectors
35
#include "OgreCommon.h"
36
#include "OgreFrustum.h"
37
#include "OgreHeaderPrefix.h"
38
39
40
namespace Ogre {
41
42
    class Matrix4;
43
    class Ray;
44
45
    /** \addtogroup Core
46
    *  @{
47
    */
48
    /** \addtogroup Scene
49
    *  @{
50
    */
51
52
    /** A viewpoint from which the scene will be rendered.
53
54
        OGRE renders scenes from a camera viewpoint into a buffer of
55
        some sort, normally a window or a texture (a subclass of
56
        RenderTarget). OGRE cameras support both perspective projection (the default,
57
        meaning objects get smaller the further away they are) and
58
        orthographic projection (blueprint-style, no decrease in size
59
        with distance). Each camera carries with it a style of rendering,
60
        e.g. full textured, flat shaded, wireframe), field of view,
61
        rendering distances etc, allowing you to use OGRE to create
62
        complex multi-window views if required. In addition, more than
63
        one camera can point at a single render target if required,
64
        each rendering to a subset of the target, allowing split screen
65
        and picture-in-picture views.
66
67
        At render time, all Scene Objects will be transformed in the camera space,
68
        which is defined as:
69
        - \f$+x\f$ is right
70
        - \f$+y\f$ is up
71
        - \f$-z\f$ is away
72
73
        Cameras maintain their own aspect ratios, field of view, and frustum,
74
        and project coordinates into normalised device coordinates measured from -1 to 1 in x and y,
75
        and 0 to 1 in z, where
76
        - \f$+x\f$ is right
77
        - \f$+y\f$ is up
78
        - \f$+z\f$ is away
79
80
        At render time, the camera will be rendering to a
81
        Viewport which will translate these parametric coordinates into real screen
82
        coordinates. Obviously it is advisable that the viewport has the same
83
        aspect ratio as the camera to avoid distortion (unless you want it!).
84
    */
85
    class _OgreExport Camera : public Frustum
86
    {
87
    public:
88
        /** Listener interface so you can be notified of Camera events. 
89
        */
90
        class _OgreExport Listener 
91
        {
92
        public:
93
0
            Listener() {}
94
0
            virtual ~Listener() {}
95
96
            /// Called prior to the scene being rendered with this camera
97
            virtual void cameraPreRenderScene(Camera* cam)
98
0
                        { (void)cam; }
99
100
            /// Called after the scene has been rendered with this camera
101
            virtual void cameraPostRenderScene(Camera* cam)
102
0
                        { (void)cam; }
103
104
            /// Called when the camera is being destroyed
105
            virtual void cameraDestroyed(Camera* cam)
106
0
                        { (void)cam; }
107
108
        };
109
    private:
110
        /// Is viewing window used.
111
        bool mWindowSet;
112
        /// Was viewing window changed.
113
        mutable bool mRecalcWindow;
114
115
        /** Whether aspect ratio will automatically be recalculated
116
            when a viewport changes its size
117
        */
118
        bool mAutoAspectRatio;
119
        /// Whether or not the rendering distance of objects should take effect for this camera
120
        bool mUseRenderingDistance;
121
        /// Whether or not the minimum display size of objects should take effect for this camera
122
        bool mUseMinPixelSize;
123
124
        /// Derived orientation/position of the camera, including reflection
125
        mutable Quaternion mDerivedOrientation;
126
        mutable Vector3 mDerivedPosition;
127
128
        /// Stored number of visible faces in the last render
129
        unsigned int mVisFacesLastRender;
130
131
        /// Stored number of visible batches in the last render
132
        unsigned int mVisBatchesLastRender;
133
134
#ifdef OGRE_NODELESS_POSITIONING
135
        /// Real world orientation/position of the camera
136
        mutable Quaternion mRealOrientation;
137
        mutable Vector3 mRealPosition;
138
139
        /// Whether to yaw around a fixed axis.
140
        bool mYawFixed;
141
        /// Fixed axis to yaw around
142
        Vector3 mYawFixedAxis;
143
        /// Camera orientation, quaternion style
144
        Quaternion mOrientation;
145
        /// Camera position - default (0,0,0)
146
        Vector3 mPosition;
147
        /// SceneNode which this Camera will automatically track
148
        SceneNode* mAutoTrackTarget;
149
        /// Tracking offset for fine tuning
150
        Vector3 mAutoTrackOffset;
151
#endif
152
        /// Scene LOD factor used to adjust overall LOD
153
        Real mSceneLodFactor;
154
        /// Inverted scene LOD factor, can be used by Renderables to adjust their LOD
155
        Real mSceneLodFactorInv;
156
157
158
        /** Viewing window. 
159
160
        Generalize camera class for the case, when viewing frustum doesn't cover all viewport.
161
        */
162
        Real mWLeft, mWTop, mWRight, mWBottom;
163
        /// Windowed viewport clip planes 
164
        mutable std::vector<Plane> mWindowClipPlanes;
165
        /// The last viewport to be added using this camera
166
        Viewport* mLastViewport;
167
        /// Custom culling frustum
168
        Frustum *mCullFrustum;
169
        /// Camera to use for LOD calculation
170
        const Camera* mLodCamera;
171
172
        typedef std::vector<Listener*> ListenerList;
173
        ListenerList mListeners;
174
        /// @see Camera::getPixelDisplayRatio
175
        Real mPixelDisplayRatio;
176
177
        SortMode mSortMode;
178
        /// Rendering type
179
        PolygonMode mSceneDetail;
180
181
        // Internal functions for calcs
182
        bool isViewOutOfDate(void) const override;
183
        /// Signal to update frustum information.
184
        void invalidateFrustum(void) const override;
185
        /// Signal to update view information.
186
        void invalidateView(void) const override;
187
188
189
        /** Do actual window setting, using parameters set in SetWindow call
190
191
            The method will called on demand.
192
        */
193
        virtual void setWindowImpl(void) const;
194
195
        /** Helper function for forwardIntersect that intersects rays with canonical plane */
196
        virtual std::vector<Vector4> getRayForwardIntersect(const Vector3& anchor, const Vector3 *dir, Real planeOffset) const;
197
198
    public:
199
        /** Standard constructor.
200
        */
201
        Camera( const String& name, SceneManager* sm);
202
203
        /** Standard destructor.
204
        */
205
        virtual ~Camera();
206
207
        /// Add a listener to this camera
208
        virtual void addListener(Listener* l);
209
        /// Remove a listener to this camera
210
        virtual void removeListener(Listener* l);
211
212
        /** Returns a pointer to the SceneManager this camera is rendering through.
213
        */
214
        SceneManager* getSceneManager(void) const;
215
216
        /** Sets the level of rendering detail required from this camera.
217
218
            Each camera is set to render at full detail by default, that is
219
            with full texturing, lighting etc. This method lets you change
220
            that behaviour, allowing you to make the camera just render a
221
            wireframe view, for example.
222
        */
223
        void setPolygonMode(PolygonMode sd);
224
225
        /** Retrieves the level of detail that the camera will render.
226
        */
227
        PolygonMode getPolygonMode(void) const;
228
229
#ifdef OGRE_NODELESS_POSITIONING
230
        /** Sets the camera's position.
231
        @deprecated attach to SceneNode and use SceneNode::setPosition
232
        */
233
        OGRE_DEPRECATED void setPosition(Real x, Real y, Real z);
234
235
        /// @overload
236
        /// @deprecated attach to SceneNode and use SceneNode::setPosition
237
        OGRE_DEPRECATED void setPosition(const Vector3& vec);
238
239
        /** Retrieves the camera's position.
240
        @deprecated attach to SceneNode and use SceneNode::getPosition
241
        */
242
        OGRE_DEPRECATED const Vector3& getPosition(void) const;
243
244
        /** Moves the camera's position by the vector offset provided along world axes.
245
        @deprecated attach to SceneNode and use SceneNode::translate
246
        */
247
        OGRE_DEPRECATED void move(const Vector3& vec);
248
249
        /** Moves the camera's position by the vector offset provided along it's own axes (relative to orientation).
250
        @deprecated attach to SceneNode and use SceneNode::translate(vec, Node::TS_LOCAL)
251
        */
252
        OGRE_DEPRECATED void moveRelative(const Vector3& vec);
253
254
        /** Sets the camera's direction vector.
255
256
            Note that the 'up' vector for the camera will automatically be recalculated based on the
257
            current 'up' vector (i.e. the roll will remain the same).
258
        @deprecated attach to SceneNode and use SceneNode::setDirection
259
        */
260
        OGRE_DEPRECATED void setDirection(Real x, Real y, Real z);
261
262
        /// @overload
263
        /// @deprecated attach to SceneNode and use SceneNode::setDirection
264
        OGRE_DEPRECATED void setDirection(const Vector3& vec);
265
266
        /** Gets the camera's direction.
267
        @deprecated attach to SceneNode and use SceneNode::getOrientation().zAxis() * -1
268
        */
269
        OGRE_DEPRECATED Vector3 getDirection(void) const;
270
271
        /** Gets the camera's up vector.
272
        @deprecated attach to SceneNode and use SceneNode::getOrientation().yAxis()
273
        */
274
        OGRE_DEPRECATED Vector3 getUp(void) const;
275
276
        /** Gets the camera's right vector.
277
        @deprecated attach to SceneNode and use SceneNode::getOrientation().xAxis()
278
        */
279
        OGRE_DEPRECATED Vector3 getRight(void) const;
280
281
        /** Points the camera at a location in worldspace.
282
283
            This is a helper method to automatically generate the
284
            direction vector for the camera, based on it's current position
285
            and the supplied look-at point.
286
        @param
287
            targetPoint A vector specifying the look at point.
288
        @deprecated attach to SceneNode and use SceneNode::lookAt
289
        */
290
        OGRE_DEPRECATED void lookAt( const Vector3& targetPoint );
291
        /// @overload
292
        /// @deprecated attach to SceneNode and use SceneNode::lookAt
293
        OGRE_DEPRECATED void lookAt(Real x, Real y, Real z);
294
295
        /** Rolls the camera anticlockwise, around its local z axis.
296
        @deprecated attach to SceneNode and use SceneNode::roll
297
        */
298
        OGRE_DEPRECATED void roll(const Radian& angle);
299
300
        /** Rotates the camera anticlockwise around it's local y axis.
301
        @deprecated attach to SceneNode and use SceneNode::yaw
302
        */
303
        OGRE_DEPRECATED void yaw(const Radian& angle);
304
305
        /** Pitches the camera up/down anticlockwise around it's local z axis.
306
        @deprecated attach to SceneNode and use SceneNode::pitch
307
        */
308
        OGRE_DEPRECATED void pitch(const Radian& angle);
309
310
        /** Rotate the camera around an arbitrary axis.
311
        @deprecated attach to SceneNode and use SceneNode::rotate
312
        */
313
        OGRE_DEPRECATED void rotate(const Vector3& axis, const Radian& angle);
314
315
        /// @overload
316
        /// @deprecated attach to SceneNode and use SceneNode::rotate
317
        OGRE_DEPRECATED void rotate(const Quaternion& q);
318
319
        /** Tells the camera whether to yaw around it's own local Y axis or a 
320
            fixed axis of choice.
321
322
            This method allows you to change the yaw behaviour of the camera
323
            - by default, the camera yaws around a fixed Y axis. This is 
324
            often what you want - for example if you're making a first-person 
325
            shooter, you really don't want the yaw axis to reflect the local 
326
            camera Y, because this would mean a different yaw axis if the 
327
            player is looking upwards rather than when they are looking
328
            straight ahead. You can change this behaviour by calling this 
329
            method, which you will want to do if you are making a completely
330
            free camera like the kind used in a flight simulator. 
331
        @param useFixed
332
            If @c true, the axis passed in the second parameter will 
333
            always be the yaw axis no matter what the camera orientation. 
334
            If false, the camera yaws around the local Y.
335
        @param fixedAxis
336
            The axis to use if the first parameter is true.
337
        @deprecated attach to SceneNode and use SceneNode::yaw(angle, Node::TS_PARENT)
338
        */
339
        OGRE_DEPRECATED void setFixedYawAxis( bool useFixed, const Vector3& fixedAxis = Vector3::UNIT_Y );
340
341
342
        /** Returns the camera's current orientation.
343
        @deprecated attach to SceneNode and use SceneNode::getOrientation
344
        */
345
        OGRE_DEPRECATED const Quaternion& getOrientation(void) const;
346
347
        /** Sets the camera's orientation.
348
        @deprecated attach to SceneNode and use SceneNode::setOrientation
349
        */
350
        OGRE_DEPRECATED void setOrientation(const Quaternion& q);
351
352
        /** Internal method used by OGRE to update auto-tracking cameras. */
353
        OGRE_DEPRECATED void _autoTrack(void);
354
355
        /** Get the auto tracking target for this camera, if any. */
356
        OGRE_DEPRECATED SceneNode* getAutoTrackTarget(void) const { return mAutoTrackTarget; }
357
        /** Get the auto tracking offset for this camera, if it is auto tracking. */
358
        OGRE_DEPRECATED const Vector3& getAutoTrackOffset(void) const { return mAutoTrackOffset; }
359
360
        /** Enables / disables automatic tracking of a SceneNode.
361
362
            If you enable auto-tracking, this Camera will automatically rotate to
363
            look at the target SceneNode every frame, no matter how
364
            it or SceneNode move. This is handy if you want a Camera to be focused on a
365
            single object or group of objects. Note that by default the Camera looks at the
366
            origin of the SceneNode, if you want to tweak this, e.g. if the object which is
367
            attached to this target node is quite big and you want to point the camera at
368
            a specific point on it, provide a vector in the 'offset' parameter and the
369
            camera's target point will be adjusted.
370
        @param enabled If true, the Camera will track the SceneNode supplied as the next
371
            parameter (cannot be null). If false the camera will cease tracking and will
372
            remain in it's current orientation.
373
        @param target Pointer to the SceneNode which this Camera will track. Make sure you don't
374
            delete this SceneNode before turning off tracking (e.g. SceneManager::clearScene will
375
            delete it so be careful of this). Can be null if and only if the enabled param is false.
376
        @param offset If supplied, the camera targets this point in local space of the target node
377
            instead of the origin of the target node. Good for fine tuning the look at point.
378
        @deprecated attach to SceneNode and use SceneNode::setAutoTracking
379
        */
380
        OGRE_DEPRECATED void setAutoTracking(bool enabled, SceneNode* const target = 0,
381
            const Vector3& offset = Vector3::ZERO);
382
383
        const Vector3& getPositionForViewUpdate(void) const override;
384
        const Quaternion& getOrientationForViewUpdate(void) const override;
385
#endif
386
        /** Tells the Camera to contact the SceneManager to render from it's viewpoint.
387
        @param vp The viewport to render to
388
        */
389
        void _renderScene(Viewport *vp);
390
391
        /// @deprecated do not use
392
0
        OGRE_DEPRECATED void _renderScene(Viewport *vp, bool unused) { _renderScene(vp); }
393
394
        /** Function for outputting to a stream.
395
        */
396
        _OgreExport friend std::ostream& operator<<(std::ostream& o, const Camera& c);
397
398
        /** Internal method to notify camera of the visible faces in the last render.
399
        */
400
0
        void _notifyRenderedFaces(unsigned int numfaces) { mVisFacesLastRender = numfaces; }
401
402
        /** Internal method to notify camera of the visible batches in the last render.
403
        */
404
0
        void _notifyRenderedBatches(unsigned int numbatches) { mVisBatchesLastRender = numbatches; }
405
406
        /** Internal method to retrieve the number of visible faces in the last render.
407
        */
408
0
        unsigned int _getNumRenderedFaces(void) const { return mVisFacesLastRender; }
409
410
        /** Internal method to retrieve the number of visible batches in the last render.
411
        */
412
0
        unsigned int _getNumRenderedBatches(void) const { return mVisBatchesLastRender; }
413
414
        /** Gets the derived orientation of the camera, including any
415
            rotation inherited from a node attachment and reflection matrix. */
416
        const Quaternion& getDerivedOrientation(void) const;
417
        /** Gets the derived position of the camera, including any
418
            translation inherited from a node attachment and reflection matrix. */
419
        const Vector3& getDerivedPosition(void) const;
420
        /** Gets the derived direction vector of the camera, including any
421
            rotation inherited from a node attachment and reflection matrix. */
422
        Vector3 getDerivedDirection(void) const;
423
        /** Gets the derived up vector of the camera, including any
424
            rotation inherited from a node attachment and reflection matrix. */
425
        Vector3 getDerivedUp(void) const;
426
        /** Gets the derived right vector of the camera, including any
427
            rotation inherited from a node attachment and reflection matrix. */
428
        Vector3 getDerivedRight(void) const;
429
430
        /** Gets the real world orientation of the camera, including any
431
            rotation inherited from a node attachment */
432
        const Quaternion& getRealOrientation(void) const;
433
        /** Gets the real world position of the camera, including any
434
            translation inherited from a node attachment. */
435
        const Vector3& getRealPosition(void) const;
436
        /** Gets the real world direction vector of the camera, including any
437
            rotation inherited from a node attachment. */
438
        Vector3 getRealDirection(void) const;
439
        /** Gets the real world up vector of the camera, including any
440
            rotation inherited from a node attachment. */
441
        Vector3 getRealUp(void) const;
442
        /** Gets the real world right vector of the camera, including any
443
            rotation inherited from a node attachment. */
444
        Vector3 getRealRight(void) const;
445
446
        const String& getMovableType(void) const override;
447
448
        /** Sets the level-of-detail factor for this Camera.
449
450
            This method can be used to influence the overall level of detail of the scenes 
451
            rendered using this camera. Various elements of the scene have level-of-detail
452
            reductions to improve rendering speed at distance; this method allows you 
453
            to hint to those elements that you would like to adjust the level of detail that
454
            they would normally use (up or down). 
455
        @par
456
            The most common use for this method is to reduce the overall level of detail used
457
            for a secondary camera used for sub viewports like rear-view mirrors etc.
458
            Note that scene elements are at liberty to ignore this setting if they choose,
459
            this is merely a hint.
460
        @param factor The factor to apply to the usual level of detail calculation. Higher
461
            values increase the detail, so 2.0 doubles the normal detail and 0.5 halves it.
462
        */
463
        void setLodBias(Real factor = 1.0);
464
465
        /** Returns the level-of-detail bias factor currently applied to this camera. 
466
467
            See Camera::setLodBias for more details.
468
        */
469
        Real getLodBias(void) const;
470
471
        /** Set a pointer to the camera which should be used to determine
472
            LOD settings. 
473
474
            Sometimes you don't want the LOD of a render to be based on the camera
475
            that's doing the rendering, you want it to be based on a different
476
            camera. A good example is when rendering shadow maps, since they will 
477
            be viewed from the perspective of another camera. Therefore this method
478
            lets you associate a different camera instance to use to determine the LOD.
479
        @par
480
            To revert the camera to determining LOD based on itself, call this method with 
481
            a pointer to itself. 
482
        */
483
        virtual void setLodCamera(const Camera* lodCam);
484
485
        /** Get a pointer to the camera which should be used to determine 
486
            LOD settings. 
487
488
            If setLodCamera hasn't been called with a different camera, this
489
            method will return 'this'. 
490
        */
491
        virtual const Camera* getLodCamera() const;
492
493
494
        /** Gets a world space ray as cast from the camera through a viewport position.
495
        @param screenx, screeny The x and y position at which the ray should intersect the viewport,
496
            in normalised screen coordinates [0,1]
497
        */
498
        Ray getCameraToViewportRay(Real screenx, Real screeny) const;
499
        /** Gets a world space ray as cast from the camera through a viewport position.
500
        @param screenx, screeny The x and y position at which the ray should intersect the viewport, 
501
            in normalised screen coordinates [0,1]
502
        @param outRay Ray instance to populate with result
503
        */
504
        void getCameraToViewportRay(Real screenx, Real screeny, Ray* outRay) const;
505
506
        /** Gets a world-space list of planes enclosing a volume based on a viewport
507
            rectangle. 
508
509
            Can be useful for populating a PlaneBoundedVolumeListSceneQuery, e.g. 
510
            for a rubber-band selection. 
511
        @param screenLeft, screenTop, screenRight, screenBottom The bounds of the
512
            on-screen rectangle, expressed in normalised screen coordinates [0,1]
513
        @param includeFarPlane If true, the volume is truncated by the camera far plane, 
514
            by default it is left open-ended
515
        */
516
        PlaneBoundedVolume getCameraToViewportBoxVolume(Real screenLeft, 
517
            Real screenTop, Real screenRight, Real screenBottom, bool includeFarPlane = false);
518
519
        /// @overload
520
        void getCameraToViewportBoxVolume(Real screenLeft, 
521
            Real screenTop, Real screenRight, Real screenBottom, 
522
            PlaneBoundedVolume* outVolume, bool includeFarPlane = false);
523
524
        /** Internal method for OGRE to use for LOD calculations. */
525
        Real _getLodBiasInverse(void) const;
526
527
        /** Sets the viewing window inside of viewport.
528
529
            This method can be used to set a subset of the viewport as the rendering
530
            target. 
531
        @param left Relative to Viewport - 0 corresponds to left edge, 1 - to right edge (default - 0).
532
        @param top Relative to Viewport - 0 corresponds to top edge, 1 - to bottom edge (default - 0).
533
        @param right Relative to Viewport - 0 corresponds to left edge, 1 - to right edge (default - 1).
534
        @param bottom Relative to Viewport - 0 corresponds to top edge, 1 - to bottom edge (default - 1).
535
        */
536
        virtual void setWindow (Real left, Real top, Real right, Real bottom);
537
        /// Cancel view window.
538
        virtual void resetWindow (void);
539
        /// Returns if a viewport window is being used
540
0
        virtual bool isWindowSet(void) const { return mWindowSet; }
541
        /// Gets the window clip planes, only applicable if isWindowSet == true
542
        const std::vector<Plane>& getWindowPlanes(void) const;
543
544
        Real getBoundingRadius(void) const override;
545
        
546
        /** Get the last viewport which was attached to this camera. 
547
        @note This is not guaranteed to be the only viewport which is
548
            using this camera, just the last once which was created referring
549
            to it.
550
        */
551
0
        Viewport* getViewport(void) const {return mLastViewport;}
552
        /** Notifies this camera that a viewport is using it.*/
553
0
        void _notifyViewport(Viewport* viewport) {mLastViewport = viewport;}
554
555
        /** If set to true a viewport that owns this frustum will be able to 
556
            recalculate the aspect ratio whenever the frustum is resized.
557
558
            You should set this to true only if the frustum / camera is used by 
559
            one viewport at the same time. Otherwise the aspect ratio for other 
560
            viewports may be wrong.
561
        */    
562
        void setAutoAspectRatio(bool autoratio);
563
564
        /** Retrieves if AutoAspectRatio is currently set or not
565
        */
566
        bool getAutoAspectRatio(void) const;
567
568
        /** Tells the camera to use a separate Frustum instance to perform culling.
569
570
            By calling this method, you can tell the camera to perform culling
571
            against a different frustum to it's own. This is mostly useful for
572
            debug cameras that allow you to show the culling behaviour of another
573
            camera, or a manual frustum instance. 
574
        @param frustum Pointer to a frustum to use; this can either be a manual
575
            Frustum instance (which you can attach to scene nodes like any other
576
            MovableObject), or another camera. If you pass 0 to this method it
577
            reverts the camera to normal behaviour.
578
        */
579
0
        void setCullingFrustum(Frustum* frustum) { mCullFrustum = frustum; }
580
        /** Returns the custom culling frustum in use. */
581
0
        Frustum* getCullingFrustum(void) const { return mCullFrustum; }
582
583
        /** Forward projects frustum rays to find forward intersection with plane.
584
585
            Forward projection may lead to intersections at infinity.
586
        */
587
        virtual void forwardIntersect(const Plane& worldPlane, std::vector<Vector4>* intersect3d) const;
588
589
        /// @copydoc Frustum::isVisible(const AxisAlignedBox&, FrustumPlane*) const
590
        bool isVisible(const AxisAlignedBox& bound, FrustumPlane* culledBy = 0) const override;
591
        /// @copydoc Frustum::isVisible(const Sphere&, FrustumPlane*) const
592
        bool isVisible(const Sphere& bound, FrustumPlane* culledBy = 0) const override;
593
        /// @copydoc Frustum::isVisible(const Vector3&, FrustumPlane*) const
594
        bool isVisible(const Vector3& vert, FrustumPlane* culledBy = 0) const override;
595
        /// @copydoc Frustum::getWorldSpaceCorners
596
        const Corners& getWorldSpaceCorners(void) const override;
597
        /// @copydoc Frustum::getFrustumPlane
598
        const Plane& getFrustumPlane( unsigned short plane ) const override;
599
        /// @copydoc Frustum::projectSphere
600
        bool projectSphere(const Sphere& sphere, 
601
            Real* left, Real* top, Real* right, Real* bottom) const override;
602
        float getNearClipDistance(void) const override;
603
        float getFarClipDistance(void) const override;
604
        const Affine3& getViewMatrix(void) const override;
605
        /** Specialised version of getViewMatrix allowing caller to differentiate
606
            whether the custom culling frustum should be allowed or not. 
607
608
            The default behaviour of the standard getViewMatrix is to delegate to 
609
            the alternate culling frustum, if it is set. This is expected when 
610
            performing CPU calculations, but the final rendering must be performed
611
            using the real view matrix in order to display the correct debug view.
612
        */
613
        const Affine3& getViewMatrix(bool ownFrustumOnly) const;
614
        /** Set whether this camera should use the 'rendering distance' on
615
            objects to exclude distant objects from the final image. The
616
            default behaviour is to use it.
617
        @param use True to use the rendering distance, false not to.
618
        */
619
0
        virtual void setUseRenderingDistance(bool use) { mUseRenderingDistance = use; }
620
        /** Get whether this camera should use the 'rendering distance' on
621
            objects to exclude distant objects from the final image.
622
        */
623
0
        virtual bool getUseRenderingDistance(void) const { return mUseRenderingDistance; }
624
625
        /** Synchronise core camera settings with another. 
626
627
            Copies the position, orientation, clip distances, projection type, 
628
            FOV, focal length and aspect ratio from another camera. Other settings like query flags, 
629
            reflection etc are preserved.
630
        */
631
        virtual void synchroniseBaseSettingsWith(const Camera* cam);
632
633
        /** @brief Sets whether to use min display size calculations.
634
            When active, objects that derive from MovableObject whose size on the screen is less then a MovableObject::mMinPixelSize will not
635
            be rendered.
636
        */
637
0
        void setUseMinPixelSize(bool enable) { mUseMinPixelSize = enable; }
638
        /** Returns whether to use min display size calculations 
639
        @see Camera::setUseMinDisplaySize
640
        */
641
0
        bool getUseMinPixelSize() const { return mUseMinPixelSize; }
642
643
        /** Returns an estimated ratio between a pixel and the display area it represents.
644
            For orthographic cameras this function returns the amount of meters covered by
645
            a single pixel along the vertical axis. For perspective cameras the value
646
            returned is the amount of meters covered by a single pixel per meter distance 
647
            from the camera.
648
        @note
649
            This parameter is calculated just before the camera is rendered
650
        @note
651
            This parameter is used in min display size calculations.
652
        */
653
0
        Real getPixelDisplayRatio() const { return mPixelDisplayRatio; }
654
655
        /// Set the function used to compute the camera-distance for sorting Renderables
656
0
        void setSortMode(SortMode sm) { mSortMode = sm; }
657
        /// get the currently used @ref SortMode
658
0
        SortMode getSortMode() const { return mSortMode; }
659
    };
660
    /** @} */
661
    /** @} */
662
663
} // namespace Ogre
664
665
#include "OgreHeaderSuffix.h"
666
667
#endif // __Camera_H__