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 CLIENTMAP_HEADER
21 #define CLIENTMAP_HEADER
23 #include "irrlichttypes_extrabloated.h"
36 blocks_would_have_drawn(0),
40 // Overrides limits by drawing everything
42 // Wanted drawing range
44 // Maximum number of blocks to draw
45 u32 wanted_max_blocks;
46 // Blocks in this range are drawn regardless of number of blocks drawn
47 float wanted_min_range;
48 // Number of blocks rendered is written here by the renderer
50 // Number of blocks that would have been drawn in wanted_range
51 u32 blocks_would_have_drawn;
52 // Distance to the farthest block drawn
62 This is the only map class that is able to render itself on screen.
65 class ClientMap : public Map, public scene::ISceneNode
71 MapDrawControl &control,
72 scene::ISceneNode* parent,
73 scene::ISceneManager* mgr,
81 return MAPTYPE_CLIENT;
89 void updateCamera(v3f pos, v3f dir, f32 fov, v3s16 offset)
91 JMutexAutoLock lock(m_camera_mutex);
92 m_camera_position = pos;
93 m_camera_direction = dir;
95 m_camera_offset = offset;
99 Forcefully get a sector from somewhere
101 MapSector * emergeSector(v2s16 p);
103 //void deSerializeSector(v2s16 p2d, std::istream &is);
109 virtual void OnRegisterSceneNode();
111 virtual void render()
113 video::IVideoDriver* driver = SceneManager->getVideoDriver();
114 driver->setTransform(video::ETS_WORLD, AbsoluteTransformation);
115 renderMap(driver, SceneManager->getSceneNodeRenderPass());
118 virtual const core::aabbox3d<f32>& getBoundingBox() const
123 void updateDrawList(video::IVideoDriver* driver);
124 void renderMap(video::IVideoDriver* driver, s32 pass);
126 int getBackgroundBrightness(float max_d, u32 daylight_factor,
127 int oldvalue, bool *sunlight_seen_result);
131 // For debug printing
132 virtual void PrintInfo(std::ostream &out);
134 // Check if sector was drawn on last render()
135 bool sectorWasDrawn(v2s16 p)
137 return (m_last_drawn_sectors.find(p) != m_last_drawn_sectors.end());
143 core::aabbox3d<f32> m_box;
145 MapDrawControl &m_control;
147 v3f m_camera_position;
148 v3f m_camera_direction;
150 v3s16 m_camera_offset;
151 JMutex m_camera_mutex;
153 std::map<v3s16, MapBlock*> m_drawlist;
155 std::set<v2s16> m_last_drawn_sectors;