3 Copyright (C) 2010-2013 celeron55, Perttu Ahola <celeron55@gmail.com>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation; either version 2.1 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 #ifndef CONTENT_MAPBLOCK_HEADER
21 #define CONTENT_MAPBLOCK_HEADER
22 #include "util/numeric.h"
24 #include <IMeshManipulator.h>
35 class MapblockMeshGenerator
39 MeshCollector *collector;
41 INodeDefManager *nodedef;
42 scene::IMeshManipulator *meshmanip;
45 bool enable_mesh_cache;
52 const ContentFeatures *f;
60 void getSmoothLightFrame();
61 u16 blendLight(const v3f &vertex_pos);
62 video::SColor blendLightColor(const v3f &vertex_pos);
63 video::SColor blendLightColor(const v3f &vertex_pos, const v3f &vertex_normal);
65 void useTile(int index = 0, u8 set_flags = MATERIAL_FLAG_CRACK_OVERLAY,
66 u8 reset_flags = 0, bool special = false);
67 void getTile(v3s16 direction, TileSpec *tile);
68 void getSpecialTile(int index, TileSpec *tile, bool apply_crack = false);
71 void drawQuad(v3f *vertices, const v3s16 &normal = v3s16(0, 0, 0),
72 float vertical_tiling = 1.0);
75 void drawCuboid(const aabb3f &box, TileSpec *tiles, int tilecount,
76 const u16 *lights , const f32 *txc);
77 void generateCuboidTextureCoords(aabb3f const &box, f32 *coords);
78 void drawAutoLightedCuboid(aabb3f box, const f32 *txc = NULL,
79 TileSpec *tiles = NULL, int tile_count = 0);
82 bool top_is_same_liquid;
84 TileSpec tile_liquid_top;
87 video::SColor color_liquid_top;
92 bool top_is_same_liquid;
94 NeighborData liquid_neighbors[3][3];
95 f32 corner_levels[2][2];
97 void prepareLiquidNodeDrawing();
98 void getLiquidNeighborhood();
99 void calculateCornerLevels();
100 f32 getCornerLevel(int i, int k);
101 void drawLiquidSides();
102 void drawLiquidTop();
105 // name of the group that enables connecting to raillike nodes of different kind
106 static const std::string raillike_groupname;
108 bool isSameRail(v3s16 dir);
110 // plantlike-specific
111 PlantlikeStyle draw_style;
114 bool random_offset_Y;
118 void drawPlantlikeQuad(float rotation, float quad_offset = 0,
119 bool offset_top_only = false);
120 void drawPlantlike();
123 void drawFirelikeQuad(float rotation, float opening_angle,
124 float offset_h, float offset_v = 0.0);
127 void drawLiquidNode();
128 void drawGlasslikeNode();
129 void drawGlasslikeFramedNode();
130 void drawAllfacesNode();
131 void drawTorchlikeNode();
132 void drawSignlikeNode();
133 void drawPlantlikeNode();
134 void drawPlantlikeRootedNode();
135 void drawFirelikeNode();
136 void drawFencelikeNode();
137 void drawRaillikeNode();
138 void drawNodeboxNode();
142 void errorUnknownDrawtype();
146 MapblockMeshGenerator(MeshMakeData *input, MeshCollector *output);