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.
22 #include "irrlichttypes_extrabloated.h"
30 // Overrides limits by drawing everything
31 bool range_all = false;
32 // Wanted drawing range
33 float wanted_range = 0.0f;
34 // show a wire frame for debugging
35 bool show_wireframe = false;
41 std::vector<std::pair<v3s16,scene::IMeshBuffer*>> bufs;
44 struct MeshBufListList
47 * Stores the mesh buffers of the world.
48 * The array index is the material's layer.
49 * The vector part groups vertices by material.
51 std::vector<MeshBufList> lists[MAX_TILE_LAYERS];
54 void add(scene::IMeshBuffer *buf, v3s16 position, u8 layer);
63 This is the only map class that is able to render itself on screen.
66 class ClientMap : public Map, public scene::ISceneNode
71 MapDrawControl &control,
75 virtual ~ClientMap() = default;
79 return MAPTYPE_CLIENT;
87 void updateCamera(const v3f &pos, const v3f &dir, f32 fov, const v3s16 &offset)
89 m_camera_position = pos;
90 m_camera_direction = dir;
92 m_camera_offset = offset;
96 Forcefully get a sector from somewhere
98 MapSector * emergeSector(v2s16 p);
100 //void deSerializeSector(v2s16 p2d, std::istream &is);
106 virtual void OnRegisterSceneNode();
108 virtual void render()
110 video::IVideoDriver* driver = SceneManager->getVideoDriver();
111 driver->setTransform(video::ETS_WORLD, AbsoluteTransformation);
112 renderMap(driver, SceneManager->getSceneNodeRenderPass());
115 virtual const aabb3f &getBoundingBox() const
120 void getBlocksInViewRange(v3s16 cam_pos_nodes,
121 v3s16 *p_blocks_min, v3s16 *p_blocks_max);
122 void updateDrawList();
123 void renderMap(video::IVideoDriver* driver, s32 pass);
125 int getBackgroundBrightness(float max_d, u32 daylight_factor,
126 int oldvalue, bool *sunlight_seen_result);
128 void renderPostFx(CameraMode cam_mode);
130 // For debug printing
131 virtual void PrintInfo(std::ostream &out);
133 const MapDrawControl & getControl() const { return m_control; }
134 f32 getCameraFov() const { return m_camera_fov; }
138 aabb3f m_box = aabb3f(-BS * 1000000, -BS * 1000000, -BS * 1000000,
139 BS * 1000000, BS * 1000000, BS * 1000000);
141 MapDrawControl &m_control;
143 v3f m_camera_position = v3f(0,0,0);
144 v3f m_camera_direction = v3f(0,0,1);
145 f32 m_camera_fov = M_PI;
146 v3s16 m_camera_offset;
148 std::map<v3s16, MapBlock*> m_drawlist;
150 std::set<v2s16> m_last_drawn_sectors;
152 bool m_cache_trilinear_filter;
153 bool m_cache_bilinear_filter;
154 bool m_cache_anistropic_filter;