Add support for parameter 'visual_scale' for drawtypes 'signlike' and 'torchlike...
authorSokomine <wegwerf@anarres.dyndns.org>
Tue, 8 Oct 2013 20:41:53 +0000 (22:41 +0200)
committerPerttu Ahola <celeron55@gmail.com>
Mon, 14 Oct 2013 18:38:56 +0000 (21:38 +0300)
doc/lua_api.txt
src/content_mapblock.cpp

index 335f8af6543d019ce89fcb9036b2b4f4e29339bd..f89f71273a1597705a8ab4c9fbfc049a0d6e3ab6 100644 (file)
@@ -1999,6 +1999,10 @@ Node definition (register_node)
 
     drawtype = "normal", -- See "Node drawtypes"
     visual_scale = 1.0,
+    ^ Supported for drawtypes "plantlike", "signlike", "torchlike".
+    ^ For plantlike, the image will start at the bottom of the node; for the
+    ^ other drawtypes, the image will be centered on the node.
+    ^ Note that positioning for "torchlike" may still change.
     tiles = {tile definition 1, def2, def3, def4, def5, def6},
     ^ Textures of node; +Y, -Y, +X, -X, +Z, -Z (old field name: tile_images)
     ^ List can be shortened to needed length
index 929682eaf4ca2d6ae29231ae92755d9296d5fbee..3cded5bdb1119bae135df357723cfdbd50dda98a 100644 (file)
@@ -908,13 +908,14 @@ void mapblock_mesh_generate_special(MeshMakeData *data,
                        u16 l = getInteriorLight(n, 1, data);
                        video::SColor c = MapBlock_LightColor(255, l, decode_light(f.light_source));
 
+                       float s = BS/2*f.visual_scale;
                        // Wall at X+ of node
                        video::S3DVertex vertices[4] =
                        {
-                               video::S3DVertex(-BS/2,-BS/2,0, 0,0,0, c, 0,1),
-                               video::S3DVertex(BS/2,-BS/2,0, 0,0,0, c, 1,1),
-                               video::S3DVertex(BS/2,BS/2,0, 0,0,0, c, 1,0),
-                               video::S3DVertex(-BS/2,BS/2,0, 0,0,0, c, 0,0),
+                               video::S3DVertex(-s,-s,0, 0,0,0, c, 0,1),
+                               video::S3DVertex( s,-s,0, 0,0,0, c, 1,1),
+                               video::S3DVertex( s, s,0, 0,0,0, c, 1,0),
+                               video::S3DVertex(-s, s,0, 0,0,0, c, 0,0),
                        };
 
                        for(s32 i=0; i<4; i++)
@@ -949,13 +950,14 @@ void mapblock_mesh_generate_special(MeshMakeData *data,
                        video::SColor c = MapBlock_LightColor(255, l, decode_light(f.light_source));
                                
                        float d = (float)BS/16;
+                       float s = BS/2*f.visual_scale;
                        // Wall at X+ of node
                        video::S3DVertex vertices[4] =
                        {
-                               video::S3DVertex(BS/2-d,BS/2,BS/2, 0,0,0, c, 0,0),
-                               video::S3DVertex(BS/2-d,BS/2,-BS/2, 0,0,0, c, 1,0),
-                               video::S3DVertex(BS/2-d,-BS/2,-BS/2, 0,0,0, c, 1,1),
-                               video::S3DVertex(BS/2-d,-BS/2,BS/2, 0,0,0, c, 0,1),
+                               video::S3DVertex(BS/2-d,  s,  s, 0,0,0, c, 0,0),
+                               video::S3DVertex(BS/2-d,  s, -s, 0,0,0, c, 1,0),
+                               video::S3DVertex(BS/2-d, -s, -s, 0,0,0, c, 1,1),
+                               video::S3DVertex(BS/2-d, -s,  s, 0,0,0, c, 0,1),
                        };
 
                        v3s16 dir = n.getWallMountedDir(nodedef);
@@ -990,16 +992,16 @@ void mapblock_mesh_generate_special(MeshMakeData *data,
                        u16 l = getInteriorLight(n, 1, data);
                        video::SColor c = MapBlock_LightColor(255, l, decode_light(f.light_source));
 
+                       float s = BS/2*f.visual_scale;
+
                        for(u32 j=0; j<2; j++)
                        {
                                video::S3DVertex vertices[4] =
                                {
-                                       video::S3DVertex(-BS/2*f.visual_scale,-BS/2,0, 0,0,0, c, 0,1),
-                                       video::S3DVertex( BS/2*f.visual_scale,-BS/2,0, 0,0,0, c, 1,1),
-                                       video::S3DVertex( BS/2*f.visual_scale,
-                                               -BS/2 + f.visual_scale*BS,0, 0,0,0, c, 1,0),
-                                       video::S3DVertex(-BS/2*f.visual_scale,
-                                               -BS/2 + f.visual_scale*BS,0, 0,0,0, c, 0,0),
+                                       video::S3DVertex(-s,-BS/2,      0, 0,0,0, c, 0,1),
+                                       video::S3DVertex( s,-BS/2,      0, 0,0,0, c, 1,1),
+                                       video::S3DVertex( s,-BS/2 + s*2,0, 0,0,0, c, 1,0),
+                                       video::S3DVertex(-s,-BS/2 + s*2,0, 0,0,0, c, 0,0),
                                };
 
                                if(j == 0)