X-Git-Url: https://eleni.mutantstargoat.com/git/?a=blobdiff_plain;f=src%2Fmain.cc;h=a23fcb54186a01118040a25894151672651f28ee;hb=2c4aeaa83ca06d604c084f1fe146ee7f51e30f90;hp=8b0fe13393ba2e031bbcb461f614169472f1ac39;hpb=da5cbacf755273da510c37c819a59c7fe9894c4e;p=hair diff --git a/src/main.cc b/src/main.cc index 8b0fe13..a23fcb5 100644 --- a/src/main.cc +++ b/src/main.cc @@ -7,6 +7,10 @@ #include #include "mesh.h" +#include "hair.h" + +#define MAX_NUM_SPAWNS 4 +#define THRESH 0.5 static bool init(); static void cleanup(); @@ -18,9 +22,10 @@ static void motion(int x, int y); static std::vector meshes; static Mesh *mesh_head; +static Hair hair; -int win_width, win_height; -float cam_theta, cam_phi = 25, cam_dist = 8; +static int win_width, win_height; +static float cam_theta, cam_phi = 25, cam_dist = 8; int main(int argc, char **argv) { @@ -55,7 +60,7 @@ static bool init() glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); - glClearColor(1, 0.5, 0.5, 1); + glClearColor(0.5, 0.5, 0.5, 1); meshes = load_meshes("data/head.fbx"); if (meshes.empty()) { fprintf(stderr, "Failed to load mesh.\n"); @@ -64,29 +69,42 @@ static bool init() for(size_t i=0; icalc_bbox(); - +/* Vec3 v0 = meshes[i]->bbox.v0; Vec3 v1 = meshes[i]->bbox.v1; printf("mesh: %s\n", meshes[i]->name.c_str()); printf("AABB mesh %d: v0: (%f, %f, %f) v1: (%f, %f, %f)\n", (int)i, v0.x, v0.y, v0.z, v1.x, v1.y, v1.z); - +*/ meshes[i]->update_vbo(MESH_ALL); +/* printf("num vertices: %d num triangles: %d\n", (int)meshes[i]->vertices.size(), (int)meshes[i]->indices.size() / 3); - +*/ if(meshes[i]->name == "head") { mesh_head = meshes[i]; } } + if(!mesh_head) { + fprintf(stderr, "Failed to find the head mesh.\n"); + return false; + } + + if(!hair.init(mesh_head, MAX_NUM_SPAWNS, THRESH)) { + fprintf(stderr, "Failed to initialize hair\n"); + return false; + } return true; } static void cleanup() { + for(size_t i=0; idraw(); } + hair.draw(); + glutSwapBuffers(); assert(glGetError() == GL_NO_ERROR); }