RigsofRods
Soft-body Physics Simulation
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  const std::string& mesh_name,
72  const std::string& resource_group_name)
73 {
74  Ogre::MeshPtr common_mesh = Ogre::MeshManager::getSingleton().load(mesh_name, resource_group_name);
75  const std::string mesh_unique_name = m_rig_spawner->ComposeName(fmt::format("{}_FlexBody", mesh_name).c_str(), flexbody_id);
76  Ogre::MeshPtr mesh = common_mesh->clone(mesh_unique_name);
77  const std::string flexbody_name = m_rig_spawner->ComposeName("Flexbody", flexbody_id);
78  Ogre::Entity* entity = App::GetGfxScene()->GetSceneManager()->createEntity(flexbody_name, mesh_unique_name, resource_group_name);
79  m_rig_spawner->SetupNewEntity(entity, Ogre::ColourValue(0.5, 0.5, 1));
80 
81  FLEX_DEBUG_LOG(__FUNCTION__);
82  FlexBodyCacheData* from_cache = nullptr;
84  {
85  FLEX_DEBUG_LOG(__FUNCTION__ " >> Get entry from cache ");
88  }
89 
90  Ogre::Quaternion rot=Ogre::Quaternion(Ogre::Degree(rotation.z), Ogre::Vector3::UNIT_Z);
91  rot=rot*Ogre::Quaternion(Ogre::Degree(rotation.y), Ogre::Vector3::UNIT_Y);
92  rot=rot*Ogre::Quaternion(Ogre::Degree(rotation.x), Ogre::Vector3::UNIT_X);
93 
94  FlexBody* new_flexbody = new FlexBody(
95  from_cache,
97  entity,
98  ref_node,
99  x_node,
100  y_node,
101  offset,
102  rot,
103  node_indices);
104 
106  {
107  m_flexbody_cache.AddItemToSave(new_flexbody);
108  }
109  new_flexbody->m_id = flexbody_id;
110  new_flexbody->m_orig_mesh_name = common_mesh->getName();
111  return new_flexbody;
112 }
113 
115  unsigned int wheel_index,
116  int axis_node_1_index,
117  int axis_node_2_index,
118  int nstart,
119  int nrays,
120  float rim_radius,
121  bool rim_reverse,
122  std::string const & rim_mesh_name,
123  std::string const & rim_mesh_rg,
124  std::string const & tire_material_name,
125  std::string const & tire_material_rg)
126 {
127  const ActorPtr& actor = m_rig_spawner->GetActor();
128 
129  // Load+instantiate static mesh for rim (may be located in addonpart ZIP-bundle!)
130  const std::string rim_entity_name = m_rig_spawner->ComposeName("rim @ *wheel*", wheel_index);
131  Ogre::Entity* rim_prop_entity = App::GetGfxScene()->GetSceneManager()->createEntity(rim_entity_name, rim_mesh_name, rim_mesh_rg);
132  m_rig_spawner->SetupNewEntity(rim_prop_entity, Ogre::ColourValue(0, 0.5, 0.8));
133 
134  // Create dynamic mesh for tire (always located in the actor resource group)
135  const std::string tire_mesh_name = m_rig_spawner->ComposeName("tire @ *wheel*", wheel_index);
136  FlexMeshWheel* flex_mesh_wheel = new FlexMeshWheel(
137  rim_prop_entity,
138  m_rig_spawner->m_wheels_parent_scenenode->createChildSceneNode(m_rig_spawner->ComposeName("*wheel*", wheel_index)), // Friend access
139  m_rig_spawner->GetActor()->GetGfxActor(), axis_node_1_index, axis_node_2_index, nstart, nrays,
140  tire_mesh_name, actor->GetGfxActor()->GetResourceGroup(),
141  tire_material_name, tire_material_rg, rim_radius, rim_reverse);
142 
143  // Instantiate the dynamic tire mesh (always located in the actor resource group)
144  const std::string tire_instance_name = m_rig_spawner->ComposeName("tire entity @ *wheel*", wheel_index);
145  Ogre::Entity *tire_entity = App::GetGfxScene()->GetSceneManager()->createEntity(
146  tire_instance_name, tire_mesh_name, actor->GetGfxActor()->GetResourceGroup());
147  m_rig_spawner->SetupNewEntity(tire_entity, Ogre::ColourValue(0, 0.5, 0.8));
148  flex_mesh_wheel->m_tire_entity = tire_entity; // Friend access.
149 
150  return flex_mesh_wheel;
151 }
152 
153 void FlexBodyFileIO::WriteToFile(void* source, size_t length)
154 {
155  size_t num_written = fwrite(source, length, 1, m_file);
156  if (num_written != 1)
157  {
158  FLEX_DEBUG_LOG(__FUNCTION__ " >> EXCEPTION!! ");
160  }
161 }
162 
163 void FlexBodyFileIO::ReadFromFile(void* dest, size_t length)
164 {
165  size_t num_written = fread(dest, length, 1, m_file);
166  if (num_written != 1)
167  {
168  FLEX_DEBUG_LOG(__FUNCTION__ " >> EXCEPTION!! ");
170  }
171 }
172 
174 {
175  FLEX_DEBUG_LOG(__FUNCTION__);
176  WriteToFile((void*)SIGNATURE, (strlen(SIGNATURE) + 1) * sizeof(char));
177 }
178 
180 {
181  FLEX_DEBUG_LOG(__FUNCTION__);
182  char signature[25];
183  this->ReadFromFile((void*)&signature, (strlen(SIGNATURE) + 1) * sizeof(char));
184  if (strcmp(SIGNATURE, signature) != 0)
185  {
187  }
188 }
189 
191 {
192  FLEX_DEBUG_LOG(__FUNCTION__);
195  meta.num_flexbodies = static_cast<int>(m_items_to_save.size());
196 
197  this->WriteToFile((void*)&meta, sizeof(FlexBodyFileMetadata));
198 }
199 
201 {
202  FLEX_DEBUG_LOG(__FUNCTION__);
203  ROR_ASSERT(meta != nullptr);
204  this->ReadFromFile((void*)meta, sizeof(FlexBodyFileMetadata));
205 }
206 
208 {
209  FLEX_DEBUG_LOG(__FUNCTION__);
210  FlexBodyRecordHeader header;
211  header.vertex_count = static_cast<int>(flexbody->m_vertex_count);
212  header.node_center = flexbody->m_node_center ;
213  header.node_x = flexbody->m_node_x ;
214  header.node_y = flexbody->m_node_y ;
215  header.center_offset = flexbody->m_center_offset ;
216  header.camera_mode = flexbody->m_camera_mode ;
217  header.shared_buf_num_verts = flexbody->m_shared_buf_num_verts ;
218  header.num_submesh_vbufs = flexbody->m_num_submesh_vbufs ;
219 
223 
224  this->WriteToFile((void*)&header, sizeof(FlexBodyRecordHeader));
225 }
226 
228 {
229  FLEX_DEBUG_LOG(__FUNCTION__);
230  this->ReadFromFile((void*)&data->header, sizeof(FlexBodyRecordHeader));
231 }
232 
233 
235 {
236  FLEX_DEBUG_LOG(__FUNCTION__);
237  this->WriteToFile((void*)flexbody->m_locators, sizeof(Locator_t) * flexbody->m_vertex_count);
238 }
239 
241 {
242  FLEX_DEBUG_LOG(__FUNCTION__);
243  // Alloc. Use <new> - experiment
244  data->locators = new Locator_t[data->header.vertex_count];
245  // Read
246  this->ReadFromFile((void*)data->locators, sizeof(Locator_t) * data->header.vertex_count);
247 }
248 
250 {
251  FLEX_DEBUG_LOG(__FUNCTION__);
252  this->WriteToFile((void*)flexbody->m_src_normals, sizeof(Ogre::Vector3) * flexbody->m_vertex_count);
253 }
254 
256 {
257  FLEX_DEBUG_LOG(__FUNCTION__);
258  const int vertex_count = data->header.vertex_count;
259  // Alloc. Use malloc() because that's how flexbodies were implemented.
260  data->src_normals=(Ogre::Vector3*)malloc(sizeof(Ogre::Vector3) * vertex_count);
261  // Read
262  this->ReadFromFile((void*)data->src_normals, sizeof(Ogre::Vector3) * vertex_count);
263 }
264 
266 {
267  FLEX_DEBUG_LOG(__FUNCTION__);
268  this->WriteToFile((void*)flexbody->m_dst_pos, sizeof(Ogre::Vector3) * flexbody->m_vertex_count);
269 }
270 
272 {
273  FLEX_DEBUG_LOG(__FUNCTION__);
274  const int vertex_count = data->header.vertex_count;
275  // Alloc. Use malloc() because that's how flexbodies were implemented.
276  data->dst_pos=(Ogre::Vector3*)malloc(sizeof(Ogre::Vector3) * vertex_count);
277  // Read
278  this->ReadFromFile((void*)data->dst_pos, sizeof(Ogre::Vector3) * vertex_count);
279 }
280 
282 {
283  FLEX_DEBUG_LOG(__FUNCTION__);
284  if (flexbody->m_has_texture_blend)
285  {
286  this->WriteToFile((void*)flexbody->m_src_colors, sizeof(Ogre::ARGB) * flexbody->m_vertex_count);
287  }
288 }
289 
291 {
292  FLEX_DEBUG_LOG(__FUNCTION__);
294  {
295  return;
296  }
297  const int vertex_count = data->header.vertex_count;
298  // Alloc. Use malloc() because that's how flexbodies were implemented.
299  data->src_colors=(Ogre::ARGB*)malloc(sizeof(Ogre::ARGB) * vertex_count);
300  // Read
301  this->ReadFromFile((void*)data->src_colors, sizeof(Ogre::ARGB) * vertex_count);
302 }
303 
304 void FlexBodyFileIO::OpenFile(const char* fopen_mode)
305 {
306  FLEX_DEBUG_LOG(__FUNCTION__);
307  if (m_cache_entry_number == -1)
308  {
310  }
311  char path[500];
312  sprintf(path, "%s%cflexbodies_mod_%00d.dat", App::sys_cache_dir->getStr().c_str(), RoR::PATH_SLASH, m_cache_entry_number);
313  m_file = fopen(path, fopen_mode);
314  if (m_file == nullptr)
315  {
317  }
318 }
319 
321 {
322  FLEX_DEBUG_LOG(__FUNCTION__);
323  if (m_items_to_save.size() == 0)
324  {
325  FLEX_DEBUG_LOG(__FUNCTION__ " >> No flexbodies to save >> EXIT");
326  return RESULT_CODE_OK;
327  }
328  try
329  {
330  this->OpenFile("wb");
331 
332  this->WriteSignature();
333  this->WriteMetadata();
334 
335  auto itor = m_items_to_save.begin();
336  auto end = m_items_to_save.end();
337  for (; itor != end; ++itor)
338  {
339  FlexBody* flexbody = *itor;
340  this->WriteFlexbodyHeader(flexbody);
341 
342  this->WriteFlexbodyLocatorList (flexbody);
343  this->WriteFlexbodyPositionsBuffer(flexbody);
344  this->WriteFlexbodyNormalsBuffer (flexbody);
345  this->WriteFlexbodyColorsBuffer (flexbody);
346  }
347  this->CloseFile();
348  FLEX_DEBUG_LOG(__FUNCTION__ " >> OK ");
349  return RESULT_CODE_OK;
350  }
351  catch (ResultCode result)
352  {
353  this->CloseFile();
354  FLEX_DEBUG_LOG(__FUNCTION__ " >> EXCEPTION!! ");
355  return result;
356  }
357 }
358 
360 {
361  FLEX_DEBUG_LOG(__FUNCTION__);
362  try
363  {
364  this->OpenFile("rb");
365  this->ReadAndCheckSignature();
366 
368  this->ReadMetadata(&meta);
371  {
373  }
374  m_loaded_items.resize(meta.num_flexbodies);
375 
376  for (unsigned int i = 0; i < meta.num_flexbodies; ++i)
377  {
378  FlexBodyCacheData* data = & m_loaded_items[i];
379  this->ReadFlexbodyHeader(data);
381  {
382  this->ReadFlexbodyLocatorList (data);
383  this->ReadFlexbodyPositionsBuffer(data);
384  this->ReadFlexbodyNormalsBuffer (data);
385  this->ReadFlexbodyColorsBuffer (data);
386  }
387  }
388 
389  this->CloseFile();
390  FLEX_DEBUG_LOG(__FUNCTION__ " >> OK ");
391  return RESULT_CODE_OK;
392  }
393  catch (ResultCode ret)
394  {
395  this->CloseFile();
396  FLEX_DEBUG_LOG(__FUNCTION__ " >> EXCEPTION!! ");
397  return ret;
398  }
399 }
400 
402  m_file(nullptr),
403  m_fileformat_version(0),
404  m_cache_entry_number(-1) // flexbody cache disabled (shouldn't be based on the cache entry number ...) ~ ulteq 01/19
405  {}
406 
408 {
409  FLEX_DEBUG_LOG(__FUNCTION__);
411  {
414  }
415 }
416 
418 {
419  FLEX_DEBUG_LOG(__FUNCTION__);
421  {
422  FLEX_DEBUG_LOG(__FUNCTION__ " >> Saving flexbodies");
424  }
425 }
426 
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:281
RoR::FlexBodyFileIO::OpenFile
void OpenFile(const char *fopen_mode)
Definition: FlexFactory.cpp:304
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:144
RoR::FlexBodyFileIO::ReadFlexbodyHeader
void ReadFlexbodyHeader(FlexBodyCacheData *flexbody)
Definition: FlexFactory.cpp:227
RoR::FlexFactory::CheckAndLoadFlexbodyCache
void CheckAndLoadFlexbodyCache()
Definition: FlexFactory.cpp:407
RoR::FlexBodyFileIO::WriteMetadata
void WriteMetadata()
Definition: FlexFactory.cpp:190
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:152
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:699
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:247
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:240
RoR::Actor::GetGfxActor
GfxActor * GetGfxActor()
Definition: Actor.h:263
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:119
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:199
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:203
Actor.h
RoR::GfxScene::GetSceneManager
Ogre::SceneManager * GetSceneManager()
Definition: GfxScene.h:64
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:255
RoR::FlexFactory::m_flexbody_cache_next_index
unsigned int m_flexbody_cache_next_index
Definition: FlexFactory.h:204
RoR::FlexBodyFileIO::SaveFile
ResultCode SaveFile()
Definition: FlexFactory.cpp:320
RoR::ActorSpawner::GetActor
ActorPtr GetActor()
Definition: ActorSpawner.h:106
RoR::FlexFactory::m_flexbody_cache
FlexBodyFileIO m_flexbody_cache
Definition: FlexFactory.h:201
RoR::ActorSpawner::SetupNewEntity
void SetupNewEntity(Ogre::Entity *e, Ogre::ColourValue simple_color)
Full texture and material setup.
Definition: ActorSpawner.cpp:6718
RoR::PATH_SLASH
char PATH_SLASH
Definition: PlatformUtils.cpp:161
RoR::FlexBody::m_has_texture
bool m_has_texture
Definition: FlexBody.h:145
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:131
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:52
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:153
RoR::FlexBody::m_src_colors
Ogre::ARGB * m_src_colors
Definition: FlexBody.h:122
RoR::FlexBody::m_shared_buf_num_verts
int m_shared_buf_num_verts
Definition: FlexBody.h:133
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:359
GfxScene.h
RoR::FlexBody::m_num_submesh_vbufs
int m_num_submesh_vbufs
Definition: FlexBody.h:138
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:207
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:179
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:163
RoR::FlexBodyCacheData::src_normals
Ogre::Vector3 * src_normals
Definition: FlexFactory.h:80
RoR::FlexBodyFileIO::WriteSignature
void WriteSignature()
Definition: FlexFactory.cpp:173
RoR::FlexBodyFileIO::m_loaded_items
std::vector< FlexBodyCacheData > m_loaded_items
Definition: FlexFactory.h:157
RoR::FlexFactory::SaveFlexbodiesToCache
void SaveFlexbodiesToCache()
Definition: FlexFactory.cpp:417
RoR::FlexBodyFileIO::FlexBodyFileIO
FlexBodyFileIO()
Definition: FlexFactory.cpp:401
RoR::FlexFactory::m_is_flexbody_cache_enabled
bool m_is_flexbody_cache_enabled
Definition: FlexFactory.h:202
RoR::FlexBodyFileIO::RESULT_CODE_OK
@ RESULT_CODE_OK
Definition: FlexFactory.h:102
RoR::FlexBodyFileIO::ReadFlexbodyPositionsBuffer
void ReadFlexbodyPositionsBuffer(FlexBodyCacheData *flexbody)
Definition: FlexFactory.cpp:271
RoR::FlexBodyFileIO::WriteFlexbodyLocatorList
void WriteFlexbodyLocatorList(FlexBody *flexbody)
Definition: FlexFactory.cpp:234
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:290
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:123
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:114
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:499
RoR::FlexBody::m_center_offset
Ogre::Vector3 m_center_offset
Definition: FlexBody.h:128
RoR::FlexBody::m_node_y
NodeNum_t m_node_y
Definition: FlexBody.h:127
RoR::FlexBody::m_src_normals
Ogre::Vector3 * m_src_normals
Definition: FlexBody.h:120
RoR::FlexBody::m_node_center
NodeNum_t m_node_center
Definition: FlexBody.h:125
RoR::FlexBody::m_has_texture_blend
bool m_has_texture_blend
Definition: FlexBody.h:146
RoR::FlexBodyFileIO::ReadMetadata
void ReadMetadata(FlexBodyFileMetadata *meta)
Definition: FlexFactory.cpp:200
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:62
RoR::FlexBodyFileIO::WriteFlexbodyPositionsBuffer
void WriteFlexbodyPositionsBuffer(FlexBody *flexbody)
Definition: FlexFactory.cpp:265
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:116
RoR::FlexBodyCacheData::dst_pos
Ogre::Vector3 * dst_pos
Definition: FlexFactory.h:79
RoR::GfxActor::GetResourceGroup
Ogre::String GetResourceGroup()
Definition: GfxActor.h:139
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:276
RoR::FlexBodyFileIO::WriteFlexbodyNormalsBuffer
void WriteFlexbodyNormalsBuffer(FlexBody *flexbody)
Definition: FlexFactory.cpp:249
RoR::FlexBody::m_node_x
NodeNum_t m_node_x
Definition: FlexBody.h:126
RoR::FlexBody::m_vertex_count
size_t m_vertex_count
Definition: FlexBody.h:114
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
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, const std::string &mesh_name, const std::string &resource_group_name)
Definition: FlexFactory.cpp:63