2 #include <assimp/scene.h>
6 #include "performance.h"
8 const float AXIS_RADIUS = 5.0f;
11 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
15 drawModelRecursive(model, (*model).mRootNode);
24 point3f xAxisStart = { 0.0f, 0.0f, 0.0f };
25 point3f xAxisEnd = { AXIS_RADIUS, 0.0f, 0.0f };
26 point3f yAxisStart = { 0.0f, 0.0f, 0.0f };
27 point3f yAxisEnd = { 0.0f, AXIS_RADIUS, 0.0f };
28 point3f zAxisStart = { 0.0f, 0.0f, 0.0f };
29 point3f zAxisEnd = { 0.0f, 0.0f, AXIS_RADIUS };
31 glColor3f(1.0f, 0.0f, 0.0f);
33 glVertex3fv(xAxisStart);
34 glVertex3fv(xAxisEnd);
37 glColor3f(0.0f, 1.0f, 0.0f);
39 glVertex3fv(yAxisStart);
40 glVertex3fv(yAxisEnd);
43 glColor3f(0.0f, 0.0f, 1.0f);
45 glVertex3fv(zAxisStart);
46 glVertex3fv(zAxisEnd);
50 void drawModelRecursive(const struct aiScene* model, const struct aiNode* node) {
51 if (((*model).mFlags & AI_SCENE_FLAGS_INCOMPLETE) == AI_SCENE_FLAGS_INCOMPLETE) {
55 for (int i = 0; i < (*node).mNumMeshes; ++i) {
56 const struct aiMesh* mesh = (*model).mMeshes[(*node).mMeshes[i]];
57 for (int k = 0; k < (*mesh).mNumFaces; ++k) {
58 const struct aiFace face = (*mesh).mFaces[k];
61 switch (face.mNumIndices) {
62 case 1: faceMode = GL_POINTS; break;
63 case 2: faceMode = GL_LINES; break;
64 case 3: faceMode = GL_TRIANGLES; break;
65 default: faceMode = GL_POLYGON; break;
70 glColor3f(1.0f, 1.0f, 1.0f);
71 for (int l = 0; l < face.mNumIndices; ++l) {
72 glVertex3fv((const GLfloat*) &(*mesh).mVertices[face.mIndices[l]]);
79 for (int i = 0; i < (*node).mNumChildren; ++i) {
80 drawModelRecursive(model, (*node).mChildren[i]);