-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFrustumG.h
70 lines (47 loc) · 1.22 KB
/
FrustumG.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/* ------------------------------------------------------
View Frustum - Std3D
--------------------------------------------------------*/
#ifndef _FRUSTUM_
#define _FRUSTUM_
#include "Vec3.h"
#include "Matrix.hpp"
#include "Plane.h"
#include "AABox.h"
class FrustumG
{
public:
enum EClipPlane
{
P_TOP = 0,
P_BOTTOM,
P_LEFT,
P_RIGHT,
P_NEAR,
P_FAR,
P_AMOUNT
};
enum
{
OUTSIDE,
INSIDE,
INTERSECT
};
FrustumG();
void setCamInternals(float fovY, UInt32 width, UInt32 height, float nearD, float farD);
void update(const Vec3& eye, const Vec3& lookAt, const Vec3& up);
void print() const;
////////////////////////////////////////////////////////////////
bool pointInFrustum(const Vec3& point) const;
int sphereInFrustum(const Vec3& center, float radius) const;
int boxInFrustum (const AABox& box) const;
//protected:
// clipping planes
Plane mClipPlanes[P_AMOUNT];
// frustum pyramid points
Vec3 mNTL, mNTR, mNBL, mNBR, mFTL, mFTR, mFBL, mFBR;
// camera configuration
float mNearD, mFarD, mRatio, mFovY;
// create for optimization, to avoid extra-calculation
float mNW, mNH, mFW, mFH;
};
#endif