RigsofRods
Soft-body Physics Simulation
ProceduralManager.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-2022 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 // @author thomas, 17th of June 2008
23 
24 #pragma once
25 
26 #include "Application.h"
27 #include "ProceduralRoad.h"
28 
29 namespace RoR {
30 
33 
34 struct ProceduralPoint: public RefCountingObject<ProceduralPoint>
35 {
37 
38  // Copy-ctor must be declared explicitly because there's a WORKAROUND mutex in RefCountingObject ~ only_a_ptr, 05/2023
40  position(orig.position),
41  rotation(orig.rotation),
42  type(orig.type),
43  width(orig.width),
44  bwidth(orig.bwidth),
45  bheight(orig.bheight),
46  pillartype(orig.pillartype) {}
47 
48  virtual ~ProceduralPoint() override {};
49 
50  Ogre::Vector3 position = Ogre::Vector3::ZERO;
51  Ogre::Quaternion rotation = Ogre::Quaternion::IDENTITY;
53  float width = 0.f;
54  float bwidth = 0.f;
55  float bheight = 0.f;
56  int pillartype = 0;
57 };
58 
59 struct ProceduralObject: public RefCountingObject<ProceduralObject>
60 {
61  virtual ~ProceduralObject() override {};
62 
63  // Nice funcs for Angelscript
64  void addPoint(ProceduralPointPtr p) { points.push_back(p); }
66  void insertPoint(int pos, ProceduralPointPtr p);
67  void deletePoint(int pos);
68  int getNumPoints() const { return (int)points.size(); }
70  std::string getName() { return name; }
71  void setName(std::string const& new_name) { name = new_name; }
72 
73  std::string name;
74  std::vector<ProceduralPointPtr> points;
76  int smoothing_num_splits = 0; // 0=off
77 };
78 
79 class ProceduralManager: public RefCountingObject<ProceduralManager>
80 {
81 public:
82  ProceduralManager(Ogre::SceneNode* groupingSceneNode);
83  virtual ~ProceduralManager() override;
84 
87 
90 
91  int getNumObjects() { return (int)pObjects.size(); }
92 
94 
95  void logDiagnostics();
96 
97  void removeAllObjects();
98 
99 private:
104 
105  std::vector<ProceduralObjectPtr> pObjects;
106  Ogre::SceneNode* pGroupingSceneNode = nullptr;
107 };
108 
110 
111 } // namespace RoR
RoR::ProceduralManager::addObject
void addObject(ProceduralObjectPtr po)
Generates road mesh and adds to internal list.
Definition: ProceduralManager.cpp:174
RoR::ProceduralPoint::type
RoadType type
Definition: ProceduralManager.h:52
RoR::ProceduralManager::removeObject
void removeObject(ProceduralObjectPtr po)
Clears road mesh and removes from internal list.
Definition: ProceduralManager.cpp:104
RoR::ProceduralObject::points
std::vector< ProceduralPointPtr > points
Definition: ProceduralManager.h:74
RoR::ProceduralPoint::bwidth
float bwidth
Definition: ProceduralManager.h:54
RoR::ProceduralManager::pObjects
std::vector< ProceduralObjectPtr > pObjects
Definition: ProceduralManager.h:105
RoR::RoadType::ROAD_AUTOMATIC
@ ROAD_AUTOMATIC
RoR::ProceduralPoint::position
Ogre::Vector3 position
Definition: ProceduralManager.h:50
RoR::ProceduralPoint::bheight
float bheight
Definition: ProceduralManager.h:55
RoR::ProceduralObject::getName
std::string getName()
Definition: ProceduralManager.h:70
RoR::ProceduralObject::deletePoint
void deletePoint(int pos)
Definition: ProceduralManager.cpp:52
RoR::ProceduralPoint::rotation
Ogre::Quaternion rotation
Definition: ProceduralManager.h:51
RoR::ProceduralManager::~ProceduralManager
virtual ~ProceduralManager() override
Definition: ProceduralManager.cpp:69
RoR::ProceduralManager::ProceduralManager
ProceduralManager(Ogre::SceneNode *groupingSceneNode)
Definition: ProceduralManager.cpp:64
RoR::ProceduralObject::getNumPoints
int getNumPoints() const
Definition: ProceduralManager.h:68
RoR::ProceduralManager::updateObject
void updateObject(ProceduralObjectPtr po)
Rebuilds the road mesh.
Definition: ProceduralManager.cpp:115
RoR::ProceduralObject::~ProceduralObject
virtual ~ProceduralObject() override
Definition: ProceduralManager.h:61
RefCountingObjectPtr
Definition: RefCountingObjectPtr.h:24
RoR::ProceduralObject::setName
void setName(std::string const &new_name)
Definition: ProceduralManager.h:71
RoR::ProceduralManager
Definition: ProceduralManager.h:79
ProceduralRoad.h
RoR::ProceduralObject
Definition: ProceduralManager.h:59
RoR::ProceduralManager::removeAllObjects
void removeAllObjects()
Definition: ProceduralManager.cpp:86
RoR::RoadType
RoadType
Definition: ProceduralRoad.h:33
RoR::ProceduralObject::road
ProceduralRoadPtr road
Definition: ProceduralManager.h:75
RoR::ProceduralObject::addPoint
void addPoint(ProceduralPointPtr p)
Definition: ProceduralManager.h:64
RoR::ProceduralPoint::width
float width
Definition: ProceduralManager.h:53
RoR::ProceduralManager::pGroupingSceneNode
Ogre::SceneNode * pGroupingSceneNode
Definition: ProceduralManager.h:106
RoR::ProceduralPoint::~ProceduralPoint
virtual ~ProceduralPoint() override
Definition: ProceduralManager.h:48
RoR::ProceduralManager::getObject
ProceduralObjectPtr getObject(int pos)
Definition: ProceduralManager.cpp:74
Application.h
Central state/object manager and communications hub.
RoR::ProceduralObject::smoothing_num_splits
int smoothing_num_splits
Definition: ProceduralManager.h:76
RoR::ProceduralObject::insertPoint
void insertPoint(int pos, ProceduralPointPtr p)
Definition: ProceduralManager.cpp:44
RoR::ProceduralObject::getPoint
ProceduralPointPtr getPoint(int pos)
Definition: ProceduralManager.cpp:32
RoR::ProceduralPoint::ProceduralPoint
ProceduralPoint()
Definition: ProceduralManager.h:36
RoR::ProceduralManager::deleteObject
void deleteObject(ProceduralObjectPtr po)
Deletes the road mesh.
Definition: ProceduralManager.cpp:95
RoR::ProceduralPoint
Definition: ProceduralManager.h:34
RoR::ProceduralManager::logDiagnostics
void logDiagnostics()
Definition: ProceduralManager.cpp:180
RoR::ProceduralObject::getRoad
ProceduralRoadPtr getRoad()
Definition: ProceduralManager.h:69
RoR::ProceduralObject::name
std::string name
Definition: ProceduralManager.h:73
RefCountingObject
Self reference-counting objects, as requred by AngelScript garbage collector.
Definition: RefCountingObject.h:26
RoR::ProceduralManager::getNumObjects
int getNumObjects()
Definition: ProceduralManager.h:91
RoR::ProceduralPoint::ProceduralPoint
ProceduralPoint(const ProceduralPoint &orig)
Definition: ProceduralManager.h:39
RoR::ProceduralPoint::pillartype
int pillartype
Definition: ProceduralManager.h:56
RoR
Definition: AppContext.h:36