RigsofRods
Soft-body Physics Simulation
Data Structures | Public Types | Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes
RoR::FlexBodyFileIO Class Reference

Enables saving and loading flexbodies from/to binary file. More...

#include <FlexFactory.h>

Data Structures

struct  FlexBodyFileMetadata
 

Public Types

enum  ResultCode {
  RESULT_CODE_OK, RESULT_CODE_GENERAL_ERROR, RESULT_CODE_ERR_FOPEN_FAILED, RESULT_CODE_ERR_SIGNATURE_MISMATCH,
  RESULT_CODE_ERR_VERSION_MISMATCH, RESULT_CODE_ERR_CACHE_NUMBER_UNDEFINED, RESULT_CODE_FREAD_OUTPUT_INCOMPLETE, RESULT_CODE_FWRITE_OUTPUT_INCOMPLETE
}
 

Public Member Functions

 FlexBodyFileIO ()
 
std::vector< FlexBody * > & GetList ()
 
void AddItemToSave (FlexBody *fb)
 
FlexBodyCacheDataGetLoadedItem (unsigned index)
 
ResultCode SaveFile ()
 
ResultCode LoadFile ()
 

Static Public Attributes

static const char * SIGNATURE = "RoR FlexBody"
 
static const unsigned int FILE_FORMAT_VERSION = 1
 

Private Member Functions

void OpenFile (const char *fopen_mode)
 
void WriteToFile (void *source, size_t length)
 
void ReadFromFile (void *dest, size_t length)
 
void CloseFile ()
 
void WriteSignature ()
 
void ReadAndCheckSignature ()
 
void WriteMetadata ()
 
void ReadMetadata (FlexBodyFileMetadata *meta)
 
void WriteFlexbodyHeader (FlexBody *flexbody)
 
void ReadFlexbodyHeader (FlexBodyCacheData *flexbody)
 
void WriteFlexbodyLocatorList (FlexBody *flexbody)
 
void ReadFlexbodyLocatorList (FlexBodyCacheData *flexbody)
 
void WriteFlexbodyNormalsBuffer (FlexBody *flexbody)
 
void ReadFlexbodyNormalsBuffer (FlexBodyCacheData *flexbody)
 
void WriteFlexbodyPositionsBuffer (FlexBody *flexbody)
 
void ReadFlexbodyPositionsBuffer (FlexBodyCacheData *flexbody)
 
void WriteFlexbodyColorsBuffer (FlexBody *flexbody)
 
void ReadFlexbodyColorsBuffer (FlexBodyCacheData *flexbody)
 

Private Attributes

std::vector< FlexBody * > m_items_to_save
 
std::vector< FlexBodyCacheDatam_loaded_items
 
FILE * m_file
 
unsigned int m_fileformat_version
 
int m_cache_entry_number
 

Detailed Description

Enables saving and loading flexbodies from/to binary file.

FILE STRUCTURE:

  1. Signature
  2. Metadata
    See also
    FlexBodyFileMetadata
  3. Flexbodies a. Header
    See also
    FlexBodyRecordHeader b. Data (not present if flexbody has flags IS_FAULTY==true or IS_ENABLED==false)
    1. Locator list
    2. Positions buffer
    3. Normals buffer
    4. Colors buffer (only present if flag HAS_TEXTURE_BLEND == true)

Definition at line 97 of file FlexFactory.h.

Member Enumeration Documentation

◆ ResultCode

Enumerator
RESULT_CODE_OK 
RESULT_CODE_GENERAL_ERROR 
RESULT_CODE_ERR_FOPEN_FAILED 
RESULT_CODE_ERR_SIGNATURE_MISMATCH 
RESULT_CODE_ERR_VERSION_MISMATCH 
RESULT_CODE_ERR_CACHE_NUMBER_UNDEFINED 
RESULT_CODE_FREAD_OUTPUT_INCOMPLETE 
RESULT_CODE_FWRITE_OUTPUT_INCOMPLETE 

Definition at line 100 of file FlexFactory.h.

Constructor & Destructor Documentation

◆ FlexBodyFileIO()

FlexBodyFileIO::FlexBodyFileIO ( )

Definition at line 401 of file FlexFactory.cpp.

Member Function Documentation

◆ AddItemToSave()

void RoR::FlexBodyFileIO::AddItemToSave ( FlexBody fb)
inline

Definition at line 118 of file FlexFactory.h.

+ Here is the caller graph for this function:

◆ CloseFile()

void RoR::FlexBodyFileIO::CloseFile ( )
inlineprivate

Definition at line 133 of file FlexFactory.h.

+ Here is the caller graph for this function:

◆ GetList()

std::vector<FlexBody*>& RoR::FlexBodyFileIO::GetList ( )

◆ GetLoadedItem()

FlexBodyCacheData* RoR::FlexBodyFileIO::GetLoadedItem ( unsigned  index)
inline

Definition at line 119 of file FlexFactory.h.

+ Here is the caller graph for this function:

◆ LoadFile()

FlexBodyFileIO::ResultCode FlexBodyFileIO::LoadFile ( )

Definition at line 359 of file FlexFactory.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ OpenFile()

void FlexBodyFileIO::OpenFile ( const char *  fopen_mode)
private

Definition at line 304 of file FlexFactory.cpp.

+ Here is the caller graph for this function:

◆ ReadAndCheckSignature()

void FlexBodyFileIO::ReadAndCheckSignature ( )
private

Definition at line 179 of file FlexFactory.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ReadFlexbodyColorsBuffer()

void FlexBodyFileIO::ReadFlexbodyColorsBuffer ( FlexBodyCacheData flexbody)
private

Definition at line 290 of file FlexFactory.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ReadFlexbodyHeader()

void FlexBodyFileIO::ReadFlexbodyHeader ( FlexBodyCacheData flexbody)
private

Definition at line 227 of file FlexFactory.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ReadFlexbodyLocatorList()

void FlexBodyFileIO::ReadFlexbodyLocatorList ( FlexBodyCacheData flexbody)
private

Definition at line 240 of file FlexFactory.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ReadFlexbodyNormalsBuffer()

void FlexBodyFileIO::ReadFlexbodyNormalsBuffer ( FlexBodyCacheData flexbody)
private

Definition at line 255 of file FlexFactory.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ReadFlexbodyPositionsBuffer()

void FlexBodyFileIO::ReadFlexbodyPositionsBuffer ( FlexBodyCacheData flexbody)
private

Definition at line 271 of file FlexFactory.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ReadFromFile()

void FlexBodyFileIO::ReadFromFile ( void *  dest,
size_t  length 
)
private

Definition at line 163 of file FlexFactory.cpp.

+ Here is the caller graph for this function:

◆ ReadMetadata()

void FlexBodyFileIO::ReadMetadata ( FlexBodyFileMetadata meta)
private

Definition at line 200 of file FlexFactory.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SaveFile()

FlexBodyFileIO::ResultCode FlexBodyFileIO::SaveFile ( )

Definition at line 320 of file FlexFactory.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ WriteFlexbodyColorsBuffer()

void FlexBodyFileIO::WriteFlexbodyColorsBuffer ( FlexBody flexbody)
private

Definition at line 281 of file FlexFactory.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ WriteFlexbodyHeader()

void FlexBodyFileIO::WriteFlexbodyHeader ( FlexBody flexbody)
private

Definition at line 207 of file FlexFactory.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ WriteFlexbodyLocatorList()

void FlexBodyFileIO::WriteFlexbodyLocatorList ( FlexBody flexbody)
private

Definition at line 234 of file FlexFactory.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ WriteFlexbodyNormalsBuffer()

void FlexBodyFileIO::WriteFlexbodyNormalsBuffer ( FlexBody flexbody)
private

Definition at line 249 of file FlexFactory.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ WriteFlexbodyPositionsBuffer()

void FlexBodyFileIO::WriteFlexbodyPositionsBuffer ( FlexBody flexbody)
private

Definition at line 265 of file FlexFactory.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ WriteMetadata()

void FlexBodyFileIO::WriteMetadata ( )
private

Definition at line 190 of file FlexFactory.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ WriteSignature()

void FlexBodyFileIO::WriteSignature ( )
private

Definition at line 173 of file FlexFactory.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ WriteToFile()

void FlexBodyFileIO::WriteToFile ( void *  source,
size_t  length 
)
private

Definition at line 153 of file FlexFactory.cpp.

+ Here is the caller graph for this function:

Field Documentation

◆ FILE_FORMAT_VERSION

const unsigned int RoR::FlexBodyFileIO::FILE_FORMAT_VERSION = 1
static

Definition at line 113 of file FlexFactory.h.

◆ m_cache_entry_number

int RoR::FlexBodyFileIO::m_cache_entry_number
private

Definition at line 160 of file FlexFactory.h.

◆ m_file

FILE* RoR::FlexBodyFileIO::m_file
private

Definition at line 158 of file FlexFactory.h.

◆ m_fileformat_version

unsigned int RoR::FlexBodyFileIO::m_fileformat_version
private

Definition at line 159 of file FlexFactory.h.

◆ m_items_to_save

std::vector<FlexBody*> RoR::FlexBodyFileIO::m_items_to_save
private

Definition at line 156 of file FlexFactory.h.

◆ m_loaded_items

std::vector<FlexBodyCacheData> RoR::FlexBodyFileIO::m_loaded_items
private

Definition at line 157 of file FlexFactory.h.

◆ SIGNATURE

const char * FlexBodyFileIO::SIGNATURE = "RoR FlexBody"
static

Definition at line 112 of file FlexFactory.h.


The documentation for this class was generated from the following files: