~ubuntu-branches/ubuntu/lucid/blender/lucid

« back to all changes in this revision

Viewing changes to source/gameengine/Converter/BL_ShapeActionActuator.h

  • Committer: Bazaar Package Importer
  • Author(s): Chris Coulson
  • Date: 2009-08-06 22:32:19 UTC
  • mfrom: (1.2.10 upstream)
  • Revision ID: james.westby@ubuntu.com-20090806223219-8z4eej1u8levu4pz
Tags: 2.49a+dfsg-0ubuntu1
* Merge from debian unstable, remaining changes:
  - debian/control: Build-depend on python-2.6 rather than python-2.5.
  - debian/misc/*.desktop: Add Spanish translation to .desktop 
    files.
  - debian/pyversions: 2.6.
  - debian/rules: Clean *.o of source/blender/python/api2_2x/
* New upstream release (LP: #382153).
* Refreshed patches:
  - 01_sanitize_sys.patch
  - 02_tmp_in_HOME
  - 10_use_systemwide_ftgl
  - 70_portability_platform_detection
* Removed patches merged upstream:
  - 30_fix_python_syntax_warning
  - 90_ubuntu_ffmpeg_52_changes

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/**
2
 
 * $Id: BL_ShapeActionActuator.h 16689 2008-09-22 21:49:48Z ben2610 $
3
 
 *
4
 
 * ***** BEGIN GPL LICENSE BLOCK *****
5
 
 *
6
 
 * This program is free software; you can redistribute it and/or
7
 
 * modify it under the terms of the GNU General Public License
8
 
 * as published by the Free Software Foundation; either version 2
9
 
 * of the License, or (at your option) any later version.
10
 
 *
11
 
 * This program is distributed in the hope that it will be useful,
12
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 
 * GNU General Public License for more details.
15
 
 *
16
 
 * You should have received a copy of the GNU General Public License
17
 
 * along with this program; if not, write to the Free Software Foundation,
18
 
 * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
19
 
 *
20
 
 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
21
 
 * All rights reserved.
22
 
 *
23
 
 * The Original Code is: all of this file.
24
 
 *
25
 
 * Contributor(s): none yet.
26
 
 *
27
 
 * ***** END GPL LICENSE BLOCK *****
28
 
 */
29
 
 
30
 
#ifndef BL_SHAPEACTIONACTUATOR
31
 
#define BL_SHAPEACTIONACTUATOR
32
 
 
33
 
#include "GEN_HashedPtr.h"
34
 
#include "SCA_IActuator.h"
35
 
#include "MT_Point3.h"
36
 
#include <vector>
37
 
 
38
 
struct Key;
39
 
class BL_ShapeActionActuator : public SCA_IActuator  
40
 
