forked from bridgecommand/bc
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLandObjects.cpp
More file actions
83 lines (63 loc) · 3.11 KB
/
LandObjects.cpp
File metadata and controls
83 lines (63 loc) · 3.11 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
/* 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. */
#include "LandObjects.hpp"
#include "LandObject.hpp"
#include "IniFile.hpp"
#include "Terrain.hpp"
//#include "Constants.hpp"
#include "SimulationModel.hpp"
#include <iostream>
using namespace irr;
LandObjects::LandObjects()
{
}
LandObjects::~LandObjects()
{
//dtor
}
void LandObjects::load(const std::string& worldName, irr::scene::ISceneManager* smgr, SimulationModel* model, const Terrain& terrain)
{
//get landObject.ini filename
std::string scenarioLandObjectFilename = worldName;
scenarioLandObjectFilename.append("/landobject.ini");
//Find number of objects
u32 numberOfObjects;
numberOfObjects = IniFile::iniFileTou32(scenarioLandObjectFilename,"Number");
for(u32 currentObject=1;currentObject<=numberOfObjects;currentObject++) {
//std::cout << "Loading land object " << currentObject << std::endl;
//Get Object type and construct filename
std::string objectName = IniFile::iniFileToString(scenarioLandObjectFilename,IniFile::enumerate1("Type",currentObject));
//Get object position
f32 objectX = model->longToX(IniFile::iniFileTof32(scenarioLandObjectFilename,IniFile::enumerate1("Long",currentObject)));
f32 objectZ = model->latToZ(IniFile::iniFileTof32(scenarioLandObjectFilename,IniFile::enumerate1("Lat",currentObject)));
f32 objectY = IniFile::iniFileTof32(scenarioLandObjectFilename,IniFile::enumerate1("HeightCorrection",currentObject));;
//Check if land object is given in absolute height, or relative to terrain.
if (IniFile::iniFileTou32(scenarioLandObjectFilename,IniFile::enumerate1("Absolute",currentObject))!=1) {
objectY += terrain.getHeight(objectX,objectZ);
}
//Get rotation
f32 rotation = IniFile::iniFileTof32(scenarioLandObjectFilename,IniFile::enumerate1("Rotation",currentObject));
//Create land object and load into vector
landObjects.push_back(LandObject (objectName.c_str(),core::vector3df(objectX,objectY,objectZ),rotation,smgr));
}
}
irr::u32 LandObjects::getNumber() const
{
return landObjects.size();
}
void LandObjects::moveNode(irr::f32 deltaX, irr::f32 deltaY, irr::f32 deltaZ)
{
for(std::vector<LandObject>::iterator it = landObjects.begin(); it != landObjects.end(); ++it) {
it->moveNode(deltaX,deltaY,deltaZ);
}
}