- SmoothTranslator():
- vect_old(0,0,0),
- vect_show(0,0,0),
- vect_aim(0,0,0),
- anim_counter(0),
- anim_time(0),
- anim_time_counter(0),
- aim_is_end(true)
- {}
-
- void init(v3f vect)
- {
- vect_old = vect;
- vect_show = vect;
- vect_aim = vect;
- anim_counter = 0;
- anim_time = 0;
- anim_time_counter = 0;
- aim_is_end = true;
- }
-
- void sharpen()
- {
- init(vect_show);
- }
-
- void update(v3f vect_new, bool is_end_position=false, float update_interval=-1)
- {
- aim_is_end = is_end_position;
- vect_old = vect_show;
- vect_aim = vect_new;
- if(update_interval > 0){
- anim_time = update_interval;
- } else {
- if(anim_time < 0.001 || anim_time > 1.0)
- anim_time = anim_time_counter;
- else
- anim_time = anim_time * 0.9 + anim_time_counter * 0.1;
- }
- anim_time_counter = 0;
- anim_counter = 0;
- }
-
- void translate(f32 dtime)
- {
- anim_time_counter = anim_time_counter + dtime;
- anim_counter = anim_counter + dtime;
- v3f vect_move = vect_aim - vect_old;
- f32 moveratio = 1.0;
- if(anim_time > 0.001)
- moveratio = anim_time_counter / anim_time;
- // Move a bit less than should, to avoid oscillation
- moveratio = moveratio * 0.5;
- float move_end = 1.5;
- if(aim_is_end)
- move_end = 1.0;
- if(moveratio > move_end)
- moveratio = move_end;
- vect_show = vect_old + vect_move * moveratio;
- }
-
- bool is_moving()
- {
- return ((anim_time_counter / anim_time) < 1.4);
- }
-};
-
-
-/*
- TestCAO
-*/