Blender V2.61 - r43446
|
00001 /* 00002 * SCA_2DFilterActuator.cpp 00003 * 00004 * 00005 * ***** BEGIN GPL LICENSE BLOCK ***** 00006 * 00007 * This program is free software; you can redistribute it and/or 00008 * modify it under the terms of the GNU General Public License 00009 * as published by the Free Software Foundation; either version 2 00010 * of the License, or (at your option) any later version. 00011 * 00012 * This program is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU General Public License 00018 * along with this program; if not, write to the Free Software Foundation, 00019 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00020 * 00021 * 00022 * ***** END GPL LICENSE BLOCK ***** 00023 */ 00024 00030 #include <stddef.h> 00031 00032 #include "SCA_IActuator.h" 00033 #include "SCA_2DFilterActuator.h" 00034 00035 #include <iostream> 00036 00037 SCA_2DFilterActuator::~SCA_2DFilterActuator() 00038 { 00039 } 00040 00041 SCA_2DFilterActuator::SCA_2DFilterActuator( 00042 SCA_IObject *gameobj, 00043 RAS_2DFilterManager::RAS_2DFILTER_MODE type, 00044 short flag, 00045 float float_arg, 00046 int int_arg, 00047 RAS_IRasterizer* rasterizer, 00048 SCA_IScene* scene) 00049 : SCA_IActuator(gameobj, KX_ACT_2DFILTER), 00050 m_type(type), 00051 m_disableMotionBlur(flag), 00052 m_float_arg(float_arg), 00053 m_int_arg(int_arg), 00054 m_rasterizer(rasterizer), 00055 m_scene(scene) 00056 { 00057 m_gameobj = NULL; 00058 if(gameobj){ 00059 m_propNames = gameobj->GetPropertyNames(); 00060 m_gameobj = gameobj; 00061 } 00062 } 00063 00064 00065 CValue* SCA_2DFilterActuator::GetReplica() 00066 { 00067 SCA_2DFilterActuator* replica = new SCA_2DFilterActuator(*this); 00068 replica->ProcessReplica(); 00069 return replica; 00070 } 00071 00072 00073 bool SCA_2DFilterActuator::Update() 00074 { 00075 bool bNegativeEvent = IsNegativeEvent(); 00076 RemoveAllEvents(); 00077 00078 00079 if (bNegativeEvent) 00080 return false; // do nothing on negative events 00081 00082 if( m_type == RAS_2DFilterManager::RAS_2DFILTER_MOTIONBLUR ) 00083 { 00084 if(!m_disableMotionBlur) 00085 m_rasterizer->EnableMotionBlur(m_float_arg); 00086 else 00087 m_rasterizer->DisableMotionBlur(); 00088 00089 return false; 00090 } 00091 else if(m_type < RAS_2DFilterManager::RAS_2DFILTER_NUMBER_OF_FILTERS) 00092 { 00093 m_scene->Update2DFilter(m_propNames, m_gameobj, m_type, m_int_arg, m_shaderText); 00094 } 00095 // once the filter is in place, no need to update it again => disable the actuator 00096 return false; 00097 } 00098 00099 00100 void SCA_2DFilterActuator::SetShaderText(const char *text) 00101 { 00102 m_shaderText = text; 00103 } 00104 00105 #ifdef WITH_PYTHON 00106 00107 /* ------------------------------------------------------------------------- */ 00108 /* Python functions */ 00109 /* ------------------------------------------------------------------------- */ 00110 00111 /* Integration hooks ------------------------------------------------------- */ 00112 PyTypeObject SCA_2DFilterActuator::Type = { 00113 PyVarObject_HEAD_INIT(NULL, 0) 00114 "SCA_2DFilterActuator", 00115 sizeof(PyObjectPlus_Proxy), 00116 0, 00117 py_base_dealloc, 00118 0, 00119 0, 00120 0, 00121 0, 00122 py_base_repr, 00123 0,0,0,0,0,0,0,0,0, 00124 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, 00125 0,0,0,0,0,0,0, 00126 Methods, 00127 0, 00128 0, 00129 &SCA_IActuator::Type, 00130 0,0,0,0,0,0, 00131 py_base_new 00132 }; 00133 00134 PyMethodDef SCA_2DFilterActuator::Methods[] = { 00135 /* add python functions to deal with m_msg... */ 00136 {NULL,NULL} 00137 }; 00138 00139 PyAttributeDef SCA_2DFilterActuator::Attributes[] = { 00140 KX_PYATTRIBUTE_STRING_RW("shaderText", 0, 64000, false, SCA_2DFilterActuator, m_shaderText), 00141 KX_PYATTRIBUTE_SHORT_RW("disableMotionBlur", 0, 1, true, SCA_2DFilterActuator, m_disableMotionBlur), 00142 KX_PYATTRIBUTE_ENUM_RW("mode",RAS_2DFilterManager::RAS_2DFILTER_ENABLED,RAS_2DFilterManager::RAS_2DFILTER_NUMBER_OF_FILTERS,false,SCA_2DFilterActuator,m_type), 00143 KX_PYATTRIBUTE_INT_RW("passNumber", 0, 100, true, SCA_2DFilterActuator, m_int_arg), 00144 KX_PYATTRIBUTE_FLOAT_RW("value", 0.0, 100.0, SCA_2DFilterActuator, m_float_arg), 00145 { NULL } //Sentinel 00146 }; 00147 00148 #endif