Old light method restored, it can be changed in lua now
This commit is contained in:
parent
7f6a4bbbe5
commit
7f918a12a2
|
@ -36,6 +36,7 @@ LightView::LightView()
|
||||||
{
|
{
|
||||||
m_lightbuffer = g_framebuffers.createFrameBuffer();
|
m_lightbuffer = g_framebuffers.createFrameBuffer();
|
||||||
m_lightTexture = generateLightBubble(0.1f);
|
m_lightTexture = generateLightBubble(0.1f);
|
||||||
|
m_blendEquation = Painter::BlendEquation_Add;
|
||||||
reset();
|
reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,6 +88,12 @@ void LightView::addLightSource(const Point& center, float scaleFactor, const Lig
|
||||||
color.setGreen(color.gF() * brightness);
|
color.setGreen(color.gF() * brightness);
|
||||||
color.setBlue(color.bF() * brightness);
|
color.setBlue(color.bF() * brightness);
|
||||||
|
|
||||||
|
if(m_blendEquation == Painter::BlendEquation_Add && m_lightMap.size() > 0) {
|
||||||
|
LightSource prevSource = m_lightMap.back();
|
||||||
|
if(prevSource.center == center && prevSource.color == color && prevSource.radius == radius)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
LightSource source;
|
LightSource source;
|
||||||
source.center = center;
|
source.center = center;
|
||||||
source.color = color;
|
source.color = color;
|
||||||
|
@ -126,7 +133,7 @@ void LightView::draw(const Rect& dest, const Rect& src)
|
||||||
m_lightbuffer->bind();
|
m_lightbuffer->bind();
|
||||||
g_painter->setCompositionMode(Painter::CompositionMode_Replace);
|
g_painter->setCompositionMode(Painter::CompositionMode_Replace);
|
||||||
drawGlobalLight(m_globalLight);
|
drawGlobalLight(m_globalLight);
|
||||||
g_painter->setBlendEquation(Painter::BlendEquation_Max);
|
g_painter->setBlendEquation(m_blendEquation);
|
||||||
g_painter->setCompositionMode(Painter::CompositionMode_Add);
|
g_painter->setCompositionMode(Painter::CompositionMode_Add);
|
||||||
for(const LightSource& source : m_lightMap)
|
for(const LightSource& source : m_lightMap)
|
||||||
drawLightSource(source.center, source.color, source.radius);
|
drawLightSource(source.center, source.color, source.radius);
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
|
|
||||||
#include "declarations.h"
|
#include "declarations.h"
|
||||||
#include <framework/graphics/declarations.h>
|
#include <framework/graphics/declarations.h>
|
||||||
|
#include <framework/graphics/painter.h>
|
||||||
#include "thingtype.h"
|
#include "thingtype.h"
|
||||||
|
|
||||||
struct LightSource {
|
struct LightSource {
|
||||||
|
@ -44,11 +45,14 @@ public:
|
||||||
void resize(const Size& size);
|
void resize(const Size& size);
|
||||||
void draw(const Rect& dest, const Rect& src);
|
void draw(const Rect& dest, const Rect& src);
|
||||||
|
|
||||||
|
void setBlendEquation(Painter::BlendEquation blendEquation) { m_blendEquation = blendEquation; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void drawGlobalLight(const Light& light);
|
void drawGlobalLight(const Light& light);
|
||||||
void drawLightSource(const Point& center, const Color& color, int radius);
|
void drawLightSource(const Point& center, const Color& color, int radius);
|
||||||
TexturePtr generateLightBubble(float centerFactor);
|
TexturePtr generateLightBubble(float centerFactor);
|
||||||
|
|
||||||
|
Painter::BlendEquation m_blendEquation;
|
||||||
TexturePtr m_lightTexture;
|
TexturePtr m_lightTexture;
|
||||||
FrameBufferPtr m_lightbuffer;
|
FrameBufferPtr m_lightbuffer;
|
||||||
Light m_globalLight;
|
Light m_globalLight;
|
||||||
|
|
|
@ -565,6 +565,7 @@ void Client::registerLuaFunctions()
|
||||||
g_lua.bindClassMemberFunction<UIMap>("setMapShader", &UIMap::setMapShader);
|
g_lua.bindClassMemberFunction<UIMap>("setMapShader", &UIMap::setMapShader);
|
||||||
g_lua.bindClassMemberFunction<UIMap>("setMinimumAmbientLight", &UIMap::setMinimumAmbientLight);
|
g_lua.bindClassMemberFunction<UIMap>("setMinimumAmbientLight", &UIMap::setMinimumAmbientLight);
|
||||||
g_lua.bindClassMemberFunction<UIMap>("setLimitVisibleRange", &UIMap::setLimitVisibleRange);
|
g_lua.bindClassMemberFunction<UIMap>("setLimitVisibleRange", &UIMap::setLimitVisibleRange);
|
||||||
|
g_lua.bindClassMemberFunction<UIMap>("setAddLightMethod", &UIMap::setAddLightMethod);
|
||||||
g_lua.bindClassMemberFunction<UIMap>("isMultifloor", &UIMap::isMultifloor);
|
g_lua.bindClassMemberFunction<UIMap>("isMultifloor", &UIMap::isMultifloor);
|
||||||
g_lua.bindClassMemberFunction<UIMap>("isAutoViewModeEnabled", &UIMap::isAutoViewModeEnabled);
|
g_lua.bindClassMemberFunction<UIMap>("isAutoViewModeEnabled", &UIMap::isAutoViewModeEnabled);
|
||||||
g_lua.bindClassMemberFunction<UIMap>("isDrawingTexts", &UIMap::isDrawingTexts);
|
g_lua.bindClassMemberFunction<UIMap>("isDrawingTexts", &UIMap::isDrawingTexts);
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
#include <framework/graphics/declarations.h>
|
#include <framework/graphics/declarations.h>
|
||||||
#include <framework/luaengine/luaobject.h>
|
#include <framework/luaengine/luaobject.h>
|
||||||
#include <framework/core/declarations.h>
|
#include <framework/core/declarations.h>
|
||||||
|
#include "lightview.h"
|
||||||
|
|
||||||
// @bindclass
|
// @bindclass
|
||||||
class MapView : public LuaObject
|
class MapView : public LuaObject
|
||||||
|
@ -110,6 +111,8 @@ public:
|
||||||
void setAnimated(bool animated) { m_animated = animated; requestVisibleTilesCacheUpdate(); }
|
void setAnimated(bool animated) { m_animated = animated; requestVisibleTilesCacheUpdate(); }
|
||||||
bool isAnimating() { return m_animated; }
|
bool isAnimating() { return m_animated; }
|
||||||
|
|
||||||
|
void setAddLightMethod(bool add) { m_lightView->setBlendEquation(add ? Painter::BlendEquation_Add : Painter::BlendEquation_Max); }
|
||||||
|
|
||||||
void setShader(const PainterShaderProgramPtr& shader, float fadein, float fadeout);
|
void setShader(const PainterShaderProgramPtr& shader, float fadein, float fadeout);
|
||||||
PainterShaderProgramPtr getShader() { return m_shader; }
|
PainterShaderProgramPtr getShader() { return m_shader; }
|
||||||
|
|
||||||
|
|
|
@ -59,6 +59,7 @@ public:
|
||||||
void setMapShader(const PainterShaderProgramPtr& shader, float fadeout, float fadein) { m_mapView->setShader(shader, fadein, fadeout); }
|
void setMapShader(const PainterShaderProgramPtr& shader, float fadeout, float fadein) { m_mapView->setShader(shader, fadein, fadeout); }
|
||||||
void setMinimumAmbientLight(float intensity) { m_mapView->setMinimumAmbientLight(intensity); }
|
void setMinimumAmbientLight(float intensity) { m_mapView->setMinimumAmbientLight(intensity); }
|
||||||
void setLimitVisibleRange(bool limitVisibleRange) { m_limitVisibleRange = limitVisibleRange; updateVisibleDimension(); }
|
void setLimitVisibleRange(bool limitVisibleRange) { m_limitVisibleRange = limitVisibleRange; updateVisibleDimension(); }
|
||||||
|
void setAddLightMethod(bool add) { m_mapView->setAddLightMethod(add); }
|
||||||
|
|
||||||
bool isMultifloor() { return m_mapView->isMultifloor(); }
|
bool isMultifloor() { return m_mapView->isMultifloor(); }
|
||||||
bool isAutoViewModeEnabled() { return m_mapView->isAutoViewModeEnabled(); }
|
bool isAutoViewModeEnabled() { return m_mapView->isAutoViewModeEnabled(); }
|
||||||
|
|
Loading…
Reference in New Issue