f32 anim_counter;
f32 anim_time;
f32 anim_time_counter;
+ bool aim_is_end;
SmoothTranslator():
vect_old(0,0,0),
vect_aim(0,0,0),
anim_counter(0),
anim_time(0),
- anim_time_counter(0)
+ anim_time_counter(0),
+ aim_is_end(true)
{}
void init(v3f 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)
+ 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(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;
+ 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;
}
moveratio = anim_time_counter / anim_time;
// Move a bit less than should, to avoid oscillation
moveratio = moveratio * 0.5;
- if(moveratio > 1.5)
- moveratio = 1.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;
}
LuaEntityCAO
*/
+struct LuaEntityProperties;
+
class LuaEntityCAO : public ClientActiveObject
{
public:
core::aabbox3d<f32>* getSelectionBox()
{return &m_selection_box;}
v3f getPosition()
- {return m_position;}
+ {return pos_translator.vect_show;}
private:
core::aabbox3d<f32> m_selection_box;
- scene::IMeshSceneNode *m_node;
+ scene::IMeshSceneNode *m_meshnode;
+ scene::MyBillboardSceneNode *m_spritenode;
v3f m_position;
+ float m_yaw;
+ struct LuaEntityProperties *m_prop;
+ SmoothTranslator pos_translator;
};