-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBoxCollider.h
71 lines (52 loc) · 1.91 KB
/
BoxCollider.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
71
#ifndef _BOXCOLLIDER_H_
#define _BOXCOLLIDER_H_
#include "Collider.h"
// STL
#include <vector>
using namespace std;
// GL
#include "GLInclude.h"
#define GL_EXT_PROTOTYPES
#include <GL/glut.h>
// GLM
#include <glm/glm.hpp>
////////////////////////////////////////////////////////////////////////////////
/// @brief Box collider for collision
////////////////////////////////////////////////////////////////////////////////
class BoxCollider{
public:
//////////////////////////////////////////////////////////////////////////////
/// @brief Constructor
BoxCollider();
//////////////////////////////////////////////////////////////////////////////
/// @brief Updates transforms
void Update(glm::vec3 _translation, glm::vec3 _rotation, float rotation_axis,
glm::vec3 _scale);
//////////////////////////////////////////////////////////////////////////////
/// @brief Draws wireframe box collider
void Draw(GLuint _program, const glm::mat4& _projection, const glm::mat4& _view);
/// Buffer offset
constexpr GLvoid* bufferOffset(size_t _off) {return (char*)NULL + _off;}
////////////////////////////////////////////////////////////////////////////
/// @brief Setup for cube
void Initialize();
//////////////////////////////////////////////////////////////////////////////
/// @brief Sets outer bounds for collision
void SetBounds();
bool CollidesWith(const BoxCollider& _other);
private:
std::vector<glm::vec3> m_vertices; //< VBO data
std::vector<GLuint> m_indices; //< EBO data
glm::vec3 Color = glm::vec3(0, 0, 0); //< Color for shader
glm::vec3 MinPoint = glm::vec3(-1, -1, -1); //< Min bounds
glm::vec3 MaxPoint = glm::vec3(1, 1, 1); //< Max bounds
// Parent data
glm::vec3 Translation;
glm::vec3 Rotation;
float Angle;
glm::vec3 Scale;
GLuint m_vertexArrayObject; //< VAO
GLuint m_vertexBuffer; //< VBO object
GLuint m_elementBuffer; //< EBO object
};
#endif