[Bf-blender-cvs] [d07c666] master: BGE: Add setMistType and setMistIntensity API.
Thomas Szepe
noreply at git.blender.org
Mon Mar 23 21:40:31 CET 2015
Commit: d07c666a0e542517914dad580d1b3f4787525852
Author: Thomas Szepe
Date: Mon Mar 23 21:40:11 2015 +0100
Branches: master
https://developer.blender.org/rBd07c666a0e542517914dad580d1b3f4787525852
BGE: Add setMistType and setMistIntensity API.
This patch adds the missing setMistType() and setMistIntensity() to the API
Reviewers: campbellbarton, brecht, moguri
Reviewed By: campbellbarton, brecht, moguri
Subscribers: campbellbarton, dingto
Differential Revision: https://developer.blender.org/D149
===================================================================
M doc/python_api/rst/bge.render.rst
M source/gameengine/Converter/BlenderWorldInfo.cpp
M source/gameengine/Converter/BlenderWorldInfo.h
M source/gameengine/Ketsji/KX_KetsjiEngine.cpp
M source/gameengine/Ketsji/KX_PythonInit.cpp
M source/gameengine/Ketsji/KX_WorldInfo.h
M source/gameengine/Rasterizer/RAS_IRasterizer.h
M source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp
M source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h
===================================================================
diff --git a/doc/python_api/rst/bge.render.rst b/doc/python_api/rst/bge.render.rst
index 3abbd50..09d16f4 100644
--- a/doc/python_api/rst/bge.render.rst
+++ b/doc/python_api/rst/bge.render.rst
@@ -87,6 +87,19 @@ Constants
Right eye being used during stereoscopic rendering.
+.. data:: KX_MIST_QUADRATIC
+
+ Type of quadratic attenuation used to fade mist.
+
+.. data:: KX_MIST_LINEAR
+
+ Type of linear attenuation used to fade mist.
+
+.. data:: KX_MIST_INV_QUADRATIC
+
+ Type of inverse quadratic attenuation used to fade mist.
+
+
*********
Functions
*********
@@ -165,20 +178,27 @@ Functions
:type rgba: list [r, g, b, a]
-.. function:: setMistColor(rgb)
+.. function:: setAmbientColor(rgb)
- Sets the mist color.
+ Sets the color of ambient light.
:type rgb: list [r, g, b]
-
-.. function:: setAmbientColor(rgb)
- Sets the color of ambient light.
+.. function:: setMistColor(rgb)
+
+ Sets the mist color.
:type rgb: list [r, g, b]
+.. function:: setMistType(mode)
+
+ Sets the mist attenuation type.
+
+ :type mode: KX_MIST_QUADRATIC, KX_MIST_LINEAR, KX_MIST_INV_QUADRATIC
+
+
.. function:: setMistStart(start)
Sets the mist start value. Objects further away than start will have mist applied to them.
@@ -193,9 +213,16 @@ Functions
:type end: float
-
+
+.. function:: setMistIntensity(intensity)
+
+ Sets the mist intensity value.
+
+ :type start: float
+
.. function:: disableMist()
+
Disables mist.
.. note:: Deprecated use setUseMist().
diff --git a/source/gameengine/Converter/BlenderWorldInfo.cpp b/source/gameengine/Converter/BlenderWorldInfo.cpp
index 28e42c1..5f47694 100644
--- a/source/gameengine/Converter/BlenderWorldInfo.cpp
+++ b/source/gameengine/Converter/BlenderWorldInfo.cpp
@@ -70,8 +70,10 @@ BlenderWorldInfo::BlenderWorldInfo(struct Scene *blenderscene, struct World *ble
if (blenderworld) {
m_hasworld = true;
m_hasmist = ((blenderworld->mode) & WO_MIST ? true : false);
+ m_misttype = blenderworld->mistype;
m_miststart = blenderworld->miststa;
m_mistdistance = blenderworld->mistdist;
+ m_mistintensity = blenderworld->misi;
copy_v3_v3(m_mistcolor, &blenderworld->horr);
copy_v3_v3(m_backgroundcolor, &blenderworld->horr);
copy_v3_v3(m_ambientcolor, &blenderworld->ambr);
@@ -131,6 +133,11 @@ float BlenderWorldInfo::getAmbientColorBlue()
return m_ambientcolor[2];
}
+short BlenderWorldInfo::getMistType()
+{
+ return m_misttype;
+}
+
float BlenderWorldInfo::getMistStart()
{
return m_miststart;
@@ -141,6 +148,11 @@ float BlenderWorldInfo::getMistDistance()
return m_mistdistance;
}
+float BlenderWorldInfo::getMistIntensity()
+{
+ return m_mistintensity;
+}
+
float BlenderWorldInfo::getMistColorRed()
{
return m_mistcolor[0];
@@ -163,6 +175,11 @@ void BlenderWorldInfo::setBackColor(float r, float g, float b)
m_backgroundcolor[2] = b;
}
+void BlenderWorldInfo::setMistType(short type)
+{
+ m_misttype = type;
+}
+
void BlenderWorldInfo::setUseMist(bool enable)
{
m_hasmist = enable;
@@ -178,6 +195,10 @@ void BlenderWorldInfo::setMistDistance(float d)
m_mistdistance = d;
}
+void BlenderWorldInfo::setMistIntensity(float intensity)
+{
+ m_mistintensity = intensity;
+}
void BlenderWorldInfo::setMistColor(float r, float g, float b)
{
m_mistcolor[0] = r;
diff --git a/source/gameengine/Converter/BlenderWorldInfo.h b/source/gameengine/Converter/BlenderWorldInfo.h
index 6c67681..4184d42 100644
--- a/source/gameengine/Converter/BlenderWorldInfo.h
+++ b/source/gameengine/Converter/BlenderWorldInfo.h
@@ -40,8 +40,10 @@ class BlenderWorldInfo : public KX_WorldInfo
float m_backgroundcolor[3];
bool m_hasmist;
+ short m_misttype;
float m_miststart;
float m_mistdistance;
+ float m_mistintensity;
float m_mistcolor[3];
float m_ambientcolor[3];
@@ -60,16 +62,20 @@ public:
float getAmbientColorGreen();
float getAmbientColorBlue();
+ short getMistType();
float getMistStart();
float getMistDistance();
+ float getMistIntensity();
float getMistColorRed();
float getMistColorGreen();
float getMistColorBlue();
void setBackColor(float r, float g, float b);
void setUseMist(bool enable);
+ void setMistType(short type);
void setMistStart(float d);
void setMistDistance(float d);
+ void setMistIntensity(float intensity);
void setMistColor(float r, float g, float b);
void setAmbientColor(float r, float g, float b);
diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp
index 44b667e..8c6cb2b 100644
--- a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp
+++ b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp
@@ -996,8 +996,10 @@ void KX_KetsjiEngine::SetWorldSettings(KX_WorldInfo* wi)
if (wi->hasMist())
{
m_rasterizer->SetFog(
+ wi->getMistType(),
wi->getMistStart(),
wi->getMistDistance(),
+ wi->getMistIntensity(),
wi->getMistColorRed(),
wi->getMistColorGreen(),
wi->getMistColorBlue()
diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp
index e0af328..8fd38db 100644
--- a/source/gameengine/Ketsji/KX_PythonInit.cpp
+++ b/source/gameengine/Ketsji/KX_PythonInit.cpp
@@ -1091,6 +1091,29 @@ static PyObject *gPySetUseMist(PyObject *, PyObject *args)
Py_RETURN_NONE;
}
+static PyObject *gPySetMistType(PyObject *, PyObject *args)
+{
+ short type;
+
+ if (!PyArg_ParseTuple(args,"i:setMistType",&type))
+ return NULL;
+
+ if (type < 0 || type > 2) {
+ PyErr_SetString(PyExc_ValueError, "Rasterizer.setMistType(int): Mist type is not known");
+ return NULL;
+ }
+
+ KX_WorldInfo *wi = gp_KetsjiScene->GetWorldInfo();
+ if (!wi->hasWorld()) {
+ PyErr_SetString(PyExc_RuntimeError, "bge.render.setMistType(int), World not available");
+ return NULL;
+ }
+
+ wi->setMistType(type);
+
+ Py_RETURN_NONE;
+}
+
static PyObject *gPySetMistStart(PyObject *, PyObject *args)
{
float miststart;
@@ -1125,6 +1148,24 @@ static PyObject *gPySetMistEnd(PyObject *, PyObject *args)
Py_RETURN_NONE;
}
+static PyObject *gPySetMistIntensity(PyObject *, PyObject *args)
+{
+
+ float intensity;
+ if (!PyArg_ParseTuple(args,"f:setMistIntensity",&intensity))
+ return NULL;
+
+ KX_WorldInfo *wi = gp_KetsjiScene->GetWorldInfo();
+ if (!wi->hasWorld()) {
+ PyErr_SetString(PyExc_RuntimeError, "bge.render.setMistIntensity(float), World not available");
+ return NULL;
+ }
+
+ wi->setMistIntensity(intensity);
+
+ Py_RETURN_NONE;
+}
+
static PyObject *gPySetAmbientColor(PyObject *, PyObject *value)
{
MT_Vector3 vec;
@@ -1522,8 +1563,10 @@ static struct PyMethodDef rasterizer_methods[] = {
{"disableMist",(PyCFunction)gPyDisableMist,METH_NOARGS,"turn off mist"},
{"setUseMist",(PyCFunction)gPySetUseMist,METH_VARARGS,"enable or disable mist"},
{"setMistColor",(PyCFunction)gPySetMistColor,METH_O,"set Mist Color (rgb)"},
+ {"setMistType",(PyCFunction)gPySetMistType,METH_VARARGS,"set mist type (short type)"},
{"setMistStart",(PyCFunction)gPySetMistStart,METH_VARARGS,"set Mist Start"},
{"setMistEnd",(PyCFunction)gPySetMistEnd,METH_VARARGS,"set Mist End"},
+ {"setMistIntensity",(PyCFunction)gPySetMistIntensity,METH_VARARGS,"set mist intensity (float intensity)"},
{"enableMotionBlur",(PyCFunction)gPyEnableMotionBlur,METH_VARARGS,"enable motion blur"},
{"disableMotionBlur",(PyCFunction)gPyDisableMotionBlur,METH_NOARGS,"disable motion blur"},
@@ -2370,6 +2413,11 @@ PyMODINIT_FUNC initRasterizerPythonBinding()
KX_MACRO_addTypesToDict(d, LEFT_EYE, RAS_IRasterizer::RAS_STEREO_LEFTEYE);
KX_MACRO_addTypesToDict(d, RIGHT_EYE, RAS_IRasterizer::RAS_STEREO_RIGHTEYE);
+ /* KX_WorldInfo mist types */
+ KX_MACRO_addTypesToDict(d, KX_MIST_QUADRATIC, KX_WorldInfo::KX_MIST_QUADRATIC);
+ KX_MACRO_addTypesToDict(d, KX_MIST_LINEAR, KX_WorldInfo::KX_MIST_LINEAR);
+ KX_MACRO_addTypesToDict(d, KX_MIST_INV_QUADRATIC, KX_WorldInfo::KX_MIST_INV_QUADRATIC);
+
// XXXX Add constants here
// Check for errors
diff --git a/source/gameengine/Ketsji/KX_WorldInfo.h b/source/gameengine/Ketsji/KX_WorldInfo.h
index 251ba95..f90a4ff 100644
--- a/source/gameengine/Ketsji/KX_WorldInfo.h
+++ b/source/gameengine/Ketsji/KX_WorldInfo.h
@@ -43,6 +43,15 @@ class MT_CmMatrix4x4;
class KX_WorldInfo
{
public:
+ /**
+ * Mist options
+ */
+ enum MistType {
+ KX_MIST_QUADRATIC,
+ KX_MIST_LINEAR,
+ KX_MIST_INV_QUADRATIC,
+ };
+
KX_WorldInfo() {}
virtual ~KX_WorldInfo();
@@ -51,8 +60,10 @@ public:
virtual float getBackColorRed() = 0;
virtual float getBackColorGreen() = 0;
virtual float getBackColorBlue() = 0;
+ virtual short getMistType() = 0;
virtual float getMistStart() = 0;
virtual float getMistDistance() = 0;
+ virtual float getMistIntensity() = 0;
virtual float getMistColorRed() = 0;
virtual float getMistColorGreen() = 0;
virtual float getMistColorBlue() = 0;
@@ -62,8 +73,10 @@ public:
virtual float getAmbientColorBlue() = 0;
virtual void setUseMist(bool enable) = 0;
+ virtual void setMistType(short) = 0;
virtual void setMistStart(float) = 0;
virtual void setMistDistance(float) = 0;
+ virtual void setMistIntensity(float) = 0;
virtual void setMistColor(float, float, float) = 0;
virtual void setBackColor(float, float, float) = 0;
virtual void setAmbientColor(float,float,float) = 0;
diff --git a/source/gameengine/Rasterizer/RAS_IRasterizer.h b/source/gameengine/Rasterizer/RAS_IRasterizer.h
index 6f5273f..22ffcd4 100644
--- a/source/gameengine/Rasterizer/RAS_IRasterizer.h
+++ b/source/gameengine/Rasterizer/RAS_IRasterizer.h
@@ -297,7 +297,7 @@ public:
/**
* Fog
*/
- virtual void SetFog(float start, float dist, float r, float g, float b) = 0;
+ 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;
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp
index 14a184b..9269640 100644
--- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list