-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathState.h
130 lines (109 loc) · 3.79 KB
/
State.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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
/***************************************************
State.h
Header file for State Class
CPSC8170 - Proj 1 GBG 8/2013
****************************************************/
#ifndef _STATE_H_
#define _STATE_H_
#include "Vector.h"
#include "Model.h"
#include <vector>
#ifdef __APPLE__
# include <GLUT/glut.h>
#else
# include <GL/glut.h>
#endif
#define MAXSTEPS 10000
class State{
private:
Vector3d Velocity; // object's velocity
Vector3d V0; // object's initial velocity
Vector3d Acceleration; // object's acceleration
Vector3d Center; // for particles...really. i should consider changing these...
Vector3d C0;
double Mass; // for particles...really. i should consider changing these...
float Radius; // for particles...really. i should consider changing these...
int Start; // is the object started
int Stopped; // is the object stopped
int Step; // is...stepping?
int Resting; // is the object resting...
int Trace; // i'll probably keep this - trace the object's path
double CoeffofRestitution; // the object's coefficient of restitution
double CoeffofFriction; // the object's coefficient of friction
float EPS; // the "fudge factor"
Vector3d Wind; // the wind vector
Vector3d G; // gravity vector...
double Viscosity; // viscosity
int Collision[MAXSTEPS]; // keeping track of the collisions
Vector3d OldCenter[MAXSTEPS]; // keeping track of the object's old centers (for collision sake & tracing)
Vector3d CollidedN; // normal that was collided with...need to clean this up...
double T; // distance from the hit..
public:
// Constructor
State();
// Setters
void SetVelocity(Vector3d v);
void SetVX(float x);
void SetVY(float y);
void SetVZ(float z);
void SetVelocity(float x, float y, float z);
void SetInitialVelocity(Vector3d v0);
void SetInitialVelocity(float x, float y, float z);
void SetAcceleration(Vector3d a);
void SetCenter(Vector3d c);
void SetCenter(float x, float y, float z);
void SetCX(float x);
void SetCY(float y);
void SetCZ(float z);
void SetInitialCenter(Vector3d c0);
void SetInitialCenter(float x, float y, float z);
void SetMass(double m);
void SetRadius(float r);
void SetStart(int start);
void SetStopped(int stop);
void SetStep(int step);
void SetTrace(int trace);
void SetCoeffR(double cor);
void SetCoeffF(double cof);
void SetEPS(float eps);
void SetResting(int type);
void AddCollision(int collision, int indx);
void AddOldCenter(int indx);
void SetCollidedN(Vector3d vn);
void SetT(double t);
void SetGravity(Vector3d g);
void SetWind(Vector3d w);
void SetViscosity(double viscosity);
// Getters
Vector3d GetVelocity();
Vector3d GetInitialVelocity();
Vector3d GetInitialCenter();
Vector3d GetAcceleration();
Vector3d GetCenter();
double GetMass();
double GetRadius();
int IsStarted();
int IsStopped();
int IsStep();
int IsResting();
int IsTrace();
double GetCoeffR();
double GetCoeffF();
Vector3d GetG();
double GetViscosity();
Vector3d GetWind();
float GetEPS();
int Collided(int i = 0);
Vector3d GetCollidedN();
Vector3d GetOldCenter(int indx = 0);
double GetT();
// Functions || Rule of thumb: if the calculations relies *mostly* on state variables, place in state. If it relies 2 entities; then...should probably NOT put it here.
void CalcAcceleration();
Vector3d CalcNewVelocity(double timestep);
Vector3d CalcNewVelocity(double timestep, double timefraction);
void ScaleVelocity(Vector3d pnormal);
Vector3d CalcNewPosition(double timestep);
Vector3d CalcNewPosition(double timestep, double timefraction);
void AdjustAccVelPos(Vector3d prnormal, Vector3d pvertex);
};
#endif