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

Function aiGetMaterialString

code/Material/MaterialSystem.cpp:307–335  ·  view source on GitHub ↗

------------------------------------------------------------------------------------------------ Get a string from the material

Source from the content-addressed store, hash-verified

305// ------------------------------------------------------------------------------------------------
306// Get a string from the material
307aiReturn aiGetMaterialString(const aiMaterial *pMat,
308 const char *pKey,
309 unsigned int type,
310 unsigned int index,
311 aiString *pOut) {
312 ai_assert(pOut != nullptr);
313
314 const aiMaterialProperty *prop{nullptr};
315 aiGetMaterialProperty(pMat, pKey, type, index, &prop);
316 if (!prop) {
317 return AI_FAILURE;
318 }
319
320 if (aiPTI_String == prop->mType) {
321 ai_assert(prop->mDataLength >= 5);
322
323 // The string is stored as 32 but length prefix followed by zero-terminated UTF8 data
324 pOut->length = static_cast<unsigned int>(*reinterpret_cast<uint32_t *>(prop->mData));
325
326 ai_assert(pOut->length + 1 + 4 == prop->mDataLength);
327 ai_assert(!prop->mData[prop->mDataLength - 1]);
328 memcpy(pOut->data, prop->mData + 4, pOut->length + 1);
329 } else {
330 // TODO - implement lexical cast as well
331 ASSIMP_LOG_ERROR("Material property", pKey, " was found, but is no string");
332 return AI_FAILURE;
333 }
334 return AI_SUCCESS;
335}
336
337// ------------------------------------------------------------------------------------------------
338// Get a c-like string fron an aiString

Callers 8

Assimp_InfoFunction · 0.85
CreateMaterialMethod · 0.85
TEST_FFunction · 0.85
JoinSkins_3DGS_MDL7Method · 0.85
GetTexSamplerMethod · 0.85
WriteFunction · 0.85
aiGetMaterialTextureFunction · 0.85

Calls 1

aiGetMaterialPropertyFunction · 0.85

Tested by

no test coverage detected