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"
37 blocks_would_have_drawn(0),
41 // Overrides limits by drawing everything
43 // Wanted drawing range
45 // Maximum number of blocks to draw
46 u32 wanted_max_blocks;
47 // Blocks in this range are drawn regardless of number of blocks drawn
48 float wanted_min_range;
49 // Number of blocks rendered is written here by the renderer
51 // Number of blocks that would have been drawn in wanted_range
52 u32 blocks_would_have_drawn;
53 // Distance to the farthest block drawn
63 This is the only map class that is able to render itself on screen.
66 class ClientMap : public Map, public scene::ISceneNode
72 MapDrawControl &control,
73 scene::ISceneNode* parent,
74 scene::ISceneManager* mgr,
82 return MAPTYPE_CLIENT;
90 void updateCamera(v3f pos, v3f dir, f32 fov, v3s16 offset)
92 JMutexAutoLock lock(m_camera_mutex);
93 m_camera_position = pos;
94 m_camera_direction = dir;
96 m_camera_offset = offset;
100 Forcefully get a sector from somewhere
102 MapSector * emergeSector(v2s16 p);
104 //void deSerializeSector(v2s16 p2d, std::istream &is);
110 virtual void OnRegisterSceneNode();
112 virtual void render()
114 video::IVideoDriver* driver = SceneManager->getVideoDriver();
115 driver->setTransform(video::ETS_WORLD, AbsoluteTransformation);
116 renderMap(driver, SceneManager->getSceneNodeRenderPass());
119 virtual const core::aabbox3d<f32>& getBoundingBox() const
124 void updateDrawList(video::IVideoDriver* driver);
125 void renderMap(video::IVideoDriver* driver, s32 pass);
127 int getBackgroundBrightness(float max_d, u32 daylight_factor,
128 int oldvalue, bool *sunlight_seen_result);
130 void renderPostFx(CameraMode cam_mode);
132 // For debug printing
133 virtual void PrintInfo(std::ostream &out);
135 // Check if sector was drawn on last render()
136 bool sectorWasDrawn(v2s16 p)
138 return (m_last_drawn_sectors.find(p) != m_last_drawn_sectors.end());
144 core::aabbox3d<f32> m_box;
146 MapDrawControl &m_control;
148 v3f m_camera_position;
149 v3f m_camera_direction;
151 v3s16 m_camera_offset;
152 JMutex m_camera_mutex;
154 std::map<v3s16, MapBlock*> m_drawlist;
156 std::set<v2s16> m_last_drawn_sectors;
158 bool m_cache_trilinear_filter;
159 bool m_cache_bilinear_filter;
160 bool m_cache_anistropic_filter;