diff options
author | Thomas Szepe <HG1_public@gmx.net> | 2015-03-24 00:49:38 +0300 |
---|---|---|
committer | Thomas Szepe <HG1_public@gmx.net> | 2015-03-24 00:49:38 +0300 |
commit | 931c3e654404bbff05f1bcce9487fc6e91392300 (patch) | |
tree | 6b71c869a8827c2231f47db7a8d22a67cbc60380 /source/gameengine/Rasterizer | |
parent | c73693d4a5c9b286333a90dd0fc6fd8a7e6ea753 (diff) |
BGE: Code clean up for world (mist, background, ambient)
Code clean up for BGE world mist, background and global ambient color.
Move mist render update to BlenderWolrdInfo
Reviewers: moguri, brecht
Reviewed By: moguri, brecht
Differential Revision: https://developer.blender.org/D152
Diffstat (limited to 'source/gameengine/Rasterizer')
3 files changed, 28 insertions, 100 deletions
diff --git a/source/gameengine/Rasterizer/RAS_IRasterizer.h b/source/gameengine/Rasterizer/RAS_IRasterizer.h index 22ffcd48739..aadecd56992 100644 --- a/source/gameengine/Rasterizer/RAS_IRasterizer.h +++ b/source/gameengine/Rasterizer/RAS_IRasterizer.h @@ -297,15 +297,11 @@ public: /** * Fog */ - virtual void SetFog(short type, float start, float dist, float intensity, float r, float g, float b) = 0; - virtual void SetFogColor(float r, float g,float b) = 0; - virtual void SetFogStart(float start) = 0; - virtual void SetFogEnd(float end) = 0; + virtual void SetFog(short type, float start, float dist, float intensity, float color[3]) = 0; virtual void DisplayFog() = 0; virtual void EnableFog(bool enable) = 0; - virtual bool IsFogEnabled() = 0; - virtual void SetBackColor(float red, float green, float blue, float alpha) = 0; + virtual void SetBackColor(float color[3]) = 0; /** * \param drawingmode = KX_BOUNDINGBOX, KX_WIREFRAME, KX_SOLID, KX_SHADED or KX_TEXTURED. @@ -380,7 +376,7 @@ public: */ virtual void SetEmissive(float eX, float eY, float eZ, float e) = 0; - virtual void SetAmbientColor(float red, float green, float blue) = 0; + virtual void SetAmbientColor(float color[3]) = 0; virtual void SetAmbient(float factor) = 0; /** diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp index 9269640afa3..f47f56541ba 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp @@ -194,109 +194,52 @@ bool RAS_OpenGLRasterizer::Init() } -void RAS_OpenGLRasterizer::SetAmbientColor(float red, float green, float blue) +void RAS_OpenGLRasterizer::SetAmbientColor(float color[3]) { - m_ambr = red; - m_ambg = green; - m_ambb = blue; + m_ambr = color[0]; + m_ambg = color[1]; + m_ambb = color[2]; } - void RAS_OpenGLRasterizer::SetAmbient(float factor) { - float ambient[] = { m_ambr*factor, m_ambg*factor, m_ambb*factor, 1.0f }; + float ambient[] = {m_ambr * factor, m_ambg * factor, m_ambb * factor, 1.0f}; glLightModelfv(GL_LIGHT_MODEL_AMBIENT, ambient); } - -void RAS_OpenGLRasterizer::SetBackColor(float red, - float green, - float blue, - float alpha) -{ - m_redback = red; - m_greenback = green; - m_blueback = blue; - m_alphaback = alpha; -} - - - -void RAS_OpenGLRasterizer::SetFogColor(float r, - float g, - float b) -{ - m_fogr = r; - m_fogg = g; - m_fogb = b; -} - - - -void RAS_OpenGLRasterizer::SetFogStart(float start) -{ - m_fogstart = start; -} - - - -void RAS_OpenGLRasterizer::SetFogEnd(float fogend) +void RAS_OpenGLRasterizer::SetBackColor(float color[3]) { - m_fogdist = fogend; + m_redback = color[0]; + m_greenback = color[1]; + m_blueback = color[2]; + m_alphaback = 1.0f; } - - -void RAS_OpenGLRasterizer::SetFog(short type, - float start, - float dist, - float intensity, - float r, - float g, - float b) +void RAS_OpenGLRasterizer::SetFog(short type, float start, float dist, float intensity, float color[3]) { - m_fogtype = type; - m_fogstart = start; - m_fogdist = dist; - m_fogintensity = intensity; - m_fogr = r; - m_fogg = g; - m_fogb = b; + float params[4] = {color[0], color[1], color[2], 1.0f}; + glFogi(GL_FOG_MODE, GL_LINEAR); + glFogf(GL_FOG_DENSITY, intensity / 10.0f); + glFogf(GL_FOG_START, start); + glFogf(GL_FOG_END, start + dist); + glFogfv(GL_FOG_COLOR, params); } - - void RAS_OpenGLRasterizer::EnableFog(bool enable) { m_fogenabled = enable; } -bool RAS_OpenGLRasterizer::IsFogEnabled() -{ - return m_fogenabled; -} - - void RAS_OpenGLRasterizer::DisplayFog() { - if ((m_drawingmode >= KX_SOLID) && m_fogenabled) - { - float params[4] = {m_fogr, m_fogg, m_fogb, 1.0f}; - glFogi(GL_FOG_MODE, GL_LINEAR); - glFogf(GL_FOG_DENSITY, m_fogintensity / 10.0f); - glFogf(GL_FOG_START, m_fogstart); - glFogf(GL_FOG_END, m_fogstart + m_fogdist); - glFogfv(GL_FOG_COLOR, params); + if ((m_drawingmode >= KX_SOLID) && m_fogenabled) { glEnable(GL_FOG); - } - else - { + } + else { glDisable(GL_FOG); } } - - bool RAS_OpenGLRasterizer::SetMaterial(const RAS_IPolyMaterial& mat) { return mat.Activate(this, m_materialCachingInfo); diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h index 48023f9786c..b034315e3d6 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h @@ -80,14 +80,7 @@ class RAS_OpenGLRasterizer : public RAS_IRasterizer /* fogging vars */ bool m_fogenabled; - short m_fogtype; - float m_fogstart; - float m_fogdist; - float m_fogintensity; - float m_fogr; - float m_fogg; - float m_fogb; - + float m_redback; float m_greenback; float m_blueback; @@ -200,16 +193,12 @@ public: virtual const MT_Point3& GetCameraPosition(); virtual bool GetCameraOrtho(); - virtual void SetFog(short type, float start, float dist, float intensity, float r, float g, float b); - virtual void SetFogColor(float r, float g, float b); - virtual void SetFogStart(float fogstart); - virtual void SetFogEnd(float fogend); + virtual void SetFog(short type, float start, float dist, float intensity, float color[3]); virtual void EnableFog(bool enable); virtual void DisplayFog(); - virtual bool IsFogEnabled(); - virtual void SetBackColor(float red, float green, float blue, float alpha); - + virtual void SetBackColor(float color[3]); + virtual void SetDrawingMode(int drawingmode); virtual int GetDrawingMode(); @@ -229,7 +218,7 @@ public: virtual void SetDiffuse(float difX, float difY, float difZ, float diffuse); virtual void SetEmissive(float eX, float eY, float eZ, float e); - virtual void SetAmbientColor(float red, float green, float blue); + virtual void SetAmbientColor(float color[3]); virtual void SetAmbient(float factor); virtual void SetPolygonOffset(float mult, float add); |