Merge from trunk
[blender.git] / source / gameengine / GameLogic / SCA_2DFilterActuator.cpp
1 #include "SCA_IActuator.h"
2
3 #include "SCA_2DFilterActuator.h"
4
5 #ifdef HAVE_CONFIG_H
6 #include <config.h>
7 #endif
8 #include <iostream>
9
10 SCA_2DFilterActuator::~SCA_2DFilterActuator()
11 {
12 }
13
14 SCA_2DFilterActuator::SCA_2DFilterActuator(
15         SCA_IObject *gameobj, 
16         RAS_2DFilterManager::RAS_2DFILTER_MODE type,
17                 short flag,
18                 float float_arg,
19                 int int_arg,
20                 RAS_IRasterizer* rasterizer,
21                 RAS_IRenderTools* rendertools,
22         PyTypeObject* T)
23     : SCA_IActuator(gameobj, T),
24      m_type(type),
25          m_flag(flag),
26          m_float_arg(float_arg),
27          m_int_arg(int_arg),
28          m_rasterizer(rasterizer),
29          m_rendertools(rendertools)
30 {
31         m_gameObj = NULL;
32         if(gameobj){
33                 m_propNames = gameobj->GetPropertyNames();
34                 m_gameObj = gameobj;
35         }
36 }
37
38 void SCA_2DFilterActuator::SetShaderText(STR_String text)
39 {
40         m_shaderText = text;
41 }
42
43
44
45 CValue* SCA_2DFilterActuator::GetReplica()
46 {
47     SCA_2DFilterActuator* replica = new SCA_2DFilterActuator(*this);
48     replica->ProcessReplica();
49     CValue::AddDataToReplica(replica);
50
51     return replica;
52 }
53
54
55 bool SCA_2DFilterActuator::Update()
56 {
57         bool bNegativeEvent = IsNegativeEvent();
58         RemoveAllEvents();
59
60
61         if (bNegativeEvent)
62                 return false; // do nothing on negative events
63
64         if( m_type == RAS_2DFilterManager::RAS_2DFILTER_MOTIONBLUR )
65         {
66                 if(!m_flag)
67                         m_rasterizer->EnableMotionBlur(m_float_arg);
68                 else
69                         m_rasterizer->DisableMotionBlur();
70
71                 return false;
72         }
73         else if(m_type < RAS_2DFilterManager::RAS_2DFILTER_NUMBER_OF_FILTERS)
74         {
75                 m_rendertools->Update2DFilter(m_propNames, m_gameObj, m_type, m_int_arg, m_shaderText);
76         }
77     return true;
78 }
79
80
81 PyTypeObject SCA_2DFilterActuator::Type = {
82         PyObject_HEAD_INIT(&PyType_Type)
83         0,
84         "SCA_2DFilterActuator",
85         sizeof(SCA_2DFilterActuator),
86         0,
87         PyDestructor,
88         0,
89         __getattr,
90         __setattr,
91         0, 
92          __repr,
93         0,
94         0,
95         0,
96         0,
97         0
98 };
99
100
101 PyParentObject SCA_2DFilterActuator::Parents[] = {
102         &SCA_2DFilterActuator::Type,
103         &SCA_IActuator::Type,
104         &SCA_ILogicBrick::Type,
105         &CValue::Type,
106         NULL
107 };
108
109
110 PyMethodDef SCA_2DFilterActuator::Methods[] = {
111     /* add python functions to deal with m_msg... */
112     {NULL,NULL}
113 };
114
115
116 PyObject* SCA_2DFilterActuator::_getattr(const STR_String& attr) {
117     _getattr_up(SCA_IActuator);
118 }