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

Revision 2782, 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                //float mClipPlane[6][4];
23                Plane3 mClipPlanes[6];
24
25                void CalcNPVertexIndices(int *indices);
26        };
27       
28        Camera();
29
30        Camera(int width, int height, float fieldOfView = 90.f);
31
32        void Precompute();
33
34        void LookInBox(const AxisAlignedBox3 &box);
35
36        void LookAtBox(const AxisAlignedBox3 &box);
37
38        void SetPosition(const Vector3 &pos);
39
40        void SetDirection(const Vector3 &dir);
41
42        inline Vector3 GetPosition() const { return mPosition; }
43        inline Vector3 GetDirection() const { return mDirection; }
44        inline Vector3 GetUpVector() const { return mUp; }
45        inline Vector3 GetRightVector() const { return mRight; }
46
47        inline float GetFov() const { return mFovy; }
48        inline void GetSize(int &width, int &height) const { width = mWidth; height = mHeight; }
49        inline float GetAspect() const { return (float) mWidth / mHeight; }
50
51        void SetupCameraView();
52        void GetProjectionMatrix(Matrix4x4 &mat);
53        void GetModelViewMatrix(Matrix4x4 &mat);
54
55        void CalcFrustum(Frustum &frustum);
56
57        void ComputePoints(Vector3 &ftl, Vector3 &ftr, Vector3 &fbl, Vector3 &fbr,
58                               Vector3 &ntl, Vector3 &ntr, Vector3 &nbl, Vector3 &nbr);
59       
60        inline float GetNear() const { return mNear; }
61        void SetNear(float nearDist);
62
63
64protected:
65
66        ////////////////
67
68        Vector3 mPosition;
69        Vector3 mDirection;
70
71        /// up vector takes into account the FOV at a unit distance from the origin
72        Vector3 mUp;
73        /// right vector takes into account the FOV at a unit distance from the origin
74        Vector3 mRight;
75
76        float mFovy;
77        int mWidth;
78        int mHeight;
79
80        float mNear;
81};
82
83}
84#endif
Note: See TracBrowser for help on using the repository browser.