RigsofRods
Soft-body Physics Simulation
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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  comments(orig.comments){}
48 
49  virtual ~ProceduralPoint() override {};
50 
51  Ogre::Vector3 position = Ogre::Vector3::ZERO;
52  Ogre::Quaternion rotation = Ogre::Quaternion::IDENTITY;
54  float width = 0.f;
55  float bwidth = 0.f;
56  float bheight = 0.f;
57  int pillartype = 0;
58  std::string comments;
59 };
60 
61 struct ProceduralObject: public RefCountingObject<ProceduralObject>
62 {
63  virtual ~ProceduralObject() override {};
64 
65  // Nice funcs for Angelscript
66  void addPoint(ProceduralPointPtr p) { points.push_back(p); }
68  void insertPoint(int pos, ProceduralPointPtr p);
69  void deletePoint(int pos);
70  int getNumPoints() const { return (int)points.size(); }
72  std::string getName() { return name; }
73  void setName(std::string const& new_name) { name = new_name; }
74 
75  std::string name;
76  std::vector<ProceduralPointPtr> points;
78  int smoothing_num_splits = 0; // 0=off
79  bool collision_enabled = true;
80 };
81 
82 class ProceduralManager: public RefCountingObject<ProceduralManager>
83 {
84 public:
85  ProceduralManager(Ogre::SceneNode* groupingSceneNode);
86  virtual ~ProceduralManager() override;
87 
90 
93 
94  int getNumObjects() { return (int)pObjects.size(); }
95 
97 
98  void logDiagnostics();
99 
100  void removeAllObjects();
101 
104 
107 
108 private:
109 
110  std::vector<ProceduralObjectPtr> pObjects;
111  Ogre::SceneNode* pGroupingSceneNode = nullptr;
112 };
113 
115 
116 } // namespace RoR
RoR::ProceduralManager::addObject
void addObject(ProceduralObjectPtr po)
Generates road mesh and adds to internal list.
Definition: ProceduralManager.cpp:173
RoR::ProceduralPoint::type
RoadType type
Definition: ProceduralManager.h:53
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:76
RoR::ProceduralPoint::bwidth
float bwidth
Definition: ProceduralManager.h:55
RoR::ProceduralManager::pObjects
std::vector< ProceduralObjectPtr > pObjects
Definition: ProceduralManager.h:110
RoR::ProceduralPoint::comments
std::string comments
Comment line(s) preceding the point-line in the .TOBJ file.
Definition: ProceduralManager.h:58
RoR::RoadType::ROAD_AUTOMATIC
@ ROAD_AUTOMATIC
RoR::ProceduralPoint::position
Ogre::Vector3 position
Definition: ProceduralManager.h:51
RoR::ProceduralPoint::bheight
float bheight
Definition: ProceduralManager.h:56
RoR::ProceduralObject::getName
std::string getName()
Definition: ProceduralManager.h:72
RoR::ProceduralObject::deletePoint
void deletePoint(int pos)
Definition: ProceduralManager.cpp:52
RoR::ProceduralPoint::rotation
Ogre::Quaternion rotation
Definition: ProceduralManager.h:52
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:70
RoR::ProceduralObject::~ProceduralObject
virtual ~ProceduralObject() override
Definition: ProceduralManager.h:63
RefCountingObjectPtr
Definition: RefCountingObjectPtr.h:24
RoR::ProceduralObject::setName
void setName(std::string const &new_name)
Definition: ProceduralManager.h:73
RoR::ProceduralManager
Definition: ProceduralManager.h:82
ProceduralRoad.h
RoR::ProceduralObject
Definition: ProceduralManager.h:61
RoR::ProceduralManager::removeAllObjects
void removeAllObjects()
Definition: ProceduralManager.cpp:86
RoR::ProceduralManager::deleteObjectMesh
void deleteObjectMesh(ProceduralObjectPtr po)
Deletes the road mesh.
Definition: ProceduralManager.cpp:95
RoR::RoadType
RoadType
Definition: ProceduralRoad.h:33
RoR::ProceduralObject::road
ProceduralRoadPtr road
Definition: ProceduralManager.h:77
RoR::ProceduralObject::addPoint
void addPoint(ProceduralPointPtr p)
Definition: ProceduralManager.h:66
RoR::ProceduralPoint::width
float width
Definition: ProceduralManager.h:54
RoR::ProceduralManager::pGroupingSceneNode
Ogre::SceneNode * pGroupingSceneNode
Definition: ProceduralManager.h:111
RoR::ProceduralPoint::~ProceduralPoint
virtual ~ProceduralPoint() override
Definition: ProceduralManager.h:49
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:78
RoR::ProceduralObject::insertPoint
void insertPoint(int pos, ProceduralPointPtr p)
Definition: ProceduralManager.cpp:44
RoR::ProceduralObject::collision_enabled
bool collision_enabled
Generate collision triangles?
Definition: ProceduralManager.h:79
RoR::ProceduralObject::getPoint
ProceduralPointPtr getPoint(int pos)
Definition: ProceduralManager.cpp:32
RoR::ProceduralPoint::ProceduralPoint
ProceduralPoint()
Definition: ProceduralManager.h:36
RoR::ProceduralPoint
Definition: ProceduralManager.h:34
RoR::ProceduralManager::rebuildObjectMesh
void rebuildObjectMesh(ProceduralObjectPtr po)
Rebuilds the road mesh.
Definition: ProceduralManager.cpp:115
RoR::ProceduralManager::logDiagnostics
void logDiagnostics()
Definition: ProceduralManager.cpp:179
RoR::ProceduralObject::getRoad
ProceduralRoadPtr getRoad()
Definition: ProceduralManager.h:71
RoR::ProceduralObject::name
std::string name
Definition: ProceduralManager.h:75
RefCountingObject
Self reference-counting objects, as requred by AngelScript garbage collector.
Definition: RefCountingObject.h:26
RoR::ProceduralManager::getNumObjects
int getNumObjects()
Definition: ProceduralManager.h:94
RoR::ProceduralPoint::ProceduralPoint
ProceduralPoint(const ProceduralPoint &orig)
Definition: ProceduralManager.h:39
RoR::ProceduralPoint::pillartype
int pillartype
Definition: ProceduralManager.h:57
RoR
Definition: AppContext.h:36