From b22168d3da597d61c40cc93dd690ba143fd5e4cc Mon Sep 17 00:00:00 2001 From: Perttu Ahola Date: Wed, 4 Apr 2012 13:16:09 +0300 Subject: Fix dropped nodeitem visuals --- builtin/item_entity.lua | 22 +++++++++++++++++----- src/content_cao.cpp | 27 +++++++++++++++++++++++++-- src/genericobject.cpp | 33 ++------------------------------- src/object_properties.cpp | 12 +++++++++--- src/object_properties.h | 3 ++- src/scriptapi.cpp | 3 +++ 6 files changed, 58 insertions(+), 42 deletions(-) diff --git a/builtin/item_entity.lua b/builtin/item_entity.lua index 8468ebedf..ad0060b48 100644 --- a/builtin/item_entity.lua +++ b/builtin/item_entity.lua @@ -12,7 +12,7 @@ minetest.register_entity("__builtin:item", { initial_properties = { hp_max = 1, physical = true, - collisionbox = {-0.25,-0.25,-0.25, 0.25,0.25,0.25}, + collisionbox = {-0.17,-0.17,-0.17, 0.17,0.17,0.17}, visual = "sprite", visual_size = {x=0.5, y=0.5}, textures = {""}, @@ -33,14 +33,26 @@ minetest.register_entity("__builtin:item", { itemname = stack:to_table().name end local item_texture = nil + local item_type = "" if minetest.registered_items[itemname] then item_texture = minetest.registered_items[itemname].inventory_image + item_type = minetest.registered_items[itemname].type end - item_texture = item_texture or "unknown_item.png" - self.object:set_properties({ - textures = {item_texture}, + prop = { is_visible = true, - }) + visual = "sprite", + textures = {"unknown_item.png"} + } + if item_texture and item_texture ~= "" then + prop.visual = "sprite" + prop.textures = {item_texture} + else + prop.visual = "wielditem" + prop.textures = {itemname} + prop.visual_size = {x=0.20, y=0.20} + prop.automatic_rotate = math.pi * 0.25 + end + self.object:set_properties(prop) end, get_staticdata = function(self) diff --git a/src/content_cao.cpp b/src/content_cao.cpp index 1241e0002..f211ff8b9 100644 --- a/src/content_cao.cpp +++ b/src/content_cao.cpp @@ -781,9 +781,27 @@ public: m_meshnode = smgr->addMeshSceneNode(mesh, NULL); mesh->drop(); - m_meshnode->setScale(v3f(1)); + m_meshnode->setScale(v3f(m_prop.visual_size.X/2, + m_prop.visual_size.Y/2, + m_prop.visual_size.X/2)); u8 li = m_last_light; setMeshColor(m_meshnode->getMesh(), video::SColor(255,li,li,li)); + } else if(m_prop.visual == "wielditem"){ + infostream<<"GenericCAO::addToScene(): node"<= 1){ + infostream<<"textures[0]: "<idef(); + ItemStack item(m_prop.textures[0], 1, 0, "", idef); + scene::IMesh *mesh = item.getDefinition(idef).wield_mesh; + m_meshnode = smgr->addMeshSceneNode(mesh, NULL); + + m_meshnode->setScale(v3f(m_prop.visual_size.X/2, + m_prop.visual_size.Y/2, + m_prop.visual_size.X/2)); + u8 li = m_last_light; + setMeshColor(m_meshnode->getMesh(), video::SColor(255,li,li,li)); + } } else { infostream<<"GenericCAO::addToScene(): \""< 0.001)){ + m_yaw += dtime * m_prop.automatic_rotate * 180 / PI; + updateNodePos(); + } } void updateTexturePos() @@ -1064,7 +1086,8 @@ public: m_position = readV3F1000(is); m_velocity = readV3F1000(is); m_acceleration = readV3F1000(is); - m_yaw = readF1000(is); + if(fabs(m_prop.automatic_rotate < 0.001)) + m_yaw = readF1000(is); bool do_interpolate = readU8(is); bool is_end_position = readU8(is); float update_interval = readF1000(is); diff --git a/src/genericobject.cpp b/src/genericobject.cpp index 563b7f7f1..1f85d9e47 100644 --- a/src/genericobject.cpp +++ b/src/genericobject.cpp @@ -25,43 +25,14 @@ std::string gob_cmd_set_properties(const ObjectProperties &prop) { std::ostringstream os(std::ios::binary); writeU8(os, GENERIC_CMD_SET_PROPERTIES); - writeS16(os, prop.hp_max); - writeU8(os, prop.physical); - writeF1000(os, prop.weight); - writeV3F1000(os, prop.collisionbox.MinEdge); - writeV3F1000(os, prop.collisionbox.MaxEdge); - os<is_visible); getboolfield(L, -1, "makes_footstep_sound", prop->makes_footstep_sound); + getfloatfield(L, -1, "automatic_rotate", prop->automatic_rotate); + dstream<<"scriptapi: prop->automatic_rotate=" + <automatic_rotate<