93
99
// this will copy properties and so on...
94
100
CValue::AddDataToReplica(replica);
98
bool BL_ActionActuator::Update(double curtime,double deltatime)
104
bool BL_ActionActuator::ClampLocalTime()
106
if (m_startframe < m_endframe)
108
if (m_localtime < m_startframe)
110
m_localtime = m_startframe;
113
else if (m_localtime > m_endframe)
115
m_localtime = m_endframe;
119
if (m_localtime > m_startframe)
121
m_localtime = m_startframe;
124
else if (m_localtime < m_endframe)
126
m_localtime = m_endframe;
133
void BL_ActionActuator::SetStartTime(float curtime)
135
float direction = m_startframe < m_endframe ? 1.0 : -1.0;
137
if (!(m_flag & ACT_FLAG_REVERSE))
138
m_starttime = curtime - direction*(m_localtime - m_startframe)/KX_FIXED_FRAME_PER_SEC;
140
m_starttime = curtime - direction*(m_endframe - m_localtime)/KX_FIXED_FRAME_PER_SEC;
143
void BL_ActionActuator::SetLocalTime(float curtime)
145
float delta_time = (curtime - m_starttime)*KX_FIXED_FRAME_PER_SEC;
147
if (m_endframe < m_startframe)
148
delta_time = -delta_time;
150
if (!(m_flag & ACT_FLAG_REVERSE))
151
m_localtime = m_startframe + delta_time;
153
m_localtime = m_endframe - delta_time;
157
bool BL_ActionActuator::Update(double curtime, bool frame)
100
159
bool bNegativeEvent = false;
101
160
bool bPositiveEvent = false;
108
167
// result = true if animation has to be continued, false if animation stops
109
168
// maybe there are events for us in the queue !
111
for (vector<CValue*>::iterator i=m_events.end(); !(i==m_events.begin());)
114
if ((*i)->GetNumber() == 0.0f)
116
bNegativeEvent = true;
119
bPositiveEvent= true;
171
for (vector<CValue*>::iterator i=m_events.end(); !(i==m_events.begin());)
174
if ((*i)->GetNumber() == 0.0f)
175
bNegativeEvent = true;
177
bPositiveEvent= true;
183
m_flag |= ACT_FLAG_ACTIVE;
187
if (!(m_flag & ACT_FLAG_ACTIVE))
189
m_flag &= ~ACT_FLAG_ACTIVE;
124
193
/* We know that action actuators have been discarded from all non armature objects:
125
194
if we're being called, we're attached to a BL_ArmatureObject */
126
195
BL_ArmatureObject *obj = (BL_ArmatureObject*)GetParent();
127
float length = m_endtime - m_starttime;
196
float length = m_endframe - m_startframe;
129
198
priority = m_priority;
148
217
m_flag &= ~ACT_FLAG_KEYUP;
149
218
m_flag &= ~ACT_FLAG_REVERSE;
150
219
m_flag |= ACT_FLAG_LOCKINPUT;
151
m_localtime = m_starttime;
220
m_localtime = m_startframe;
221
m_starttime = curtime;
154
224
if (bNegativeEvent){
159
229
if (bPositiveEvent){
160
230
if (!(m_flag & ACT_FLAG_LOCKINPUT)){
161
231
m_flag &= ~ACT_FLAG_REVERSE;
232
m_flag &= ~ACT_FLAG_KEYUP;
233
m_flag |= ACT_FLAG_LOCKINPUT;
234
SetStartTime(curtime);
164
237
if (bNegativeEvent){
238
m_flag |= ACT_FLAG_KEYUP;
239
m_flag &= ~ACT_FLAG_LOCKINPUT;
170
245
if (bPositiveEvent){
171
246
if (!(m_flag & ACT_FLAG_LOCKINPUT)){
172
247
m_flag &= ~ACT_FLAG_REVERSE;
248
m_flag |= ACT_FLAG_LOCKINPUT;
249
SetStartTime(curtime);
175
252
else if (bNegativeEvent){
176
253
m_flag |= ACT_FLAG_REVERSE;
254
m_flag &= ~ACT_FLAG_LOCKINPUT;
255
SetStartTime(curtime);
179
258
case ACT_ACTION_PLAY:
203
283
m_lastpos = newpos;
206
if (m_flag & ACT_FLAG_REVERSE)
207
m_localtime -= deltatime* KX_FIXED_FRAME_PER_SEC;
209
m_localtime += deltatime* KX_FIXED_FRAME_PER_SEC;
286
SetLocalTime(curtime);
213
290
/* Check if a wrapping response is needed */
215
if (m_flag & ACT_FLAG_REVERSE){
216
if (m_localtime < m_starttime){
217
m_localtime = m_endtime+(
218
(int)((m_localtime - m_starttime)/length)
224
if (m_localtime > m_endtime){
225
m_localtime = m_starttime+(
226
(int)((m_localtime - m_endtime)/length)
292
if (m_localtime < m_startframe || m_localtime > m_endframe)
294
m_localtime = m_startframe + fmod(m_localtime, length);
234
m_localtime = m_starttime;
299
m_localtime = m_startframe;
236
301
/* Perform post-increment tasks */
237
302
switch (m_playtype){
238
303
case ACT_ACTION_FROM_PROP:
240
305
CValue* propval = GetParent()->GetProperty(m_propname);
242
307
m_localtime = propval->GetNumber();
245
309
if (bNegativeEvent){
268
332
if (m_flag & ACT_FLAG_KEYUP){
269
333
keepgoing = false;
270
m_localtime = m_endtime;
334
m_localtime = m_endframe;
271
335
m_flag &= ~ACT_FLAG_LOCKINPUT;
337
SetStartTime(curtime);
275
340
case ACT_ACTION_PLAY:
277
m_localtime = m_endtime;
342
m_localtime = m_endframe;
278
343
keepgoing = false;
279
344
m_flag &= ~ACT_FLAG_LOCKINPUT;
323
386
blend_poses(m_pose, m_blendpose, 1.0 - newweight, POSE_BLEND);
325
388
/* Increment current blending percentage */
326
m_blendframe+=(deltatime*KX_FIXED_FRAME_PER_SEC);
389
m_blendframe = (curtime - m_blendstart)*KX_FIXED_FRAME_PER_SEC;
327
390
if (m_blendframe>m_blendin)
328
391
m_blendframe = m_blendin;
395
458
{"getProperty", (PyCFunction) BL_ActionActuator::sPyGetProperty, METH_VARARGS, GetProperty_doc},
396
459
{"setChannel", (PyCFunction) BL_ActionActuator::sPySetChannel, METH_VARARGS, SetChannel_doc},
397
460
// {"getChannel", (PyCFunction) BL_ActionActuator::sPyGetChannel, METH_VARARGS},
461
{"getType", (PyCFunction) BL_ActionActuator::sPyGetType, METH_VARARGS, GetType_doc},
462
{"setType", (PyCFunction) BL_ActionActuator::sPySetType, METH_VARARGS, SetType_doc},
399
463
{NULL,NULL} //Sentinel
402
PyObject* BL_ActionActuator::_getattr(char* attr) {
466
PyObject* BL_ActionActuator::_getattr(const STR_String& attr) {
403
467
_getattr_up(SCA_IActuator);
670
734
if (PyArg_ParseTuple(args,"f",&frame))
672
736
m_localtime = frame;
673
if (m_localtime<m_starttime)
674
m_localtime=m_starttime;
675
else if (m_localtime>m_endtime)
676
m_localtime=m_endtime;
737
if (m_localtime<m_startframe)
738
m_localtime=m_startframe;
739
else if (m_localtime>m_endframe)
740
m_localtime=m_endframe;
679
743
Py_INCREF(Py_None);
873
char BL_ActionActuator::GetType_doc[] =
875
"\tReturns the operation mode of the actuator.\n";
876
PyObject* BL_ActionActuator::PyGetType(PyObject* self,
879
return Py_BuildValue("h", m_playtype);
883
char BL_ActionActuator::SetType_doc[] =
885
"\t - mode: Play (0), Flipper (2), LoopStop (3), LoopEnd (4) or Property (6)\n"
886
"\tSet the operation mode of the actuator.\n";
887
PyObject* BL_ActionActuator::PySetType(PyObject* self,
892
if (!PyArg_ParseTuple(args, "h", &typeArg)) {
897
case KX_ACT_ACTION_PLAY:
898
case KX_ACT_ACTION_FLIPPER:
899
case KX_ACT_ACTION_LOOPSTOP:
900
case KX_ACT_ACTION_LOOPEND:
901
case KX_ACT_ACTION_PROPERTY:
902
m_playtype = typeArg;
905
printf("Invalid type for action actuator: %d\n", typeArg); /* error */