aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/content_cao.cpp27
-rw-r--r--src/genericobject.cpp33
-rw-r--r--src/object_properties.cpp12
-rw-r--r--src/object_properties.h3
-rw-r--r--src/scriptapi.cpp3
5 files changed, 41 insertions, 37 deletions
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"<<std::endl;
+ infostream<<"textures: "<<m_prop.textures.size()<<std::endl;
+ if(m_prop.textures.size() >= 1){
+ infostream<<"textures[0]: "<<m_prop.textures[0]<<std::endl;
+ IItemDefManager *idef = m_gamedef->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(): \""<<m_prop.visual
<<"\" not supported"<<std::endl;
@@ -916,6 +934,10 @@ public:
updateTextures("");
}
}
+ if(fabs(m_prop.automatic_rotate > 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<<serializeString(prop.visual);
- writeV2F1000(os, prop.visual_size);
- writeU16(os, prop.textures.size());
- for(u32 i=0; i<prop.textures.size(); i++){
- os<<serializeString(prop.textures[i]);
- }
- writeV2S16(os, prop.spritediv);
- writeV2S16(os, prop.initial_sprite_basepos);
- writeU8(os, prop.is_visible);
- writeU8(os, prop.makes_footstep_sound);
+ prop.serialize(os);
return os.str();
}
ObjectProperties gob_read_set_properties(std::istream &is)
{
ObjectProperties prop;
- prop.hp_max = readS16(is);
- prop.physical = readU8(is);
- prop.weight = readF1000(is);
- prop.collisionbox.MinEdge = readV3F1000(is);
- prop.collisionbox.MaxEdge = readV3F1000(is);
- prop.visual = deSerializeString(is);
- prop.visual_size = readV2F1000(is);
- prop.textures.clear();
- u32 texture_count = readU16(is);
- for(u32 i=0; i<texture_count; i++){
- prop.textures.push_back(deSerializeString(is));
- }
- prop.spritediv = readV2S16(is);
- prop.initial_sprite_basepos = readV2S16(is);
- prop.is_visible = readU8(is);
- prop.makes_footstep_sound = readU8(is);
+ prop.deSerialize(is);
return prop;
}
diff --git a/src/object_properties.cpp b/src/object_properties.cpp
index edd50c30a..08e9f63cf 100644
--- a/src/object_properties.cpp
+++ b/src/object_properties.cpp
@@ -33,7 +33,8 @@ ObjectProperties::ObjectProperties():
spritediv(1,1),
initial_sprite_basepos(0,0),
is_visible(true),
- makes_footstep_sound(false)
+ makes_footstep_sound(false),
+ automatic_rotate(0)
{
textures.push_back("unknown_object.png");
}
@@ -54,12 +55,13 @@ std::string ObjectProperties::dump()
os<<"]";
os<<", spritediv="<<PP2(spritediv);
os<<", initial_sprite_basepos="<<PP2(initial_sprite_basepos);
- os<<", is_visible"<<is_visible;
+ os<<", is_visible="<<is_visible;
os<<", makes_footstep_sound="<<makes_footstep_sound;
+ os<<", automatic_rotate="<<automatic_rotate;
return os.str();
}
-void ObjectProperties::serialize(std::ostream &os)
+void ObjectProperties::serialize(std::ostream &os) const
{
writeU8(os, 1); // version
writeS16(os, hp_max);
@@ -77,6 +79,7 @@ void ObjectProperties::serialize(std::ostream &os)
writeV2S16(os, initial_sprite_basepos);
writeU8(os, is_visible);
writeU8(os, makes_footstep_sound);
+ writeF1000(os, automatic_rotate);
}
void ObjectProperties::deSerialize(std::istream &is)
@@ -100,6 +103,9 @@ void ObjectProperties::deSerialize(std::istream &is)
initial_sprite_basepos = readV2S16(is);
is_visible = readU8(is);
makes_footstep_sound = readU8(is);
+ try{
+ automatic_rotate = readF1000(is);
+ }catch(SerializationError &e){}
}
diff --git a/src/object_properties.h b/src/object_properties.h
index 99683a917..75ba1f895 100644
--- a/src/object_properties.h
+++ b/src/object_properties.h
@@ -38,10 +38,11 @@ struct ObjectProperties
v2s16 initial_sprite_basepos;
bool is_visible;
bool makes_footstep_sound;
+ float automatic_rotate;
ObjectProperties();
std::string dump();
- void serialize(std::ostream &os);
+ void serialize(std::ostream &os) const;
void deSerialize(std::istream &is);
};
diff --git a/src/scriptapi.cpp b/src/scriptapi.cpp
index a45c27de6..5453d9b2e 100644
--- a/src/scriptapi.cpp
+++ b/src/scriptapi.cpp
@@ -915,6 +915,9 @@ static void read_object_properties(lua_State *L, int index,
getboolfield(L, -1, "is_visible", prop->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="
+ <<prop->automatic_rotate<<std::endl;
}
/*