init_render();
- import_model("out/assets/wall01.3ds");
-
+ model = import_model("out/assets/wall01.3ds");
+ /*
+ fprintf(stderr, "*model = ");
+ print_struct_aiScene(stderr, model);
+ fprintf(stderr, "\n*(*model).mRootNode = ");
+ print_struct_aiNode(stderr, (*model).mRootNode);
+ fprintf(stderr, "\n");
+ */
glutMainLoop();
return 0;
}
#include <GL/glut.h>
+#include <assimp/scene.h>
#include "render.h"
#include "typedefs.h"
glLoadIdentity();
draw_axes();
+ draw_model_recursive(model, (*model).mRootNode);
glFlush();
glutSwapBuffers();
glVertex3fv(z_axis_end);
glEnd();
}
+
+void draw_model_recursive(const struct aiScene* model, const struct aiNode* node) {
+ if (((*model).mFlags & AI_SCENE_FLAGS_INCOMPLETE) == AI_SCENE_FLAGS_INCOMPLETE) {
+ return;
+ }
+
+ for (int i = 0; i < (*node).mNumMeshes; ++i) {
+ const struct aiMesh* mesh = (*model).mMeshes[(*node).mMeshes[i]];
+ for (int k = 0; k < (*mesh).mNumFaces; ++k) {
+ const struct aiFace face = (*mesh).mFaces[k];
+
+ GLenum face_mode;
+ switch(face.mNumIndices) {
+ case 1: face_mode = GL_POINTS; break;
+ case 2: face_mode = GL_LINES; break;
+ case 3: face_mode = GL_TRIANGLES; break;
+ default: face_mode = GL_POLYGON; break;
+ }
+
+ glBegin(face_mode);
+
+ glColor3f(1.0f, 1.0f, 1.0f);
+ for (int l = 0; l < face.mNumIndices; ++l) {
+ glVertex3fv((const GLfloat*) &(*mesh).mVertices[face.mIndices[l]]);
+ }
+
+ glEnd();
+ }
+ }
+
+ for (int i = 0; i < (*node).mNumChildren; ++i) {
+ draw_model_recursive(model, (*node).mChildren[i]);
+ }
+}