Browse Source

log debug info from assimp for animation prep

testing
cinnaboot 6 years ago
parent
commit
d3e8a791cc
  1. 1
      .gitattributes
  2. 38
      examples/assimp_loading/animation_testing.cpp
  3. 20
      examples/assimp_loading/main.cpp

1
.gitattributes vendored

@ -1,2 +1,3 @@
*.png filter=lfs diff=lfs merge=lfs -text *.png filter=lfs diff=lfs merge=lfs -text
*.glb filter=lfs diff=lfs merge=lfs -text *.glb filter=lfs diff=lfs merge=lfs -text
*.blend filter=lfs diff=lfs merge=lfs -text

38
examples/assimp_loading/animation_testing.cpp

@ -0,0 +1,38 @@
#include <cstdio> // snprintf
#include <iostream> // std::cout
#include <assimp/cimport.h>
#include <assimp/scene.h>
#include <assimp/postprocess.h>
#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";
}

20
examples/assimp_loading/main.cpp

@ -10,6 +10,7 @@
typedef void (*frame_callback_fn) (render_state*); typedef void (*frame_callback_fn) (render_state*);
void void
doFrameCallback(render_state* rs) doFrameCallback(render_state* rs)
{ {
@ -37,7 +38,14 @@ doRenderLoop(render_state* rs, frame_callback_fn callback_fn, Entity* entities,
} }
callback_fn(rs); callback_fn(rs);
// TODO: entity pointer and entity count should be stored somewhere on the render_state object // 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); renRenderFrame(rs, entities, entity_count);
SDL_GL_SwapWindow(rs->handles.window); SDL_GL_SwapWindow(rs->handles.window);
frameTime = SDL_GetTicks() - frameStart; 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 int
main() main()
{ {
@ -77,6 +88,14 @@ main()
rs->num_lights = 1; rs->num_lights = 1;
rs->lights[0].position = glm::vec3(200, -150, 150); 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)) if (entInit(spaceship, "../data/spaceship.glb", rs->default_shader))
doRenderLoop(rs, doFrameCallback, &spaceship, 1); doRenderLoop(rs, doFrameCallback, &spaceship, 1);
else else
@ -86,3 +105,4 @@ main()
meShutdownAssimp(); meShutdownAssimp();
return 0; return 0;
} }

Loading…
Cancel
Save