]> git.lizzy.rs Git - minetest.git/blobdiff - src/mapnode.h
added simple skybox
[minetest.git] / src / mapnode.h
index fcbb80fd123f025011907cfcde6d376277ec4f83..ef1ec8ae3f3819df4dcfba83372118740c1a3bcd 100644 (file)
@@ -27,15 +27,20 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "exceptions.h"
 #include "serialization.h"
 #include "tile.h"
-#include "iirrlichtwrapper.h"
 
 /*
        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();
@@ -88,12 +93,12 @@ void init_content_inventory_texture_paths();
 #define CONTENT_COALSTONE 11
 #define CONTENT_WOOD 12
 #define CONTENT_SAND 13
-
-/*
-       This is used by all kinds of things to allocate memory for all
-       contents except CONTENT_AIR and CONTENT_IGNORE
-*/
-#define USEFUL_CONTENT_COUNT 14
+#define CONTENT_SIGN_WALL 14
+#define CONTENT_CHEST 15
+#define CONTENT_FURNACE 16
+//#define CONTENT_WORKBENCH 17
+#define CONTENT_COBBLE 18
+#define CONTENT_STEEL 19
 
 /*
        Content feature list
@@ -103,7 +108,9 @@ enum ContentParamType
 {
        CPT_NONE,
        CPT_LIGHT,
-       CPT_MINERAL
+       CPT_MINERAL,
+       // Direction for chests and furnaces and such
+       CPT_FACEDIR_SIMPLE
 };
 
 enum LiquidType
@@ -114,6 +121,7 @@ enum LiquidType
 };
 
 class MapNode;
+class NodeMetadata;
 
 struct ContentFeatures
 {
@@ -132,11 +140,10 @@ struct ContentFeatures
                5: front
        */
        TileSpec tiles[6];
+       
+       video::ITexture *inventory_texture;
 
-       //std::string inventory_image_path;
-       TextureSpec inventory_texture;
-
-       bool is_ground_content; //TODO: Remove, use walkable instead
+       bool is_ground_content;
        bool light_propagates;
        bool sunlight_propagates;
        u8 solidness; // Used when choosing which face is drawn
@@ -145,7 +152,16 @@ struct ContentFeatures
        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;
+       
+       // Initial metadata is cloned from this
+       NodeMetadata *initial_metadata;
 
        //TODO: Move more properties here
 
@@ -153,6 +169,7 @@ struct ContentFeatures
        {
                translate_to = NULL;
                param_type = CPT_NONE;
+               inventory_texture = NULL;
                is_ground_content = false;
                light_propagates = false;
                sunlight_propagates = false;
@@ -163,40 +180,42 @@ struct ContentFeatures
                buildable_to = false;
                liquid_type = LIQUID_NONE;
                wall_mounted = false;
+               dug_item = "";
+               initial_metadata = NULL;
        }
 
        ~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++)
                {
-                       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 setTile(u16 i, const TileSpec &tile)
        {
-               tiles[i].spec = spec;
-               tiles[i].alpha = alpha;
+               tiles[i] = tile;
        }
-
-       void setInventoryTexture(const TextureSpec &spec)
+       void setAllTiles(const TileSpec &tile)
        {
-               inventory_texture = spec;
+               for(u16 i=0; i<6; i++)
+               {
+                       setTile(i, tile);
+               }
        }
 
-       /*void setInventoryImage(std::string imgname)
-       {
-               inventory_image_path = porting::getDataPath(imgname.c_str());
-       }*/
+       void setInventoryTexture(std::string imgname);
+       
+       void setInventoryTextureCube(std::string top,
+                       std::string left, std::string right);
 };
 
 /*
@@ -391,6 +410,13 @@ inline v3s16 unpackDir(u8 b)
        return d;
 }
 
+/*
+       facedir: CPT_FACEDIR_SIMPLE param1 value
+       dir: The face for which stuff is wanted
+       return value: The face from which the stuff is actually found
+*/
+v3s16 facedir_rotate(u8 facedir, v3s16 dir);
+
 enum LightBank
 {
        LIGHTBANK_DAY,
@@ -413,16 +439,19 @@ struct MapNode
                  Sunlight is LIGHT_SUN, which is LIGHT_MAX+1.
                - Contains 2 values, day- and night lighting. Each takes 4 bits.
        */
-       s8 param;
+       union
+       {
+               s8 param;
+               u8 param1;
+       };
        
+       /*
+               The second parameter. Initialized to 0.
+               E.g. direction for torches and flowing water.
+       */
        union
        {
                u8 param2;
-
-               /*
-                       Direction for torches and other stuff.
-                       Format is freeform. e.g. packDir or encode_dirs can be used.
-               */
                u8 dir;
        };
 
@@ -650,32 +679,6 @@ struct MapNode
        }
 };
 
-/*
-       Returns integer position of the node in given
-       floating point position.
-*/
-inline v3s16 floatToInt(v3f p)
-{
-       v3s16 p2(
-               (p.X + (p.X>0 ? BS/2 : -BS/2))/BS,
-               (p.Y + (p.Y>0 ? BS/2 : -BS/2))/BS,
-               (p.Z + (p.Z>0 ? BS/2 : -BS/2))/BS);
-       return p2;
-}
-
-/*
-       The same thing backwards
-*/
-inline v3f intToFloat(v3s16 p)
-{
-       v3f p2(
-               p.X * BS,
-               p.Y * BS,
-               p.Z * BS
-       );
-       return p2;
-}
-
 
 
 #endif