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

Method getVertexData

Engine/source/ts/collada/colladaAppMesh.cpp:626–756  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

624}
625
626void ColladaAppMesh::getVertexData(const domGeometry* geometry, F32 time, const MatrixF& objOffset,
627 Vector<Point3F>& v_points,
628 Vector<Point3F>& v_norms,
629 Vector<ColorI>& v_colors,
630 Vector<Point2F>& v_uvs,
631 Vector<Point2F>& v_uv2s,
632 bool appendValues)
633{
634 if (!primitives.size())
635 return;
636
637 MeshStreams streams;
638 S32 lastPrimitive = -1;
639 ColladaAppMaterial* appMat = 0;
640
641 // Get the supported primitive elements for this geometry
642 Vector<BasePrimitive*> meshPrims;
643 const daeElementRefArray& contents = geometry->getMesh()->getContents();
644 for (S32 iElem = 0; iElem < contents.getCount(); iElem++) {
645 if (BasePrimitive::isSupportedPrimitive(contents[iElem]))
646 meshPrims.push_back(BasePrimitive::get(contents[iElem]));
647 }
648
649 // If appending values, pre-allocate the arrays
650 if (appendValues) {
651 v_points.setSize(v_points.size() + vertTuples.size());
652 v_uvs.setSize(v_uvs.size() + vertTuples.size());
653 }
654
655 // Get pointers to arrays
656 Point3F* points_array = &v_points[v_points.size() - vertTuples.size()];
657 Point2F* uvs_array = &v_uvs[v_uvs.size() - vertTuples.size()];
658 Point3F* norms_array = NULL;
659 ColorI* colors_array = NULL;
660 Point2F* uv2s_array = NULL;
661
662 for (S32 iVert = 0; iVert < vertTuples.size(); iVert++) {
663
664 const VertTuple& tuple = vertTuples[iVert];
665
666 // Change primitives?
667 if (tuple.prim != lastPrimitive) {
668 if (meshPrims.size() <= tuple.prim) {
669 daeErrorHandler::get()->handleError(avar("Failed to get vertex data "
670 "for %s. Primitives do not match base geometry.", geometry->getID()));
671 break;
672 }
673
674 // Update vertex/normal/UV streams and get the new material index
675 streams.reset();
676 streams.readInputs(meshPrims[tuple.prim]->getInputs());
677 S32 matIndex = addMaterial(meshPrims[tuple.prim]->getMaterial());
678 if (matIndex != TSDrawPrimitive::NoMaterial)
679 appMat = static_cast<ColladaAppMaterial*>(appMaterials[matIndex]);
680 else
681 appMat = 0;
682
683 lastPrimitive = tuple.prim;

Callers

nothing calls this directly

Calls 15

avarFunction · 0.85
addMaterialFunction · 0.85
getContentsMethod · 0.80
readInputsMethod · 0.80
getPoint3FValueMethod · 0.80
mulPMethod · 0.80
getPoint2FValueMethod · 0.80
applyTextureTransformMethod · 0.80
getColorIValueMethod · 0.80
getFunction · 0.50
sizeMethod · 0.45
getMeshMethod · 0.45

Tested by

no test coverage detected