Rigs of Rods 2023.09
Soft-body Physics Simulation
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Loading...
Searching...
No Matches
ProceduralRoad.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
6 For more information, see http://www.rigsofrods.org/
7
8 Rigs of Rods is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License version 3, as
10 published by the Free Software Foundation.
11
12 Rigs of Rods is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with Rigs of Rods. If not, see <http://www.gnu.org/licenses/>.
19*/
20
21#pragma once
22
23#include <Ogre.h>
24
25#include "Application.h"
26#include "RefCountingObject.h"
27
28namespace RoR {
29
32
43
58
59// dynamic roads
60class ProceduralRoad : public RefCountingObject<ProceduralRoad>
61{
62public:
63
65 virtual ~ProceduralRoad() override;
66
67 void addBlock(Ogre::Vector3 pos, Ogre::Quaternion rot, RoadType type, float width, float bwidth, float bheight, int pillartype = 1);
72 void addQuad(Ogre::Vector3 p1, Ogre::Vector3 p2, Ogre::Vector3 p3, Ogre::Vector3 p4, TextureFit texfit, Ogre::Vector3 pos, Ogre::Vector3 lastpos, float width, bool flip = false);
73 void addCollisionQuad(Ogre::Vector3 p1, Ogre::Vector3 p2, Ogre::Vector3 p3, Ogre::Vector3 p4, ground_model_t* gm, bool flip = false);
74 void addCollisionQuad(Ogre::Vector3 p1, Ogre::Vector3 p2, Ogre::Vector3 p3, Ogre::Vector3 p4, std::string const& gm_name, bool flip = false);
75 void createMesh();
76 void finish(Ogre::SceneNode* snode);
77 void setCollisionEnabled(bool v) { collision = v; }
78
79 static const unsigned int MAX_VERTEX = 50000;
80 static const unsigned int MAX_TRIS = 50000;
81
82private:
83
84 inline Ogre::Vector3 baseOf(Ogre::Vector3 p);
85 void computePoints(Ogre::Vector3* pts, Ogre::Vector3 pos, Ogre::Quaternion rot, RoadType type, float width, float bwidth, float bheight);
86 void textureFit(Ogre::Vector3 p1, Ogre::Vector3 p2, Ogre::Vector3 p3, Ogre::Vector3 p4, TextureFit texfit, Ogre::Vector2* texc, Ogre::Vector3 pos, Ogre::Vector3 lastpos, float width);
87
89 {
90 Ogre::Vector3 vertex;
91 Ogre::Vector3 normal;
92 Ogre::Vector2 texcoord;
93 };
94
95 Ogre::MeshPtr msh;
96 Ogre::SubMesh* mainsub = nullptr;
97
98 Ogre::Vector2 tex[MAX_VERTEX] = {};
99 Ogre::Vector3 vertex[MAX_VERTEX] = {};
100 int tricount = 0;
101 int vertexcount = 0;
102 uint16_t tris[MAX_TRIS * 3] = {};
103
104 Ogre::Quaternion lastrot;
105 Ogre::SceneNode* snode = nullptr;
106 Ogre::Vector3 lastpos;
107 bool first = true;
108 float lastbheight = 0.f;
109 float lastbwidth = 0.f;
110 float lastwidth = 0.f;
112 int mid = 0;
113 bool collision = true;
114 std::vector<int> registeredCollTris;
115};
116
118
119} // namespace RoR
120
Central state/object manager and communications hub.
Self reference-counting objects, as requred by AngelScript garbage collector.
static const unsigned int MAX_TRIS
static const unsigned int MAX_VERTEX
Ogre::SceneNode * snode
void textureFit(Ogre::Vector3 p1, Ogre::Vector3 p2, Ogre::Vector3 p3, Ogre::Vector3 p4, TextureFit texfit, Ogre::Vector2 *texc, Ogre::Vector3 pos, Ogre::Vector3 lastpos, float width)
uint16_t tris[MAX_TRIS *3]
void setCollisionEnabled(bool v)
Ogre::Vector2 tex[MAX_VERTEX]
virtual ~ProceduralRoad() override
void addCollisionQuad(Ogre::Vector3 p1, Ogre::Vector3 p2, Ogre::Vector3 p3, Ogre::Vector3 p4, ground_model_t *gm, bool flip=false)
std::vector< int > registeredCollTris
void addBlock(Ogre::Vector3 pos, Ogre::Quaternion rot, RoadType type, float width, float bwidth, float bheight, int pillartype=1)
void addQuad(Ogre::Vector3 p1, Ogre::Vector3 p2, Ogre::Vector3 p3, Ogre::Vector3 p4, TextureFit texfit, Ogre::Vector3 pos, Ogre::Vector3 lastpos, float width, bool flip=false)
bool collision
Register collision triangles?
Ogre::Vector3 vertex[MAX_VERTEX]
Ogre::Vector3 baseOf(Ogre::Vector3 p)
Ogre::Vector3 lastpos
Ogre::SubMesh * mainsub
void finish(Ogre::SceneNode *snode)
Ogre::Quaternion lastrot
void computePoints(Ogre::Vector3 *pts, Ogre::Vector3 pos, Ogre::Quaternion rot, RoadType type, float width, float bwidth, float bheight)
Surface friction properties.
Definition SimData.h:704