2 * SCA_2DFilterActuator.cpp
6 * ***** BEGIN GPL LICENSE BLOCK *****
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software Foundation,
20 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 * ***** END GPL LICENSE BLOCK *****
26 #include "SCA_IActuator.h"
27 #include "SCA_2DFilterActuator.h"
34 SCA_2DFilterActuator::~SCA_2DFilterActuator()
38 SCA_2DFilterActuator::SCA_2DFilterActuator(
40 RAS_2DFilterManager::RAS_2DFILTER_MODE type,
44 RAS_IRasterizer* rasterizer,
45 RAS_IRenderTools* rendertools,
47 : SCA_IActuator(gameobj, T),
49 m_disableMotionBlur(flag),
50 m_float_arg(float_arg),
52 m_rasterizer(rasterizer),
53 m_rendertools(rendertools)
57 m_propNames = gameobj->GetPropertyNames();
63 CValue* SCA_2DFilterActuator::GetReplica()
65 SCA_2DFilterActuator* replica = new SCA_2DFilterActuator(*this);
66 replica->ProcessReplica();
67 CValue::AddDataToReplica(replica);
73 bool SCA_2DFilterActuator::Update()
75 bool bNegativeEvent = IsNegativeEvent();
80 return false; // do nothing on negative events
82 if( m_type == RAS_2DFilterManager::RAS_2DFILTER_MOTIONBLUR )
84 if(!m_disableMotionBlur)
85 m_rasterizer->EnableMotionBlur(m_float_arg);
87 m_rasterizer->DisableMotionBlur();
91 else if(m_type < RAS_2DFilterManager::RAS_2DFILTER_NUMBER_OF_FILTERS)
93 m_rendertools->Update2DFilter(m_propNames, m_gameObj, m_type, m_int_arg, m_shaderText);
95 // once the filter is in place, no need to update it again => disable the actuator
100 void SCA_2DFilterActuator::SetShaderText(STR_String text)
105 /* ------------------------------------------------------------------------- */
106 /* Python functions */
107 /* ------------------------------------------------------------------------- */
111 /* Integration hooks ------------------------------------------------------- */
112 PyTypeObject SCA_2DFilterActuator::Type = {
113 PyObject_HEAD_INIT(NULL)
115 "SCA_2DFilterActuator",
116 sizeof(SCA_2DFilterActuator),
132 PyParentObject SCA_2DFilterActuator::Parents[] = {
133 &SCA_2DFilterActuator::Type,
134 &SCA_IActuator::Type,
135 &SCA_ILogicBrick::Type,
141 PyMethodDef SCA_2DFilterActuator::Methods[] = {
142 /* add python functions to deal with m_msg... */
146 PyAttributeDef SCA_2DFilterActuator::Attributes[] = {
147 KX_PYATTRIBUTE_STRING_RW("shaderText", 0, 64000, false, SCA_2DFilterActuator, m_shaderText),
148 KX_PYATTRIBUTE_SHORT_RW("disableMotionBlur", 0, 1, true, SCA_2DFilterActuator, m_disableMotionBlur),
149 KX_PYATTRIBUTE_ENUM_RW("type",RAS_2DFilterManager::RAS_2DFILTER_ENABLED,RAS_2DFilterManager::RAS_2DFILTER_NUMBER_OF_FILTERS,false,SCA_2DFilterActuator,m_type),
150 KX_PYATTRIBUTE_INT_RW("passNb", 0, 100, true, SCA_2DFilterActuator, m_int_arg),
151 KX_PYATTRIBUTE_FLOAT_RW("value", 0.0, 100.0, SCA_2DFilterActuator, m_float_arg),
155 PyObject* SCA_2DFilterActuator::py_getattro(PyObject *attr)
157 py_getattro_up(SCA_IActuator);
160 int SCA_2DFilterActuator::py_setattro(PyObject *attr, PyObject* value)
162 py_setattro_up(SCA_IActuator);