dbf-udg
diff src/mballs.cc @ 9:7056437a361b
added demosys
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Tue, 19 Feb 2013 18:17:17 +0200 |
parents | f0a47f46ee45 |
children | 5f99c4c7a9fe |
line diff
1.1 --- a/src/mballs.cc Mon Feb 18 06:53:44 2013 +0200 1.2 +++ b/src/mballs.cc Tue Feb 19 18:17:17 2013 +0200 1.3 @@ -3,6 +3,7 @@ 1.4 #include "mballs.h" 1.5 #include "metasurf.h" 1.6 #include "vmath/vmath.h" 1.7 +#include "dsys.h" 1.8 1.9 struct MetaBall { 1.10 Vector3 pos; 1.11 @@ -14,7 +15,7 @@ 1.12 #define VOL_SZ 2 1.13 #define MBALL_GRID_SZ 50 1.14 1.15 -static void update(); 1.16 +static void update(float sec); 1.17 static float calc_field(float x, float y, float z); 1.18 static float eval(float x, float y, float z); 1.19 static void vertex(float x, float y, float z); 1.20 @@ -43,7 +44,7 @@ 1.21 for(int i=0; i<10; i++) { 1.22 MetaBall mb; 1.23 mb.orbit = 0.25 * rand() / (float)RAND_MAX + 0.35; 1.24 - mb.energy = 0.2 * rand() / (float)RAND_MAX + 0.15; 1.25 + mb.energy = 0.1 * rand() / (float)RAND_MAX + 0.15; 1.26 mb.phase_offs = rand() / (float)RAND_MAX * M_PI * 2.0; 1.27 balls.push_back(mb); 1.28 } 1.29 @@ -51,9 +52,9 @@ 1.30 return true; 1.31 } 1.32 1.33 -void mball_render() 1.34 +void mball_render(float sec) 1.35 { 1.36 - update(); 1.37 + update(sec); 1.38 1.39 const float blue[] = {0.4, 0.45, 1.0, 1}; 1.40 const float dark_red[] = {0.6, 0.2, 0.1, 1}; 1.41 @@ -114,11 +115,8 @@ 1.42 } 1.43 1.44 1.45 -static void update() 1.46 +static void update(float sec) 1.47 { 1.48 - unsigned int msec = glutGet(GLUT_ELAPSED_TIME); 1.49 - float sec = msec / 1000.0; 1.50 - 1.51 for(size_t i=0; i<balls.size(); i++) { 1.52 float t = sec + balls[i].phase_offs; 1.53 balls[i].pos.x = cos(t * 1.8) * balls[i].orbit;