source: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Camera.h @ 2826

Revision 2826, 2.1 KB checked in by mattausch, 16 years ago (diff)

changed font

Line 
1#ifndef __CAMERA_H
2#define __CAMERA_H
3
4#include "Vector3.h"
5#include "AxisAlignedBox3.h"
6#include "Plane3.h"
7
8
9namespace CHCDemoEngine
10{
11
12
13class Camera
14{
15public:
16       
17        /** Small struct representing a frustum.
18        */
19        struct Frustum
20        {
21                /// the 6 clip planes
22                Plane3 mClipPlanes[6];
23
24                void CalcNPVertexIndices(int *indices);
25        };
26       
27        Camera();
28
29        Camera(int width, int height, float fieldOfView = 90.f);
30
31
32        void SetPosition(const Vector3 &pos);
33
34        inline Vector3 GetPosition() const { return mPosition; }
35        Vector3 GetDirection() const;
36        Vector3 GetUpVector() const;
37        Vector3 GetRightVector() const;
38
39        inline float GetFov() const { return mFovy; }
40        inline float GetAspect() const { return (float) mWidth / mHeight; }
41        inline int GetWidth() const { return mWidth; }
42        inline int GetHeight() const { return mHeight; }
43
44        /** Sets up viewing in gl
45        */
46        void SetupCameraView();
47        /** Returns the current projection matrix.
48        */
49        void GetProjectionMatrix(Matrix4x4 &mat);
50        /** Returns the current model view matrix.
51        */
52        void GetModelViewMatrix(Matrix4x4 &mat);
53
54        void CalcFrustum(Frustum &frustum);
55        /** Computes the extremal points of this frustum.
56        */
57        void ComputePoints(Vector3 &ftl, Vector3 &ftr, Vector3 &fbl, Vector3 &fbr,
58                               Vector3 &ntl, Vector3 &ntr, Vector3 &nbl, Vector3 &nbr);
59       
60        /** Returns the near plane.
61        */
62        inline float GetNear() const { return mNear; }
63        /** Returns the far plane.
64        */
65        inline float GetFar() const { return mFar; }
66        /** Sets the near plane
67        */
68        void SetNear(float nearDist);
69        /** Sets the far plane.
70        */
71        void SetFar(float farDist);
72       
73        void SetOrtho(bool ortho);
74
75        void Yaw(float angle);
76        void Pitch(float angle);
77       
78        float GetPitch() const { return mPitch; }
79        float GetYaw() const { return mYaw; }
80
81
82
83protected:
84
85        void Precompute(const Vector3 &direction);
86
87        void CalculateFromPitchAndYaw();
88
89
90        ////////////////
91        //-- members
92
93        float mFovy;
94        int mWidth;
95        int mHeight;
96
97        float mNear;
98
99        float mFar;
100
101        bool mIsOrtho;
102
103        Matrix4x4 mBaseOrientation;
104        Matrix4x4 mViewOrientation;
105
106        float mPitch;
107        float mYaw;
108
109        Vector3 mPosition;
110};
111
112}
113#endif
Note: See TracBrowser for help on using the repository browser.