ScummVM API documentation
Frustum.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 /*
23  * Copyright (C) 2006-2010 - Frictional Games
24  *
25  * This file is part of HPL1 Engine.
26  */
27 
28 #ifndef HPL_FRUSTUM_H
29 #define HPL_FRUSTUM_H
30 
31 #include "hpl1/engine/graphics/GraphicsTypes.h"
32 #include "hpl1/engine/math/BoundingVolume.h"
33 #include "hpl1/engine/math/MathTypes.h"
34 #include "hpl1/engine/system/SystemTypes.h"
35 
36 namespace hpl {
37 
38 class iLowLevelGraphics;
39 
40 enum eFrustumPlane {
41  eFrustumPlane_Left = 0,
42  eFrustumPlane_Right = 1,
43  eFrustumPlane_Bottom = 2,
44  eFrustumPlane_Top = 3,
45  eFrustumPlane_Near = 4,
46  eFrustumPlane_Far = 5,
47  eFrustumPlane_LastEnum = 7,
48 };
49 
50 enum eFrustumCollision {
51  eFrustumCollision_Inside,
52  eFrustumCollision_Outside,
53  eFrustumCollision_Intersect,
54  eFrustumCollision_LastEnum
55 };
56 
57 class cFrustum {
58 public:
59  cFrustum();
60 
61  void SetViewProjMatrix(const cMatrixf &a_mtxProj, const cMatrixf &a_mtxView,
62  float afFarPlane, float afNearPlane, float afFOV, float afAspect,
63  const cVector3f &avOrigin, bool abInfFarPlane = false);
64 
65  cPlanef GetPlane(eFrustumPlane aType);
66 
67  eFrustumCollision CollideBoundingVolume(cBoundingVolume *aBV);
68 
69  eFrustumCollision CollideFustrumSphere(cBoundingVolume *aBV);
70 
71  eFrustumCollision CollideBVSphere(cBoundingVolume *aBV);
72  eFrustumCollision CollideBVAABB(cBoundingVolume *aBV);
73 
77  bool CheckLineIntersection(const cVector3f &avPoint1, const cVector3f &avPoint2);
78 
84 
85  bool CheckVolumeIntersection(cShadowVolumeBV *apVolume);
86 
87  cSpheref GetBoundingSphere() { return mBoundingSphere; }
88  const cBoundingVolume &GetBoundingVolume() { return mBoundingVolume; }
89 
90  const cVector3f &GetOrigin();
91  cBoundingVolume *GetOriginBV();
92 
93  cVector3f GetForward();
94 
95  void Draw(iLowLevelGraphics *apLowLevelGraphics);
96 
97 private:
98  void UpdatePlanes();
99  void UpdateSphere();
100  void UpdateEndPoints();
101  void UpdateBV();
102 
103  float mfFarPlane;
104  float mfNearPlane;
105  float mfAspect;
106  float mfFOV;
107 
108  bool mbInfFarPlane;
109 
110  cVector3f mvOrigin;
111  cBoundingVolume mOriginBV;
112 
113  cMatrixf m_mtxViewProj;
114  cMatrixf m_mtxModelView;
115  cPlanef mPlane[6];
116  cSpheref mBoundingSphere;
117  cBoundingVolume mBoundingVolume;
118 
119  cVector3f mvEndPoints[4];
120  tVector3fVec mvPoints;
121 };
122 
123 } // namespace hpl
124 
125 #endif // HPL_FRUSTUM_H
Definition: AI.h:36
Definition: BoundingVolume.h:71
Definition: BoundingVolume.h:57
bool CheckLineIntersection(const cVector3f &avPoint1, const cVector3f &avPoint2)
bool CheckQuadMeshIntersection(tVector3fVec *apPoints)
Definition: LowLevelGraphics.h:200
Definition: Frustum.h:57