3 Copyright (C) 2010-2012 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 General Public License as published by
7 the Free Software Foundation; either version 2 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 General Public License for more details.
15 You should have received a copy of the GNU 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 "common_irrlicht.h"
34 blocks_would_have_drawn(0)
37 // Overrides limits by drawing everything
39 // Wanted drawing range
41 // Maximum number of blocks to draw
42 u32 wanted_max_blocks;
43 // Blocks in this range are drawn regardless of number of blocks drawn
44 float wanted_min_range;
45 // Number of blocks rendered is written here by the renderer
47 // Number of blocks that would have been drawn in wanted_range
48 u32 blocks_would_have_drawn;
57 This is the only map class that is able to render itself on screen.
60 class ClientMap : public Map, public scene::ISceneNode
66 MapDrawControl &control,
67 scene::ISceneNode* parent,
68 scene::ISceneManager* mgr,
76 return MAPTYPE_CLIENT;
84 void updateCamera(v3f pos, v3f dir, f32 fov)
86 JMutexAutoLock lock(m_camera_mutex);
87 m_camera_position = pos;
88 m_camera_direction = dir;
93 Forcefully get a sector from somewhere
95 MapSector * emergeSector(v2s16 p);
97 //void deSerializeSector(v2s16 p2d, std::istream &is);
103 virtual void OnRegisterSceneNode();
105 virtual void render()
107 video::IVideoDriver* driver = SceneManager->getVideoDriver();
108 driver->setTransform(video::ETS_WORLD, AbsoluteTransformation);
109 renderMap(driver, SceneManager->getSceneNodeRenderPass());
112 virtual const core::aabbox3d<f32>& getBoundingBox() const
117 void renderMap(video::IVideoDriver* driver, s32 pass);
119 int getBackgroundBrightness(float max_d, u32 daylight_factor,
120 int oldvalue, bool *sunlight_seen_result);
124 // For debug printing
125 virtual void PrintInfo(std::ostream &out);
127 // Check if sector was drawn on last render()
128 bool sectorWasDrawn(v2s16 p)
130 return (m_last_drawn_sectors.find(p) != NULL);
136 core::aabbox3d<f32> m_box;
138 MapDrawControl &m_control;
140 v3f m_camera_position;
141 v3f m_camera_direction;
143 JMutex m_camera_mutex;
145 core::map<v2s16, bool> m_last_drawn_sectors;