[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [19610] trunk/blender/source/gameengine: BGE API cleanup: 2DFilterActuator.

Benoit Bolsee benoit.bolsee at online.be
Wed Apr 8 23:40:55 CEST 2009


Revision: 19610
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=19610
Author:   ben2610
Date:     2009-04-08 23:40:55 +0200 (Wed, 08 Apr 2009)

Log Message:
-----------
BGE API cleanup: 2DFilterActuator.

Modified Paths:
--------------
    trunk/blender/source/gameengine/GameLogic/SCA_2DFilterActuator.cpp
    trunk/blender/source/gameengine/GameLogic/SCA_2DFilterActuator.h
    trunk/blender/source/gameengine/Ketsji/KX_PythonInit.cpp

Added Paths:
-----------
    trunk/blender/source/gameengine/PyDoc/SCA_2DFilterActuator.py

Modified: trunk/blender/source/gameengine/GameLogic/SCA_2DFilterActuator.cpp
===================================================================
--- trunk/blender/source/gameengine/GameLogic/SCA_2DFilterActuator.cpp	2009-04-08 20:19:20 UTC (rev 19609)
+++ trunk/blender/source/gameengine/GameLogic/SCA_2DFilterActuator.cpp	2009-04-08 21:40:55 UTC (rev 19610)
@@ -1,5 +1,29 @@
+/**
+ * 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 @@
         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,13 +59,7 @@
 	}
 }
 
-void SCA_2DFilterActuator::SetShaderText(STR_String text)
-{
-	m_shaderText = text;
-}
 
-
-
 CValue* SCA_2DFilterActuator::GetReplica()
 {
     SCA_2DFilterActuator* replica = new SCA_2DFilterActuator(*this);
@@ -63,7 +81,7 @@
 
 	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 @@
 }
 
 
+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 @@
 
 
 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);
+}
+

Modified: trunk/blender/source/gameengine/GameLogic/SCA_2DFilterActuator.h
===================================================================
--- trunk/blender/source/gameengine/GameLogic/SCA_2DFilterActuator.h	2009-04-08 20:19:20 UTC (rev 19609)
+++ trunk/blender/source/gameengine/GameLogic/SCA_2DFilterActuator.h	2009-04-08 21:40:55 UTC (rev 19610)
@@ -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 @@
 	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 @@
     virtual bool Update();
 
     virtual CValue* GetReplica();
+
+	/* --------------------------------------------------------------------- */
+	/* Python interface ---------------------------------------------------- */
+	/* --------------------------------------------------------------------- */
+
     virtual PyObject* py_getattro(PyObject *attr);
+	virtual int py_setattro(PyObject *attr, PyObject* value);
 
 };
 #endif

Modified: trunk/blender/source/gameengine/Ketsji/KX_PythonInit.cpp
===================================================================
--- trunk/blender/source/gameengine/Ketsji/KX_PythonInit.cpp	2009-04-08 20:19:20 UTC (rev 19609)
+++ trunk/blender/source/gameengine/Ketsji/KX_PythonInit.cpp	2009-04-08 21:40:55 UTC (rev 19610)
@@ -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 @@
 	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 @@
 	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 @@
 	KX_MACRO_addTypesToDict(d, PAGEDOWNKEY, SCA_IInputDevice::KX_PAGEDOWNKEY);
 	KX_MACRO_addTypesToDict(d, ENDKEY, SCA_IInputDevice::KX_ENDKEY);
 
-
 	// Check for errors
 	if (PyErr_Occurred())
     {

Added: trunk/blender/source/gameengine/PyDoc/SCA_2DFilterActuator.py
===================================================================
--- trunk/blender/source/gameengine/PyDoc/SCA_2DFilterActuator.py	                        (rev 0)
+++ trunk/blender/source/gameengine/PyDoc/SCA_2DFilterActuator.py	2009-04-08 21:40:55 UTC (rev 19610)
@@ -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

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list