m_digging_anim(0),
m_digging_button(-1),
- m_dummymesh(createCubeMesh(v3f(1,1,1)))
+ m_dummymesh(createCubeMesh(v3f(1,1,1))),
+
+ m_wield_change_timer(0.125),
+ m_wield_mesh_next(NULL),
+ m_previous_playeritem(-1),
+ m_previous_itemname("")
{
//dstream<<__FUNCTION_NAME<<std::endl;
m_view_bobbing_fall = -1; // Mark the effect as finished
}
+ if(m_wield_change_timer < 0.125)
+ m_wield_change_timer += dtime;
+ if(m_wield_change_timer > 0.125)
+ m_wield_change_timer = 0.125;
+
+ if(m_wield_change_timer >= 0 && m_wield_change_timer - dtime < 0) {
+ if(m_wield_mesh_next) {
+ m_wieldnode->setMesh(m_wield_mesh_next);
+ m_wieldnode->setVisible(true);
+ } else {
+ m_wieldnode->setVisible(false);
+ }
+ m_wield_mesh_next = NULL;
+ }
+
if (m_view_bobbing_state != 0)
{
//f32 offset = dtime * m_view_bobbing_speed * 0.035;
v3f wield_position = v3f(55, -35, 65);
//v3f wield_rotation = v3f(-100, 120, -100);
v3f wield_rotation = v3f(-100, 120, -100);
+ if(m_wield_change_timer < 0)
+ wield_position.Y -= 40 + m_wield_change_timer*320;
+ else
+ wield_position.Y -= 40 - m_wield_change_timer*320;
if(m_digging_anim < 0.05 || m_digging_anim > 0.5){
f32 frac = 1.0;
if(m_digging_anim > 0.5)
m_digging_button = button;
}
-void Camera::wield(const ItemStack &item)
+void Camera::wield(const ItemStack &item, u16 playeritem)
{
IItemDefManager *idef = m_gamedef->idef();
- scene::IMesh *wield_mesh = idef->getWieldMesh(item.getDefinition(idef).name, m_gamedef);
- if(wield_mesh)
- {
- m_wieldnode->setMesh(wield_mesh);
- m_wieldnode->setVisible(true);
- }
- else
- {
- m_wieldnode->setVisible(false);
+ std::string itemname = item.getDefinition(idef).name;
+ m_wield_mesh_next = idef->getWieldMesh(itemname, m_gamedef);
+ if(playeritem != m_previous_playeritem) {
+ m_previous_playeritem = playeritem;
+ m_previous_itemname = itemname;
+ if(m_wield_change_timer >= 0.125)
+ m_wield_change_timer = -0.125;
+ else if(m_wield_change_timer > 0) {
+ m_wield_change_timer = -m_wield_change_timer;
+ }
+ } else {
+ if(m_wield_mesh_next) {
+ m_wieldnode->setMesh(m_wield_mesh_next);
+ m_wieldnode->setVisible(true);
+ } else {
+ m_wieldnode->setVisible(false);
+ }
+ m_wield_mesh_next = NULL;
+ if(m_previous_itemname != itemname) {
+ m_previous_itemname = itemname;
+ m_wield_change_timer = 0;
+ }
+ else
+ m_wield_change_timer = 0.125;
}
}
void setDigging(s32 button);
// Replace the wielded item mesh
- void wield(const ItemStack &item);
+ void wield(const ItemStack &item, u16 playeritem);
// Draw the wielded tool.
// This has to happen *after* the main scene is drawn.
//dummymesh for camera
irr::scene::IAnimatedMesh* m_dummymesh;
+
+ // Animation when changing wielded item
+ f32 m_wield_change_timer;
+ scene::IMesh *m_wield_mesh_next;
+ u16 m_previous_playeritem;
+ std::string m_previous_itemname;
};
#endif