projects
/
hair
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
added forces + damping, k factors
[hair]
/
src
/
main.cc
diff --git
a/src/main.cc
b/src/main.cc
index
307f647
..
54959a8
100644
(file)
--- a/
src/main.cc
+++ b/
src/main.cc
@@
-11,7
+11,7
@@
#include "mesh.h"
#include "hair.h"
#include "mesh.h"
#include "hair.h"
-#define MAX_NUM_SPAWNS 4
+#define MAX_NUM_SPAWNS 400
#define THRESH 0.5
static bool init();
#define THRESH 0.5
static bool init();
@@
-120,6
+120,11
@@
static void cleanup()
static void display()
{
static void display()
{
+ static unsigned long prev_time;
+ unsigned long msec = glutGet(GLUT_ELAPSED_TIME);
+ float dt = (float)(msec - prev_time) / 1000.0;
+ prev_time = msec;
+
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
head_xform = Mat4::identity;
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
head_xform = Mat4::identity;
@@
-131,14
+136,16
@@
static void display()
glTranslatef(0, 0, -cam_dist);
glRotatef(cam_phi, 1, 0, 0);
glRotatef(cam_theta, 0, 1, 0);
glTranslatef(0, 0, -cam_dist);
glRotatef(cam_phi, 1, 0, 0);
glRotatef(cam_theta, 0, 1, 0);
-
+ /* multiplying with the head rot matrix */
+ glPushMatrix();
glMultMatrixf(head_xform[0]);
glMultMatrixf(head_xform[0]);
-
for(size_t i=0; i<meshes.size(); i++) {
meshes[i]->draw();
}
for(size_t i=0; i<meshes.size(); i++) {
meshes[i]->draw();
}
+ glPopMatrix();
hair.set_transform(head_xform);
hair.set_transform(head_xform);
+ hair.update(dt);
hair.draw();
glutSwapBuffers();
hair.draw();
glutSwapBuffers();
@@
-211,7
+218,7
@@
static void motion(int x, int y)
if(head_rx > 45) head_rx = 45;
if(head_rz < -90) head_rz = -90;
if(head_rx > 45) head_rx = 45;
if(head_rz < -90) head_rz = -90;
- if(head_rz > 90) head_rx = 90;
+ if(head_rz > 90) head_rz = 30;
}
}
else {
}
}
else {