MCPcopy Create free account
hub / github.com/assimp/assimp / ProcessScene

Method ProcessScene

code/Common/ScenePreprocessor.cpp:50–100  ·  view source on GitHub ↗

---------------------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

48
49// ---------------------------------------------------------------------------------------------
50void ScenePreprocessor::ProcessScene() {
51 ai_assert(scene != nullptr);
52
53 // Process all meshes
54 for (unsigned int i = 0; i < scene->mNumMeshes; ++i) {
55 if (nullptr == scene->mMeshes[i]) {
56 continue;
57 }
58 ProcessMesh(scene->mMeshes[i]);
59 }
60
61 // - nothing to do for nodes for the moment
62 // - nothing to do for textures for the moment
63 // - nothing to do for lights for the moment
64 // - nothing to do for cameras for the moment
65
66 // Process all animations
67 for (unsigned int i = 0; i < scene->mNumAnimations; ++i) {
68 if (nullptr == scene->mAnimations[i]) {
69 continue;
70 }
71 ProcessAnimation(scene->mAnimations[i]);
72 }
73
74 // Generate a default material if none was specified
75 if (!scene->mNumMaterials && scene->mNumMeshes) {
76 scene->mMaterials = new aiMaterial *[2];
77 aiMaterial *helper;
78
79 aiString name;
80
81 scene->mMaterials[scene->mNumMaterials] = helper = new aiMaterial();
82 aiColor3D clr(0.6f, 0.6f, 0.6f);
83 helper->AddProperty(&clr, 1, AI_MATKEY_COLOR_DIFFUSE);
84
85 // setup the default name to make this material identifiable
86 name.Set(AI_DEFAULT_MATERIAL_NAME);
87 helper->AddProperty(&name, AI_MATKEY_NAME);
88
89 ASSIMP_LOG_DEBUG("ScenePreprocessor: Adding default material \'" AI_DEFAULT_MATERIAL_NAME "\'");
90
91 for (unsigned int i = 0; i < scene->mNumMeshes; ++i) {
92 if (nullptr == scene->mMeshes[i]) {
93 continue;
94 }
95 scene->mMeshes[i]->mMaterialIndex = scene->mNumMaterials;
96 }
97
98 scene->mNumMaterials++;
99 }
100}
101
102// ---------------------------------------------------------------------------------------------
103void ScenePreprocessor::ProcessMesh(aiMesh *mesh) {

Callers 2

TEST_FFunction · 0.80
ReadFileMethod · 0.80

Calls 2

AddPropertyMethod · 0.45
SetMethod · 0.45

Tested by

no test coverage detected