RigsofRods
Soft-body Physics Simulation
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
FlexFactory.cpp
Go to the documentation of this file.
1 /*
2  This source file is part of Rigs of Rods
3 
4  Copyright 2015-2020 Petr Ohlidal
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 
24 
25 #include "FlexFactory.h"
26 
27 #include "Application.h"
28 #include "Actor.h"
29 #include "CacheSystem.h"
30 #include "FlexBody.h"
31 #include "FlexMeshWheel.h"
32 #include "GfxScene.h"
33 #include "PlatformUtils.h"
34 #include "RigDef_File.h"
35 #include "ActorSpawner.h"
36 
37 #include <OgreMeshManager.h>
38 #include <OgreSceneManager.h>
39 #include <MeshLodGenerator/OgreMeshLodGenerator.h>
40 
41 //#define FLEXFACTORY_DEBUG_LOGGING
42 
43 #ifdef FLEXFACTORY_DEBUG_LOGGING
44 # include "RoRPrerequisites.h"
45 # define FLEX_DEBUG_LOG(TEXT) LOG("FlexFactory | " TEXT)
46 #else
47 # define FLEX_DEBUG_LOG(TEXT)
48 #endif // FLEXFACTORY_DEBUG_LOGGING
49 
50 using namespace RoR;
51 
52 // Static
53 const char * FlexBodyFileIO::SIGNATURE = "RoR FlexBody";
54 
56  m_rig_spawner(rig_spawner),
57  m_is_flexbody_cache_loaded(false),
58  m_is_flexbody_cache_enabled(App::gfx_flexbody_cache->getBool()),
59  m_flexbody_cache_next_index(0)
60 {
61 }
62 
64  FlexbodyID_t flexbody_id,
65  const NodeNum_t ref_node,
66  const NodeNum_t x_node,
67  const NodeNum_t y_node,
68  Ogre::Vector3 offset,
69  Ogre::Vector3 rotation,
70  std::vector<unsigned int> & node_indices,
71  std::vector<ForvertTempData>& forvert_data,
72  const std::string& mesh_name,
73  const std::string& resource_group_name)
74 {
75  Ogre::MeshPtr common_mesh = Ogre::MeshManager::getSingleton().load(mesh_name, resource_group_name);
76  const std::string mesh_unique_name = m_rig_spawner->ComposeName(fmt::format("{}_FlexBody", mesh_name).c_str(), flexbody_id);
77  Ogre::MeshPtr mesh = common_mesh->clone(mesh_unique_name);
78  const std::string flexbody_name = m_rig_spawner->ComposeName("Flexbody", flexbody_id);
79  Ogre::Entity* entity = App::GetGfxScene()->GetSceneManager()->createEntity(flexbody_name, mesh_unique_name, resource_group_name);
80  m_rig_spawner->SetupNewEntity(entity, Ogre::ColourValue(0.5, 0.5, 1));
81 
82  FLEX_DEBUG_LOG(__FUNCTION__);
83  FlexBodyCacheData* from_cache = nullptr;
85  {
86  FLEX_DEBUG_LOG(__FUNCTION__ " >> Get entry from cache ");
89  }
90 
91  Ogre::Quaternion rot=Ogre::Quaternion(Ogre::Degree(rotation.z), Ogre::Vector3::UNIT_Z);
92  rot=rot*Ogre::Quaternion(Ogre::Degree(rotation.y), Ogre::Vector3::UNIT_Y);
93  rot=rot*Ogre::Quaternion(Ogre::Degree(rotation.x), Ogre::Vector3::UNIT_X);
94 
95  FlexBody* new_flexbody = new FlexBody(
96  from_cache,
98  entity,
99  ref_node,
100  x_node,
101  y_node,
102  offset,
103  rot,
104  node_indices,
105  forvert_data);
106 
108  {
109  m_flexbody_cache.AddItemToSave(new_flexbody);
110  }
111  new_flexbody->m_id = flexbody_id;
112  new_flexbody->m_orig_mesh_name = common_mesh->getName();
113  return new_flexbody;
114 }
115 
117  unsigned int wheel_index,
118  int axis_node_1_index,
119  int axis_node_2_index,
120  int nstart,
121  int nrays,
122  float rim_radius,
123  bool rim_reverse,
124  std::string const & rim_mesh_name,
125  std::string const & rim_mesh_rg,
126  std::string const & tire_material_name,
127  std::string const & tire_material_rg)
128 {
129  const ActorPtr& actor = m_rig_spawner->GetActor();
130 
131  // Load+instantiate static mesh for rim (may be located in addonpart ZIP-bundle!)
132  const std::string rim_entity_name = m_rig_spawner->ComposeName("rim @ *wheel*", wheel_index);
133  Ogre::Entity* rim_prop_entity = App::GetGfxScene()->GetSceneManager()->createEntity(rim_entity_name, rim_mesh_name, rim_mesh_rg);
134  m_rig_spawner->SetupNewEntity(rim_prop_entity, Ogre::ColourValue(0, 0.5, 0.8));
135 
136  // Create dynamic mesh for tire (always located in the actor resource group)
137  const std::string tire_mesh_name = m_rig_spawner->ComposeName("tire @ *wheel*", wheel_index);
138  FlexMeshWheel* flex_mesh_wheel = new FlexMeshWheel(
139  rim_prop_entity,
140  m_rig_spawner->m_wheels_parent_scenenode->createChildSceneNode(m_rig_spawner->ComposeName("*wheel*", wheel_index)), // Friend access
141  m_rig_spawner->GetActor()->GetGfxActor(), axis_node_1_index, axis_node_2_index, nstart, nrays,
142  tire_mesh_name, actor->GetGfxActor()->GetResourceGroup(),
143  tire_material_name, tire_material_rg, rim_radius, rim_reverse);
144 
145  // Instantiate the dynamic tire mesh (always located in the actor resource group)
146  const std::string tire_instance_name = m_rig_spawner->ComposeName("tire entity @ *wheel*", wheel_index);
147  Ogre::Entity *tire_entity = App::GetGfxScene()->GetSceneManager()->createEntity(
148  tire_instance_name, tire_mesh_name, actor->GetGfxActor()->GetResourceGroup());
149  m_rig_spawner->SetupNewEntity(tire_entity, Ogre::ColourValue(0, 0.5, 0.8));
150  flex_mesh_wheel->m_tire_entity = tire_entity; // Friend access.
151 
152  return flex_mesh_wheel;
153 }
154 
155 void FlexBodyFileIO::WriteToFile(void* source, size_t length)
156 {
157  size_t num_written = fwrite(source, length, 1, m_file);
158  if (num_written != 1)
159  {
160  FLEX_DEBUG_LOG(__FUNCTION__ " >> EXCEPTION!! ");
162  }
163 }
164 
165 void FlexBodyFileIO::ReadFromFile(void* dest, size_t length)
166 {
167  size_t num_written = fread(dest, length, 1, m_file);
168  if (num_written != 1)
169  {
170  FLEX_DEBUG_LOG(__FUNCTION__ " >> EXCEPTION!! ");
172  }
173 }
174 
176 {
177  FLEX_DEBUG_LOG(__FUNCTION__);
178  WriteToFile((void*)SIGNATURE, (strlen(SIGNATURE) + 1) * sizeof(char));
179 }
180 
182 {
183  FLEX_DEBUG_LOG(__FUNCTION__);
184  char signature[25];
185  this->ReadFromFile((void*)&signature, (strlen(SIGNATURE) + 1) * sizeof(char));
186  if (strcmp(SIGNATURE, signature) != 0)
187  {
189  }
190 }
191 
193 {
194  FLEX_DEBUG_LOG(__FUNCTION__);
197  meta.num_flexbodies = static_cast<int>(m_items_to_save.size());
198 
199  this->WriteToFile((void*)&meta, sizeof(FlexBodyFileMetadata));
200 }
201 
203 {
204  FLEX_DEBUG_LOG(__FUNCTION__);
205  ROR_ASSERT(meta != nullptr);
206  this->ReadFromFile((void*)meta, sizeof(FlexBodyFileMetadata));
207 }
208 
210 {
211  FLEX_DEBUG_LOG(__FUNCTION__);
212  FlexBodyRecordHeader header;
213  header.vertex_count = static_cast<int>(flexbody->m_vertex_count);
214  header.node_center = flexbody->m_node_center ;
215  header.node_x = flexbody->m_node_x ;
216  header.node_y = flexbody->m_node_y ;
217  header.center_offset = flexbody->m_center_offset ;
218  header.camera_mode = flexbody->m_camera_mode ;
219  header.shared_buf_num_verts = flexbody->m_shared_buf_num_verts ;
220  header.num_submesh_vbufs = flexbody->m_num_submesh_vbufs ;
221 
225 
226  this->WriteToFile((void*)&header, sizeof(FlexBodyRecordHeader));
227 }
228 
230 {
231  FLEX_DEBUG_LOG(__FUNCTION__);
232  this->ReadFromFile((void*)&data->header, sizeof(FlexBodyRecordHeader));
233 }
234 
235 
237 {
238  FLEX_DEBUG_LOG(__FUNCTION__);
239  this->WriteToFile((void*)flexbody->m_locators, sizeof(Locator_t) * flexbody->m_vertex_count);
240 }
241 
243 {
244  FLEX_DEBUG_LOG(__FUNCTION__);
245  // Alloc. Use <new> - experiment
246  data->locators = new Locator_t[data->header.vertex_count];
247  // Read
248  this->ReadFromFile((void*)data->locators, sizeof(Locator_t) * data->header.vertex_count);
249 }
250 
252 {
253  FLEX_DEBUG_LOG(__FUNCTION__);
254  this->WriteToFile((void*)flexbody->m_src_normals, sizeof(Ogre::Vector3) * flexbody->m_vertex_count);
255 }
256 
258 {
259  FLEX_DEBUG_LOG(__FUNCTION__);
260  const int vertex_count = data->header.vertex_count;
261  // Alloc. Use malloc() because that's how flexbodies were implemented.
262  data->src_normals=(Ogre::Vector3*)malloc(sizeof(Ogre::Vector3) * vertex_count);
263  // Read
264  this->ReadFromFile((void*)data->src_normals, sizeof(Ogre::Vector3) * vertex_count);
265 }
266 
268 {
269  FLEX_DEBUG_LOG(__FUNCTION__);
270  this->WriteToFile((void*)flexbody->m_dst_pos, sizeof(Ogre::Vector3) * flexbody->m_vertex_count);
271 }
272 
274 {
275  FLEX_DEBUG_LOG(__FUNCTION__);
276  const int vertex_count = data->header.vertex_count;
277  // Alloc. Use malloc() because that's how flexbodies were implemented.
278  data->dst_pos=(Ogre::Vector3*)malloc(sizeof(Ogre::Vector3) * vertex_count);
279  // Read
280  this->ReadFromFile((void*)data->dst_pos, sizeof(Ogre::Vector3) * vertex_count);
281 }
282 
284 {
285  FLEX_DEBUG_LOG(__FUNCTION__);
286  if (flexbody->m_has_texture_blend)
287  {
288  this->WriteToFile((void*)flexbody->m_src_colors, sizeof(Ogre::ARGB) * flexbody->m_vertex_count);
289  }
290 }
291 
293 {
294  FLEX_DEBUG_LOG(__FUNCTION__);
296  {
297  return;
298  }
299  const int vertex_count = data->header.vertex_count;
300  // Alloc. Use malloc() because that's how flexbodies were implemented.
301  data->src_colors=(Ogre::ARGB*)malloc(sizeof(Ogre::ARGB) * vertex_count);
302  // Read
303  this->ReadFromFile((void*)data->src_colors, sizeof(Ogre::ARGB) * vertex_count);
304 }
305 
306 void FlexBodyFileIO::OpenFile(const char* fopen_mode)
307 {
308  FLEX_DEBUG_LOG(__FUNCTION__);
309  if (m_cache_entry_number == -1)
310  {
312  }
313  char path[500];
314  sprintf(path, "%s%cflexbodies_mod_%00d.dat", App::sys_cache_dir->getStr().c_str(), RoR::PATH_SLASH, m_cache_entry_number);
315  m_file = fopen(path, fopen_mode);
316  if (m_file == nullptr)
317  {
319  }
320 }
321 
323 {
324  FLEX_DEBUG_LOG(__FUNCTION__);
325  if (m_items_to_save.size() == 0)
326  {
327  FLEX_DEBUG_LOG(__FUNCTION__ " >> No flexbodies to save >> EXIT");
328  return RESULT_CODE_OK;
329  }
330  try
331  {
332  this->OpenFile("wb");
333 
334  this->WriteSignature();
335  this->WriteMetadata();
336 
337  auto itor = m_items_to_save.begin();
338  auto end = m_items_to_save.end();
339  for (; itor != end; ++itor)
340  {
341  FlexBody* flexbody = *itor;
342  this->WriteFlexbodyHeader(flexbody);
343 
344  this->WriteFlexbodyLocatorList (flexbody);
345  this->WriteFlexbodyPositionsBuffer(flexbody);
346  this->WriteFlexbodyNormalsBuffer (flexbody);
347  this->WriteFlexbodyColorsBuffer (flexbody);
348  }
349  this->CloseFile();
350  FLEX_DEBUG_LOG(__FUNCTION__ " >> OK ");
351  return RESULT_CODE_OK;
352  }
353  catch (ResultCode result)
354  {
355  this->CloseFile();
356  FLEX_DEBUG_LOG(__FUNCTION__ " >> EXCEPTION!! ");
357  return result;
358  }
359 }
360 
362 {
363  FLEX_DEBUG_LOG(__FUNCTION__);
364  try
365  {
366  this->OpenFile("rb");
367  this->ReadAndCheckSignature();
368 
370  this->ReadMetadata(&meta);
373  {
375  }
376  m_loaded_items.resize(meta.num_flexbodies);
377 
378  for (unsigned int i = 0; i < meta.num_flexbodies; ++i)
379  {
380  FlexBodyCacheData* data = & m_loaded_items[i];
381  this->ReadFlexbodyHeader(data);
383  {
384  this->ReadFlexbodyLocatorList (data);
385  this->ReadFlexbodyPositionsBuffer(data);
386  this->ReadFlexbodyNormalsBuffer (data);
387  this->ReadFlexbodyColorsBuffer (data);
388  }
389  }
390 
391  this->CloseFile();
392  FLEX_DEBUG_LOG(__FUNCTION__ " >> OK ");
393  return RESULT_CODE_OK;
394  }
395  catch (ResultCode ret)
396  {
397  this->CloseFile();
398  FLEX_DEBUG_LOG(__FUNCTION__ " >> EXCEPTION!! ");
399  return ret;
400  }
401 }
402 
404  m_file(nullptr),
405  m_fileformat_version(0),
406  m_cache_entry_number(-1) // flexbody cache disabled (shouldn't be based on the cache entry number ...) ~ ulteq 01/19
407  {}
408 
410 {
411  FLEX_DEBUG_LOG(__FUNCTION__);
413  {
416  }
417 }
418 
420 {
421  FLEX_DEBUG_LOG(__FUNCTION__);
423  {
424  FLEX_DEBUG_LOG(__FUNCTION__ " >> Saving flexbodies");
426  }
427 }
428 
ROR_ASSERT
#define ROR_ASSERT(_EXPR)
Definition: Application.h:40
RoR::FlexBodyCacheData
Definition: FlexFactory.h:66
RoR::FlexBodyFileIO::FlexBodyFileMetadata::num_flexbodies
unsigned int num_flexbodies
Definition: FlexFactory.h:127
RoR::FlexBodyRecordHeader::node_x
int node_x
Definition: FlexFactory.h:52
RoR::FlexBodyCacheData::header
FlexBodyRecordHeader header
Definition: FlexFactory.h:77
FlexMeshWheel.h
RoR::FlexBodyFileIO::RESULT_CODE_FREAD_OUTPUT_INCOMPLETE
@ RESULT_CODE_FREAD_OUTPUT_INCOMPLETE
Definition: FlexFactory.h:108
RoR::Locator_t
Definition: Locator_t.h:10
RoR::FlexBodyFileIO::WriteFlexbodyColorsBuffer
void WriteFlexbodyColorsBuffer(FlexBody *flexbody)
Definition: FlexFactory.cpp:283
RoR::FlexBodyFileIO::OpenFile
void OpenFile(const char *fopen_mode)
Definition: FlexFactory.cpp:306
RoR::FlexBodyRecordHeader::HAS_TEXTURE
static const BitMask_t HAS_TEXTURE
Definition: FlexFactory.h:62
RoR::FlexBody::m_uses_shared_vertex_data
bool m_uses_shared_vertex_data
Definition: FlexBody.h:145
RoR::FlexBodyFileIO::ReadFlexbodyHeader
void ReadFlexbodyHeader(FlexBodyCacheData *flexbody)
Definition: FlexFactory.cpp:229
RoR::FlexFactory::CheckAndLoadFlexbodyCache
void CheckAndLoadFlexbodyCache()
Definition: FlexFactory.cpp:409
RoR::FlexBodyFileIO::WriteMetadata
void WriteMetadata()
Definition: FlexFactory.cpp:192
RoR::FlexBodyRecordHeader::USES_SHARED_VERTEX_DATA
static const BitMask_t USES_SHARED_VERTEX_DATA
Definition: FlexFactory.h:61
RoR::FlexBody::m_orig_mesh_name
std::string m_orig_mesh_name
Definition: FlexBody.h:153
RoR::ActorSpawner::ComposeName
std::string ComposeName(const std::string &object, int number=-1)
Creates name containing actor ID token, i.e. "Object#1 (filename.truck [Instance ID 1])".
Definition: ActorSpawner.cpp:703
RoR::FlexBodyFileIO::GetLoadedItem
FlexBodyCacheData * GetLoadedItem(unsigned index)
Definition: FlexFactory.h:119
format
Truck file format(technical spec)
RoR::FlexBodyRecordHeader::shared_buf_num_verts
int shared_buf_num_verts
Definition: FlexFactory.h:56
RoR::FlexMeshWheel
Consists of static mesh, representing the rim, and dynamic mesh, representing the tire.
Definition: FlexMeshWheel.h:40
RoR::App::gfx_flexbody_cache
CVar * gfx_flexbody_cache
Definition: Application.cpp:258
RoR::FlexBodyRecordHeader::HAS_TEXTURE_BLEND
static const BitMask_t HAS_TEXTURE_BLEND
Definition: FlexFactory.h:63
RoR::FlexBodyFileIO::ReadFlexbodyLocatorList
void ReadFlexbodyLocatorList(FlexBodyCacheData *flexbody)
Definition: FlexFactory.cpp:242
RoR::Actor::GetGfxActor
GfxActor * GetGfxActor()
Definition: Actor.h:281
RoR::FlexMeshWheel::m_tire_entity
Ogre::Entity * m_tire_entity
Definition: FlexMeshWheel.h:98
RoR::FlexBody::m_dst_pos
Ogre::Vector3 * m_dst_pos
Definition: FlexBody.h:120
RoR::FlexBodyFileIO::FlexBodyFileMetadata
Definition: FlexFactory.h:124
RoR::FlexBodyRecordHeader::node_center
int node_center
Definition: FlexFactory.h:51
RoR::FlexFactory::m_rig_spawner
ActorSpawner * m_rig_spawner
Definition: FlexFactory.h:200
RefCountingObjectPtr< Actor >
ActorSpawner.h
Vehicle spawning logic.
RoR::FlexBodyRecordHeader::IS_FAULTY
static const BitMask_t IS_FAULTY
Definition: FlexFactory.h:60
RoR::FlexFactory::m_is_flexbody_cache_loaded
bool m_is_flexbody_cache_loaded
Definition: FlexFactory.h:204
Actor.h
RoR::GfxScene::GetSceneManager
Ogre::SceneManager * GetSceneManager()
Definition: GfxScene.h:83
RoR::FlexBodyFileIO::CloseFile
void CloseFile()
Definition: FlexFactory.h:133
RoR::ActorSpawner
Processes a RigDef::Document (parsed from 'truck' file format) into a simulated gameplay object (Acto...
Definition: ActorSpawner.h:70
RoR::FlexBodyFileIO::ReadFlexbodyNormalsBuffer
void ReadFlexbodyNormalsBuffer(FlexBodyCacheData *flexbody)
Definition: FlexFactory.cpp:257
RoR::FlexFactory::m_flexbody_cache_next_index
unsigned int m_flexbody_cache_next_index
Definition: FlexFactory.h:205
RoR::FlexBodyFileIO::SaveFile
ResultCode SaveFile()
Definition: FlexFactory.cpp:322
RoR::ActorSpawner::GetActor
ActorPtr GetActor()
Definition: ActorSpawner.h:106
RoR::FlexFactory::m_flexbody_cache
FlexBodyFileIO m_flexbody_cache
Definition: FlexFactory.h:202
RoR::ActorSpawner::SetupNewEntity
void SetupNewEntity(Ogre::Entity *e, Ogre::ColourValue simple_color)
Full texture and material setup.
Definition: ActorSpawner.cpp:6851
RoR::PATH_SLASH
char PATH_SLASH
Definition: PlatformUtils.cpp:161
RoR::FlexBody::m_has_texture
bool m_has_texture
Definition: FlexBody.h:146
BITMASK_IS_0
#define BITMASK_IS_0(VAR, FLAGS)
Definition: BitFlags.h:13
RoR::FlexBody::m_camera_mode
int m_camera_mode
Visibility control {-2 = always, -1 = 3rdPerson only, 0+ = cinecam index}.
Definition: FlexBody.h:132
RoR::FlexBodyFileIO::m_items_to_save
std::vector< FlexBody * > m_items_to_save
Definition: FlexFactory.h:156
RoR::FlexBodyFileIO::RESULT_CODE_ERR_FOPEN_FAILED
@ RESULT_CODE_ERR_FOPEN_FAILED
Definition: FlexFactory.h:104
RoR::FlexBodyFileIO::SIGNATURE
static const char * SIGNATURE
Definition: FlexFactory.h:112
RoR::NodeNum_t
uint16_t NodeNum_t
Node position within Actor::ar_nodes; use RoR::NODENUM_INVALID as empty value.
Definition: ForwardDeclarations.h:54
CacheSystem.h
A database of user-installed content alias 'mods' (vehicles, terrains...)
RoR::FlexBodyFileIO::WriteToFile
void WriteToFile(void *source, size_t length)
Definition: FlexFactory.cpp:155
RoR::FlexBody::m_src_colors
Ogre::ARGB * m_src_colors
Definition: FlexBody.h:123
RoR::FlexBody::m_shared_buf_num_verts
int m_shared_buf_num_verts
Definition: FlexBody.h:134
RoR::FlexFactory::CreateFlexBody
FlexBody * CreateFlexBody(FlexbodyID_t flexbody_id, const NodeNum_t ref_node, const NodeNum_t x_node, const NodeNum_t y_node, Ogre::Vector3 offset, Ogre::Vector3 rotation, std::vector< unsigned int > &node_indices, std::vector< ForvertTempData > &forvert_data, const std::string &mesh_name, const std::string &resource_group_name)
Definition: FlexFactory.cpp:63
BITMASK_SET_1
#define BITMASK_SET_1(VAR, FLAGS)
Definition: BitFlags.h:17
RoR::FlexBodyFileIO::m_file
FILE * m_file
Definition: FlexFactory.h:158
RoR::App::sys_cache_dir
CVar * sys_cache_dir
Definition: Application.cpp:165
RoR::FlexBodyRecordHeader::camera_mode
int camera_mode
Definition: FlexFactory.h:55
RoR::FlexBodyFileIO::LoadFile
ResultCode LoadFile()
Definition: FlexFactory.cpp:361
GfxScene.h
RoR::FlexBody::m_num_submesh_vbufs
int m_num_submesh_vbufs
Definition: FlexBody.h:139
PlatformUtils.h
Platform-specific utilities. We use narrow UTF-8 encoded strings as paths. Inspired by http://utf8eve...
RoR::FlexBodyRecordHeader::center_offset
Ogre::Vector3 center_offset
Definition: FlexFactory.h:54
RoR::FlexBodyFileIO::WriteFlexbodyHeader
void WriteFlexbodyHeader(FlexBody *flexbody)
Definition: FlexFactory.cpp:209
RoR::FlexBodyFileIO::ResultCode
ResultCode
Definition: FlexFactory.h:100
Application.h
Central state/object manager and communications hub.
FlexBody.h
RoR::FlexBodyFileIO::m_cache_entry_number
int m_cache_entry_number
Definition: FlexFactory.h:160
RoR::FlexBodyFileIO::ReadAndCheckSignature
void ReadAndCheckSignature()
Definition: FlexFactory.cpp:181
RoR::FlexBodyRecordHeader
Definition: FlexFactory.h:48
RoR::FlexFactory::FlexFactory
FlexFactory()
Definition: FlexFactory.h:166
RoR::FlexBodyFileIO::RESULT_CODE_ERR_SIGNATURE_MISMATCH
@ RESULT_CODE_ERR_SIGNATURE_MISMATCH
Definition: FlexFactory.h:105
RoR::FlexBodyFileIO::ReadFromFile
void ReadFromFile(void *dest, size_t length)
Definition: FlexFactory.cpp:165
RoR::FlexBodyCacheData::src_normals
Ogre::Vector3 * src_normals
Definition: FlexFactory.h:80
RoR::FlexBodyFileIO::WriteSignature
void WriteSignature()
Definition: FlexFactory.cpp:175
RoR::FlexBodyFileIO::m_loaded_items
std::vector< FlexBodyCacheData > m_loaded_items
Definition: FlexFactory.h:157
RoR::FlexFactory::SaveFlexbodiesToCache
void SaveFlexbodiesToCache()
Definition: FlexFactory.cpp:419
RoR::FlexBodyFileIO::FlexBodyFileIO
FlexBodyFileIO()
Definition: FlexFactory.cpp:403
RoR::FlexFactory::m_is_flexbody_cache_enabled
bool m_is_flexbody_cache_enabled
Definition: FlexFactory.h:203
RoR::FlexBodyFileIO::RESULT_CODE_OK
@ RESULT_CODE_OK
Definition: FlexFactory.h:102
RoR::FlexBodyFileIO::ReadFlexbodyPositionsBuffer
void ReadFlexbodyPositionsBuffer(FlexBodyCacheData *flexbody)
Definition: FlexFactory.cpp:273
RoR::FlexBodyFileIO::WriteFlexbodyLocatorList
void WriteFlexbodyLocatorList(FlexBody *flexbody)
Definition: FlexFactory.cpp:236
RoR::FlexBodyCacheData::src_colors
Ogre::ARGB * src_colors
Definition: FlexFactory.h:81
RoR::FlexBodyFileIO::RESULT_CODE_ERR_VERSION_MISMATCH
@ RESULT_CODE_ERR_VERSION_MISMATCH
Definition: FlexFactory.h:106
RoR::FlexBodyFileIO::m_fileformat_version
unsigned int m_fileformat_version
Definition: FlexFactory.h:159
RoR::FlexBodyFileIO::ReadFlexbodyColorsBuffer
void ReadFlexbodyColorsBuffer(FlexBodyCacheData *flexbody)
Definition: FlexFactory.cpp:292
RoR::FlexBodyRecordHeader::flags
BitMask_t flags
Definition: FlexFactory.h:58
RoR::FlexBody::m_locators
Locator_t * m_locators
1 loc per vertex
Definition: FlexBody.h:124
RoR::FlexFactory::CreateFlexMeshWheel
FlexMeshWheel * CreateFlexMeshWheel(unsigned int wheel_index, int axis_node_1_index, int axis_node_2_index, int nstart, int nrays, float rim_radius, bool rim_reverse, std::string const &rim_mesh_name, std::string const &rim_mesh_rg, std::string const &tire_material_name, std::string const &tire_material_rg)
Definition: FlexFactory.cpp:116
RoR::ActorSpawner::m_wheels_parent_scenenode
Ogre::SceneNode * m_wheels_parent_scenenode
this isn't used for moving/hiding things, just helps developers inspect the scene graph.
Definition: ActorSpawner.h:496
RoR::FlexBody::m_center_offset
Ogre::Vector3 m_center_offset
Definition: FlexBody.h:129
RoR::FlexBody::m_node_y
NodeNum_t m_node_y
Definition: FlexBody.h:128
RoR::FlexBody::m_src_normals
Ogre::Vector3 * m_src_normals
Definition: FlexBody.h:121
RoR::FlexBody::m_node_center
NodeNum_t m_node_center
Definition: FlexBody.h:126
RoR::FlexBody::m_has_texture_blend
bool m_has_texture_blend
Definition: FlexBody.h:147
RoR::FlexBodyFileIO::ReadMetadata
void ReadMetadata(FlexBodyFileMetadata *meta)
Definition: FlexFactory.cpp:202
RoR::FlexBodyFileIO::AddItemToSave
void AddItemToSave(FlexBody *fb)
Definition: FlexFactory.h:118
RoR::FlexbodyID_t
int FlexbodyID_t
Index to GfxActor::m_flexbodies, use RoR::FLEXBODYID_INVALID as empty value.
Definition: ForwardDeclarations.h:64
RoR::FlexBodyFileIO::WriteFlexbodyPositionsBuffer
void WriteFlexbodyPositionsBuffer(FlexBody *flexbody)
Definition: FlexFactory.cpp:267
RoR::FlexBody
Flexbody = A deformable mesh; updated on CPU every frame, then uploaded to video memory.
Definition: FlexBody.h:43
RoR::FlexBodyRecordHeader::num_submesh_vbufs
int num_submesh_vbufs
Definition: FlexFactory.h:57
RoR::FlexBodyRecordHeader::vertex_count
int vertex_count
Definition: FlexFactory.h:50
FlexFactory.h
RoR::FlexBodyCacheData::locators
Locator_t * locators
1 loc per vertex
Definition: FlexFactory.h:82
RoR::FlexBodyFileIO::FILE_FORMAT_VERSION
static const unsigned int FILE_FORMAT_VERSION
Definition: FlexFactory.h:113
RoR::FlexBodyFileIO::FlexBodyFileMetadata::file_format_version
unsigned int file_format_version
Definition: FlexFactory.h:126
RoR::FlexBody::m_id
FlexbodyID_t m_id
Definition: FlexBody.h:117
RoR::FlexBodyCacheData::dst_pos
Ogre::Vector3 * dst_pos
Definition: FlexFactory.h:79
RoR::GfxActor::GetResourceGroup
Ogre::String GetResourceGroup()
Definition: GfxActor.h:146
RigDef_File.h
Data structures representing 'truck' file format, see https://docs.rigsofrods.org/vehicle-creation/fi...
RoR
Definition: AppContext.h:36
RoR::FlexBodyRecordHeader::node_y
int node_y
Definition: FlexFactory.h:53
RoR::FlexBodyFileIO::RESULT_CODE_ERR_CACHE_NUMBER_UNDEFINED
@ RESULT_CODE_ERR_CACHE_NUMBER_UNDEFINED
Definition: FlexFactory.h:107
RoR::App::GetGfxScene
GfxScene * GetGfxScene()
Definition: Application.cpp:292
RoR::FlexBodyFileIO::WriteFlexbodyNormalsBuffer
void WriteFlexbodyNormalsBuffer(FlexBody *flexbody)
Definition: FlexFactory.cpp:251
RoR::FlexBody::m_node_x
NodeNum_t m_node_x
Definition: FlexBody.h:127
RoR::FlexBody::m_vertex_count
size_t m_vertex_count
Definition: FlexBody.h:115
FLEX_DEBUG_LOG
#define FLEX_DEBUG_LOG(TEXT)
Definition: FlexFactory.cpp:47
RoR::FlexBodyFileIO::RESULT_CODE_FWRITE_OUTPUT_INCOMPLETE
@ RESULT_CODE_FWRITE_OUTPUT_INCOMPLETE
Definition: FlexFactory.h:109