ScummVM API documentation
BoundingVolume.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_BOUNDING_VOLUME_H
29 #define HPL_BOUNDING_VOLUME_H
30 
31 #include "hpl1/engine/graphics/GraphicsTypes.h"
32 #include "hpl1/engine/math/MathTypes.h"
33 #include "hpl1/engine/system/SerializeClass.h"
34 #include "hpl1/engine/system/SystemTypes.h"
35 
36 namespace hpl {
37 
38 class iLowLevelGraphics;
39 class cBoundingVolume;
40 
41 class cBVTempArray {
42 public:
43  const float *mpArray;
44  int mlSize;
45 };
46 
47 enum eBVCollision {
48  eBVCollision_Inside,
49  eBVCollision_Outside,
50  eBVCollision_Intersect,
51  eBVCollision_LastEnum
52 };
53 
56 
58 public:
59  cPlanef mvPlanes[12];
60  int mlPlaneCount;
61  tVector3fVec mvPoints;
62  int mlCapPlanes;
63 
64  bool CollideBoundingVolume(cBoundingVolume *aBV);
65 
66 private:
67  bool CollideBVSphere(cBoundingVolume *aBV);
68  bool CollideBVAABB(cBoundingVolume *aBV);
69 };
70 
72  friend class cMath;
73  kSerializableClassInit(cBoundingVolume) public : cBoundingVolume();
74 
75  cVector3f GetMax();
76  cVector3f GetMin();
77 
78  cVector3f GetLocalMax();
79  cVector3f GetLocalMin();
80 
81  void SetLocalMinMax(const cVector3f &mvMin, const cVector3f &mvMax);
82 
83  void SetPosition(const cVector3f &avPos);
84  cVector3f GetPosition();
85 
86  void SetSize(const cVector3f &avSize);
87  cVector3f GetSize();
88 
89  void SetTransform(const cMatrixf &a_mtxTransform);
90  const cMatrixf &GetTransform();
91 
92  cVector3f GetLocalCenter();
93  cVector3f GetWorldCenter();
94 
95  float GetRadius();
96 
97  void AddArrayPoints(const float *apArray, int alNumOfVectors);
98  void CreateFromPoints(int alStride);
99 
100  cShadowVolumeBV *GetShadowVolume(const cVector3f &avLightPos, float afLightRange, bool abForceUpdate);
101 
102  // Debug:
103  void DrawEdges(const cVector3f &avLightPos, float afLightRange, iLowLevelGraphics *apLowLevelGraphics);
104  void UpdateSize();
105 
106  cMatrixf m_mtxTransform;
107 
108  cVector3f mvLocalMax;
109  cVector3f mvLocalMin;
110 
111  cVector3f mvMax;
112  cVector3f mvMin;
113 
114  cVector3f mvPivot;
115 
116  cVector3f mvWorldMax;
117  cVector3f mvWorldMin;
118 
119  cVector3f mvPosition;
120  cVector3f mvSize;
121  float mfRadius;
122 
123 private:
124  bool mbPositionUpdated;
125  bool mbSizeUpdated;
126 
127  tBVTempArrayList mlstArrays;
128 
129  cShadowVolumeBV mShadowVolume;
130  bool mbShadowPlanesNeedUpdate;
131 };
132 
133 } // namespace hpl
134 
135 #endif // HPL_BOUNDING_VOLUME_H
Definition: AI.h:36
Definition: BoundingVolume.h:71
Definition: SerializeClass.h:230
Definition: BoundingVolume.h:57
Definition: BoundingVolume.h:41
Definition: Math.h:39
Definition: list_intern.h:51
Definition: LowLevelGraphics.h:200