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
FlexObj.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#include "SimData.h"
26
27#include <Ogre.h>
28
29namespace RoR {
30
33
36
39{
43};
44
56
60{
61public:
62
63 FlexObj(
64 RoR::GfxActor* gfx_actor,
65 node_t* all_nodes, // For initial setup only, pointer is not stored
66 std::vector<CabTexcoord>& texcoords,
67 int numtriangles,
68 int* triangles,
69 std::vector<CabSubmesh>& submeshes,
70 char* texname,
71 const char* name,
72 char* backtexname,
73 char* transtexname);
74
75 ~FlexObj();
76
77 Ogre::Vector3 UpdateFlexObj();
78 void ScaleFlexObj(float factor);
79
80private:
81
83 {
84 Ogre::Vector3 position;
85 Ogre::Vector3 normal;
86 Ogre::Vector2 texcoord;
87 };
88
90 int ComputeVertexPos(int tidx, int v, std::vector<CabSubmesh>& submeshes);
91 Ogre::Vector3 UpdateMesh();
92
93 Ogre::MeshPtr m_mesh;
94 std::vector<Ogre::SubMesh*> m_submeshes;
96 float* m_s_ref;
97
100 Ogre::VertexDeclaration* m_vertex_format;
101 Ogre::HardwareVertexBufferSharedPtr m_hw_vbuf;
102 union
103 {
106 };
107
109 unsigned short* m_indices;
111};
112
115
116} // namespace RoRs
Central state/object manager and communications hub.
Core data structures for simulation; Everything affected by by either physics, network or user intera...
A visual mesh, forming a chassis for softbody actor At most one instance is created per actor.
Definition FlexObj.h:60
FlexObjVertex * m_vertices
Definition FlexObj.h:105
Ogre::Vector3 UpdateMesh()
Definition FlexObj.cpp:186
unsigned short * m_indices
Definition FlexObj.h:109
int ComputeVertexPos(int tidx, int v, std::vector< CabSubmesh > &submeshes)
Compute vertex position in the vertexbuffer (0-based offset) for node v of triangle tidx
Definition FlexObj.cpp:158
size_t m_index_count
Definition FlexObj.h:108
int m_triangle_count
Definition FlexObj.h:110
int * m_vertex_nodes
Definition FlexObj.h:99
Ogre::MeshPtr m_mesh
Definition FlexObj.h:93
RoR::GfxActor * m_gfx_actor
Definition FlexObj.h:95
float * m_s_ref
Definition FlexObj.h:96
size_t m_vertex_count
Definition FlexObj.h:98
std::vector< Ogre::SubMesh * > m_submeshes
Definition FlexObj.h:94
void ScaleFlexObj(float factor)
Definition FlexObj.cpp:149
Ogre::HardwareVertexBufferSharedPtr m_hw_vbuf
Definition FlexObj.h:101
Ogre::Vector3 UpdateFlexObj()
Definition FlexObj.cpp:230
float * m_vertices_raw
Definition FlexObj.h:104
Ogre::VertexDeclaration * m_vertex_format
Definition FlexObj.h:100
Submesh for old-style actor body (the "cab")
Definition FlexObj.h:47
@ BACKMESH_TRANSPARENT
Definition FlexObj.h:48
size_t cabs_pos
Definition FlexObj.h:54
BackmeshType backmesh_type
Definition FlexObj.h:52
size_t texcoords_pos
Definition FlexObj.h:53
Texture coordinates for old-style actor body (the "cab")
Definition FlexObj.h:39
float texcoord_u
Definition FlexObj.h:41
float texcoord_v
Definition FlexObj.h:42
Ogre::Vector2 texcoord
Definition FlexObj.h:86
Ogre::Vector3 position
Definition FlexObj.h:84
Physics: A vertex in the softbody structure.
Definition SimData.h:260