-
- u8 i;
- ContentFeatures *f = NULL;
-
- i = CONTENT_STONE;
- f = &g_content_features[i];
- f->setAllTextures("stone.png");
- f->setInventoryTextureCube("stone.png", "stone.png", "stone.png");
- f->param_type = CPT_MINERAL;
- f->is_ground_content = true;
- f->dug_item = std::string("MaterialItem ")+itos(CONTENT_COBBLE)+" 1";
-
- i = CONTENT_GRASS;
- f = &g_content_features[i];
- f->setAllTextures("mud.png^grass_side.png");
- f->setTexture(0, "grass.png");
- f->setTexture(1, "mud.png");
- f->param_type = CPT_MINERAL;
- f->is_ground_content = true;
- f->dug_item = std::string("MaterialItem ")+itos(CONTENT_MUD)+" 1";
-
- i = CONTENT_GRASS_FOOTSTEPS;
- f = &g_content_features[i];
- f->setAllTextures("mud.png^grass_side.png");
- f->setTexture(0, "grass_footsteps.png");
- f->setTexture(1, "mud.png");
- f->param_type = CPT_MINERAL;
- f->is_ground_content = true;
- f->dug_item = std::string("MaterialItem ")+itos(CONTENT_MUD)+" 1";
-
- i = CONTENT_MUD;
- f = &g_content_features[i];
- f->setAllTextures("mud.png");
- f->setInventoryTextureCube("mud.png", "mud.png", "mud.png");
- f->param_type = CPT_MINERAL;
- f->is_ground_content = true;
- f->dug_item = std::string("MaterialItem ")+itos(i)+" 1";
-
- i = CONTENT_SAND;
- f = &g_content_features[i];
- f->setAllTextures("sand.png");
- f->param_type = CPT_MINERAL;
- f->is_ground_content = true;
- f->dug_item = std::string("MaterialItem ")+itos(i)+" 1";
-
- i = CONTENT_SANDSTONE;
- f = &g_content_features[i];
- f->setAllTextures("sandstone.png");
- f->setInventoryTextureCube("sandstone.png", "sandstone.png", "sandstone.png");
- f->param_type = CPT_MINERAL;
- f->is_ground_content = true;
- f->dug_item = std::string("MaterialItem ")+itos(CONTENT_SAND)+" 1";
-
- i = CONTENT_BRICK;
- f = &g_content_features[i];
- f->setAllTextures("brick.png");
- f->setInventoryTextureCube("brick.png", "brick.png", "brick.png");
- f->param_type = CPT_MINERAL;
- f->is_ground_content = true;
- f->dug_item = std::string("MaterialItem ")+itos(i)+" 1";
-
- i = CONTENT_TREE;
- f = &g_content_features[i];
- f->setAllTextures("tree.png");
- f->setTexture(0, "tree_top.png");
- f->setTexture(1, "tree_top.png");
- f->param_type = CPT_MINERAL;
- f->is_ground_content = true;
- f->dug_item = std::string("MaterialItem ")+itos(i)+" 1";
-
- i = CONTENT_LEAVES;
- f = &g_content_features[i];
- f->light_propagates = true;
- //f->param_type = CPT_MINERAL;
- f->param_type = CPT_LIGHT;
- f->is_ground_content = true;
- if(new_style_leaves)
- {
- f->solidness = 0; // drawn separately, makes no faces
- f->setInventoryTextureCube("leaves.png", "leaves.png", "leaves.png");
+}
+
+void transformNodeBox(const MapNode &n, const NodeBox &nodebox,
+ INodeDefManager *nodemgr, std::vector<aabb3f> *p_boxes, u8 neighbors = 0)
+{
+ std::vector<aabb3f> &boxes = *p_boxes;
+
+ if (nodebox.type == NODEBOX_FIXED || nodebox.type == NODEBOX_LEVELED) {
+ const std::vector<aabb3f> &fixed = nodebox.fixed;
+ int facedir = n.getFaceDir(nodemgr);
+ u8 axisdir = facedir>>2;
+ facedir&=0x03;
+ for(std::vector<aabb3f>::const_iterator
+ i = fixed.begin();
+ i != fixed.end(); ++i)
+ {
+ aabb3f box = *i;
+
+ if (nodebox.type == NODEBOX_LEVELED) {
+ box.MaxEdge.Y = -BS/2 + BS*((float)1/LEVELED_MAX) * n.getLevel(nodemgr);
+ }
+
+ switch (axisdir)
+ {
+ case 0:
+ if(facedir == 1)
+ {
+ box.MinEdge.rotateXZBy(-90);
+ box.MaxEdge.rotateXZBy(-90);
+ }
+ else if(facedir == 2)
+ {
+ box.MinEdge.rotateXZBy(180);
+ box.MaxEdge.rotateXZBy(180);
+ }
+ else if(facedir == 3)
+ {
+ box.MinEdge.rotateXZBy(90);
+ box.MaxEdge.rotateXZBy(90);
+ }
+ break;
+ case 1: // z+
+ box.MinEdge.rotateYZBy(90);
+ box.MaxEdge.rotateYZBy(90);
+ if(facedir == 1)
+ {
+ box.MinEdge.rotateXYBy(90);
+ box.MaxEdge.rotateXYBy(90);
+ }
+ else if(facedir == 2)
+ {
+ box.MinEdge.rotateXYBy(180);
+ box.MaxEdge.rotateXYBy(180);
+ }
+ else if(facedir == 3)
+ {
+ box.MinEdge.rotateXYBy(-90);
+ box.MaxEdge.rotateXYBy(-90);
+ }
+ break;
+ case 2: //z-
+ box.MinEdge.rotateYZBy(-90);
+ box.MaxEdge.rotateYZBy(-90);
+ if(facedir == 1)
+ {
+ box.MinEdge.rotateXYBy(-90);
+ box.MaxEdge.rotateXYBy(-90);
+ }
+ else if(facedir == 2)
+ {
+ box.MinEdge.rotateXYBy(180);
+ box.MaxEdge.rotateXYBy(180);
+ }
+ else if(facedir == 3)
+ {
+ box.MinEdge.rotateXYBy(90);
+ box.MaxEdge.rotateXYBy(90);
+ }
+ break;
+ case 3: //x+
+ box.MinEdge.rotateXYBy(-90);
+ box.MaxEdge.rotateXYBy(-90);
+ if(facedir == 1)
+ {
+ box.MinEdge.rotateYZBy(90);
+ box.MaxEdge.rotateYZBy(90);
+ }
+ else if(facedir == 2)
+ {
+ box.MinEdge.rotateYZBy(180);
+ box.MaxEdge.rotateYZBy(180);
+ }
+ else if(facedir == 3)
+ {
+ box.MinEdge.rotateYZBy(-90);
+ box.MaxEdge.rotateYZBy(-90);
+ }
+ break;
+ case 4: //x-
+ box.MinEdge.rotateXYBy(90);
+ box.MaxEdge.rotateXYBy(90);
+ if(facedir == 1)
+ {
+ box.MinEdge.rotateYZBy(-90);
+ box.MaxEdge.rotateYZBy(-90);
+ }
+ else if(facedir == 2)
+ {
+ box.MinEdge.rotateYZBy(180);
+ box.MaxEdge.rotateYZBy(180);
+ }
+ else if(facedir == 3)
+ {
+ box.MinEdge.rotateYZBy(90);
+ box.MaxEdge.rotateYZBy(90);
+ }
+ break;
+ case 5:
+ box.MinEdge.rotateXYBy(-180);
+ box.MaxEdge.rotateXYBy(-180);
+ if(facedir == 1)
+ {
+ box.MinEdge.rotateXZBy(90);
+ box.MaxEdge.rotateXZBy(90);
+ }
+ else if(facedir == 2)
+ {
+ box.MinEdge.rotateXZBy(180);
+ box.MaxEdge.rotateXZBy(180);
+ }
+ else if(facedir == 3)
+ {
+ box.MinEdge.rotateXZBy(-90);
+ box.MaxEdge.rotateXZBy(-90);
+ }
+ break;
+ default:
+ break;
+ }
+ box.repair();
+ boxes.push_back(box);
+ }