From b44da4916aa09b27155ce6675cccbcc128b5a66c Mon Sep 17 00:00:00 2001 From: RealBadAngel Date: Sun, 7 Feb 2016 04:08:43 +0100 Subject: Cleanup selection mesh code, add shaders for halo and selection boxes --- src/mesh.cpp | 42 ++++++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 18 deletions(-) (limited to 'src/mesh.cpp') 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 &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 boxes = f->node_box.fixed; - - for(std::vector::iterator + for(std::vector::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; -- cgit v1.2.3