MCPcopy Create free account
hub / github.com/assimp/assimp / ExportData

Function ExportData

code/AssetLib/glTF/glTFExporter.cpp:239–277  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

237}
238
239inline Ref<Accessor> ExportData(Asset &a, std::string &meshName, Ref<Buffer> &buffer,
240 unsigned int count, void *data, AttribType::Value typeIn, AttribType::Value typeOut, ComponentType compType, BufferViewTarget target = BufferViewTarget_NONE) {
241 if (!count || !data) return Ref<Accessor>();
242
243 unsigned int numCompsIn = AttribType::GetNumComponents(typeIn);
244 unsigned int numCompsOut = AttribType::GetNumComponents(typeOut);
245 unsigned int bytesPerComp = ComponentTypeSize(compType);
246
247 size_t offset = buffer->byteLength;
248 // make sure offset is correctly byte-aligned, as required by spec
249 size_t padding = offset % bytesPerComp;
250 offset += padding;
251 size_t length = count * numCompsOut * bytesPerComp;
252 buffer->Grow(length + padding);
253
254 // bufferView
255 Ref<BufferView> bv = a.bufferViews.Create(a.FindUniqueID(meshName, "view"));
256 bv->buffer = buffer;
257 bv->byteOffset = unsigned(offset);
258 bv->byteLength = length; //! The target that the WebGL buffer should be bound to.
259 bv->target = target;
260
261 // accessor
262 Ref<Accessor> acc = a.accessors.Create(a.FindUniqueID(meshName, "accessor"));
263 acc->bufferView = bv;
264 acc->byteOffset = 0;
265 acc->byteStride = 0;
266 acc->componentType = compType;
267 acc->count = count;
268 acc->type = typeOut;
269
270 // calculate min and max values
271 SetAccessorRange(compType, acc, data, count, numCompsIn, numCompsOut);
272
273 // copy the data
274 acc->WriteData(count, data, numCompsIn*bytesPerComp);
275
276 return acc;
277}
278
279namespace {
280 void GetMatScalar(const aiMaterial* mat, float& val, const char* propName, int type, int idx) {

Callers 3

ExportSkinFunction · 0.70
ExportMeshesMethod · 0.70
ExtractAnimationDataFunction · 0.70

Calls 5

WriteDataMethod · 0.80
ComponentTypeSizeFunction · 0.70
SetAccessorRangeFunction · 0.70
GrowMethod · 0.45
CreateMethod · 0.45

Tested by

no test coverage detected