-
Notifications
You must be signed in to change notification settings - Fork 4
/
car.h
executable file
·72 lines (64 loc) · 1.88 KB
/
car.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
#ifndef CAR_H
#define CAR_H
#include <QVector>
#include "Box2D.h"
#include "geneticalgorithm.h"
class Car: public QObject {
Q_OBJECT
public:
Car(GeneticAlgorithm *pAlghorithm, b2World *world);
void breakFixture(const int index);
void deletePhisicsBody();
b2Body *getAxleBody(const int index);
b2Fixture *getAxleFixture(const int index);
b2Body *getBody();
b2Fixture *getCartFixture(const int index);
b2Body *getWheel(const int index);
float getMaxPossition();
b2Body *getPiece(const int index);
int getPiecesCount();
b2Vec2 getPossition();
int getRemainingTime();
float getSpeed();
float getTime();
float getTorque();
void setBreakFixture(const int index, const bool val);
void update();
void updateTorque();
signals:
void stoped();
private:
static const float MASS_MULT = 1.5;
static const int MAX_ITTERATION = 5*60*60;
static const float TRACK_LENGTH = 1500.0f;
static const int NO_WHEELS = -1;
static const int BROKEN_WHEELS = -2;
void createCart();
b2Fixture *createFixture(const b2FixtureDef* def, b2Body *body,
const QColor color);
void createWheels(b2BodyDef &bodyDef);
void init(b2BodyDef &bodyDef);
GeneticAlgorithm *algorithm;
b2Body *axle[8];
b2Fixture *axleFixture[8];
b2PolygonShape axleShapes[8];
float baseSpringForce;
b2World *b2world;
bool breakCartFixture[16];
int brokeNum;
b2Body *carBody;
b2Fixture *cartFixture[8];
b2PolygonShape cartShapes[8];
int itteration;
float maxPossition;
b2RevoluteJoint *motor[8];
float prevPossition;
int slow;
b2PrismaticJoint *spring[8];
float torque;
b2Fixture *wheel[8];
int wheelsCount;
int wheelOn[8];
QVector<b2Fixture *> pieces;
};
#endif // CAR_H