weird keyup keydown behavior
[hair] / src / main.cc
index 750a2d8..5a93d0e 100644 (file)
@@ -9,13 +9,15 @@
 #include "mesh.h"
 #include "hair.h"
 
-#define MAX_NUM_SPAWNS 500
+#define MAX_NUM_SPAWNS 4
+#define THRESH 0.5
 
 static bool init();
 static void cleanup();
 static void display();
 static void reshape(int x, int y);
 static void keydown(unsigned char key, int x, int y);
+static void keyup(unsigned char key, int x, int y);
 static void mouse(int bn, int st, int x, int y);
 static void motion(int x, int y);
 
@@ -23,8 +25,9 @@ static std::vector<Mesh*> 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;
+static float hair_deg;
 
 int main(int argc, char **argv)
 {
@@ -36,6 +39,7 @@ int main(int argc, char **argv)
        glutDisplayFunc(display);
        glutReshapeFunc(reshape);
        glutKeyboardFunc(keydown);
+       glutKeyboardUpFunc(keyup);
        glutMouseFunc(mouse);
        glutMotionFunc(motion);
 
@@ -68,19 +72,20 @@ static bool init()
 
        for(size_t i=0; i<meshes.size(); i++) {
                meshes[i]->calc_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];
                }
@@ -90,7 +95,7 @@ static bool init()
                return false;
        }
 
-       if(!hair.init(mesh_head, MAX_NUM_SPAWNS, 0.1)) {
+       if(!hair.init(mesh_head, MAX_NUM_SPAWNS, THRESH)) {
                fprintf(stderr, "Failed to initialize hair\n");
                return false;
        }
@@ -139,8 +144,26 @@ static void reshape(int x, int y)
 static void keydown(unsigned char key, int /*x*/, int /*y*/)
 {
        switch(key) {
+       case 'h':
+       case 'H':
+               printf("key %u down\n", key);
+               break;
        case 27:
                exit(0);
+       default:
+               break;
+       }
+}
+
+static void keyup(unsigned char key, int /*x*/, int /*y*/)
+{
+       switch(key) {
+               case 'h':
+               case 'H':
+                       printf("key %u up\n", key);
+                       break;
+               default:
+                       break;
        }
 }