MCPcopy Create free account
hub / github.com/NVIDIAGameWorks/Falcor / addTriangleMesh

Method addTriangleMesh

Source/Falcor/Scene/SceneBuilder.cpp:418–450  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

416 }
417
418 MeshID SceneBuilder::addTriangleMesh(const ref<TriangleMesh>& pTriangleMesh, const ref<Material>& pMaterial, bool isAnimated)
419 {
420 FALCOR_CHECK(pTriangleMesh != nullptr, "'pTriangleMesh' is missing");
421 FALCOR_CHECK(pMaterial != nullptr, "'pMaterial' is missing");
422
423 Mesh mesh;
424
425 const auto& indices = pTriangleMesh->getIndices();
426 const auto& vertices = pTriangleMesh->getVertices();
427
428 mesh.name = pTriangleMesh->getName();
429 mesh.faceCount = (uint32_t)(indices.size() / 3);
430 mesh.vertexCount = (uint32_t)vertices.size();
431 mesh.indexCount = (uint32_t)indices.size();
432 mesh.pIndices = indices.data();
433 mesh.topology = Vao::Topology::TriangleList;
434 mesh.isFrontFaceCW = pTriangleMesh->getFrontFaceCW();
435 mesh.pMaterial = pMaterial;
436 mesh.isAnimated = isAnimated;
437
438 std::vector<float3> positions(vertices.size());
439 std::vector<float3> normals(vertices.size());
440 std::vector<float2> texCoords(vertices.size());
441 std::transform(vertices.begin(), vertices.end(), positions.begin(), [] (const auto& v) { return v.position; });
442 std::transform(vertices.begin(), vertices.end(), normals.begin(), [] (const auto& v) { return v.normal; });
443 std::transform(vertices.begin(), vertices.end(), texCoords.begin(), [] (const auto& v) { return v.texCoord; });
444
445 mesh.positions = { positions.data(), SceneBuilder::Mesh::AttributeFrequency::Vertex };
446 mesh.normals = { normals.data(), SceneBuilder::Mesh::AttributeFrequency::Vertex };
447 mesh.texCrds = { texCoords.data(), SceneBuilder::Mesh::AttributeFrequency::Vertex };
448
449 return addMesh(mesh);
450 }
451
452 SceneBuilder::ProcessedMesh SceneBuilder::processMesh(const Mesh& mesh_, MeshAttributeIndices* pAttributeIndices, std::vector<float4>* pTangents) const
453 {

Callers 3

createInstanceDefinitionFunction · 0.80
buildSceneFunction · 0.80
buildSceneFunction · 0.80

Calls 6

getIndicesMethod · 0.45
getNameMethod · 0.45
sizeMethod · 0.45
dataMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected