-
Notifications
You must be signed in to change notification settings - Fork 0
/
CollisionSystem.h
93 lines (74 loc) · 1.92 KB
/
CollisionSystem.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/*
* CollisionSystem.h
*
* Created on: 15/10/2013
* Author: stewart
*/
#ifndef COLLISIONSYSTEM_H_
#define COLLISIONSYSTEM_H_
#pragma once
#include "define.h"
#include <GL/glut.h>
#include "SculptObject.h"
class CollisionSystem {
private:
int num_NonSunObjects;
typedef struct Model {
// Array for Geometry
G308_Point* m_pVertexArray; // Vertex Array
G308_Normal* m_pNormalArray; // Normal Array
G308_Triangle* m_pTriangles; // Triangle Array
G308_UVcoord* m_pUVArray; // Texture Coordinate Array
// Data for Geometry
int m_nNumPoint;
int m_nNumUV;
int m_nNumNormal;
int m_nNumPolygon;
} Model;
typedef struct Sphere {
G308_Point relativePosition;
float radius;
};
typedef struct CollisionModel {
int sphereCount;
Sphere* spheres;
Model* fullPolyModel;
SculptObject* fullPolyModelSculpt;
float scale;
};
typedef struct Object {
G308_Point position;
G308_Point rotation;
G308_Vector direction;
float speed;
float weight;
SculptObject* displayModel;
CollisionModel* collisionModel;
// for bogus implementation
float radius;
} Object;
Object* worldObjects;
CollisionModel** collisionModels;
Model* loadModel(const char*);
float floatRand(int, int, int);
void processPhysics();
void processCollisions();
bool detectCollision(int, int);
void reactCollision(int, int, G308_Point, G308_Point);
void render();
void normalize(G308_Vector*);
float magnitude(G308_Vector*);
float dotProduct(G308_Vector*, G308_Vector*);
float distanceCalcP(G308_Point, G308_Point);
float distanceCalc(G308_Vector, G308_Vector);
CollisionModel* simpleSphereModel(Model*, float);
CollisionModel* multiSphereModel(SculptObject*, int, float);
void updateMultiModel(CollisionModel*, int);
G308_Point* pickRandomPoints(G308_Point*, int, int);
float orbitalVelocity(int, int);
public:
CollisionSystem(SculptObject**);
void step();
void updateAll();
};
#endif /* COLLISIONSYSTEM_H_ */