Rigs of Rods 2023.09
Soft-body Physics Simulation
Loading...
Searching...
No Matches
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
29namespace RoR {
30
33
34struct 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),
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
61struct 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
82class ProceduralManager: public RefCountingObject<ProceduralManager>
83{
84public:
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
108private:
109
110 std::vector<ProceduralObjectPtr> pObjects;
111 Ogre::SceneNode* pGroupingSceneNode = nullptr;
112};
113
115
116} // namespace RoR
Central state/object manager and communications hub.
Self reference-counting objects, as requred by AngelScript garbage collector.
void rebuildObjectMesh(ProceduralObjectPtr po)
Rebuilds the road mesh.
virtual ~ProceduralManager() override
void deleteObjectMesh(ProceduralObjectPtr po)
Deletes the road mesh.
void addObject(ProceduralObjectPtr po)
Generates road mesh and adds to internal list.
void removeObject(ProceduralObjectPtr po)
Clears road mesh and removes from internal list.
Ogre::SceneNode * pGroupingSceneNode
ProceduralObjectPtr getObject(int pos)
std::vector< ProceduralObjectPtr > pObjects
void setName(std::string const &new_name)
ProceduralPointPtr getPoint(int pos)
bool collision_enabled
Generate collision triangles?
std::vector< ProceduralPointPtr > points
void insertPoint(int pos, ProceduralPointPtr p)
virtual ~ProceduralObject() override
ProceduralRoadPtr road
ProceduralRoadPtr getRoad()
void addPoint(ProceduralPointPtr p)
ProceduralPoint(const ProceduralPoint &orig)
std::string comments
Comment line(s) preceding the point-line in the .TOBJ file.
virtual ~ProceduralPoint() override
Ogre::Quaternion rotation