MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / addMaterial

Method addMaterial

Engine/source/ts/collada/colladaAppMesh.cpp:427–475  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

425}
426
427S32 ColladaAppMesh::addMaterial(const char* symbol)
428{
429 if (!symbol)
430 return TSDrawPrimitive::NoMaterial;
431
432 // Lookup the symbol in the materials already bound to this geometry/controller
433 // instance
434 Map<StringTableEntry,U32>::Iterator itr = boundMaterials.find(symbol);
435 if (itr != boundMaterials.end())
436 return itr->value;
437
438 // Find the Collada material that this symbol maps to
439 U32 matIndex = TSDrawPrimitive::NoMaterial;
440 const domBind_material* binds = instanceGeom ? instanceGeom->getBind_material() :
441 instanceCtrl->getBind_material();
442 if (binds) {
443 const domInstance_material_Array& matArray = binds->getTechnique_common()->getInstance_material_array();
444 for (S32 iBind = 0; iBind < matArray.getCount(); iBind++) {
445 if (dStrEqual(matArray[iBind]->getSymbol(), symbol)) {
446
447 // Find the index of the bound material in the shape global list
448 const domMaterial* mat = daeSafeCast<domMaterial>(matArray[iBind]->getTarget().getElement());
449 for (matIndex = 0; matIndex < appMaterials.size(); matIndex++) {
450 if (static_cast<ColladaAppMaterial*>(appMaterials[matIndex])->mat == mat)
451 break;
452 }
453
454 // Check if this material needs to be added to the shape global list
455 if (matIndex == appMaterials.size()) {
456 if (mat)
457 appMaterials.push_back(new ColladaAppMaterial(mat));
458 else
459 appMaterials.push_back(new ColladaAppMaterial(symbol));
460 }
461
462 break;
463 }
464 }
465 }
466 else
467 {
468 // No Collada material is present for this symbol, so just create an empty one
469 appMaterials.push_back(new ColladaAppMaterial(symbol));
470 }
471
472 // Add this symbol to the bound list for the mesh
473 boundMaterials.insert(StringTable->insert(symbol), matIndex);
474 return matIndex;
475}
476
477void ColladaAppMesh::getPrimitives(const domGeometry* geometry)
478{

Callers

nothing calls this directly

Calls 12

dStrEqualFunction · 0.85
findMethod · 0.45
endMethod · 0.45
getBind_materialMethod · 0.45
getTechnique_commonMethod · 0.45
getCountMethod · 0.45
getSymbolMethod · 0.45
getElementMethod · 0.45
getTargetMethod · 0.45
sizeMethod · 0.45
push_backMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected