Otclient  14/8/2020
lightview.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2010-2020 OTClient <https://github.com/edubart/otclient>
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a copy
5  * of this software and associated documentation files (the "Software"), to deal
6  * in the Software without restriction, including without limitation the rights
7  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8  * copies of the Software, and to permit persons to whom the Software is
9  * furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included in
12  * all copies or substantial portions of the Software.
13  *
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20  * THE SOFTWARE.
21  */
22 
23 #ifndef LIGHTVIEW_H
24 #define LIGHTVIEW_H
25 
26 #include "declarations.h"
29 #include "thingtype.h"
30 
31 struct LightSource {
34  int radius;
35 };
36 
37 class LightView : public LuaObject
38 {
39 public:
40  LightView();
41 
42  void reset();
43  void setGlobalLight(const Light& light);
44  void addLightSource(const Point& center, float scaleFactor, const Light& light);
45  void resize(const Size& size);
46  void draw(const Rect& dest, const Rect& src);
47 
48  void setBlendEquation(Painter::BlendEquation blendEquation) { m_blendEquation = blendEquation; }
49 
50 private:
51  void drawGlobalLight(const Light& light);
52  void drawLightSource(const Point& center, const Color& color, int radius);
53  TexturePtr generateLightBubble(float centerFactor);
54 
55  Painter::BlendEquation m_blendEquation;
56  TexturePtr m_lightTexture;
57  FrameBufferPtr m_lightbuffer;
58  Light m_globalLight;
59  std::vector<LightSource> m_lightMap;
60 };
61 
62 #endif
LightView::setGlobalLight
void setGlobalLight(const Light &light)
Definition: lightview.cpp:74
Color
Definition: color.h:32
LightView::resize
void resize(const Size &size)
Definition: lightview.cpp:125
TRect< int >
LightSource::color
Color color
Definition: lightview.h:32
LightView::addLightSource
void addLightSource(const Point &center, float scaleFactor, const Light &light)
Definition: lightview.cpp:79
LightView
Definition: lightview.h:37
painter.h
LightSource::center
Point center
Definition: lightview.h:33
declarations.h
LightView::LightView
LightView()
Definition: lightview.cpp:35
LightView::setBlendEquation
void setBlendEquation(Painter::BlendEquation blendEquation)
Definition: lightview.h:48
Painter::BlendEquation
BlendEquation
Definition: painter.h:34
LightSource
Definition: lightview.h:31
declarations.h
LightView::draw
void draw(const Rect &dest, const Rect &src)
Definition: lightview.cpp:130
stdext::shared_object_ptr< Texture >
LightView::reset
void reset()
Definition: lightview.cpp:69
Light
Definition: thingtype.h:117
TPoint< int >
thingtype.h
LuaObject
LuaObject, all script-able classes have it as base.
Definition: luaobject.h:30
TSize< int >
LightSource::radius
int radius
Definition: lightview.h:34