RigsofRods
Soft-body Physics Simulation
Terrain.h
Go to the documentation of this file.
1 /*
2  This source file is part of Rigs of Rods
3  Copyright 2005-2012 Pierre-Michel Ricordel
4  Copyright 2007-2012 Thomas Fischer
5  Copyright 2013-2023 Petr Ohlidal
6 
7  For more information, see http://www.rigsofrods.org/
8 
9  Rigs of Rods is free software: you can redistribute it and/or modify
10  it under the terms of the GNU General Public License version 3, as
11  published by the Free Software Foundation.
12 
13  Rigs of Rods is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with Rigs of Rods. If not, see <http://www.gnu.org/licenses/>.
20 */
21 
23 
24 #pragma once
25 
26 #include "Application.h"
27 #include "RefCountingObject.h"
28 #include "SurveyMapEntity.h"
29 #include "TerrainEditor.h"
30 #include "Terrn2FileFormat.h"
31 
32 #include <OgreVector3.h>
33 #include <string>
34 
35 namespace RoR {
36 
39 
40 class Terrain : public RefCountingObject<Terrain>
41 {
42 public:
43  static const int UNLIMITED_SIGHTRANGE = 4999;
44 
45  Terrain(CacheEntryPtr entry, Terrn2Def def);
46  virtual ~Terrain() override;
47  bool initialize();
48  void dispose();
49 
52  std::string getTerrainName() const { return m_def.name; }
53  std::string getTerrainFileName();
54  std::string getTerrainFileResourceGroup();
55  std::string getGUID() const { return m_def.guid; }
56  int getCategoryID() const { return m_def.category_id; }
57  int getVersion() const { return m_def.version; }
60 
63  Terrn2Def& GetDef() { return m_def; }
64  Ogre::Vector3 getSpawnPos() { return m_def.start_position; }
65  float getWaterHeight() const { return m_def.water_height; }
66  bool isFlat();
67  float getPagedDetailFactor() const { return m_paged_detail_factor; }
68  void addSurveyMapEntity(const std::string& type, const std::string& filename, const std::string& resource_group, const std::string& caption, const Ogre::Vector3& pos, float angle, int id);
69  void delSurveyMapEntities(int id);
72 
79  SkyManager* getSkyManager();
84  IWater* getWater() { return m_water.get(); }
86 
89  Ogre::Light* getMainLight() { return m_main_light; }
90  int getFarClip() const { return m_sight_range; }
92 
95  void setGravity(float value);
96  float getGravity() const { return m_cur_gravity; }
97  float GetHeightAt(float x, float z);
98  Ogre::Vector3 GetNormalAt(float x, float y, float z);
99  Ogre::Vector3 getMaxTerrainSize();
100  Ogre::AxisAlignedBox getTerrainCollisionAAB();
102 
105  void LoadTelepoints();
106  void LoadPredefinedActors();
107  bool HasPredefinedActors();
108  void HandleException(const char* summary);
110 
111 private:
112 
113  // internal methods
114  void initCamera();
115  void initTerrainCollisions();
116  void initFog();
117  void initLight();
118  void initObjects();
119  void initScripting();
120  void initShadows();
121  void initSkySubSystem();
122  void initVegetation();
123  void initWater();
124 
126  void loadTerrainObjects();
127 
128  // Managers
129 
132  std::unique_ptr<IWater> m_water;
136  SkyManager* m_sky_manager;
139 
140  // Properties
141 
146 
147  // Gameplay
148 
149  Ogre::Light* m_main_light;
151  bool m_disposed = false;
152 };
153 
155 
156 } // namespace RoR
RoR::Terrain::Terrain
Terrain(CacheEntryPtr entry, Terrn2Def def)
Definition: Terrain.cpp:53
RoR::Terrain::initCamera
void initCamera()
Definition: Terrain.cpp:225
RoR::Terrain::m_cache_entry
CacheEntryPtr m_cache_entry
Definition: Terrain.h:142
y
float y
Definition: (ValueTypes) quaternion.h:6
RoR::Terrn2Def::water_height
float water_height
Definition: Terrn2FileFormat.h:60
RoR::Terrn2Def
Definition: Terrn2FileFormat.h:48
RoR::Terrain::fixCompositorClearColor
void fixCompositorClearColor()
Definition: Terrain.cpp:365
RoR::Terrain::getPagedDetailFactor
float getPagedDetailFactor() const
Definition: Terrain.h:67
RoR::Terrain::getCategoryID
int getCategoryID() const
Definition: Terrain.h:56
RoR::Terrain::getMaxTerrainSize
Ogre::Vector3 getMaxTerrainSize()
Definition: Terrain.cpp:496
RoR::Collisions
Definition: Collisions.h:80
RoR::Terrain::initScripting
void initScripting()
Definition: Terrain.cpp:457
RoR::TerrainObjectManager
Definition: TerrainObjectManager.h:49
RoR::Terrain::initShadows
void initShadows()
Definition: Terrain.cpp:435
z
float z
Definition: (ValueTypes) quaternion.h:7
RoR::Terrain::getShadowManager
ShadowManager * getShadowManager()
Definition: Terrain.h:81
RoR::Terrain::getTerrainFileResourceGroup
std::string getTerrainFileResourceGroup()
Definition: Terrain.cpp:575
RoR::Terrain::isFlat
bool isFlat()
Definition: Terrain.cpp:518
RoR::Terrain::getObjectManager
TerrainObjectManager * getObjectManager()
Definition: Terrain.h:77
RoR::Terrain::getSkyManager
SkyManager * getSkyManager()
Definition: Terrain.cpp:513
RoR::Terrain::UNLIMITED_SIGHTRANGE
static const int UNLIMITED_SIGHTRANGE
Definition: Terrain.h:43
Terrn2FileFormat.h
RoR::Terrain::setGravity
void setGravity(float value)
Definition: Terrain.cpp:481
RoR::ShadowManager
Definition: ShadowManager.h:51
RoR::HydraxWater
Definition: HydraxWater.h:34
RoR::Terrain::~Terrain
virtual ~Terrain() override
Definition: Terrain.cpp:70
RoR::IWater
< TODO: Mixed gfx+physics (waves) - must be separated ~ only_a_ptr, 02/2018
Definition: IWater.h:32
RoR::Terrain::GetTerrainEditor
TerrainEditor * GetTerrainEditor()
Definition: Terrain.h:82
SurveyMapEntity.h
RoR::Terrain::GetDef
Terrn2Def & GetDef()
Definition: Terrain.h:63
RoR::Terrain::m_terrain_editor
TerrainEditor m_terrain_editor
Definition: Terrain.h:133
RoR::Terrain::initSkySubSystem
void initSkySubSystem()
Definition: Terrain.cpp:253
RoR::Terrain::getTerrainCollisionAAB
Ogre::AxisAlignedBox getTerrainCollisionAAB()
Definition: Terrain.cpp:491
RoR::Terrain::m_paged_detail_factor
float m_paged_detail_factor
Definition: Terrain.h:144
RoR::Terrain::m_shadow_manager
ShadowManager * m_shadow_manager
Definition: Terrain.h:135
RefCountingObjectPtr< CacheEntry >
RoR::Terrain::m_def
RoR::Terrn2Def m_def
Definition: Terrain.h:143
RoR::Terrain::getProceduralManager
ProceduralManagerPtr getProceduralManager()
Definition: Terrain.cpp:565
RoR::Terrain::getTerrainName
std::string getTerrainName() const
Definition: Terrain.h:52
RoR::Terrain::getTerrainFileName
std::string getTerrainFileName()
Definition: Terrain.cpp:570
RoR::Terrain::GetHeightAt
float GetHeightAt(float x, float z)
Definition: Terrain.cpp:503
RoR::Terrain::GetNormalAt
Ogre::Vector3 GetNormalAt(float x, float y, float z)
Definition: Terrain.cpp:508
RoR::Terrain::getWaterHeight
float getWaterHeight() const
Definition: Terrain.h:65
RoR::SurveyMapEntityVec
std::vector< SurveyMapEntity > SurveyMapEntityVec
Definition: SurveyMapEntity.h:56
RoR::Terrain::m_main_light
Ogre::Light * m_main_light
Definition: Terrain.h:149
RoR::Terrain::addSurveyMapEntity
void addSurveyMapEntity(const std::string &type, const std::string &filename, const std::string &resource_group, const std::string &caption, const Ogre::Vector3 &pos, float angle, int id)
Definition: Terrain.cpp:580
RoR::Terrain::initLight
void initLight()
Definition: Terrain.cpp:307
RoR::Terrain::m_geometry_manager
TerrainGeometryManager * m_geometry_manager
Definition: Terrain.h:131
RoR::Terrain::m_sight_range
int m_sight_range
Definition: Terrain.h:145
RoR::Terrain::HandleException
void HandleException(const char *summary)
Definition: Terrain.cpp:545
RoR::Terrain::getSurveyMapEntities
SurveyMapEntityVec & getSurveyMapEntities()
Definition: Terrain.cpp:590
RoR::Terrain::m_water
std::unique_ptr< IWater > m_water
Definition: Terrain.h:132
RoR::Terrain::getGeometryManager
TerrainGeometryManager * getGeometryManager()
Definition: Terrain.h:75
RoR::Terrain::getFarClip
int getFarClip() const
Definition: Terrain.h:90
RoR::Terrain::GetCollisions
Collisions * GetCollisions()
Definition: Terrain.h:83
RoR::Terrain::m_sky_manager
SkyManager * m_sky_manager
Definition: Terrain.h:136
RefCountingObject.h
RoR::Terrn2Def::version
int version
Definition: Terrn2FileFormat.h:58
RoR::Terrain::initFog
void initFog()
Definition: Terrain.cpp:338
Application.h
Central state/object manager and communications hub.
RoR::Terrain::LoadPredefinedActors
void LoadPredefinedActors()
Definition: Terrain.cpp:532
TerrainEditor.h
RoR::Terrain::dispose
void dispose()
Definition: Terrain.cpp:78
RoR::Terrain::m_object_manager
TerrainObjectManager * m_object_manager
Definition: Terrain.h:130
RoR::Terrain::getHydraxManager
HydraxWater * getHydraxManager()
Definition: Terrain.h:78
RoR::Terrain::initTerrainCollisions
void initTerrainCollisions()
Definition: Terrain.cpp:449
RoR::Terrn2Def::guid
std::string guid
Definition: Terrn2FileFormat.h:57
RoR::Terrain
Definition: Terrain.h:40
RoR::Terrain::getVersion
int getVersion() const
Definition: Terrain.h:57
RoR::Terrain::initialize
bool initialize()
Definition: Terrain.cpp:145
RoR::Terrain::loadTerrainObjects
void loadTerrainObjects()
Definition: Terrain.cpp:441
RoR::Terrain::getSpawnPos
Ogre::Vector3 getSpawnPos()
Definition: Terrain.h:64
RoR::Terrain::getSkyXManager
SkyXManager * getSkyXManager()
Definition: Terrain.h:80
RoR::Terrain::LoadTelepoints
void LoadTelepoints()
Definition: Terrain.cpp:526
RoR::Terrain::m_disposed
bool m_disposed
Definition: Terrain.h:151
RoR::Terrain::getCacheEntry
CacheEntryPtr getCacheEntry()
Definition: Terrain.cpp:595
RoR::Terrain::getGravity
float getGravity() const
Definition: Terrain.h:96
RoR::Terrain::initVegetation
void initVegetation()
Definition: Terrain.cpp:346
RoR::Terrain::getGUID
std::string getGUID() const
Definition: Terrain.h:55
RoR::Terrain::SkyX_manager
SkyXManager * SkyX_manager
Definition: Terrain.h:137
RoR::Terrain::getMainLight
Ogre::Light * getMainLight()
Definition: Terrain.h:89
RoR::Terrn2Def::category_id
int category_id
Definition: Terrn2FileFormat.h:55
RefCountingObject
Self reference-counting objects, as requred by AngelScript garbage collector.
Definition: RefCountingObject.h:26
RoR::Terrain::delSurveyMapEntities
void delSurveyMapEntities(int id)
Definition: Terrain.cpp:585
RoR::Terrain::initWater
void initWater()
Definition: Terrain.cpp:391
RoR::Terrn2Def::name
std::string name
Definition: Terrn2FileFormat.h:52
RoR::Terrain::m_collisions
Collisions * m_collisions
Definition: Terrain.h:134
RoR::TerrainGeometryManager
this class handles all interactions with the Ogre Terrain system
Definition: TerrainGeometryManager.h:38
RoR
Definition: AppContext.h:36
RoR::Terrain::initObjects
void initObjects()
Definition: Terrain.cpp:486
x
float x
Definition: (ValueTypes) quaternion.h:5
RoR::Terrain::m_cur_gravity
float m_cur_gravity
Definition: Terrain.h:150
RoR::Terrain::m_hydrax_water
HydraxWater * m_hydrax_water
Definition: Terrain.h:138
RoR::TerrainEditor
Minimalist editor mode; orig.
Definition: TerrainEditor.h:36
RoR::Terrain::getWater
IWater * getWater()
Definition: Terrain.h:84
RoR::SkyXManager
Definition: SkyXManager.h:32
RoR::Terrn2Def::start_position
Ogre::Vector3 start_position
Definition: Terrn2FileFormat.h:56
RoR::Terrain::HasPredefinedActors
bool HasPredefinedActors()
Definition: Terrain.cpp:538