MCPcopy Create free account
hub / github.com/KTStephano/StratusGFX / ProcessMesh

Function ProcessMesh

Source/Engine/StratusResourceManager.cpp:367–430  ·  view source on GitHub ↗

static void ProcessMesh( RenderComponent * renderNode, const aiMatrix4x4& transform, aiMesh * mesh, const aiScene * scene, MaterialPtr rootMat, const std::string& directory, const std::string& extension, RenderFaceCulling defaultCullMode, const ColorSpace& cspace) {

Source from the content-addressed store, hash-verified

365 // RenderFaceCulling defaultCullMode,
366 // const ColorSpace& cspace) {
367 static void ProcessMesh(
368 MeshToProcess_& processMesh,
369 const aiScene * scene,
370 const std::string& directory,
371 const std::string& extension,
372 RenderFaceCulling defaultCullMode,
373 const ColorSpace& cspace) {
374
375 //if (mesh->mNumUVComponents[0] == 0) return;
376 //if (mesh->mNormals == nullptr || mesh->mTangents == nullptr || mesh->mBitangents == nullptr) return;
377 //if (mesh->mNormals == nullptr) return;
378
379 //MeshPtr rmesh = Mesh::Create();
380 aiMesh * mesh = processMesh.aim;
381 MeshPtr rmesh = processMesh.mesh;
382
383 // Process core primitive data
384 for (uint32_t i = 0; i < mesh->mNumVertices; i++) {
385 rmesh->AddVertex(glm::vec3(mesh->mVertices[i].x, mesh->mVertices[i].y, mesh->mVertices[i].z));
386 rmesh->AddNormal(glm::vec3(mesh->mNormals[i].x, mesh->mNormals[i].y, mesh->mNormals[i].z));
387
388 if (mesh->mNumUVComponents[0] != 0) {
389 rmesh->AddUV(glm::vec2(mesh->mTextureCoords[0][i].x, mesh->mTextureCoords[0][i].y));
390 }
391 else {
392 rmesh->AddUV(glm::vec2(1.0f, 1.0f));
393 }
394
395 if (mesh->mTangents != nullptr) rmesh->AddTangent(glm::vec3(mesh->mTangents[i].x, mesh->mTangents[i].y, mesh->mTangents[i].z));
396 if (mesh->mBitangents != nullptr) rmesh->AddBitangent(glm::vec3(mesh->mBitangents[i].x, mesh->mBitangents[i].y, mesh->mBitangents[i].z));
397 }
398
399 // Process indices
400 for(uint32_t i = 0; i < mesh->mNumFaces; i++) {
401 aiFace face = mesh->mFaces[i];
402 for(uint32_t j = 0; j < face.mNumIndices; j++) {
403 rmesh->AddIndex(face.mIndices[j]);
404 }
405 }
406
407 // Process material
408 //MaterialPtr m = rootMat->CreateSubMaterial();
409 MaterialPtr m = processMesh.material;
410
411 RenderFaceCulling cull = defaultCullMode;
412 if (mesh->mMaterialIndex >= 0) {
413 aiMaterial * aimat = scene->mMaterials[mesh->mMaterialIndex];
414
415 // Disable face culling if applicable
416 int doubleSided = 0;
417 if(AI_SUCCESS == aimat->Get(AI_MATKEY_TWOSIDED, doubleSided)) {
418 //STRATUS_LOG << "Double Sided: " << doubleSided << std::endl;
419 if (doubleSided != 0) {
420 cull = RenderFaceCulling::CULLING_NONE;
421 }
422 }
423 }
424

Callers 1

LoadModel_Method · 0.85

Calls 8

AddVertexMethod · 0.80
AddNormalMethod · 0.80
AddUVMethod · 0.80
AddTangentMethod · 0.80
AddBitangentMethod · 0.80
AddIndexMethod · 0.80
GetMethod · 0.80
SetFaceCullingMethod · 0.80

Tested by

no test coverage detected