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
FlexMesh.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
26#include "Flexable.h"
27#include "SimData.h" // NodeNum_t
28
29#include <OgreString.h>
30#include <OgreEntity.h>
31#include <OgreVector3.h>
32#include <OgreMesh.h>
33#include <OgreSubMesh.h>
34#include <OgreHardwareBuffer.h>
35
36namespace RoR {
37
40
43
44class FlexMesh: public Flexable
45{
46public:
47
49 Ogre::String const& name,
50 RoR::GfxActor* gfx_actor,
51 NodeNum_t n1,
52 NodeNum_t n2,
53 NodeNum_t nstart,
54 int nrays,
55 Ogre::String const& face_material_name,
56 Ogre::String const& face_material_rg,
57 Ogre::String const& band_material_name,
58 Ogre::String const& band_material_rg,
59 bool rimmed = false,
60 float rimratio = 1.f
61 );
62
63 ~FlexMesh();
64
65 Ogre::Vector3 updateVertices();
66
67 // Flexable
68 bool flexitPrepare() { return true; };
69 void flexitCompute();
70 Ogre::Vector3 flexitFinal();
71
72 void setVisible(bool visible) {} // Nothing to do here
73
74private:
75
76 struct FlexMeshVertex // staging
77 {
78 Ogre::Vector3 position = Ogre::Vector3::ZERO;
79 Ogre::Vector3 normal = Ogre::Vector3::ZERO;
80 Ogre::Vector2 texcoord = Ogre::Vector2::ZERO;
81 };
82
83 // Wheel
84 Ogre::Vector3 m_flexit_center;
88
89 // Meshes
90 Ogre::MeshPtr m_mesh;
91 Ogre::SubMesh* m_submesh_wheelface = nullptr;
92 Ogre::SubMesh* m_submesh_tiretread = nullptr;
93 Ogre::VertexDeclaration* m_vertex_format;
94 Ogre::HardwareVertexBufferSharedPtr m_hw_vbuf;
95
96 // Vertices - staging
97 std::vector<FlexMeshVertex> m_vertices;
98 std::vector<NodeNum_t> m_vertex_nodes;
99
100 // Indices
101 std::vector<uint16_t> m_wheelface_indices;
102 std::vector<uint16_t> m_tiretread_indices;
103
104 // Skeletal animation (1 bone per node)
105};
106
109
110} // namespace RoR
Central state/object manager and communications hub.
Core data structures for simulation; Everything affected by by either physics, network or user intera...
std::vector< uint16_t > m_wheelface_indices
Definition FlexMesh.h:101
Ogre::Vector3 m_flexit_center
Definition FlexMesh.h:84
Ogre::SubMesh * m_submesh_wheelface
Definition FlexMesh.h:91
bool flexitPrepare()
Definition FlexMesh.h:68
std::vector< FlexMeshVertex > m_vertices
Definition FlexMesh.h:97
Ogre::MeshPtr m_mesh
Definition FlexMesh.h:90
Ogre::HardwareVertexBufferSharedPtr m_hw_vbuf
Definition FlexMesh.h:94
bool m_is_rimmed
Definition FlexMesh.h:87
std::vector< uint16_t > m_tiretread_indices
Definition FlexMesh.h:102
void flexitCompute()
Definition FlexMesh.cpp:293
Ogre::Vector3 updateVertices()
Definition FlexMesh.cpp:243
void setVisible(bool visible)
Definition FlexMesh.h:72
Ogre::VertexDeclaration * m_vertex_format
Definition FlexMesh.h:93
RoR::GfxActor * m_gfx_actor
Definition FlexMesh.h:85
Ogre::SubMesh * m_submesh_tiretread
Definition FlexMesh.h:92
Ogre::Vector3 flexitFinal()
Definition FlexMesh.cpp:298
std::vector< NodeNum_t > m_vertex_nodes
Definition FlexMesh.h:98
uint16_t NodeNum_t
Node position within Actor::ar_nodes; use RoR::NODENUM_INVALID as empty value.