Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenoit Bolsee <benoit.bolsee@online.be>2009-04-09 01:40:55 +0400
committerBenoit Bolsee <benoit.bolsee@online.be>2009-04-09 01:40:55 +0400
commit5b0d75e831d891015b82dcc3d30856125c7b913e (patch)
tree14554cc14bd2e324397175bd410d533dc7b490eb
parent24f1355d4f7d1121b4a1dd209ce86f9ce4aa5561 (diff)
BGE API cleanup: 2DFilterActuator.
-rw-r--r--source/gameengine/GameLogic/SCA_2DFilterActuator.cpp64
-rw-r--r--source/gameengine/GameLogic/SCA_2DFilterActuator.h35
-rw-r--r--source/gameengine/Ketsji/KX_PythonInit.cpp21
-rw-r--r--source/gameengine/PyDoc/SCA_2DFilterActuator.py44
4 files changed, 150 insertions, 14 deletions
diff --git a/source/gameengine/GameLogic/SCA_2DFilterActuator.cpp b/source/gameengine/GameLogic/SCA_2DFilterActuator.cpp
index 9d4dc1f33d6..171d3fbc265 100644
--- a/source/gameengine/GameLogic/SCA_2DFilterActuator.cpp
+++ b/source/gameengine/GameLogic/SCA_2DFilterActuator.cpp
@@ -1,5 +1,29 @@
-#include "SCA_IActuator.h"
+/**
+ * SCA_2DFilterActuator.cpp
+ *
+ * $Id$
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+#include "SCA_IActuator.h"
#include "SCA_2DFilterActuator.h"
#ifdef HAVE_CONFIG_H
@@ -22,7 +46,7 @@ SCA_2DFilterActuator::SCA_2DFilterActuator(
PyTypeObject* T)
: SCA_IActuator(gameobj, T),
m_type(type),
- m_flag(flag),
+ m_disableMotionBlur(flag),
m_float_arg(float_arg),
m_int_arg(int_arg),
m_rasterizer(rasterizer),
@@ -35,12 +59,6 @@ SCA_2DFilterActuator::SCA_2DFilterActuator(
}
}
-void SCA_2DFilterActuator::SetShaderText(STR_String text)
-{
- m_shaderText = text;
-}
-
-
CValue* SCA_2DFilterActuator::GetReplica()
{
@@ -63,7 +81,7 @@ bool SCA_2DFilterActuator::Update()
if( m_type == RAS_2DFilterManager::RAS_2DFILTER_MOTIONBLUR )
{
- if(!m_flag)
+ if(!m_disableMotionBlur)
m_rasterizer->EnableMotionBlur(m_float_arg);
else
m_rasterizer->DisableMotionBlur();
@@ -79,6 +97,18 @@ bool SCA_2DFilterActuator::Update()
}
+void SCA_2DFilterActuator::SetShaderText(STR_String text)
+{
+ m_shaderText = text;
+}
+
+/* ------------------------------------------------------------------------- */
+/* Python functions */
+/* ------------------------------------------------------------------------- */
+
+
+
+/* Integration hooks ------------------------------------------------------- */
PyTypeObject SCA_2DFilterActuator::Type = {
PyObject_HEAD_INIT(NULL)
0,
@@ -109,14 +139,26 @@ PyParentObject SCA_2DFilterActuator::Parents[] = {
PyMethodDef SCA_2DFilterActuator::Methods[] = {
- /* add python functions to deal with m_msg... */
+ /* add python functions to deal with m_msg... */
{NULL,NULL}
};
PyAttributeDef SCA_2DFilterActuator::Attributes[] = {
+ KX_PYATTRIBUTE_STRING_RW("shaderText", 0, 64000, false, SCA_2DFilterActuator, m_shaderText),
+ KX_PYATTRIBUTE_SHORT_RW("disableMotionBlur", 0, 1, true, SCA_2DFilterActuator, m_disableMotionBlur),
+ KX_PYATTRIBUTE_ENUM_RW("type",RAS_2DFilterManager::RAS_2DFILTER_ENABLED,RAS_2DFilterManager::RAS_2DFILTER_NUMBER_OF_FILTERS,false,SCA_2DFilterActuator,m_type),
+ KX_PYATTRIBUTE_INT_RW("passNb", 0, 100, true, SCA_2DFilterActuator, m_int_arg),
+ KX_PYATTRIBUTE_FLOAT_RW("value", 0.0, 100.0, SCA_2DFilterActuator, m_float_arg),
{ NULL } //Sentinel
};
-PyObject* SCA_2DFilterActuator::py_getattro(PyObject *attr) {
+PyObject* SCA_2DFilterActuator::py_getattro(PyObject *attr)
+{
py_getattro_up(SCA_IActuator);
}
+
+int SCA_2DFilterActuator::py_setattro(PyObject *attr, PyObject* value)
+{
+ py_setattro_up(SCA_IActuator);
+}
+
diff --git a/source/gameengine/GameLogic/SCA_2DFilterActuator.h b/source/gameengine/GameLogic/SCA_2DFilterActuator.h
index f69c680b774..de0201a4b19 100644
--- a/source/gameengine/GameLogic/SCA_2DFilterActuator.h
+++ b/source/gameengine/GameLogic/SCA_2DFilterActuator.h
@@ -1,3 +1,30 @@
+/**
+ * SCA_2DFilterActuator.h
+ *
+ * $Id$
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
#ifndef __SCA_2DFILETRACTUATOR_H__
#define __SCA_2DFILETRACTUATOR_H__
@@ -13,7 +40,7 @@ private:
vector<STR_String> m_propNames;
void * m_gameObj;
RAS_2DFilterManager::RAS_2DFILTER_MODE m_type;
- short m_flag;
+ short m_disableMotionBlur;
float m_float_arg;
int m_int_arg;
STR_String m_shaderText;
@@ -38,7 +65,13 @@ public:
virtual bool Update();
virtual CValue* GetReplica();
+
+ /* --------------------------------------------------------------------- */
+ /* Python interface ---------------------------------------------------- */
+ /* --------------------------------------------------------------------- */
+
virtual PyObject* py_getattro(PyObject *attr);
+ virtual int py_setattro(PyObject *attr, PyObject* value);
};
#endif
diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp
index 8302855577d..88aa042f502 100644
--- a/source/gameengine/Ketsji/KX_PythonInit.cpp
+++ b/source/gameengine/Ketsji/KX_PythonInit.cpp
@@ -61,6 +61,7 @@
#include "RAS_IRasterizer.h"
#include "RAS_ICanvas.h"
#include "RAS_BucketManager.h"
+#include "RAS_2DFilterManager.h"
#include "MT_Vector3.h"
#include "MT_Point3.h"
#include "ListValue.h"
@@ -184,7 +185,7 @@ static PyObject* gPySendMessage(PyObject*, PyObject* args)
char* to = "";
char* from = "";
- if (!PyArg_ParseTuple(args, "s|sss:sendMessage", &subject, &body, &to, &from))
+ if (!PyArg_ParseTuple(args, "s|sss", &subject, &body, &to, &from))
return NULL;
gp_KetsjiScene->GetNetworkScene()->SendMessage(to, from, subject, body);
@@ -1129,6 +1130,23 @@ PyObject* initGameLogic(KX_KetsjiEngine *engine, KX_Scene* scene) // quick hack
KX_MACRO_addTypesToDict(d, KX_MOUSE_BUT_MIDDLE, SCA_IInputDevice::KX_MIDDLEMOUSE);
KX_MACRO_addTypesToDict(d, KX_MOUSE_BUT_RIGHT, SCA_IInputDevice::KX_RIGHTMOUSE);
+ KX_MACRO_addTypesToDict(d, RAS_2DFILTER_ENABLED, RAS_2DFilterManager::RAS_2DFILTER_ENABLED);
+ KX_MACRO_addTypesToDict(d, RAS_2DFILTER_DISABLED, RAS_2DFilterManager::RAS_2DFILTER_DISABLED);
+ KX_MACRO_addTypesToDict(d, RAS_2DFILTER_NOFILTER, RAS_2DFilterManager::RAS_2DFILTER_NOFILTER);
+ KX_MACRO_addTypesToDict(d, RAS_2DFILTER_MOTIONBLUR, RAS_2DFilterManager::RAS_2DFILTER_MOTIONBLUR);
+ KX_MACRO_addTypesToDict(d, RAS_2DFILTER_BLUR, RAS_2DFilterManager::RAS_2DFILTER_BLUR);
+ KX_MACRO_addTypesToDict(d, RAS_2DFILTER_SHARPEN, RAS_2DFilterManager::RAS_2DFILTER_SHARPEN);
+ KX_MACRO_addTypesToDict(d, RAS_2DFILTER_DILATION, RAS_2DFilterManager::RAS_2DFILTER_DILATION);
+ KX_MACRO_addTypesToDict(d, RAS_2DFILTER_EROSION, RAS_2DFilterManager::RAS_2DFILTER_EROSION);
+ KX_MACRO_addTypesToDict(d, RAS_2DFILTER_LAPLACIAN, RAS_2DFilterManager::RAS_2DFILTER_LAPLACIAN);
+ KX_MACRO_addTypesToDict(d, RAS_2DFILTER_SOBEL, RAS_2DFilterManager::RAS_2DFILTER_SOBEL);
+ KX_MACRO_addTypesToDict(d, RAS_2DFILTER_PREWITT, RAS_2DFilterManager::RAS_2DFILTER_PREWITT);
+ KX_MACRO_addTypesToDict(d, RAS_2DFILTER_GRAYSCALE, RAS_2DFilterManager::RAS_2DFILTER_GRAYSCALE);
+ KX_MACRO_addTypesToDict(d, RAS_2DFILTER_SEPIA, RAS_2DFilterManager::RAS_2DFILTER_SEPIA);
+ KX_MACRO_addTypesToDict(d, RAS_2DFILTER_INVERT, RAS_2DFilterManager::RAS_2DFILTER_INVERT);
+ KX_MACRO_addTypesToDict(d, RAS_2DFILTER_CUSTOMFILTER, RAS_2DFilterManager::RAS_2DFILTER_CUSTOMFILTER);
+
+
// Check for errors
if (PyErr_Occurred())
{
@@ -1609,7 +1627,6 @@ PyObject* initGameKeys()
KX_MACRO_addTypesToDict(d, PAGEDOWNKEY, SCA_IInputDevice::KX_PAGEDOWNKEY);
KX_MACRO_addTypesToDict(d, ENDKEY, SCA_IInputDevice::KX_ENDKEY);
-
// Check for errors
if (PyErr_Occurred())
{
diff --git a/source/gameengine/PyDoc/SCA_2DFilterActuator.py b/source/gameengine/PyDoc/SCA_2DFilterActuator.py
new file mode 100644
index 00000000000..12baed6fa0c
--- /dev/null
+++ b/source/gameengine/PyDoc/SCA_2DFilterActuator.py
@@ -0,0 +1,44 @@
+# $Id$
+# Documentation for SCA_2DFilterActuator
+from SCA_IActuator import *
+from SCA_ILogicBrick import *
+
+class SCA_2DFilterActuator(SCA_IActuator):
+ """
+ Create, enable and disable 2D filters
+
+ Properties:
+
+ The following properties don't have an immediate effect.
+ You must active the actuator to get the result.
+ The actuator is not persistent: it automatically stops itself after setting up the filter
+ but the filter remains active. To stop a filter you must activate the actuator with 'type'
+ set to RAS_2DFILTER_DISABLED or RAS_2DFILTER_NOFILTER.
+
+ @ivar shaderText: shader source code for custom shader
+ @type shaderText: string
+ @ivar disableMotionBlur: action on motion blur: 0=enable, 1=disable
+ @type disableMotionBlur: integer
+ @ivar type: type of 2D filter, use one of the following constants:
+ RAS_2DFILTER_ENABLED (-2) : enable the filter that was previously disabled
+ RAS_2DFILTER_DISABLED (-1) : disable the filter that is currently active
+ RAS_2DFILTER_NOFILTER (0) : disable and destroy the filter that is currently active
+ RAS_2DFILTER_MOTIONBLUR (1) : create and enable preset filters
+ RAS_2DFILTER_BLUR (2)
+ RAS_2DFILTER_SHARPEN (3)
+ RAS_2DFILTER_DILATION (4)
+ RAS_2DFILTER_EROSION (5)
+ RAS_2DFILTER_LAPLACIAN (6)
+ RAS_2DFILTER_SOBEL (7)
+ RAS_2DFILTER_PREWITT (8)
+ RAS_2DFILTER_GRAYSCALE (9)
+ RAS_2DFILTER_SEPIA (10)
+ RAS_2DFILTER_INVERT (11)
+ RAS_2DFILTER_CUSTOMFILTER (12) : customer filter, the code code is set via shaderText property
+ @type type: integer
+ @ivar passNb: order number of filter in the stack of 2D filters. Filters are executed in increasing order of passNb.
+ Only be one filter can be defined per passNb.
+ @type passNb: integer (0-100)
+ @ivar value: argument for motion blur filter
+ @type value: float (0.0-100.0)
+ """