-
Notifications
You must be signed in to change notification settings - Fork 0
/
city.h
194 lines (111 loc) · 3.17 KB
/
city.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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
#ifndef INC_CITY_H
#define INC_CITY_H
#include "common.h"
#include <list>
#include <vector>
#include "line.h"
#include "vertex.h"
//#include "path.h"
#include "lights.h"
#include "buildings.h"
#include "routes.h"
//class routes;
class sign {
public:
point p;
double k;
int nr;
};
class city {
public:
int selectedBuilding;
std::vector<vertex> p;
buildings b;
std::vector<sign> signs;
bool Init();
void Clear();
bool Load();
void Generate();
void Progress(double time, bool editor);
void Draw();
bool Crossroad(int nr);
//lights
bool LAvailable(int lightNr, int roadNr);
point GetPointOnRoad(double progress, int from, int to, int lane);
point SidePoint(int prev, int now, int next, double laneNr);
int LanesNr(int from, int to);
rect CityRect();
//adding/removing vehicles in vLists
void AddVList(int nr, int from, int to, int lane);
void RemVList(int nr, int from, int to, int lane);
//for vehicle
double GetRoadProgress(int from, int to, point pos);
double DistanceToCrossroad(int from, int to, point pos);
double Length(int from, int to);
//path Path(int pointsL[2]);
std::list<int> Path(int fromB, int toB);
//for editor
int AddVertex(point pos);
int ClosestVertex(point pos);
void AddRoad(int from, int to);
int highlightVertex;
bool drawSBuilding;
//point sampleBuilding;
building sampleBuilding;
void DrawForEditor();
//editor models
model mFlag, mMarker;
//void DrawSampleBuilding();
void SetSampleBuilding(point pos);
void BuildSampleBuilding();
bool drawRoutes;
void DrawRoutes();
routes r;
//background
//saving/loading
void SaveCity();
void LoadCity();
void DrawBuildings(bool color = 0);
private:
//rendering
//buidlings
void DrawBuilding(building *now);
point GetBuildingPos(building *now);
double buildingLinesProgress;
void DrawSigns();
void DrawCity();
void DrawCrossroads();
void DrawRoads();
void DrawSidewalks();
//GLuint glRoads, glCrossroads;
GLuint glCity;
GLuint tRoad, tCrossroad, tSidewalk, tSidewalkSide;
model mSigns[5];
void DrawBackground();
GLuint tGround, tWater;
bool LoadMap(const char *mapFilename);
void LoadLights(const char *filename);
void MakeRoad(int nr, int begin);
std::vector<std::vector<int>> roads;//between crossroads
void MakeRoads();
line SideLine(int from, int to, double side);//private
bool *used;//change it to function's parameter
lights l;
int Neigh(int from, int notTo);
//for sorting
void SortRoad(int nr);
void SortRoads();
//for generating
void GenerateSides();
//for path
void AddFakePoints(int fromB, int toB);
void city::RemoveFakePoints(int toB);
//open
bool OpenRoads(const char *mapFilename);
//buildings
void SetAvailBuildingProgress(building *bNow);
double GetBuildingPosNoCollision(double progr, building *bCheck, bool left, bool right);
void BuildingRoadBounds(double bounds[2], int from, int to);
};
//-----------------------------------------------------------------
#endif