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

Revision 2796, 1.8 KB checked in by mattausch, 16 years ago (diff)
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 void GetSize(int &width, int &height) const { width = mWidth; height = mHeight; }
41        inline float GetAspect() const { return (float) mWidth / mHeight; }
42
43        /** Sets up viewing in gl
44        */
45        void SetupCameraView();
46        void GetProjectionMatrix(Matrix4x4 &mat);
47        void GetModelViewMatrix(Matrix4x4 &mat);
48
49        void CalcFrustum(Frustum &frustum);
50
51        void ComputePoints(Vector3 &ftl, Vector3 &ftr, Vector3 &fbl, Vector3 &fbr,
52                               Vector3 &ntl, Vector3 &ntr, Vector3 &nbl, Vector3 &nbr);
53       
54        inline float GetNear() const { return mNear; }
55        void SetNear(float nearDist);
56       
57        inline float GetFar() const { return mFar; }
58
59        void SetFar(float farDist) { mFar = farDist; }
60
61        void SetOrtho(bool ortho);
62
63        void Yaw(float angle);
64        void Pitch(float angle);
65       
66
67
68protected:
69
70        void Precompute(const Vector3 &direction);
71
72        void CalculateFromPitchAndYaw();
73
74
75        ////////////////
76        //-- members
77
78        float mFovy;
79        int mWidth;
80        int mHeight;
81
82        float mNear;
83
84        float mFar;
85
86        bool mIsOrtho;
87
88        Matrix4x4 mBaseOrientation;
89        Matrix4x4 mViewOrientation;
90
91        float mPitch;
92        float mYaw;
93
94        Vector3 mPosition;
95};
96
97}
98#endif
Note: See TracBrowser for help on using the repository browser.