Rigs of Rods 2023.09
Soft-body Physics Simulation
Loading...
Searching...
No Matches
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
32namespace RoR {
33
36
39{
40public:
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
59private:
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);
69 void SetupLayers(RoR::OTCPage& page, Ogre::Terrain *terrain);
70 Ogre::DataStreamPtr getPageConfig(int x, int z);
71
72 std::shared_ptr<RoR::OTCDocument> 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;
87};
88
90
91} // namespace RoR
Central state/object manager and communications hub.
this class handles all interactions with the Ogre Terrain system
bool InitTerrain(std::string otc_filename)
Ogre::TerrainGroup * getTerrainGroup()
void SetupLayers(RoR::OTCPage &page, Ogre::Terrain *terrain)
bool loadTerrainConfig(Ogre::String filename)
Ogre::DataStreamPtr getPageConfig(int x, int z)
Ogre::TerrainGroup * m_ogre_terrain_group
float getHeightAtTerrainPosition(float x, float z)
Ogre::Vector3 getNormalAt(float x, float y, float z)
bool getTerrainImage(int x, int y, Ogre::Image &img)
void SetupBlendMaps(RoR::OTCPage &page, Ogre::Terrain *t)
void SetupGeometry(RoR::OTCPage &page, bool flat=false)
std::shared_ptr< RoR::OTCDocument > m_spec