diff options
author | sapier <sapier at gmx dot net> | 2012-01-15 20:22:41 +0100 |
---|---|---|
committer | sapier <sapier at gmx dot net> | 2012-01-15 20:22:41 +0100 |
commit | f0679969b2d512c0093c31608172425a2ac0f740 (patch) | |
tree | 7d09a3417933b555efd835135e2149cde68f9a54 /src/mesh.cpp | |
parent | 285f5a025975207f9251165e82dadb50d4744991 (diff) | |
download | minetest-f0679969b2d512c0093c31608172425a2ac0f740.tar.xz |
added plantlike luaentity
Diffstat (limited to 'src/mesh.cpp')
-rw-r--r-- | src/mesh.cpp | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/src/mesh.cpp b/src/mesh.cpp index 1d347a09f..8b9668593 100644 --- a/src/mesh.cpp +++ b/src/mesh.cpp @@ -82,6 +82,52 @@ scene::IAnimatedMesh* createCubeMesh(v3f scale) return anim_mesh; } +scene::IAnimatedMesh* createPlantMesh(v3f scale) +{ + video::SColor c(255,255,255,255); + video::S3DVertex vertices[16] = + { + // Plane 1 Front + video::S3DVertex(-0.5,-0.5,-0.5, 0.5,0,-0.5, c, 0,1), + video::S3DVertex(-0.5,+0.5,-0.5, 0.5,0,-0.5, c, 0,0), + video::S3DVertex(+0.5,+0.5,+0.5, 0.5,0,-0.5, c, 1,0), + video::S3DVertex(+0.5,-0.5,+0.5, 0.5,0,-0.5, c, 1,1), + // Plane 1 Back + video::S3DVertex(+0.5,-0.5,+0.5, -0.5,0,0.5, c, 1,1), + video::S3DVertex(+0.5,+0.5,+0.5, -0.5,0,0.5, c, 1,0), + video::S3DVertex(-0.5,+0.5,-0.5, -0.5,0,0.5, c, 0,0), + video::S3DVertex(-0.5,-0.5,-0.5, -0.5,0,0.5, c, 0,1), + + // Plane 2 Front + video::S3DVertex(-0.5,-0.5,+0.5, -0.5,0,-0.5, c, 1,1), + video::S3DVertex(-0.5,+0.5,+0.5, -0.5,0,-0.5, c, 1,0), + video::S3DVertex(+0.5,+0.5,-0.5, -0.5,0,-0.5, c, 0,0), + video::S3DVertex(+0.5,-0.5,-0.5, -0.5,0,-0.5, c, 0,1), + + // Plane 2 Back + video::S3DVertex(+0.5,-0.5,-0.5, 0.5,0,0.5, c, 0,1), + video::S3DVertex(+0.5,+0.5,-0.5, 0.5,0,0.5, c, 0,0), + video::S3DVertex(-0.5,+0.5,+0.5, 0.5,0,0.5, c, 1,0), + video::S3DVertex(-0.5,-0.5,+0.5, 0.5,0,0.5, c, 1,1) + + }; + + u16 indices[6] = {0,1,2,2,3,0}; + + scene::SMesh *mesh = new scene::SMesh(); + for (u32 i=0; i<4; ++i) + { + scene::IMeshBuffer *buf = new scene::SMeshBuffer(); + buf->append(vertices + 4 * i, 4, indices, 6); + mesh->addMeshBuffer(buf); + buf->drop(); + } + scene::SAnimatedMesh *anim_mesh = new scene::SAnimatedMesh(mesh); + mesh->drop(); + scaleMesh(anim_mesh, scale); // also recalculates bounding box + return anim_mesh; +} + static scene::IAnimatedMesh* extrudeARGB(u32 twidth, u32 theight, u8 *data) { const s32 argb_wstep = 4 * twidth; |