-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFrustum.h
70 lines (42 loc) · 1.75 KB
/
Frustum.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
#ifndef _FRUSTUM_H
#define _FRUSTUM_H
#include "Main.h"
#define GLM_FORCE_RADIANS
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
// This will allow us to create an object to keep track of our frustum
class CFrustum {
public:
// Call this every time the camera moves to update the frustum
void CalculateFrustum();
// This takes a 3D point and returns TRUE if it's inside of the frustum
bool PointInFrustum(float x, float y, float z);
// This takes a 3D point and a radius and returns TRUE if the sphere is inside of the frustum
bool SphereInFrustum(float x, float y, float z, float radius);
// This takes the center and half the length of the cube.
bool CubeInFrustum(float x, float y, float z, float size);
/////// * /////////// * /////////// * NEW * /////// * /////////// * /////////// *
// This checks if a box is in the frustum
bool BoxInFrustum(float x, float y, float z, float sizeX, float sizeY, float sizeZ);
/////// * /////////// * /////////// * NEW * /////// * /////////// * /////////// *
private:
// This holds the A B C and D values for each side of our frustum.
float m_Frustum[6][4];
};
// This is our debug lines class to view the octree visually
class CDebug
{
public:
// This adds a line to our list of debug lines
void AddDebugLine(glm::vec3 vPoint1, glm::vec3 vPoint2);
// This adds a rectangle with a given center, width, height and depth to our list
void AddDebugBox(glm::vec3 vCenter, float width, float height, float depth);
// This renders all of the lines
void RenderDebugLines();
// This clears all of the debug lines
void Clear();
private:
// This is the vector list of all of our lines
vector<glm::vec3> m_vLines;
};
#endif