dbf-udg
diff src/mballs.cc @ 11:5f99c4c7a9fe
now it looks pretty much ok
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Wed, 20 Feb 2013 04:55:03 +0200 |
parents | 7056437a361b |
children | 1abbed71e9c9 |
line diff
1.1 --- a/src/mballs.cc Tue Feb 19 23:46:44 2013 +0200 1.2 +++ b/src/mballs.cc Wed Feb 20 04:55:03 2013 +0200 1.3 @@ -4,6 +4,7 @@ 1.4 #include "metasurf.h" 1.5 #include "vmath/vmath.h" 1.6 #include "dsys.h" 1.7 +#include "udg.h" 1.8 1.9 struct MetaBall { 1.10 Vector3 pos; 1.11 @@ -26,6 +27,8 @@ 1.12 static struct metasurface *msurf; 1.13 static float floor_height = -0.95; 1.14 1.15 +static struct dsys_event *evrise; 1.16 + 1.17 bool mball_init() 1.18 { 1.19 static const float bbmin = -VOL_SZ / 2.0; 1.20 @@ -49,6 +52,9 @@ 1.21 balls.push_back(mb); 1.22 } 1.23 1.24 + evrise = dsys_event(demo, "mball_rise"); 1.25 + dsys_set_event_eval(evrise, dsys_eval_sigmoid); 1.26 + 1.27 return true; 1.28 } 1.29 1.30 @@ -117,11 +123,13 @@ 1.31 1.32 static void update(float sec) 1.33 { 1.34 + float trise = dsys_event_value(evrise); 1.35 + 1.36 for(size_t i=0; i<balls.size(); i++) { 1.37 float t = sec + balls[i].phase_offs; 1.38 balls[i].pos.x = cos(t * 1.8) * balls[i].orbit; 1.39 balls[i].pos.z = sin(t * 1.2) * balls[i].orbit; 1.40 - balls[i].pos.y = (sin(t) + cos(t * 2.0) / 2.0 + sin(t * 3.0) / 3.0) * 0.45; 1.41 + balls[i].pos.y = (sin(t) + cos(t * 2.0) / 2.0 + sin(t * 3.0) / 3.0) * 0.45 - (2.0 - trise * 2.0); 1.42 } 1.43 1.44 for(int i=0; i<MBALL_GRID_SZ; i++) {