{
41
 
public:
42
 
        Py_Header;
43
 
        BL_ShapeActionActuator(SCA_IObject* gameobj,
44
 
                                                const STR_String& propname,
45
 
                                                const STR_String& framepropname,
46
 
                                                float starttime,
47
 
                                                float endtime,
48
 
                                                struct bAction *action,
49
 
                                                short   playtype,
50
 
                                                short   blendin,
51
 
                                                short   priority,
52
 
                                                float   stride,
53
 
                                                PyTypeObject* T=&Type) 
54
 
                : SCA_IActuator(gameobj,T),
55
 
                
56
 
                m_lastpos(0, 0, 0),
57
 
                m_blendframe(0),
58
 
                m_flag(0),
59
 
                m_startframe (starttime),
60
 
                m_endframe(endtime) ,
61
 
                m_starttime(0),
62
 
                m_localtime(starttime),
63
 
                m_lastUpdate(-1),
64
 
                m_blendin(blendin),
65
 
                m_blendstart(0),
66
 
                m_stridelength(stride),
67
 
                m_playtype(playtype),
68
 
                m_priority(priority),
69
 
                m_action(action),
70
 
                m_framepropname(framepropname), 
71
 
                m_propname(propname)
72
 
        {
73
 
        };
74
 
        virtual ~BL_ShapeActionActuator();
75
 
        virtual bool Update(double curtime, bool frame);
76
 
        virtual CValue* GetReplica();
77
 
        virtual void ProcessReplica();
78
 
        
79
 
        void SetBlendTime (float newtime);
80
 
        void BlendShape(struct Key* key, float weigth);
81
 
 
82
 
        KX_PYMETHOD_DOC(BL_ShapeActionActuator,SetAction);
83
 
        KX_PYMETHOD_DOC(BL_ShapeActionActuator,SetBlendin);
84
 
        KX_PYMETHOD_DOC(BL_ShapeActionActuator,SetPriority);
85
 
        KX_PYMETHOD_DOC(BL_ShapeActionActuator,SetStart);
86
 
        KX_PYMETHOD_DOC(BL_ShapeActionActuator,SetEnd);
87
 
        KX_PYMETHOD_DOC(BL_ShapeActionActuator,SetFrame);
88
 
        KX_PYMETHOD_DOC(BL_ShapeActionActuator,SetProperty);
89
 
        KX_PYMETHOD_DOC(BL_ShapeActionActuator,SetFrameProperty);
90
 
        KX_PYMETHOD_DOC(BL_ShapeActionActuator,SetBlendtime);
91
 
        KX_PYMETHOD_DOC(BL_ShapeActionActuator,SetChannel);
92
 
 
93
 
        KX_PYMETHOD_DOC_NOARGS(BL_ShapeActionActuator,GetAction);
94
 
        KX_PYMETHOD_DOC_NOARGS(BL_ShapeActionActuator,GetBlendin);
95
 
        KX_PYMETHOD_DOC_NOARGS(BL_ShapeActionActuator,GetPriority);
96
 
        KX_PYMETHOD_DOC_NOARGS(BL_ShapeActionActuator,GetStart);
97
 
        KX_PYMETHOD_DOC_NOARGS(BL_ShapeActionActuator,GetEnd);
98
 
        KX_PYMETHOD_DOC_NOARGS(BL_ShapeActionActuator,GetFrame);
99
 
        KX_PYMETHOD_DOC_NOARGS(BL_ShapeActionActuator,GetProperty);
100
 
        KX_PYMETHOD_DOC_NOARGS(BL_ShapeActionActuator,GetFrameProperty);
101
 
//      KX_PYMETHOD(BL_ActionActuator,GetChannel);
102
 
        KX_PYMETHOD_DOC_NOARGS(BL_ShapeActionActuator,GetType);
103
 
        KX_PYMETHOD_DOC(BL_ShapeActionActuator,SetType);
104
 
 
105
 
        virtual PyObject* _getattr(const STR_String& attr);
106
 
 
107
 
protected:
108
 
 
109
 
        void SetStartTime(float curtime);
110
 
        void SetLocalTime(float curtime);
111
 
        bool ClampLocalTime();
112
 
 
113
 
        MT_Point3       m_lastpos;
114
 
        float   m_blendframe;
115
 
        int             m_flag;
116
 
        /** The frame this action starts */
117
 
        float   m_startframe;
118
 
        /** The frame this action ends */
119
 
        float   m_endframe;
120
 
        /** The time this action started */
121
 
        float   m_starttime;
122
 
        /** The current time of the action */
123
 
        float   m_localtime;
124
 
        
125
 
        float   m_lastUpdate;
126
 
        float   m_blendin;
127
 
        float   m_blendstart;
128
 
        float   m_stridelength;
129
 
        short   m_playtype;
130
 
        short   m_priority;
131
 
        struct bAction *m_action;
132
 
        STR_String      m_propname;
133
 
        STR_String      m_framepropname;
134
 
        vector<float> m_blendshape;
135
 
};
136
 
 
137
 
#endif
138
 
 
 
1
/**
 
2
 * $Id: BL_ShapeActionActuator.h 19826 2009-04-20 23:17:52Z campbellbarton $
 
3
 *
 
4
 * ***** BEGIN GPL LICENSE BLOCK *****
 
5
 *
 
6
 * This program is free software; you can redistribute it and/or
 
7
 * modify it under the terms of the GNU General Public License
 
8
 * as published by the Free Software Foundation; either version 2
 
9
 * of the License, or (at your option) any later version.
 
10
 *
 
11
 * This program is distributed in the hope that it will be useful,
 
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
 * GNU General Public License for more details.
 
15
 *
 
16
 * You should have received a copy of the GNU General Public License
 
17
 * along with this program; if not, write to the Free Software Foundation,
 
18
 * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
19
 *
 
20
 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
 
21
 * All rights reserved.
 
22
 *
 
23
 * The Original Code is: all of this file.
 
24
 *
 
25
 * Contributor(s): none yet.
 
26
 *
 
27
 * ***** END GPL LICENSE BLOCK *****
 
28
 */
 
