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::ISceneManager *smgr;
43 scene::IMeshManipulator *meshmanip;
46 bool enable_mesh_cache;
53 const ContentFeatures *f;
61 void getSmoothLightFrame();
62 u16 blendLight(const v3f &vertex_pos);
63 video::SColor blendLightColor(const v3f &vertex_pos);
64 video::SColor blendLightColor(const v3f &vertex_pos, const v3f &vertex_normal);
66 void useTile(int index, bool disable_backface_culling);
67 void useDefaultTile(bool set_color = true);
68 void getTile(const v3s16 &direction, TileSpec &tile);
71 void drawQuad(v3f *vertices, const v3s16 &normal = v3s16(0, 0, 0));
74 void drawCuboid(const aabb3f &box, TileSpec *tiles, int tilecount,
75 const u16 *lights , const f32 *txc);
76 void generateCuboidTextureCoords(aabb3f const &box, f32 *coords);
77 void drawAutoLightedCuboid(aabb3f box, const f32 *txc = NULL,
78 TileSpec *tiles = NULL, int tile_count = 0);
81 bool top_is_same_liquid;
83 TileSpec tile_liquid_top;
86 video::SColor color_liquid_top;
91 bool top_is_same_liquid;
93 NeighborData liquid_neighbors[3][3];
94 f32 corner_levels[2][2];
96 void prepareLiquidNodeDrawing();
97 void getLiquidNeighborhood();
98 void calculateCornerLevels();
99 f32 getCornerLevel(int i, int k);
100 void drawLiquidSides();
101 void drawLiquidTop();
104 // name of the group that enables connecting to raillike nodes of different kind
105 static const std::string raillike_groupname;
107 bool isSameRail(v3s16 dir);
109 // plantlike-specific
110 PlantlikeStyle draw_style;
113 bool random_offset_Y;
116 void drawPlantlikeQuad(float rotation, float quad_offset = 0,
117 bool offset_top_only = false);
120 void drawFirelikeQuad(float rotation, float opening_angle,
121 float offset_h, float offset_v = 0.0);
124 void drawLiquidNode();
125 void drawGlasslikeNode();
126 void drawGlasslikeFramedNode();
127 void drawAllfacesNode();
128 void drawTorchlikeNode();
129 void drawSignlikeNode();
130 void drawPlantlikeNode();
131 void drawFirelikeNode();
132 void drawFencelikeNode();
133 void drawRaillikeNode();
134 void drawNodeboxNode();
138 void errorUnknownDrawtype();
142 MapblockMeshGenerator(MeshMakeData *input, MeshCollector *output);