From ec50ab9fd4fe6f2c6c4e6f3e2af63105c8d5e3af Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 9 Dec 2012 18:39:44 +0100 Subject: [PATCH] Fixed Mesh Infos demo Former-commit-id: 8fb5a452ea0dee650aaa37ed7ed4278ef6ba54b8 --- examples/MeshInfos/main.cpp | 67 ++++++++++++++++++++++++------------- 1 file changed, 43 insertions(+), 24 deletions(-) diff --git a/examples/MeshInfos/main.cpp b/examples/MeshInfos/main.cpp index e64786a36..6312bbe26 100644 --- a/examples/MeshInfos/main.cpp +++ b/examples/MeshInfos/main.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #include #include #include @@ -65,7 +66,7 @@ int main() break; NzMesh mesh; - if (!mesh.LoadFromFile("resources/" + models[iChoice-1])) + if (!mesh.LoadFromFile("resources/" + models[iChoice-1], params)) { std::cout << "Failed to load mesh" << std::endl; std::getchar(); @@ -120,41 +121,59 @@ int main() } } - if (mesh.HasAnimation()) + NzString animationPath = mesh.GetAnimation(); + if (!animationPath.IsEmpty()) { - const NzAnimation* animation = mesh.GetAnimation(); - unsigned int sequenceCount = animation->GetSequenceCount(); - std::cout << "It has an animation made of " << animation->GetFrameCount() << " frame(s) for " << sequenceCount << " sequence(s)." << std::endl; - std::cout << "Print sequences ? (Y/N) "; - - char cChoice; - std::cin >> cChoice; - std::cin.ignore(std::numeric_limits::max(), '\n'); - - if (std::tolower(cChoice) == 'y') + NzAnimation animation; + if (animation.LoadFromFile(animationPath)) { - for (unsigned int i = 0; i < sequenceCount; ++i) + unsigned int sequenceCount = animation.GetSequenceCount(); + std::cout << "It has an animation made of " << animation.GetFrameCount() << " frame(s) for " << sequenceCount << " sequence(s)." << std::endl; + std::cout << "Print sequences ? (Y/N) "; + + char cChoice; + std::cin >> cChoice; + std::cin.ignore(std::numeric_limits::max(), '\n'); + + if (std::tolower(cChoice) == 'y') { - const NzSequence* sequence = animation->GetSequence(i); - std::cout << "\t" << (i+1) << ": " << sequence->name << std::endl; - std::cout << "\t\tStart frame: " << sequence->firstFrame << std::endl; - std::cout << "\t\tFrame count: " << sequence->frameCount << std::endl; - std::cout << "\t\tFrame rate: " << sequence->frameRate << std::endl; - std::cin.ignore(std::numeric_limits::max(), '\n'); + for (unsigned int i = 0; i < sequenceCount; ++i) + { + const NzSequence* sequence = animation.GetSequence(i); + std::cout << "\t" << (i+1) << ": " << sequence->name << std::endl; + std::cout << "\t\tStart frame: " << sequence->firstFrame << std::endl; + std::cout << "\t\tFrame count: " << sequence->frameCount << std::endl; + std::cout << "\t\tFrame rate: " << sequence->frameRate << std::endl; + std::cin.ignore(std::numeric_limits::max(), '\n'); + } } } + else + std::cout << "It has animation information but animation file could'nt be loaded" << std::endl; } else - std::cout << "It's animable but has no loaded animation" << std::endl; + std::cout << "It's animable but has no animation information" << std::endl; } - /*NzCubef cube = mesh.GetAABB().GetCube(); - std::cout << "Mesh is " << cube.width << " unit wide, " << cube.height << "unit height and " << cube.depth << " unit depth" << std::endl; + NzCubef cube = mesh.GetAABB().GetCube(); + std::cout << "Mesh is " << cube.width << " units wide, " << cube.height << " units height and " << cube.depth << " units depth" << std::endl; unsigned int materialCount = mesh.GetMaterialCount(); std::cout << "It has " << materialCount << " materials registred" << std::endl; - for (unsigned int i = 0; i < materialCount; ++i) - std::cout << "\t" << (i+1) << ": " << mesh.GetMaterial(i) << std::endl;*/ + std::cout << "Print materials ? (Y/N) "; + + char cChoice; + std::cin >> cChoice; + std::cin.ignore(std::numeric_limits::max(), '\n'); + + if (std::tolower(cChoice) == 'y') + { + for (unsigned int i = 0; i < materialCount; ++i) + { + std::cout << "\t" << (i+1) << ": " << mesh.GetMaterial(i) << std::endl; + std::cin.ignore(std::numeric_limits::max(), '\n'); + } + } std::cout << std::endl << std::endl; }