Old light method restored, it can be changed in lua now

This commit is contained in:
Henrique Santiago 2013-02-06 20:47:17 -02:00
parent 7f6a4bbbe5
commit 7f918a12a2
5 changed files with 17 additions and 1 deletions

View File

@ -36,6 +36,7 @@ LightView::LightView()
{
m_lightbuffer = g_framebuffers.createFrameBuffer();
m_lightTexture = generateLightBubble(0.1f);
m_blendEquation = Painter::BlendEquation_Add;
reset();
}
@ -87,6 +88,12 @@ void LightView::addLightSource(const Point& center, float scaleFactor, const Lig
color.setGreen(color.gF() * 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;
source.center = center;
source.color = color;
@ -126,7 +133,7 @@ void LightView::draw(const Rect& dest, const Rect& src)
m_lightbuffer->bind();
g_painter->setCompositionMode(Painter::CompositionMode_Replace);
drawGlobalLight(m_globalLight);
g_painter->setBlendEquation(Painter::BlendEquation_Max);
g_painter->setBlendEquation(m_blendEquation);
g_painter->setCompositionMode(Painter::CompositionMode_Add);
for(const LightSource& source : m_lightMap)
drawLightSource(source.center, source.color, source.radius);

View File

@ -25,6 +25,7 @@
#include "declarations.h"
#include <framework/graphics/declarations.h>
#include <framework/graphics/painter.h>
#include "thingtype.h"
struct LightSource {
@ -44,11 +45,14 @@ public:
void resize(const Size& size);
void draw(const Rect& dest, const Rect& src);
void setBlendEquation(Painter::BlendEquation blendEquation) { m_blendEquation = blendEquation; }
private:
void drawGlobalLight(const Light& light);
void drawLightSource(const Point& center, const Color& color, int radius);
TexturePtr generateLightBubble(float centerFactor);
Painter::BlendEquation m_blendEquation;
TexturePtr m_lightTexture;
FrameBufferPtr m_lightbuffer;
Light m_globalLight;

View File

@ -565,6 +565,7 @@ void Client::registerLuaFunctions()
g_lua.bindClassMemberFunction<UIMap>("setMapShader", &UIMap::setMapShader);
g_lua.bindClassMemberFunction<UIMap>("setMinimumAmbientLight", &UIMap::setMinimumAmbientLight);
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>("isAutoViewModeEnabled", &UIMap::isAutoViewModeEnabled);
g_lua.bindClassMemberFunction<UIMap>("isDrawingTexts", &UIMap::isDrawingTexts);

View File

@ -28,6 +28,7 @@
#include <framework/graphics/declarations.h>
#include <framework/luaengine/luaobject.h>
#include <framework/core/declarations.h>
#include "lightview.h"
// @bindclass
class MapView : public LuaObject
@ -110,6 +111,8 @@ public:
void setAnimated(bool animated) { m_animated = animated; requestVisibleTilesCacheUpdate(); }
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);
PainterShaderProgramPtr getShader() { return m_shader; }

View File

@ -59,6 +59,7 @@ public:
void setMapShader(const PainterShaderProgramPtr& shader, float fadeout, float fadein) { m_mapView->setShader(shader, fadein, fadeout); }
void setMinimumAmbientLight(float intensity) { m_mapView->setMinimumAmbientLight(intensity); }
void setLimitVisibleRange(bool limitVisibleRange) { m_limitVisibleRange = limitVisibleRange; updateVisibleDimension(); }
void setAddLightMethod(bool add) { m_mapView->setAddLightMethod(add); }
bool isMultifloor() { return m_mapView->isMultifloor(); }
bool isAutoViewModeEnabled() { return m_mapView->isAutoViewModeEnabled(); }