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

Method getPrimitives

Engine/source/ts/collada/colladaAppMesh.cpp:477–624  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

475}
476
477void ColladaAppMesh::getPrimitives(const domGeometry* geometry)
478{
479 // Only do this once
480 if (primitives.size())
481 return;
482
483 // Read the <geometry> extension
484 if (!geomExt)
485 geomExt = new ColladaExtension_geometry(geometry);
486
487 // Get the supported primitive elements for this geometry, and warn
488 // about unsupported elements
489 Vector<BasePrimitive*> meshPrims;
490 const daeElementRefArray& contents = geometry->getMesh()->getContents();
491 for (S32 iElem = 0; iElem < contents.getCount(); iElem++) {
492
493 if (BasePrimitive::isPrimitive(contents[iElem])) {
494 if (BasePrimitive::isSupportedPrimitive(contents[iElem]))
495 meshPrims.push_back(BasePrimitive::get(contents[iElem]));
496 else {
497 daeErrorHandler::get()->handleWarning(avar("Collada <%s> element "
498 "in %s is not supported.", contents[iElem]->getElementName(),
499 _GetNameOrId(geometry)));
500 }
501 }
502 }
503
504 MeshStreams streams;
505 VertTupleMap tupleMap;
506
507 // Create Torque primitives
508 for (S32 iPrim = 0; iPrim < meshPrims.size(); iPrim++) {
509
510 // Primitive element must have at least 1 triangle
511 const domListOfUInts* pTriData = meshPrims[iPrim]->getTriangleData();
512 if (!pTriData)
513 continue;
514
515 U32 numTriangles = pTriData->getCount() / meshPrims[iPrim]->getStride() / 3;
516 if (!numTriangles)
517 continue;
518
519 // Create TSMesh primitive
520 primitives.increment();
521 TSDrawPrimitive& primitive = primitives.last();
522 primitive.start = indices.size();
523 primitive.matIndex = (TSDrawPrimitive::Triangles | TSDrawPrimitive::Indexed) |
524 addMaterial(meshPrims[iPrim]->getMaterial());
525
526 // Get the AppMaterial associated with this primitive
527 ColladaAppMaterial* appMat = 0;
528 if (!(primitive.matIndex & TSDrawPrimitive::NoMaterial))
529 appMat = static_cast<ColladaAppMaterial*>(appMaterials[primitive.matIndex & TSDrawPrimitive::MaterialMask]);
530
531 // Force the material to be double-sided if this geometry is double-sided.
532 if (geomExt->double_sided && appMat && appMat->effectExt)
533 appMat->effectExt->double_sided = true;
534

Callers

nothing calls this directly

Calls 15

avarFunction · 0.85
_GetNameOrIdFunction · 0.85
addMaterialFunction · 0.85
TSDrawPrimitiveClass · 0.85
getContentsMethod · 0.80
incrementMethod · 0.80
readInputsMethod · 0.80
getPoint3FValueMethod · 0.80
getColorIValueMethod · 0.80
getPoint2FValueMethod · 0.80
VertTupleClass · 0.70
getFunction · 0.50

Tested by

no test coverage detected