Assimp  v3.1.1 (June 2014)
glTF::Buffer Struct Reference

A buffer points to binary geometry, animation, or skins. More...

Inherits glTF::Object.

Classes

struct  SEncodedRegion
 Descriptor of encoded region in "bufferView". More...
 

Public Types

enum  Type { Type_arraybuffer, Type_text }
 

Public Member Functions

size_t AppendData (uint8_t *data, size_t length)
 
 Buffer ()
 
void EncodedRegion_Mark (const size_t pOffset, const size_t pEncodedData_Length, uint8_t *pDecodedData, const size_t pDecodedData_Length, const std::string &pID)
 Mark region of "bufferView" as encoded. More...
 
void EncodedRegion_SetCurrent (const std::string &pID)
 Select current encoded region by ID. More...
 
uint8_tGetPointer ()
 
std::string GetURI ()
 
void Grow (size_t amount)
 
bool IsSpecial () const
 Objects marked as special are not exported (used to emulate the binary body buffer) More...
 
bool LoadFromStream (IOStream &stream, size_t length=0, size_t baseOffset=0)
 
void MarkAsSpecial ()
 
void Read (Value &obj, Asset &r)
 
bool ReplaceData (const size_t pBufferData_Offset, const size_t pBufferData_Count, const uint8_t *pReplace_Data, const size_t pReplace_Count)
 Replace part of buffer data. More...
 
 ~Buffer ()
 
- Public Member Functions inherited from glTF::Object
virtual ~Object ()
 

Static Public Member Functions

static const char * TranslateId (Asset &r, const char *id)
 
- Static Public Member Functions inherited from glTF::Object
static const char * TranslateId (Asset &r, const char *id)
 Maps special IDs to another ID, where needed. Subclasses may override it (statically) More...
 

Public Attributes

size_t byteLength
 The length of the buffer in bytes. (default: 0) More...
 
SEncodedRegionEncodedRegion_Current
 Pointer to currently active encoded region. More...
 
Type type
 
- Public Attributes inherited from glTF::Object
std::string id
 The globally unique ID used to reference this object. More...
 
std::string name
 The user-defined name of this object. More...
 

Detailed Description

A buffer points to binary geometry, animation, or skins.

Member Enumeration Documentation

◆ Type

Enumerator
Type_arraybuffer 
Type_text 

Constructor & Destructor Documentation

◆ Buffer()

glTF::Buffer::Buffer ( )
inline

◆ ~Buffer()

glTF::Buffer::~Buffer ( )
inline

Member Function Documentation

◆ AppendData()

size_t glTF::Buffer::AppendData ( uint8_t data,
size_t  length 
)
inline

◆ EncodedRegion_Mark()

void glTF::Buffer::EncodedRegion_Mark ( const size_t  pOffset,
const size_t  pEncodedData_Length,
uint8_t pDecodedData,
const size_t  pDecodedData_Length,
const std::string &  pID 
)
inline

Mark region of "bufferView" as encoded.

When data is request from such region then "bufferView" use decoded data.

Parameters
[in]pOffset- offset from begin of "bufferView" to encoded region, in bytes.
[in]pEncodedData_Length- size of encoded region, in bytes.
[in]pDecodedData- pointer to decoded data array.
[in]pDecodedData_Length- size of encoded region, in bytes.
[in]pID- ID of the region.

◆ EncodedRegion_SetCurrent()

void glTF::Buffer::EncodedRegion_SetCurrent ( const std::string &  pID)
inline

Select current encoded region by ID.

See also
EncodedRegion_Current.
Parameters
[in]pID- ID of the region.

◆ GetPointer()

uint8_t* glTF::Buffer::GetPointer ( )
inline

◆ GetURI()

std::string glTF::Buffer::GetURI ( )
inline

◆ Grow()

void glTF::Buffer::Grow ( size_t  amount)
inline

◆ IsSpecial()

bool glTF::Buffer::IsSpecial ( ) const
inlinevirtual

Objects marked as special are not exported (used to emulate the binary body buffer)

Reimplemented from glTF::Object.

◆ LoadFromStream()

bool glTF::Buffer::LoadFromStream ( IOStream stream,
size_t  length = 0,
size_t  baseOffset = 0 
)
inline

◆ MarkAsSpecial()

void glTF::Buffer::MarkAsSpecial ( )
inline

◆ Read()

void glTF::Buffer::Read ( Value obj,
Asset r 
)
inline

◆ ReplaceData()

bool glTF::Buffer::ReplaceData ( const size_t  pBufferData_Offset,
const size_t  pBufferData_Count,
const uint8_t pReplace_Data,
const size_t  pReplace_Count 
)
inline

Replace part of buffer data.

Pay attention that function work with original array of data (mData) not with encoded regions.

Parameters
[in]pBufferData_Offset- index of first element in buffer from which new data will be placed.
[in]pBufferData_Count- count of bytes in buffer which will be replaced.
[in]pReplace_Data- pointer to array with new data for buffer.
[in]pReplace_Count- count of bytes in new data.
Returns
true - if successfully replaced, false if input arguments is out of range.

◆ TranslateId()

const char * glTF::Buffer::TranslateId ( Asset r,
const char *  id 
)
inlinestatic

Member Data Documentation

◆ byteLength

size_t glTF::Buffer::byteLength

The length of the buffer in bytes. (default: 0)

◆ EncodedRegion_Current

glTF::Buffer::EncodedRegion_Current

Pointer to currently active encoded region.

Why not decoding all regions at once and not to set one buffer with decoded data? Yes, why not? Even "accessor" point to decoded data. I mean that fields "byteOffset", "byteStride" and "count" has values which describes decoded data array. But only in range of mesh while is active parameters from "compressedData". For another mesh accessors point to decoded data too. But offset is counted for another regions is encoded. Example. You have two meshes. For every of it you have 4 bytes of data. That data compressed to 2 bytes. So, you have buffer with encoded data: M1_E0, M1_E1, M2_E0, M2_E1. After decoding you'll get: M1_D0, M1_D1, M1_D2, M1_D3, M2_D0, M2_D1, M2_D2, M2_D3. "accessors" must to use values that point to decoded data - obviously. So, you'll expect "accessors" like "accessor_0" : { byteOffset: 0, byteLength: 4}, "accessor_1" : { byteOffset: 4, byteLength: 4} but in real life you'll get: "accessor_0" : { byteOffset: 0, byteLength: 4}, "accessor_1" : { byteOffset: 2, byteLength: 4} Yes, accessor of next mesh has offset and length which mean: current mesh data is decoded, all other data is encoded. And when before you start to read data of current mesh (with encoded data ofcourse) you must decode region of "bufferView", after read finished delete encoding mark. And after that you can repeat process: decode data of mesh, read, delete decoded data.

Remark. Encoding all data at once is good in world with computers which do not has RAM limitation. So, you must use step by step encoding in exporter and importer. And, thanks to such way, there is no need to load whole file into memory.

◆ type

Type glTF::Buffer::type

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