summaryrefslogtreecommitdiff
path: root/src/mesh.cpp
diff options
context:
space:
mode:
authorRealBadAngel <maciej.kasatkin@o2.pl>2016-02-07 04:08:43 +0100
committerkwolekr <kwolekr@minetest.net>2016-02-08 03:57:42 -0500
commitb44da4916aa09b27155ce6675cccbcc128b5a66c (patch)
treebe51c3a097e1371cb126bf1516e81aaad20bb768 /src/mesh.cpp
parent430195381d8d7254a7b8cdcf6b50769c2c598329 (diff)
downloadminetest-b44da4916aa09b27155ce6675cccbcc128b5a66c.tar.gz
minetest-b44da4916aa09b27155ce6675cccbcc128b5a66c.tar.bz2
minetest-b44da4916aa09b27155ce6675cccbcc128b5a66c.zip
Cleanup selection mesh code, add shaders for halo and selection boxes
Diffstat (limited to 'src/mesh.cpp')
-rw-r--r--src/mesh.cpp42
1 files changed, 24 insertions, 18 deletions
diff --git a/src/mesh.cpp b/src/mesh.cpp
index a800ddf1e..d79f545f3 100644
--- a/src/mesh.cpp
+++ b/src/mesh.cpp
@@ -405,9 +405,11 @@ scene::IMesh* cloneMesh(scene::IMesh *src_mesh)
return dst_mesh;
}
-scene::IMesh* convertNodeboxNodeToMesh(ContentFeatures *f)
+scene::IMesh* convertNodeboxesToMesh(const std::vector<aabb3f> &boxes,
+ const f32 *uv_coords)
{
scene::SMesh* dst_mesh = new scene::SMesh();
+
for (u16 j = 0; j < 6; j++)
{
scene::IMeshBuffer *buf = new scene::SMeshBuffer();
@@ -416,12 +418,10 @@ scene::IMesh* convertNodeboxNodeToMesh(ContentFeatures *f)
dst_mesh->addMeshBuffer(buf);
buf->drop();
}
-
+
video::SColor c(255,255,255,255);
- std::vector<aabb3f> boxes = f->node_box.fixed;
-
- for(std::vector<aabb3f>::iterator
+ for(std::vector<aabb3f>::const_iterator
i = boxes.begin();
i != boxes.end(); ++i)
{
@@ -446,27 +446,33 @@ scene::IMesh* convertNodeboxNodeToMesh(ContentFeatures *f)
box.MinEdge.Z=box.MaxEdge.Z;
box.MaxEdge.Z=temp;
}
- // Compute texture coords
- f32 tx1 = (box.MinEdge.X/BS)+0.5;
- f32 ty1 = (box.MinEdge.Y/BS)+0.5;
- f32 tz1 = (box.MinEdge.Z/BS)+0.5;
- f32 tx2 = (box.MaxEdge.X/BS)+0.5;
- f32 ty2 = (box.MaxEdge.Y/BS)+0.5;
- f32 tz2 = (box.MaxEdge.Z/BS)+0.5;
- f32 txc[24] = {
+
+ // Compute texture UV coords
+ f32 tx1 = (box.MinEdge.X / BS) + 0.5;
+ f32 ty1 = (box.MinEdge.Y / BS) + 0.5;
+ f32 tz1 = (box.MinEdge.Z / BS) + 0.5;
+ f32 tx2 = (box.MaxEdge.X / BS) + 0.5;
+ f32 ty2 = (box.MaxEdge.Y / BS) + 0.5;
+ f32 tz2 = (box.MaxEdge.Z / BS) + 0.5;
+
+ f32 txc_default[24] = {
// up
- tx1, 1-tz2, tx2, 1-tz1,
+ tx1, 1 - tz2, tx2, 1 - tz1,
// down
tx1, tz1, tx2, tz2,
// right
- tz1, 1-ty2, tz2, 1-ty1,
+ tz1, 1 - ty2, tz2, 1 - ty1,
// left
- 1-tz2, 1-ty2, 1-tz1, 1-ty1,
+ 1 - tz2, 1 - ty2, 1 - tz1, 1 - ty1,
// back
- 1-tx2, 1-ty2, 1-tx1, 1-ty1,
+ 1 - tx2, 1 - ty2, 1 - tx1, 1 - ty1,
// front
- tx1, 1-ty2, tx2, 1-ty1,
+ tx1, 1 - ty2, tx2, 1 - ty1,
};
+
+ // use default texture UV mapping if not provided
+ const f32 *txc = uv_coords ? uv_coords : txc_default;
+
v3f min = box.MinEdge;
v3f max = box.MaxEdge;