summaryrefslogtreecommitdiff
path: root/src/content_cao.cpp
diff options
context:
space:
mode:
authorMirceaKitsune <sonichedgehog_hyperblast00@yahoo.com>2012-10-27 01:49:01 +0300
committerPerttu Ahola <celeron55@gmail.com>2012-11-25 18:14:15 +0200
commite42eeec8f626acbaa54ae31c10ca06c868c7931c (patch)
tree61ea64416548b5ad858c6d275da90ace607fd163 /src/content_cao.cpp
parent118285e6babd511c285780b07c275d527d7da9b1 (diff)
downloadminetest-e42eeec8f626acbaa54ae31c10ca06c868c7931c.tar.gz
minetest-e42eeec8f626acbaa54ae31c10ca06c868c7931c.tar.bz2
minetest-e42eeec8f626acbaa54ae31c10ca06c868c7931c.zip
Framework for the attachment system, new object property which allows changing the color and alpha of mesh materials
New object property which allows changing the color and alpha of mesh materials. Due to the current lighting systems it doesn't work yet, but the full implementation is there Framework for the attachment system, with no actual functionality yet Send bone and player object to the setAttachment function in content_sao.cpp, but we need a way to translate it there and send it to the client I will also want position and rotation offsets to be possible to apply to attachments Network object ID from server to client. This will be used to identify the parent client-side and know what to attach to
Diffstat (limited to 'src/content_cao.cpp')
-rw-r--r--src/content_cao.cpp40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/content_cao.cpp b/src/content_cao.cpp
index b12bfe1c8..3e18337d2 100644
--- a/src/content_cao.cpp
+++ b/src/content_cao.cpp
@@ -555,6 +555,7 @@ private:
std::string m_name;
bool m_is_player;
bool m_is_local_player; // determined locally
+ int m_id;
// Property-ish things
ObjectProperties m_prop;
//
@@ -596,6 +597,7 @@ public:
//
m_is_player(false),
m_is_local_player(false),
+ m_id(0),
//
m_smgr(NULL),
m_irr(NULL),
@@ -640,6 +642,7 @@ public:
}
m_name = deSerializeString(is);
m_is_player = readU8(is);
+ m_id = readS16(is);
m_position = readV3F1000(is);
m_yaw = readF1000(is);
m_hp = readS16(is);
@@ -930,6 +933,7 @@ public:
addToScene(m_smgr, m_gamedef->tsrc(), m_irr);
updateAnimations();
updateBonePosRot();
+ updateAttachment();
}
if(m_prop.physical){
@@ -1062,6 +1066,10 @@ public:
texturestring += mod;
m_spritenode->setMaterialTexture(0,
tsrc->getTextureRaw(texturestring));
+
+ // Does not work yet with the current lighting settings
+ m_meshnode->getMaterial(0).AmbientColor = m_prop.colors[0];
+ m_meshnode->getMaterial(0).DiffuseColor = m_prop.colors[0];
}
}
if(m_animated_meshnode)
@@ -1087,6 +1095,12 @@ public:
material.setFlag(video::EMF_LIGHTING, false);
material.setFlag(video::EMF_BILINEAR_FILTER, false);
}
+ for (u32 i = 0; i < m_prop.colors.size(); ++i)
+ {
+ // Does not work yet with the current lighting settings
+ m_animated_meshnode->getMaterial(i).AmbientColor = m_prop.colors[i];
+ m_animated_meshnode->getMaterial(i).DiffuseColor = m_prop.colors[i];
+ }
}
}
if(m_meshnode)
@@ -1113,6 +1127,10 @@ public:
material.setTexture(0, atlas);
material.getTextureMatrix(0).setTextureTranslate(pos.X, pos.Y);
material.getTextureMatrix(0).setTextureScale(size.X, size.Y);
+
+ // Does not work yet with the current lighting settings
+ m_meshnode->getMaterial(i).AmbientColor = m_prop.colors[i];
+ m_meshnode->getMaterial(i).DiffuseColor = m_prop.colors[i];
}
}
else if(m_prop.visual == "upright_sprite")
@@ -1126,6 +1144,10 @@ public:
scene::IMeshBuffer *buf = mesh->getMeshBuffer(0);
buf->getMaterial().setTexture(0,
tsrc->getTextureRaw(tname));
+
+ // Does not work yet with the current lighting settings
+ m_meshnode->getMaterial(0).AmbientColor = m_prop.colors[0];
+ m_meshnode->getMaterial(0).DiffuseColor = m_prop.colors[0];
}
{
std::string tname = "unknown_object.png";
@@ -1137,6 +1159,10 @@ public:
scene::IMeshBuffer *buf = mesh->getMeshBuffer(1);
buf->getMaterial().setTexture(0,
tsrc->getTextureRaw(tname));
+
+ // Does not work yet with the current lighting settings
+ m_meshnode->getMaterial(1).AmbientColor = m_prop.colors[1];
+ m_meshnode->getMaterial(1).DiffuseColor = m_prop.colors[1];
}
}
}
@@ -1168,6 +1194,11 @@ public:
}
}
+ void updateAttachment()
+ {
+ // Code for attachments goes here
+ }
+
void processMessage(const std::string &data)
{
//infostream<<"GenericCAO: Got message"<<std::endl;
@@ -1254,6 +1285,15 @@ public:
updateBonePosRot();
expireVisuals();
}
+ else if(cmd == GENERIC_CMD_SET_ATTACHMENT)
+ {
+ // Part of the attachment structure, not used yet!
+
+ // Get properties here.
+
+ updateAttachment();
+ expireVisuals();
+ }
else if(cmd == GENERIC_CMD_PUNCHED)
{
/*s16 damage =*/ readS16(is);