RigsofRods
Soft-body Physics Simulation
TerrainGeometryManager.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-2020 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 
22 #pragma once
23 
24 #include "Application.h"
25 #include "ConfigFile.h"
26 #include "OTCFileFormat.h"
27 
28 #include <OgreVector3.h>
29 #include <Terrain/OgreTerrain.h>
30 #include <Terrain/OgreTerrainGroup.h>
31 
32 namespace RoR {
33 
36 
39 {
40 public:
43 
44  bool InitTerrain(std::string otc_filename);
45 
46  Ogre::TerrainGroup* getTerrainGroup() { return m_ogre_terrain_group; };
47 
48  float getHeightAt(float x, float z);
49 
50  Ogre::Vector3 getNormalAt(float x, float y, float z);
51 
52  Ogre::Vector3 getMaxTerrainSize();
53 
54  bool isFlat() { return mIsFlat; };
55 
57  void updateLightMap();
58 
59 private:
60 
61  float getHeightAtTerrainPosition(float x, float z);
62 
63  bool getTerrainImage(int x, int y, Ogre::Image& img);
64  bool loadTerrainConfig(Ogre::String filename);
66  void SetupGeometry(RoR::OTCPage& page, bool flat=false);
67  void SetupBlendMaps(RoR::OTCPage& page, Ogre::Terrain* t);
68  void initTerrain();
69  void SetupLayers(RoR::OTCPage& page, Ogre::Terrain *terrain);
70  Ogre::DataStreamPtr getPageConfig(int x, int z);
71 
72  std::shared_ptr<RoR::OTCFile> m_spec;
74  Ogre::TerrainGroup* m_ogre_terrain_group;
76 
77  // Terrn position lookup - ported from OGRE engine.
78  Ogre::Vector3 mPos = Ogre::Vector3::ZERO;
79  Ogre::Real mBase = 0.f;
80  Ogre::Real mScale = 0.f;
81  Ogre::uint16 mSize = 0;
82  float* mHeightData = nullptr;
83 
84  bool mIsFlat;
85  float mMinHeight;
86  float mMaxHeight;
87 };
88 
90 
91 } // namespace RoR
RoR::TerrainGeometryManager::mScale
Ogre::Real mScale
Definition: TerrainGeometryManager.h:80
y
float y
Definition: (ValueTypes) quaternion.h:6
RoR::TerrainGeometryManager::getPageConfig
Ogre::DataStreamPtr getPageConfig(int x, int z)
RoR::TerrainGeometryManager::mBase
Ogre::Real mBase
Definition: TerrainGeometryManager.h:79
OTCFileFormat.h
z
float z
Definition: (ValueTypes) quaternion.h:7
RoR::TerrainGeometryManager::getNormalAt
Ogre::Vector3 getNormalAt(float x, float y, float z)
Definition: TerrainGeometryManager.cpp:247
RoR::TerrainGeometryManager::~TerrainGeometryManager
~TerrainGeometryManager()
Definition: TerrainGeometryManager.cpp:149
RoR::TerrainGeometryManager::getHeightAt
float getHeightAt(float x, float z)
Definition: TerrainGeometryManager.cpp:231
RoR::TerrainGeometryManager::mMinHeight
float mMinHeight
Definition: TerrainGeometryManager.h:85
RoR::TerrainGeometryManager::terrainManager
RoR::Terrain * terrainManager
Definition: TerrainGeometryManager.h:73
RoR::TerrainGeometryManager::getHeightAtTerrainPosition
float getHeightAtTerrainPosition(float x, float z)
Definition: TerrainGeometryManager.cpp:158
RoR::TerrainGeometryManager::SetupGeometry
void SetupGeometry(RoR::OTCPage &page, bool flat=false)
Definition: TerrainGeometryManager.cpp:657
RoR::TerrainGeometryManager::updateLightMap
void updateLightMap()
Definition: TerrainGeometryManager.cpp:388
RoR::TerrainGeometryManager::configureTerrainDefaults
void configureTerrainDefaults()
Definition: TerrainGeometryManager.cpp:420
RoR::TerrainGeometryManager::mIsFlat
bool mIsFlat
Definition: TerrainGeometryManager.h:84
RoR::TerrainGeometryManager::getMaxTerrainSize
Ogre::Vector3 getMaxTerrainSize()
Definition: TerrainGeometryManager.cpp:689
RoR::OTCPage
Definition: OTCFileFormat.h:47
RoR::TerrainGeometryManager::InitTerrain
bool InitTerrain(std::string otc_filename)
Definition: TerrainGeometryManager.cpp:255
RoR::TerrainGeometryManager::UpdateMainLightPosition
void UpdateMainLightPosition()
Definition: TerrainGeometryManager.cpp:406
Application.h
Central state/object manager and communications hub.
RoR::TerrainGeometryManager::isFlat
bool isFlat()
Definition: TerrainGeometryManager.h:54
RoR::TerrainGeometryManager::m_was_new_geometry_generated
bool m_was_new_geometry_generated
Definition: TerrainGeometryManager.h:75
RoR::TerrainGeometryManager::m_spec
std::shared_ptr< RoR::OTCFile > m_spec
Definition: TerrainGeometryManager.h:72
RoR::TerrainGeometryManager::m_ogre_terrain_group
Ogre::TerrainGroup * m_ogre_terrain_group
Definition: TerrainGeometryManager.h:74
RoR::Terrain
Definition: Terrain.h:40
RoR::TerrainGeometryManager::mSize
Ogre::uint16 mSize
Definition: TerrainGeometryManager.h:81
RoR::TerrainGeometryManager::mPos
Ogre::Vector3 mPos
Definition: TerrainGeometryManager.h:78
RoR::TerrainGeometryManager::TerrainGeometryManager
TerrainGeometryManager(Terrain *terrainManager)
Definition: TerrainGeometryManager.cpp:138
RoR::TerrainGeometryManager::getTerrainImage
bool getTerrainImage(int x, int y, Ogre::Image &img)
RoR::TerrainGeometryManager::mHeightData
float * mHeightData
Definition: TerrainGeometryManager.h:82
RoR::TerrainGeometryManager::loadTerrainConfig
bool loadTerrainConfig(Ogre::String filename)
RoR::TerrainGeometryManager::mMaxHeight
float mMaxHeight
Definition: TerrainGeometryManager.h:86
RoR::TerrainGeometryManager::initTerrain
void initTerrain()
RoR::TerrainGeometryManager::SetupBlendMaps
void SetupBlendMaps(RoR::OTCPage &page, Ogre::Terrain *t)
Definition: TerrainGeometryManager.cpp:549
RoR::TerrainGeometryManager
this class handles all interactions with the Ogre Terrain system
Definition: TerrainGeometryManager.h:38
ConfigFile.h
RoR
Definition: AppContext.h:36
x
float x
Definition: (ValueTypes) quaternion.h:5
RoR::TerrainGeometryManager::SetupLayers
void SetupLayers(RoR::OTCPage &page, Ogre::Terrain *terrain)
Definition: TerrainGeometryManager.cpp:517
RoR::TerrainGeometryManager::getTerrainGroup
Ogre::TerrainGroup * getTerrainGroup()
Definition: TerrainGeometryManager.h:46