Assimp
v4.1. (December 2018)
|
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_t * | GetPointer () |
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 () | |
![]() | |
virtual | ~Object () |
Static Public Member Functions | |
static const char * | TranslateId (Asset &r, const char *id) |
![]() | |
static const char * | TranslateId (Asset &, 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... | |
SEncodedRegion * | EncodedRegion_Current |
Pointer to currently active encoded region. More... | |
Type | type |
![]() | |
std::string | id |
The globally unique ID used to reference this object. More... | |
std::string | name |
The user-defined name of this object. More... | |
A buffer points to binary geometry, animation, or skins.
enum glTF::Buffer::Type |
|
inline |
|
inline |
|
inline |
|
inline |
Mark region of "bufferView" as encoded.
When data is request from such region then "bufferView" use decoded data.
[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. |
|
inline |
Select current encoded region by ID.
[in] | pID | - ID of the region. |
|
inline |
|
inline |
|
inline |
|
inlinevirtual |
Objects marked as special are not exported (used to emulate the binary body buffer)
Reimplemented from glTF::Object.
|
inline |
|
inline |
|
inline |
Replace part of buffer data.
Pay attention that function work with original array of data (mData) not with encoded regions.
[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. |
|
inlinestatic |
size_t glTF::Buffer::byteLength |
The length of the buffer in bytes. (default: 0)
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 glTF::Buffer::type |