A small OpenGL 3+ renderer and game engine
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

72 lines
1.8 KiB

#include <cstdio> // snprintf
#include <iostream> // std::cout
#include <assimp/cimport.h>
#include <assimp/scene.h>
#include <assimp/postprocess.h>
#include "util.h"
#include "dumbLog.h"
#include "mesh.h"
void
debugParseNode(aiNode* node, aiMatrix4x4 xform, uint depth=0)
{
depth++;
char tabs[256];
snprintf(tabs, 256, "%*s", depth * 4, " ");
std::cout << tabs << node->mName.C_Str() << ", has meshes: " << (node->mNumMeshes > 0) << "\n";
if (node->mNumMeshes > 0) {
for (uint i = 0; i < node->mNumMeshes; i++)
std::cout << tabs << " mesh index: " << node->mMeshes[i] << "\n";
}
for (uint i = 0; i < node->mNumChildren; i++)
debugParseNode(node->mChildren[i], xform, depth);
}
void
debugParseAnimation(aiAnimation* anim)
{
std::cout << "Animation, ticks/s: " << anim->mTicksPerSecond
<< ", duration: " << anim->mDuration
<< ", channels: " << anim->mNumChannels
<< "\n";
for (uint i = 0; i < anim->mNumChannels; i++) {
aiNodeAnim* chan = anim->mChannels[i];
std::cout << " channel " << i
<< ", node name: " << chan->mNodeName.C_Str()
<< ", mNumPositionKeys: " << chan->mNumPositionKeys
<< ", mNumRotationKeys: " << chan->mNumRotationKeys
<< ", mNumScalingKeys: " << chan->mNumScalingKeys
<< "\n";
}
}
void
logDebugAnimationInfo(const char* model_name)
{
const aiScene* scene = aiImportFile(model_name, aiProcessPreset_TargetRealtime_MaxQuality);
if (!scene) {
LOG(Error) << "Error loading file: " << model_name << "\n";
return;
}
std::cout << "\n\n--------------------------------------\n";
std::cout << "Nodes:\n";
aiMatrix4x4 identity_mat;
debugParseNode(scene->mRootNode, identity_mat);
std::cout << "--------------------------------------\n";
std::cout << "Animations:\n";
if (scene->HasAnimations())
debugParseAnimation(scene->mAnimations[0]);
std::cout << "--------------------------------------\n\n\n";
}