]> git.lizzy.rs Git - dragonfireclient.git/blobdiff - src/mapnode.h
Set ambient light in inventory cube generation
[dragonfireclient.git] / src / mapnode.h
index 07153f934649b1673f4f65e7487734e39e98c90f..d67b9629e56ed8b27400662a64e1539bd0334fd1 100644 (file)
@@ -1,6 +1,6 @@
 /*
 Minetest-c55
 /*
 Minetest-c55
-Copyright (C) 2010 celeron55, Perttu Ahola <celeron55@gmail.com>
+Copyright (C) 2010-2011 celeron55, Perttu Ahola <celeron55@gmail.com>
 
 This program is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 
 This program is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
@@ -33,9 +33,15 @@ with this program; if not, write to the Free Software Foundation, Inc.,
        Initializes all kind of stuff in here.
        Many things depend on this.
 
        Initializes all kind of stuff in here.
        Many things depend on this.
 
-       irrlicht: Used for getting texture ids.
+       This accesses g_texturesource; if it is non-NULL, textures are set.
+
+       Client first calls this with g_texturesource=NULL to run some
+       unit tests and stuff, then it runs this again with g_texturesource
+       defined to get the textures.
+
+       Server only calls this once with g_texturesource=NULL.
 */
 */
-void init_mapnode(IIrrlichtWrapper *irrlicht);
+void init_mapnode();
 
 // Initializes g_content_inventory_texture_paths
 void init_content_inventory_texture_paths();
 
 // Initializes g_content_inventory_texture_paths
 void init_content_inventory_texture_paths();
@@ -132,9 +138,12 @@ struct ContentFeatures
                5: front
        */
        TileSpec tiles[6];
                5: front
        */
        TileSpec tiles[6];
-
+       
+       // TODO: Somehow specify inventory image
        //std::string inventory_image_path;
        //std::string inventory_image_path;
-       TextureSpec inventory_texture;
+       //TextureSpec inventory_texture;
+       //u32 inventory_texture_id;
+       video::ITexture *inventory_texture;
 
        bool is_ground_content; //TODO: Remove, use walkable instead
        bool light_propagates;
 
        bool is_ground_content; //TODO: Remove, use walkable instead
        bool light_propagates;
@@ -145,7 +154,13 @@ struct ContentFeatures
        bool diggable;
        bool buildable_to;
        enum LiquidType liquid_type;
        bool diggable;
        bool buildable_to;
        enum LiquidType liquid_type;
-       bool wall_mounted; // If true, param2 is set to direction when placed
+       // If true, param2 is set to direction when placed
+       // NOTE: the direction format is quite inefficient and should be changed
+       bool wall_mounted;
+       
+       // Inventory item string as which the node appears in inventory when dug.
+       // Mineral overrides this.
+       std::string dug_item;
 
        //TODO: Move more properties here
 
 
        //TODO: Move more properties here
 
@@ -153,6 +168,7 @@ struct ContentFeatures
        {
                translate_to = NULL;
                param_type = CPT_NONE;
        {
                translate_to = NULL;
                param_type = CPT_NONE;
+               inventory_texture = NULL;
                is_ground_content = false;
                light_propagates = false;
                sunlight_propagates = false;
                is_ground_content = false;
                light_propagates = false;
                sunlight_propagates = false;
@@ -163,40 +179,58 @@ struct ContentFeatures
                buildable_to = false;
                liquid_type = LIQUID_NONE;
                wall_mounted = false;
                buildable_to = false;
                liquid_type = LIQUID_NONE;
                wall_mounted = false;
+               dug_item = "";
        }
 
        ~ContentFeatures();
        
        }
 
        ~ContentFeatures();
        
-       void setAllTextures(const TextureSpec &spec, u8 alpha=255)
+       /*
+               Quickhands for simple materials
+       */
+       
+       void setTexture(u16 i, std::string name, u8 alpha=255);
+
+       void setAllTextures(std::string name, u8 alpha=255)
        {
                for(u16 i=0; i<6; i++)
                {
        {
                for(u16 i=0; i<6; i++)
                {
-                       tiles[i].spec = spec;
-                       tiles[i].alpha = alpha;
+                       setTexture(i, name, alpha);
                }
                }
-               
-               // Set this too so it can be left as is most times
-               /*if(inventory_image_path == "")
-                       inventory_image_path = porting::getDataPath(imgname.c_str());*/
-
-               if(inventory_texture.empty())
-                       inventory_texture = spec;
        }
        }
-       void setTexture(u16 i, const TextureSpec &spec, u8 alpha=255)
+
+       /*void setTexture(u16 i, AtlasPointer p, u8 alpha=255)
        {
        {
-               tiles[i].spec = spec;
-               tiles[i].alpha = alpha;
+               tiles[i].texture = p;
+               if(alpha != 255)
+               {
+                       tiles[i].alpha = alpha;
+                       tiles[i].material_type = MATERIAL_ALPHA_VERTEX;
+               }
        }
        }
+       void setAllTextures(AtlasPointer p, u8 alpha=255)
+       {
+               for(u16 i=0; i<6; i++)
+               {
+                       setTexture(i, p, alpha);
+               }
+       }*/
 
 
-       void setInventoryTexture(const TextureSpec &spec)
+       void setTile(u16 i, const TileSpec &tile)
        {
        {
-               inventory_texture = spec;
+               tiles[i] = tile;
        }
        }
-
-       /*void setInventoryImage(std::string imgname)
+       void setAllTiles(const TileSpec &tile)
        {
        {
-               inventory_image_path = porting::getDataPath(imgname.c_str());
-       }*/
+               for(u16 i=0; i<6; i++)
+               {
+                       setTile(i, tile);
+               }
+       }
+
+       void setInventoryTexture(std::string imgname);
+       
+       void setInventoryTextureCube(std::string top,
+                       std::string left, std::string right);
 };
 
 /*
 };
 
 /*
@@ -417,12 +451,11 @@ struct MapNode
        
        union
        {
        
        union
        {
-               u8 param2;
-
                /*
                /*
-                       Direction for torches and other stuff.
-                       Format is freeform. e.g. packDir or encode_dirs can be used.
+                       The second parameter. Initialized to 0.
+                       Direction for torches and flowing water.
                */
                */
+               u8 param2;
                u8 dir;
        };
 
                u8 dir;
        };
 
@@ -438,6 +471,14 @@ struct MapNode
                param2 = a_param2;
        }
 
                param2 = a_param2;
        }
 
+       /*MapNode & operator=(const MapNode &other)
+       {
+               d = other.d;
+               param = other.param;
+               param2 = other.param2;
+               return *this;
+       }*/
+
        bool operator==(const MapNode &other)
        {
                return (d == other.d
        bool operator==(const MapNode &other)
        {
                return (d == other.d
@@ -630,6 +671,8 @@ struct MapNode
                }
 
                // Translate deprecated stuff
                }
 
                // Translate deprecated stuff
+               // NOTE: This doesn't get used because MapBlock handles node
+               // parameters directly
                MapNode *translate_to = content_features(d).translate_to;
                if(translate_to)
                {
                MapNode *translate_to = content_features(d).translate_to;
                if(translate_to)
                {