From d3e8a791cc97859919f33f8e5fd5c2cdb28811ba Mon Sep 17 00:00:00 2001 From: cinnaboot Date: Tue, 27 Oct 2020 13:46:24 -0400 Subject: [PATCH] log debug info from assimp for animation prep --- .gitattributes | 1 + examples/assimp_loading/animation_testing.cpp | 38 +++++++++++++++++++ examples/assimp_loading/main.cpp | 20 ++++++++++ 3 files changed, 59 insertions(+) create mode 100644 examples/assimp_loading/animation_testing.cpp diff --git a/.gitattributes b/.gitattributes index f2c2af3..97f12d1 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,2 +1,3 @@ *.png filter=lfs diff=lfs merge=lfs -text *.glb filter=lfs diff=lfs merge=lfs -text +*.blend filter=lfs diff=lfs merge=lfs -text diff --git a/examples/assimp_loading/animation_testing.cpp b/examples/assimp_loading/animation_testing.cpp new file mode 100644 index 0000000..91e307b --- /dev/null +++ b/examples/assimp_loading/animation_testing.cpp @@ -0,0 +1,38 @@ + +#include // snprintf +#include // std::cout + +#include +#include +#include + +#include "dumbLog.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"; + + for (uint i = 0; i < node->mNumChildren; i++) + debugParseNode(node->mChildren[i], xform, depth); +} + +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"; + aiMatrix4x4 identity_mat; + debugParseNode(scene->mRootNode, identity_mat); + std::cout << "--------------------------------------\n\n\n"; +} diff --git a/examples/assimp_loading/main.cpp b/examples/assimp_loading/main.cpp index e93d4f6..ebeaf59 100644 --- a/examples/assimp_loading/main.cpp +++ b/examples/assimp_loading/main.cpp @@ -10,6 +10,7 @@ typedef void (*frame_callback_fn) (render_state*); + void doFrameCallback(render_state* rs) { @@ -37,7 +38,14 @@ doRenderLoop(render_state* rs, frame_callback_fn callback_fn, Entity* entities, } callback_fn(rs); + // TODO: entity pointer and entity count should be stored somewhere on the render_state object + // TODO: render_group should track a group of entity objects. the entity objects + // should keep track of their own render_objects? + /* + * render_group -> entities -> render_object(s) + * -> mesh_info ? + */ renRenderFrame(rs, entities, entity_count); SDL_GL_SwapWindow(rs->handles.window); frameTime = SDL_GetTicks() - frameStart; @@ -47,6 +55,9 @@ doRenderLoop(render_state* rs, frame_callback_fn callback_fn, Entity* entities, } } +// TODO: remove/refactor this when we get animation working +#include "animation_testing.cpp" + int main() { @@ -77,6 +88,14 @@ main() rs->num_lights = 1; rs->lights[0].position = glm::vec3(200, -150, 150); + // TODO: look into setting up git-annex for large files. git-lfs works fine for gitlab, + // but has no real implementation for self-hosting: + // https://github.com/git-lfs/git-lfs/issues/1044 + // https://git-annex.branchable.com/ + // + // NOTE: testing assimp animation info + logDebugAnimationInfo("../data/spaceship.glb"); + if (entInit(spaceship, "../data/spaceship.glb", rs->default_shader)) doRenderLoop(rs, doFrameCallback, &spaceship, 1); else @@ -86,3 +105,4 @@ main() meShutdownAssimp(); return 0; } +