forked from bridgecommand/bc
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSimulationModel.hpp
More file actions
181 lines (161 loc) · 6.78 KB
/
Copy pathSimulationModel.hpp
File metadata and controls
181 lines (161 loc) · 6.78 KB
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
/* Bridge Command 5.0 Ship Simulator
Copyright (C) 2014 James Packer
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2 as
published by the Free Software Foundation
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY Or FITNESS For A PARTICULAR PURPOSE. See the
GNU General Public License For more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */
#ifndef __SIMULATIONMODEL_HPP_INCLUDED__
#define __SIMULATIONMODEL_HPP_INCLUDED__
#include <iostream> //For debugging
#include <string>
#include <vector>
#include <stdint.h> //for uint64_t
#include "irrlicht.h"
#include "GUIMain.hpp"
#include "Terrain.hpp"
#include "Light.hpp"
#include "Water.hpp"
#include "Rain.hpp"
#include "Tide.hpp"
#include "Sky.hpp"
#include "Buoys.hpp"
#include "OtherShips.hpp"
#include "LandObjects.hpp"
#include "LandLights.hpp"
#include "OwnShip.hpp"
#include "Camera.hpp"
#include "RadarCalculation.hpp"
#include "RadarScreen.hpp"
#include "IniFile.hpp" //For ini handling: confirm if this is needed
class SimulationModel //Start of the 'Model' part of MVC
{
public:
SimulationModel(irr::IrrlichtDevice* dev, irr::scene::ISceneManager* scene, GUIMain* gui, std::string scenarioName, bool secondary);
~SimulationModel();
irr::f32 longToX(irr::f32 longitude) const;
irr::f32 latToZ(irr::f32 latitude) const;
void setSpeed(irr::f32 spd); //Sets the own ship's speed
void setHeading(irr::f32 hdg); //Sets the own ship's heading
void setPos(irr::f32 positionX, irr::f32 positionZ);
void setRudder(irr::f32 rudder); //Set the rudder (-ve is port, +ve is stbd)
irr::f32 getRudder() const;
void setPortEngine(irr::f32 port); //Set the engine, (-ve astern, +ve ahead)
void setStbdEngine(irr::f32 stbd); //Set the engine, (-ve astern, +ve ahead)
irr::f32 getPortEngineRPM() const;
irr::f32 getStbdEngineRPM() const;
//irr::f32 getPortEngine() const;
//irr::f32 getStbdEngine() const;
void setAccelerator(irr::f32 accelerator); //Set simulation time compression
irr::f32 getAccelerator() const;
irr::f32 getSpeed() const; //Gets the own ship's speed
irr::f32 getHeading() const; //Gets the own ship's heading
irr::f32 getLat() const;
irr::f32 getLong() const;
irr::f32 getPosX() const;
irr::f32 getPosZ() const;
irr::f32 getCOG() const;
irr::f32 getSOG() const; //In metres/second
//void getTime(irr::u8& hour, irr::u8& min, irr::u8& sec) const;
//void getDate(irr::u8& day, irr::u8& month, irr::u16& year) const;
uint64_t getTimestamp() const; //The unix timestamp in s
uint64_t getTimeOffset() const; //The timestamp at the start of the first day of the scenario
irr::f32 getTimeDelta() const; //The change in time (s) since the start of the start day of the scenario
void setTimeDelta(irr::f32 scenarioTime);
irr::u32 getNumberOfOtherShips() const;
irr::u32 getNumberOfBuoys() const;
std::string getOtherShipName(int number) const;
irr::f32 getOtherShipPosX(int number) const;
irr::f32 getOtherShipPosZ(int number) const;
irr::f32 getOtherShipHeading(int number) const;
irr::f32 getOtherShipSpeed(int number) const; //Speed in m/s
void setOtherShipHeading(int number, irr::f32 hdg);
void setOtherShipPos(int number, irr::f32 positionX, irr::f32 positionZ);
void setOtherShipSpeed(int number, irr::f32 speed); //Speed in m/s
std::vector<Leg> getOtherShipLegs(int number) const;
irr::f32 getBuoyPosX(int number) const;
irr::f32 getBuoyPosZ(int number) const;
void changeOtherShipLeg(int shipNumber, int legNumber, irr::f32 bearing, irr::f32 speed, irr::f32 distance);
void addOtherShipLeg(int shipNumber, int afterLegNumber, irr::f32 bearing, irr::f32 speed, irr::f32 distance);
void deleteOtherShipLeg(int shipNumber, int legNumber);
void setWeather(irr::f32 weather); //Range 0-12.
irr::f32 getWeather() const;
void setRain(irr::f32 rainIntensity); //Range 0-10
irr::f32 getRain() const;
void lookUp();
void lookDown();
void lookLeft();
void lookRight();
void lookAhead();
void lookAstern();
void lookPort();
void lookStbd();
void changeView();
irr::u32 getCameraView() const;
void increaseRadarRange();
void decreaseRadarRange();
void setRadarGain(irr::f32 value);
void setRadarClutter(irr::f32 value);
void setRadarRain(irr::f32 value);
void increaseRadarEBLRange();
void decreaseRadarEBLRange();
void increaseRadarEBLBrg();
void decreaseRadarEBLBrg();
void setMainCameraActive();
void setRadarCameraActive();
void updateViewport(irr::f32 aspect);
void toggleZoom();
irr::u32 getLoopNumber() const;
std::string getScenarioName() const;
std::string getWorldName() const;
void update();
void sinkOwnShip();
bool checkOwnShipSunk();
private:
irr::IrrlichtDevice* device;
irr::video::IVideoDriver* driver;
irr::scene::ISceneManager* smgr;
bool secondary; //Are we in secondary mode?
irr::video::IImage* radarImage;
//irr::f32 accelerator;
irr::f32 tideHeight;
irr::f32 weather; //0-12.0
irr::f32 rainIntensity; //0-10
irr::u32 loopNumber; //Todo: check if this is a reasonable size
irr::f32 zoom;
Terrain terrain;
Light light;
OwnShip ownShip;
OtherShips otherShips;
Buoys buoys;
LandObjects landObjects;
LandLights landLights;
Camera camera;
Camera radarCamera;
Water water;
Tide tide;
Rain rain;
RadarCalculation radarCalculation;
RadarScreen radarScreen;
GUIMain* guiMain;
//Simulation time handling
irr::u32 currentTime; //Computer clock time
irr::u32 previousTime; //Computer clock time
irr::f32 deltaTime;
irr::f32 scenarioTime; //Simulation internal time, starting at zero at 0000h on start day of simulation
uint64_t scenarioOffsetTime; //Simulation day's start time from unix epoch (1 Jan 1970)
uint64_t absoluteTime; //Unix timestamp for current time, including start day. Calculated from scenarioTime and scenarioOffsetTime
//utility function to check for collision
bool checkOwnShipCollision();
//Offset position handling
irr::core::vector3d<irr::s64> offsetPosition;//Fixme: check size of this
//store useful information
std::string scenarioName;
std::string worldName;
};
#endif