aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsapier <sapier at gmx dot net>2012-02-04 18:08:25 +0100
committersapier <sapier at gmx dot net>2012-02-04 18:08:25 +0100
commit09476447297a35f04b0bd89dddafbadcbb96f83d (patch)
treec3bb8585966d2fd29a4bb2570ccd2245409f0276
parent77df09540c4d7eadef760779e123af88a48aafaa (diff)
downloadminetest-09476447297a35f04b0bd89dddafbadcbb96f83d.tar.xz
added drawallfaces to luaentities20120204_luaentity_allfaces
-rw-r--r--src/content_cao.cpp9
-rw-r--r--src/mesh.cpp54
-rw-r--r--src/mesh.h2
3 files changed, 63 insertions, 2 deletions
diff --git a/src/content_cao.cpp b/src/content_cao.cpp
index 37da0f67d..d08be6f1a 100644
--- a/src/content_cao.cpp
+++ b/src/content_cao.cpp
@@ -1818,6 +1818,15 @@ public:
m_meshnode->setScale(v3f(1));
// Will be shown when we know the brightness
m_meshnode->setVisible(false);
+ } else if(m_prop->visual == "cube_allfaces"){
+ infostream<<"LuaEntityCAO::addToScene(): cube_allfaces"<<std::endl;
+ scene::IMesh *mesh = createCubeMesh(v3f(BS,BS,BS),true);
+ m_meshnode = smgr->addMeshSceneNode(mesh, NULL);
+ mesh->drop();
+
+ m_meshnode->setScale(v3f(1));
+ // Will be shown when we know the brightness
+ m_meshnode->setVisible(false);
} else if (m_prop->visual == "plant") {
infostream<<"LuaEntityCAO::addToScene(): plant"<<std::endl;
scene::IMesh *mesh = createPlantMesh(v3f(BS,BS,BS));
diff --git a/src/mesh.cpp b/src/mesh.cpp
index 44b3b9bbb..134f2b30d 100644
--- a/src/mesh.cpp
+++ b/src/mesh.cpp
@@ -33,7 +33,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#define MY_ETLM_READ_ONLY video::ETLM_READ_ONLY
#endif
-scene::IAnimatedMesh* createCubeMesh(v3f scale)
+scene::IAnimatedMesh* createCubeMesh(v3f scale,bool allfaces)
{
video::SColor c(255,255,255,255);
video::S3DVertex vertices[24] =
@@ -86,6 +86,58 @@ scene::IAnimatedMesh* createCubeMesh(v3f scale)
buf->drop();
}
+ if (allfaces) {
+ video::S3DVertex vertices[24] =
+ {
+ // Up
+ video::S3DVertex(-0.5,-0.5,-0.5, 0,1,0, c, 0,1),
+ video::S3DVertex(-0.5,-0.5,+0.5, 0,1,0, c, 0,0),
+ video::S3DVertex(+0.5,-0.5,+0.5, 0,1,0, c, 1,0),
+ video::S3DVertex(+0.5,-0.5,-0.5, 0,1,0, c, 1,1),
+ // Down
+ video::S3DVertex(-0.5,+0.5,-0.5, 0,-1,0, c, 0,0),
+ video::S3DVertex(+0.5,+0.5,-0.5, 0,-1,0, c, 1,0),
+ video::S3DVertex(+0.5,+0.5,+0.5, 0,-1,0, c, 1,1),
+ video::S3DVertex(-0.5,+0.5,+0.5, 0,-1,0, c, 0,1),
+ // Right
+ video::S3DVertex(-0.5,-0.5,-0.5, 1,0,0, c, 0,1),
+ video::S3DVertex(-0.5,+0.5,-0.5, 1,0,0, c, 0,0),
+ video::S3DVertex(-0.5,+0.5,+0.5, 1,0,0, c, 1,0),
+ video::S3DVertex(-0.5,-0.5,+0.5, 1,0,0, c, 1,1),
+ // Left
+ video::S3DVertex(+0.5,-0.5,-0.5, -1,0,0, c, 1,1),
+ video::S3DVertex(+0.5,-0.5,+0.5, -1,0,0, c, 0,1),
+ video::S3DVertex(+0.5,+0.5,+0.5, -1,0,0, c, 0,0),
+ video::S3DVertex(+0.5,+0.5,-0.5, -1,0,0, c, 1,0),
+ // Back
+ video::S3DVertex(-0.5,-0.5,-0.5, 0,0,1, c, 1,1),
+ video::S3DVertex(+0.5,-0.5,-0.5, 0,0,1, c, 0,1),
+ video::S3DVertex(+0.5,+0.5,-0.5, 0,0,1, c, 0,0),
+ video::S3DVertex(-0.5,+0.5,-0.5, 0,0,1, c, 1,0),
+ // Front
+ video::S3DVertex(-0.5,-0.5,+0.5, 0,0,-1, c, 0,1),
+ video::S3DVertex(-0.5,+0.5,+0.5, 0,0,-1, c, 0,0),
+ video::S3DVertex(+0.5,+0.5,+0.5, 0,0,-1, c, 1,0),
+ video::S3DVertex(+0.5,-0.5,+0.5, 0,0,-1, c, 1,1),
+ };
+
+ u16 indices[6] = {0,1,2,2,3,0};
+
+ for (u32 i=0; i<6; ++i)
+ {
+ scene::IMeshBuffer *buf = new scene::SMeshBuffer();
+ buf->append(vertices + 4 * i, 4, indices, 6);
+ // Set default material
+ buf->getMaterial().setFlag(video::EMF_LIGHTING, false);
+ buf->getMaterial().setFlag(video::EMF_BILINEAR_FILTER, false);
+ buf->getMaterial().MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF;
+ // Add mesh buffer to mesh
+ mesh->addMeshBuffer(buf);
+ buf->drop();
+ }
+
+ }
+
scene::SAnimatedMesh *anim_mesh = new scene::SAnimatedMesh(mesh);
mesh->drop();
scaleMesh(anim_mesh, scale); // also recalculates bounding box
diff --git a/src/mesh.h b/src/mesh.h
index 631dc0cca..89c8fae03 100644
--- a/src/mesh.h
+++ b/src/mesh.h
@@ -30,7 +30,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
The resulting mesh has 6 materials (up, down, right, left, back, front)
which must be defined by the caller.
*/
-scene::IAnimatedMesh* createCubeMesh(v3f scale);
+scene::IAnimatedMesh* createCubeMesh(v3f scale, bool allfaces=false);
/*
Create a new cube mesh not linked to mapnode size.