summaryrefslogtreecommitdiff
path: root/src/content_mapblock.cpp
diff options
context:
space:
mode:
authorKahrl <kahrl@gmx.net>2012-03-19 04:25:09 +0100
committerPerttu Ahola <celeron55@gmail.com>2012-06-17 16:34:39 +0300
commit1575448b1a71dd029a8d135d2aff9096483a9953 (patch)
tree3e4c7a68abbcf630484615e6ee202f2f0d83ade2 /src/content_mapblock.cpp
parent9f031a67594162a53b07acbfbc65faf8c4938e99 (diff)
downloadminetest-1575448b1a71dd029a8d135d2aff9096483a9953.tar.gz
minetest-1575448b1a71dd029a8d135d2aff9096483a9953.tar.bz2
minetest-1575448b1a71dd029a8d135d2aff9096483a9953.zip
Custom boxy nodes (stairs, slabs) and collision changes
Diffstat (limited to 'src/content_mapblock.cpp')
-rw-r--r--src/content_mapblock.cpp47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/content_mapblock.cpp b/src/content_mapblock.cpp
index ebf9fd59e..d87ae32fb 100644
--- a/src/content_mapblock.cpp
+++ b/src/content_mapblock.cpp
@@ -1027,6 +1027,53 @@ void mapblock_mesh_generate_special(MeshMakeData *data,
u16 indices[] = {0,1,2,2,3,0};
collector.append(tile, vertices, 4, indices, 6);
break;}
+ case NDT_NODEBOX:
+ {
+ TileSpec tiles[6];
+ for(int i = 0; i < 6; i++)
+ {
+ tiles[i] = getNodeTileN(n, p, i, data);
+ }
+
+ u16 l = getInteriorLight(n, 0, data);
+ video::SColor c = MapBlock_LightColor(255, l);
+
+ v3f pos = intToFloat(p, BS);
+
+ std::vector<aabb3f> boxes = n.getNodeBoxes(nodedef);
+ for(std::vector<aabb3f>::iterator
+ i = boxes.begin();
+ i != boxes.end(); i++)
+ {
+ aabb3f box = *i;
+ box.MinEdge += pos;
+ box.MaxEdge += pos;
+
+ // Compute texture coords
+ f32 tx1 = (i->MinEdge.X/BS)+0.5;
+ f32 ty1 = (i->MinEdge.Y/BS)+0.5;
+ f32 tz1 = (i->MinEdge.Z/BS)+0.5;
+ f32 tx2 = (i->MaxEdge.X/BS)+0.5;
+ f32 ty2 = (i->MaxEdge.Y/BS)+0.5;
+ f32 tz2 = (i->MaxEdge.Z/BS)+0.5;
+ f32 txc[24] = {
+ // up
+ tx1, 1-tz2, tx2, 1-tz1,
+ // down
+ tx1, tz1, tx2, tz2,
+ // right
+ tz1, 1-ty2, tz2, 1-ty1,
+ // left
+ 1-tz2, 1-ty2, 1-tz1, 1-ty1,
+ // back
+ 1-tx2, 1-ty2, 1-tx1, 1-ty1,
+ // front
+ tx1, 1-ty2, tx2, 1-ty1,
+ };
+
+ makeCuboid(&collector, box, tiles, 6, c, txc);
+ }
+ break;}
}
}
}