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, bool disable_backface_culling);
66 void useDefaultTile(bool set_color = true);
67 void getTile(const v3s16 &direction, TileSpec &tile);
70 void drawQuad(v3f *vertices, const v3s16 &normal = v3s16(0, 0, 0));
73 void drawCuboid(const aabb3f &box, TileSpec *tiles, int tilecount,
74 const u16 *lights , const f32 *txc);
75 void generateCuboidTextureCoords(aabb3f const &box, f32 *coords);
76 void drawAutoLightedCuboid(aabb3f box, const f32 *txc = NULL,
77 TileSpec *tiles = NULL, int tile_count = 0);
80 bool top_is_same_liquid;
82 TileSpec tile_liquid_top;
85 video::SColor color_liquid_top;
90 bool top_is_same_liquid;
92 NeighborData liquid_neighbors[3][3];
93 f32 corner_levels[2][2];
95 void prepareLiquidNodeDrawing();
96 void getLiquidNeighborhood();
97 void calculateCornerLevels();
98 f32 getCornerLevel(int i, int k);
99 void drawLiquidSides();
100 void drawLiquidTop();
103 // name of the group that enables connecting to raillike nodes of different kind
104 static const std::string raillike_groupname;
106 bool isSameRail(v3s16 dir);
108 // plantlike-specific
109 PlantlikeStyle draw_style;
112 bool random_offset_Y;
115 void drawPlantlikeQuad(float rotation, float quad_offset = 0,
116 bool offset_top_only = false);
119 void drawFirelikeQuad(float rotation, float opening_angle,
120 float offset_h, float offset_v = 0.0);
123 void drawLiquidNode();
124 void drawGlasslikeNode();
125 void drawGlasslikeFramedNode();
126 void drawAllfacesNode();
127 void drawTorchlikeNode();
128 void drawSignlikeNode();
129 void drawPlantlikeNode();
130 void drawFirelikeNode();
131 void drawFencelikeNode();
132 void drawRaillikeNode();
133 void drawNodeboxNode();
137 void errorUnknownDrawtype();
141 MapblockMeshGenerator(MeshMakeData *input, MeshCollector *output);