29
 
 
30
#ifndef BL_SHAPEACTIONACTUATOR
 
31
#define BL_SHAPEACTIONACTUATOR
 
32
 
 
33
#include "GEN_HashedPtr.h"
 
34
#include "SCA_IActuator.h"
 
35
#include "BL_ActionActuator.h"
 
36
#include "MT_Point3.h"
 
37
#include <vector>
 
38
 
 
39
struct Key;
 
40
class BL_ShapeActionActuator : public SCA_IActuator  
 
41
{
 
42
public:
 
43
        Py_Header;
 
44
        BL_ShapeActionActuator(SCA_IObject* gameobj,
 
45
                                                const STR_String& propname,
 
46
                                                const STR_String& framepropname,
 
47
                                                float starttime,
 
48
                                                float endtime,
 
49
                                                struct bAction *action,
 
50
                                                short   playtype,
 
51
                                                short   blendin,
 
52
                                                short   priority,
 
53
                                                float   stride,
 
54
                                                PyTypeObject* T=&Type) 
 
55
                : SCA_IActuator(gameobj,T),
 
56
                
 
57
                m_lastpos(0, 0, 0),
 
58
                m_blendframe(0),
 
59
                m_flag(0),
 
60
                m_startframe (starttime),
 
61
                m_endframe(endtime) ,
 
62
                m_starttime(0),
 
63
                m_localtime(starttime),
 
64
                m_lastUpdate(-1),
 
65
                m_blendin(blendin),
 
66
                m_blendstart(0),
 
67
                m_stridelength(stride),
 
68
                m_playtype(playtype),
 
69
                m_priority(priority),
 
70
                m_action(action),
 
71
                m_framepropname(framepropname), 
 
72
                m_propname(propname)
 
73
        {
 
74
        };
 
75
        virtual ~BL_ShapeActionActuator();
 
76
        virtual bool Update(double curtime, bool frame);
 
77
        virtual CValue* GetReplica();
 
78
        virtual void ProcessReplica();
 
79
        
 
80
        void SetBlendTime (float newtime);
 
81
        void BlendShape(struct Key* key, float weigth);
 
82
        
 
83
        bAction*        GetAction() { return m_action; }
 
84
        void            SetAction(bAction* act) { m_action= act; }
 
85
 
 
86
        KX_PYMETHOD_DOC_VARARGS(BL_ShapeActionActuator,SetAction);
 
87
        KX_PYMETHOD_DOC_VARARGS(BL_ShapeActionActuator,SetBlendin);
 
88
        KX_PYMETHOD_DOC_VARARGS(BL_ShapeActionActuator,SetPriority);
 
89
        KX_PYMETHOD_DOC_VARARGS(BL_ShapeActionActuator,SetStart);
 
90
        KX_PYMETHOD_DOC_VARARGS(BL_ShapeActionActuator,SetEnd);
 
91
        KX_PYMETHOD_DOC_VARARGS(BL_ShapeActionActuator,SetFrame);
 
92
        KX_PYMETHOD_DOC_VARARGS(BL_ShapeActionActuator,SetProperty);
 
93
        KX_PYMETHOD_DOC_VARARGS(BL_ShapeActionActuator,SetFrameProperty);
 
94
        KX_PYMETHOD_DOC_VARARGS(BL_ShapeActionActuator,SetBlendtime);
 
95
        KX_PYMETHOD_DOC_VARARGS(BL_ShapeActionActuator,SetChannel);
 
96
 
 
97
        KX_PYMETHOD_DOC_NOARGS(BL_ShapeActionActuator,GetAction);
 
98
        KX_PYMETHOD_DOC_NOARGS(BL_ShapeActionActuator,GetBlendin);
 
99
        KX_PYMETHOD_DOC_NOARGS(BL_ShapeActionActuator,GetPriority);
 
100
        KX_PYMETHOD_DOC_NOARGS(BL_ShapeActionActuator,GetStart);
 
101
        KX_PYMETHOD_DOC_NOARGS(BL_ShapeActionActuator,GetEnd);
 
102
        KX_PYMETHOD_DOC_NOARGS(BL_ShapeActionActuator,GetFrame);
 
103
        KX_PYMETHOD_DOC_NOARGS(BL_ShapeActionActuator,GetProperty);
 
104
        KX_PYMETHOD_DOC_NOARGS(BL_ShapeActionActuator,GetFrameProperty);
 
105
//      KX_PYMETHOD(BL_ActionActuator,GetChannel);
 
106
        KX_PYMETHOD_DOC_NOARGS(BL_ShapeActionActuator,GetType);
 
107
        KX_PYMETHOD_DOC_VARARGS(BL_ShapeActionActuator,SetType);
 
108
 
 
109
        virtual PyObject* py_getattro(PyObject* attr);
 
110
        virtual PyObject*               py_getattro_dict();
 
111
        virtual int py_setattro(PyObject* attr, PyObject* value);
 
112
 
 
113
        static PyObject*        pyattr_get_action(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
 
114
        static int                      pyattr_set_action(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
 
115
 
 
116
        static int CheckBlendTime(void *self, const PyAttributeDef*)
 
117
        {
 
118
                BL_ShapeActionActuator* act = reinterpret_cast<BL_ShapeActionActuator*>(self);
 
119
 
 
120
                if (act->m_blendframe > act->m_blendin)
 
121
                        act->m_blendframe = act->m_blendin;
 
122
 
 
123
                return 0;
 
124
        }
 
125
        static int CheckFrame(void *self, const PyAttributeDef*)
 
126
        {
 
127
                BL_ShapeActionActuator* act = reinterpret_cast<BL_ShapeActionActuator*>(self);
 
128
 
 
129
                if (act->m_localtime < act->m_startframe)
 
130
                        act->m_localtime = act->m_startframe;
 
131
                else if (act->m_localtime > act->m_endframe)
 
132
                        act->m_localtime = act->m_endframe;
 
133
 
 
134
                return 0;
 
135
        }
 
136
        static int CheckType(void *self, const PyAttributeDef*)
 
137
        {
 
138
                BL_ShapeActionActuator* act = reinterpret_cast<BL_ShapeActionActuator*>(self);
 
139
 
 
140
                switch (act->m_playtype) {
 
141
                        case ACT_ACTION_PLAY:
 
142
                        case ACT_ACTION_FLIPPER:
 
143
                        case ACT_ACTION_LOOP_STOP:
 
144
                        case ACT_ACTION_LOOP_END:
 
145
                        case ACT_ACTION_FROM_PROP:
 
146
                                return 0;
 
147
                        default:
 
148
                                PyErr_SetString(PyExc_ValueError, "Shape Action Actuator, invalid play type supplied");
 
149
                                return 1;
 
150
                }
 
151
 
 
152
        }
 
153
 
 
154
protected:
 
155
 
 
156
        void SetStartTime(float curtime);
 
157
        void SetLocalTime(float curtime);
 
158
        bool ClampLocalTime();
 
159
 
 
160
        MT_Point3       m_lastpos;
 
161
        float   m_blendframe;
 
162
        int             m_flag;
 
163
        /** The frame this action starts */
 
164
        float   m_startframe;
 
165
        /** The frame this action ends */
 
166
        float   m_endframe;
 
167
        /** The time this action started */
 
168
        float   m_starttime;
 
169
        /** The current time of the action */
 
170
        float   m_localtime;
 
171
        
 
172
        float   m_lastUpdate;
 
173
        float   m_blendin;
 
174
        float   m_blendstart;
 
175
        float   m_stridelength;
 
176
        short   m_playtype;
 
177
        short   m_priority;
 
178
        struct bAction *m_action;
 
179
        STR_String      m_framepropname;
 
180
        STR_String      m_propname;
 
181
        vector<float> m_blendshape;
 
182
};
 
183
 
 
184
#endif
 
185