merging trunk 17520:19093
[blender.git] / source / gameengine / Converter / KX_ConvertActuators.cpp
1 /**
2 * $Id$
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 * Convert Blender actuators for use in the GameEngine
29 */
30
31 #ifdef WIN32
32 #pragma warning (disable : 4786) 
33 #endif //WIN32
34
35 #define BLENDER_HACK_DTIME 0.02
36
37 #include "MEM_guardedalloc.h"
38
39 #include "KX_BlenderSceneConverter.h"
40 #include "KX_ConvertActuators.h"
41
42 // Actuators
43 //SCA logiclibrary native logicbricks
44 #include "SCA_PropertyActuator.h"
45 #include "SCA_LogicManager.h"
46 #include "SCA_RandomActuator.h"
47 #include "SCA_2DFilterActuator.h"
48
49 // Ketsji specific logicbricks
50 #include "KX_SceneActuator.h"
51 #include "KX_IpoActuator.h"
52 #include "KX_SoundActuator.h"
53 #include "KX_CDActuator.h"
54 #include "KX_ObjectActuator.h"
55 #include "KX_TrackToActuator.h"
56 #include "KX_ConstraintActuator.h"
57 #include "KX_CameraActuator.h"
58 #include "KX_GameActuator.h"
59 #include "KX_StateActuator.h"
60 #include "KX_VisibilityActuator.h"
61 #include "KX_SCA_AddObjectActuator.h"
62 #include "KX_SCA_EndObjectActuator.h"
63 #include "KX_SCA_ReplaceMeshActuator.h"
64 #include "KX_ParentActuator.h"
65 #include "KX_SCA_DynamicActuator.h"
66
67 #include "KX_Scene.h"
68 #include "KX_KetsjiEngine.h"
69
70 #include "IntValue.h"
71 #include "KX_GameObject.h"
72
73 /* This little block needed for linking to Blender... */
74 #include "BKE_text.h"
75 #include "BLI_blenlib.h"
76
77 #define FILE_MAX 240 // repeated here to avoid dependency from BKE_utildefines.h
78
79 #include "KX_NetworkMessageActuator.h"
80
81 #ifdef WIN32
82 #include "BLI_winstuff.h"
83 #endif
84
85 #include "DNA_object_types.h"
86 #include "DNA_sound_types.h"
87 #include "DNA_scene_types.h"
88 #include "DNA_actuator_types.h"
89 #include "DNA_packedFile_types.h"
90 #include "BL_ActionActuator.h"
91 #include "BL_ShapeActionActuator.h"
92 /* end of blender include block */
93
94 #include "BL_BlenderDataConversion.h"
95
96 /** 
97 KX_BLENDERTRUNC needed to round 'almost' zero values to zero, else velocities etc. are incorrectly set 
98 */
99
100 #define KX_BLENDERTRUNC(x)  (( x < 0.0001 && x > -0.0001 )  ? 0.0 : x)
101
102 void BL_ConvertActuators(char* maggiename,
103                                                  struct Object* blenderobject,
104                                                  KX_GameObject* gameobj,
105                                                  SCA_LogicManager* logicmgr,
106                                                  KX_Scene* scene,
107                                                  KX_KetsjiEngine* ketsjiEngine,
108                                                  int & executePriority, 
109                                                  int activeLayerBitInfo,
110                                                  bool isInActiveLayer,
111                                                  RAS_IRenderTools* rendertools,
112                                                  KX_BlenderSceneConverter* converter
113                                                  )
114 {
115         
116         int uniqueint = 0;
117         bActuator* bact = (bActuator*) blenderobject->actuators.first;
118         while(bact)
119         {
120                 STR_String uniquename = bact->name;
121                 STR_String objectname = gameobj->GetName();
122                 
123                 SCA_IActuator* baseact = NULL;
124                 switch (bact->type)
125                 {
126                 case ACT_OBJECT:
127                         {
128                                 bObjectActuator* obact = (bObjectActuator*) bact->data;
129                                 MT_Vector3 forcevec(KX_BLENDERTRUNC(obact->forceloc[0]),
130                                         KX_BLENDERTRUNC(obact->forceloc[1]),
131                                         KX_BLENDERTRUNC(obact->forceloc[2]));
132                                 MT_Vector3 torquevec(obact->forcerot[0],obact->forcerot[1],obact->forcerot[2]);
133                                 MT_Vector3 dlocvec ( KX_BLENDERTRUNC(obact->dloc[0]),
134                                         KX_BLENDERTRUNC(obact->dloc[1]),
135                                         KX_BLENDERTRUNC(obact->dloc[2]));
136                                 MT_Vector3 drotvec ( KX_BLENDERTRUNC(obact->drot[0]),obact->drot[1],obact->drot[2]);
137                                 MT_Vector3 linvelvec ( KX_BLENDERTRUNC(obact->linearvelocity[0]),
138                                         KX_BLENDERTRUNC(obact->linearvelocity[1]),
139                                         KX_BLENDERTRUNC(obact->linearvelocity[2]));
140                                 MT_Vector3 angvelvec ( KX_BLENDERTRUNC(obact->angularvelocity[0]),
141                                         KX_BLENDERTRUNC(obact->angularvelocity[1]),
142                                         KX_BLENDERTRUNC(obact->angularvelocity[2]));
143                                 short damping = obact->damping;
144                                 
145                                 drotvec /=              BLENDER_HACK_DTIME;
146                                 //drotvec /=            BLENDER_HACK_DTIME;
147                                 drotvec *= MT_2_PI/360.0;
148                                 //dlocvec /= BLENDER_HACK_DTIME;
149                                 //linvelvec /=  BLENDER_HACK_DTIME;
150                                 //angvelvec /=  BLENDER_HACK_DTIME;
151                                 
152                                 /* Blender uses a bit vector internally for the local-flags. In */
153                                 /* KX, we have four bools. The compiler should be smart enough  */
154                                 /* to do the right thing. We need to explicitly convert here!   */
155                                 
156                                 KX_LocalFlags bitLocalFlag;
157                                 
158                                 bitLocalFlag.Force = bool((obact->flag & ACT_FORCE_LOCAL)!=0);
159                                 bitLocalFlag.Torque = bool((obact->flag & ACT_TORQUE_LOCAL) !=0);//rlocal;
160                                 bitLocalFlag.DLoc = bool((obact->flag & ACT_DLOC_LOCAL)!=0);
161                                 bitLocalFlag.DRot = bool((obact->flag & ACT_DROT_LOCAL)!=0);
162                                 bitLocalFlag.LinearVelocity = bool((obact->flag & ACT_LIN_VEL_LOCAL)!=0);
163                                 bitLocalFlag.AngularVelocity = bool((obact->flag & ACT_ANG_VEL_LOCAL)!=0);
164                                 bitLocalFlag.ServoControl = bool(obact->type == ACT_OBJECT_SERVO);
165                                 bitLocalFlag.AddOrSetLinV = bool((obact->flag & ACT_ADD_LIN_VEL)!=0);
166                                 
167                                 
168                                 KX_ObjectActuator* tmpbaseact = new KX_ObjectActuator(gameobj,
169                                         forcevec.getValue(),
170                                         torquevec.getValue(),
171                                         dlocvec.getValue(),
172                                         drotvec.getValue(),
173                                         linvelvec.getValue(),
174                                         angvelvec.getValue(),
175                                         damping,
176                                         bitLocalFlag
177                                         );
178                                 baseact = tmpbaseact;
179                                 break;
180                         }
181                 case ACT_ACTION:
182                         {
183                                 if (blenderobject->type==OB_ARMATURE){
184                                         bActionActuator* actact = (bActionActuator*) bact->data;
185                                         STR_String propname = (actact->name ? actact->name : "");
186                                         STR_String propframe = (actact->frameProp ? actact->frameProp : "");
187                                         
188                                         BL_ActionActuator* tmpbaseact = new BL_ActionActuator(
189                                                 gameobj,
190                                                 propname,
191                                                 propframe,
192                                                 actact->sta,
193                                                 actact->end,
194                                                 actact->act,
195                                                 actact->type, // + 1, because Blender starts to count at zero,
196                                                 actact->blendin,
197                                                 actact->priority,
198                                                 actact->end_reset,
199                                                 actact->stridelength
200                                                 // Ketsji at 1, because zero is reserved for "NoDef"
201                                                 );
202                                         baseact= tmpbaseact;
203                                         break;
204                                 }
205                                 else
206                                         printf ("Discarded action actuator from non-armature object [%s]\n", blenderobject->id.name+2);
207                         }
208                 case ACT_SHAPEACTION:
209                         {
210                                 if (blenderobject->type==OB_MESH){
211                                         bActionActuator* actact = (bActionActuator*) bact->data;
212                                         STR_String propname = (actact->name ? actact->name : "");
213                                         STR_String propframe = (actact->frameProp ? actact->frameProp : "");
214                                         
215                                         BL_ShapeActionActuator* tmpbaseact = new BL_ShapeActionActuator(
216                                                 gameobj,
217                                                 propname,
218                                                 propframe,
219                                                 actact->sta,
220                                                 actact->end,
221                                                 actact->act,
222                                                 actact->type, // + 1, because Blender starts to count at zero,
223                                                 actact->blendin,
224                                                 actact->priority,
225                                                 actact->stridelength
226                                                 // Ketsji at 1, because zero is reserved for "NoDef"
227                                                 );
228                                         baseact= tmpbaseact;
229                                         break;
230                                 }
231                                 else
232                                         printf ("Discarded shape action actuator from non-mesh object [%s]\n", blenderobject->id.name+2);
233                         }
234                 case ACT_IPO:
235                         {
236                                 bIpoActuator* ipoact = (bIpoActuator*) bact->data;
237                                 bool ipochild = (ipoact->flag & ACT_IPOCHILD) !=0;
238                                 STR_String propname = ipoact->name;
239                                 STR_String frameProp = ipoact->frameProp;
240                                 // first bit?
241                                 bool ipo_as_force = (ipoact->flag & ACT_IPOFORCE);
242                                 bool local = (ipoact->flag & ACT_IPOLOCAL);
243                                 bool ipo_add = (ipoact->flag & ACT_IPOADD);
244                                 
245                                 KX_IpoActuator* tmpbaseact = new KX_IpoActuator(
246                                         gameobj,
247                                         propname ,
248                                         frameProp,
249                                         ipoact->sta,
250                                         ipoact->end,
251                                         ipochild,
252                                         ipoact->type + 1, // + 1, because Blender starts to count at zero,
253                                         // Ketsji at 1, because zero is reserved for "NoDef"
254                                         ipo_as_force,
255                                         ipo_add,
256                                         local);
257                                 baseact = tmpbaseact;
258                                 break;
259                         }
260                 case ACT_LAMP:
261                         {
262                                 break;
263                         }
264                 case ACT_CAMERA:
265                         {
266                                 bCameraActuator *camact = (bCameraActuator *) bact->data;
267                                 if (camact->ob) {
268                                         KX_GameObject *tmpgob = converter->FindGameObject(camact->ob);
269                                         
270                                         /* visifac, fac and axis are not copied from the struct...   */ 
271                                         /* that's some internal state...                             */
272                                         KX_CameraActuator *tmpcamact
273                                                 = new KX_CameraActuator(gameobj,
274                                                 tmpgob,
275                                                 camact->height,
276                                                 camact->min,
277                                                 camact->max,
278                                                 camact->axis=='x');
279                                         baseact = tmpcamact;
280                                 }
281                                 break;
282                         }
283                 case ACT_MESSAGE:
284                         {
285                                 bMessageActuator *msgAct = (bMessageActuator *) bact->data;
286                                 
287                                 /**
288                                 * Get the name of the properties that objects must own that
289                                 * we're sending to, if present
290                                 */
291                                 STR_String toPropName = (msgAct->toPropName
292                                         ? (char*) msgAct->toPropName
293                                         : "");
294                                 /* BGE Wants "OB" prefix */
295                                 if (toPropName != "")
296                                         toPropName = "OB" + toPropName;
297                                 
298                                 /**
299                                 * Get the Message Subject to send.
300                                 */
301                                 STR_String subject = (msgAct->subject
302                                         ? (char*) msgAct->subject
303                                         : "");
304                                 
305                                 /**
306                                 * Get the bodyType
307                                 */
308                                 int bodyType = msgAct->bodyType;
309                                 
310                                 /**
311                                 * Get the body (text message or property name whose value
312                                 * we'll be sending, might be empty
313                                 */
314                                 STR_String body = (msgAct->body
315                                         ? (char*) msgAct->body
316                                         : "");
317                                 
318                                 KX_NetworkMessageActuator *tmpmsgact = 
319                                         new KX_NetworkMessageActuator(
320                                         gameobj,                                        // actuator controlling object
321                                         scene->GetNetworkScene(),       // needed for replication
322                                         toPropName,
323                                         subject,
324                                         bodyType,
325                                         body);
326                                 baseact = tmpmsgact;
327                                 break;
328                         }
329                 case ACT_MATERIAL:
330                         {
331                                 break;
332                         }
333                 case ACT_SOUND:
334                         {
335                                 bSoundActuator* soundact = (bSoundActuator*) bact->data;
336                                 /* get type, and possibly a start and end frame */
337                                 short startFrame = soundact->sta, stopFrame = soundact->end;
338                                 KX_SoundActuator::KX_SOUNDACT_TYPE 
339                                         soundActuatorType = KX_SoundActuator::KX_SOUNDACT_NODEF;
340                                 
341                                 switch(soundact->type) {
342                                 case ACT_SND_PLAY_STOP_SOUND:
343                                         soundActuatorType = KX_SoundActuator::KX_SOUNDACT_PLAYSTOP;
344                                         break;
345                                 case ACT_SND_PLAY_END_SOUND:
346                                         soundActuatorType = KX_SoundActuator::KX_SOUNDACT_PLAYEND;
347                                         break;
348                                 case ACT_SND_LOOP_STOP_SOUND:
349                                         soundActuatorType = KX_SoundActuator::KX_SOUNDACT_LOOPSTOP;
350                                         break;
351                                 case ACT_SND_LOOP_END_SOUND:
352                                         soundActuatorType = KX_SoundActuator::KX_SOUNDACT_LOOPEND;
353                                         break;
354                                 case ACT_SND_LOOP_BIDIRECTIONAL_SOUND:
355                                         soundActuatorType = KX_SoundActuator::KX_SOUNDACT_LOOPBIDIRECTIONAL;
356                                         break;
357                                 case ACT_SND_LOOP_BIDIRECTIONAL_STOP_SOUND:
358                                         soundActuatorType = KX_SoundActuator::KX_SOUNDACT_LOOPBIDIRECTIONAL_STOP;
359                                         break;
360                                         
361                                 default:
362                                         /* This is an error!!! */
363                                         soundActuatorType = KX_SoundActuator::KX_SOUNDACT_NODEF;
364                                 }
365                                 
366                                 if (soundActuatorType != KX_SoundActuator::KX_SOUNDACT_NODEF) 
367                                 {
368                                         SND_Scene* soundscene = scene->GetSoundScene();
369                                         STR_String samplename = "";
370                                         bool sampleisloaded = false;
371                                         
372                                         if (soundact->sound) {
373                                                 /* Need to convert the samplename into absolute path
374                                                  * before checking if its loaded */
375                                                 char fullpath[FILE_MAX];
376                                                 
377                                                 /* dont modify soundact->sound->name, only change a copy */
378                                                 BLI_strncpy(fullpath, soundact->sound->name, sizeof(fullpath));
379                                                 BLI_convertstringcode(fullpath, maggiename);
380                                                 samplename = fullpath;
381                                                 
382                                                 /* let's see if the sample was already loaded */
383                                                 if (soundscene->IsSampleLoaded(samplename))
384                                                 {
385                                                         sampleisloaded = true;
386                                                 }
387                                                 else {
388                                                         /* if not, make it so */
389                                                         PackedFile* pf = soundact->sound->newpackedfile;
390                                                         
391                                                         /* but we need a packed file then */
392                                                         if (pf)
393                                                         {
394                                                                 if (soundscene->LoadSample(samplename, pf->data, pf->size) > -1)
395                                                                         sampleisloaded = true;
396                                                         }
397                                                         /* or else load it from disk */
398                                                         else
399                                                         {
400                                                                 if (soundscene->LoadSample(samplename, NULL, 0) > -1) {
401                                                                         sampleisloaded = true;
402                                                                 }
403                                                                 else {
404                                                                         std::cout <<    "WARNING: Sound actuator \"" << bact->name <<
405                                                                                                         "\" from object \"" <<  blenderobject->id.name+2 <<
406                                                                                                         "\" failed to load sample." << std::endl;
407                                                                 }
408                                                         }
409                                                 }
410                                         } else {
411                                                 std::cout <<    "WARNING: Sound actuator \"" << bact->name <<
412                                                                                 "\" from object \"" <<  blenderobject->id.name+2 <<
413                                                                                 "\" has no sound datablock." << std::endl;
414                                         }
415                                         
416                                         /* Note, allowing actuators for sounds that are not there was added since 2.47
417                                          * This is because python may expect the actuator and raise an exception if it dosnt find it
418                                          * better just to add a dummy sound actuator. */
419                                         SND_SoundObject* sndobj = NULL;
420                                         if (sampleisloaded)
421                                         {
422                                                 /* setup the SND_SoundObject */
423                                                 sndobj = new SND_SoundObject();
424                                                 sndobj->SetSampleName(samplename.Ptr());
425                                                 sndobj->SetObjectName(bact->name);
426                                                 if (soundact->sound) {
427                                                         sndobj->SetRollOffFactor(soundact->sound->attenuation);
428                                                         sndobj->SetGain(soundact->sound->volume);
429                                                         sndobj->SetPitch(exp((soundact->sound->pitch / 12.0) * log(2.0)));
430                                                         //                                                      sndobj->SetLoopStart(soundact->sound->loopstart);
431                                                         //                                                      sndobj->SetLoopStart(soundact->sound->loopend);
432                                                         if (soundact->sound->flags & SOUND_FLAGS_LOOP)
433                                                         {
434                                                                 if (soundact->sound->flags & SOUND_FLAGS_BIDIRECTIONAL_LOOP)
435                                                                         sndobj->SetLoopMode(SND_LOOP_BIDIRECTIONAL);
436                                                                 else
437                                                                         sndobj->SetLoopMode(SND_LOOP_NORMAL);
438                                                         }
439                                                         else {
440                                                                 sndobj->SetLoopMode(SND_LOOP_OFF);
441                                                         }
442                                                         
443                                                         if (soundact->sound->flags & SOUND_FLAGS_PRIORITY)
444                                                                 sndobj->SetHighPriority(true);
445                                                         else
446                                                                 sndobj->SetHighPriority(false);
447                                                         
448                                                         if (soundact->sound->flags & SOUND_FLAGS_3D)
449                                                                 sndobj->Set3D(true);
450                                                         else
451                                                                 sndobj->Set3D(false);
452                                                 }
453                                                 else {
454                                                         /* dummy values for a NULL sound
455                                                         * see editsound.c - defaults are unlikely to change soon */
456                                                         sndobj->SetRollOffFactor(1.0);
457                                                         sndobj->SetGain(1.0);
458                                                         sndobj->SetPitch(1.0);
459                                                         sndobj->SetLoopMode(SND_LOOP_OFF);
460                                                         sndobj->SetHighPriority(false);
461                                                         sndobj->Set3D(false);
462                                                 }
463                                         }
464                                         KX_SoundActuator* tmpsoundact = 
465                                                 new KX_SoundActuator(gameobj, 
466                                                 sndobj,
467                                                 scene->GetSoundScene(), // needed for replication!
468                                                 soundActuatorType,
469                                                 startFrame,
470                                                 stopFrame);
471                                         
472                                         tmpsoundact->SetName(bact->name);
473                                         baseact = tmpsoundact;
474                                         if (sndobj)
475                                                 soundscene->AddObject(sndobj);
476                                 }
477                                 break;
478                         }
479                 case ACT_CD:
480                         {
481                                 bCDActuator* cdact = (bCDActuator*) bact->data;
482                                 /* get type, and possibly a start and end frame */
483                                 short startFrame = cdact->sta, stopFrame = cdact->end;
484                                 KX_CDActuator::KX_CDACT_TYPE 
485                                         cdActuatorType = KX_CDActuator::KX_CDACT_NODEF;
486                                 
487                                 switch(cdact->type)
488                                 {
489                                 case ACT_CD_PLAY_ALL:
490                                         cdActuatorType = KX_CDActuator::KX_CDACT_PLAY_ALL;
491                                         break;
492                                 case ACT_CD_PLAY_TRACK:
493                                         cdActuatorType = KX_CDActuator::KX_CDACT_PLAY_TRACK;
494                                         break;
495                                 case ACT_CD_LOOP_TRACK:
496                                         cdActuatorType = KX_CDActuator::KX_CDACT_LOOP_TRACK;
497                                         break;
498                                 case ACT_CD_VOLUME:
499                                         cdActuatorType = KX_CDActuator::KX_CDACT_VOLUME;
500                                         break;
501                                 case ACT_CD_STOP:
502                                         cdActuatorType = KX_CDActuator::KX_CDACT_STOP;
503                                         break;
504                                 case ACT_CD_PAUSE:
505                                         cdActuatorType = KX_CDActuator::KX_CDACT_PAUSE;
506                                         break;
507                                 case ACT_CD_RESUME:
508                                         cdActuatorType = KX_CDActuator::KX_CDACT_RESUME;
509                                         break;
510                                         
511                                 default:
512                                         /* This is an error!!! */
513                                         cdActuatorType = KX_CDActuator::KX_CDACT_NODEF;
514                                 }
515                                 
516                                 if (cdActuatorType != KX_CDActuator::KX_CDACT_NODEF) 
517                                 {
518                                         SND_CDObject* pCD = SND_CDObject::Instance();
519                                         
520                                         if (pCD)
521                                         {
522                                                 pCD->SetGain(cdact->volume);
523                                                 
524                                                 KX_CDActuator* tmpcdact = 
525                                                         new KX_CDActuator(gameobj, 
526                                                         scene->GetSoundScene(), // needed for replication!
527                                                         cdActuatorType,
528                                                         cdact->track,
529                                                         startFrame,
530                                                         stopFrame);
531                                                 
532                                                 tmpcdact->SetName(bact->name);
533                                                 baseact = tmpcdact;
534                                         }
535                                 }
536                                 break;
537                         }
538                 case ACT_PROPERTY:
539                         {
540                                 bPropertyActuator* propact = (bPropertyActuator*) bact->data;
541                                 SCA_IObject* destinationObj = NULL;
542                                 
543                                 /*
544                                 here the destinationobject is searched. problem with multiple scenes: other scenes
545                                 have not been converted yet, so the destobj will not be found, so the prop will
546                                 not be copied.
547                                 possible solutions:
548                                 - convert everything when possible and not realtime only when needed.
549                                 - let the object-with-property report itself to the act when converted
550                                 */
551                                 if (propact->ob)
552                                         destinationObj = converter->FindGameObject(propact->ob);
553                                 
554                                 SCA_PropertyActuator* tmppropact = new SCA_PropertyActuator(
555                                         gameobj,
556                                         destinationObj,
557                                         propact->name,
558                                         propact->value,
559                                         propact->type+1); // + 1 because Ketsji Logic starts
560                                 // with 0 for KX_ACT_PROP_NODEF
561                                 baseact = tmppropact;
562                                 break;
563                         }
564                 case ACT_EDIT_OBJECT:
565                         {
566                                 bEditObjectActuator *editobact 
567                                         = (bEditObjectActuator *) bact->data;
568                                 /* There are four different kinds of 'edit object' thingies  */
569                                 /* The alternative to this lengthy conversion is packing     */
570                                 /* several actuators in one, which is not very nice design.. */
571                                 switch (editobact->type) {
572                                 case ACT_EDOB_ADD_OBJECT: 
573                                         {
574                                                 
575                                                 // does the 'original' for replication exists, and 
576                                                 // is it in a non-active layer ?
577                                                 SCA_IObject* originalval = NULL;
578                                                 if (editobact->ob)
579                                                 {
580                                                         if (editobact->ob->lay & activeLayerBitInfo)
581                                                         {
582                                                                 fprintf(stderr, "Warning, object \"%s\" from AddObject actuator \"%s\" is not in a hidden layer.\n", objectname.Ptr(), uniquename.Ptr());
583                                                         }
584                                                         else {
585                                                                 originalval = converter->FindGameObject(editobact->ob);
586                                                         }
587                                                 }
588                                                 MT_Vector3 linvelvec (
589                                                         KX_BLENDERTRUNC(editobact->linVelocity[0]),
590                                                         KX_BLENDERTRUNC(editobact->linVelocity[1]),
591                                                         KX_BLENDERTRUNC(editobact->linVelocity[2]));
592                                                 
593                                                 MT_Vector3 angvelvec (
594                                                         KX_BLENDERTRUNC(editobact->angVelocity[0]),
595                                                         KX_BLENDERTRUNC(editobact->angVelocity[1]),
596                                                         KX_BLENDERTRUNC(editobact->angVelocity[2]));
597                                                 
598                                                 KX_SCA_AddObjectActuator* tmpaddact = 
599                                                         new KX_SCA_AddObjectActuator(
600                                                                 gameobj, 
601                                                                 originalval,
602                                                                 editobact->time,
603                                                                 scene,
604                                                                 linvelvec.getValue(),
605                                                                 (editobact->localflag & ACT_EDOB_LOCAL_LINV)!=0,
606                                                                 angvelvec.getValue(),
607                                                                 (editobact->localflag & ACT_EDOB_LOCAL_ANGV)!=0
608                                                                 );
609                                                                 
610                                                                 //editobact->ob to gameobj
611                                                                 baseact = tmpaddact;
612                                         }
613                                         break;
614                                 case ACT_EDOB_END_OBJECT:
615                                         {
616                                                 KX_SCA_EndObjectActuator* tmpendact 
617                                                         = new KX_SCA_EndObjectActuator(gameobj,scene);
618                                                 baseact = tmpendact;
619                                         }
620                                         break;
621                                 case ACT_EDOB_REPLACE_MESH:
622                                         {
623                                                 RAS_MeshObject *tmpmesh = NULL;
624                                                 if (editobact->me)
625                                                         tmpmesh = BL_ConvertMesh(
626                                                                 editobact->me,
627                                                                 blenderobject,
628                                                                 rendertools,
629                                                                 scene,
630                                                                 converter
631                                                                 );
632
633                                                 KX_SCA_ReplaceMeshActuator* tmpreplaceact
634                                                         = new KX_SCA_ReplaceMeshActuator(
635                                                                 gameobj,
636                                                                 tmpmesh,
637                                                                 scene
638                                                                 );
639                                                         
640                                                         baseact = tmpreplaceact;
641                                         }
642                                         break;
643                                 case ACT_EDOB_TRACK_TO:
644                                         {
645                                                 SCA_IObject* originalval = NULL;
646                                                 if (editobact->ob)
647                                                         originalval = converter->FindGameObject(editobact->ob);
648                                                         
649                                                 KX_TrackToActuator* tmptrackact 
650                                                         = new KX_TrackToActuator(gameobj, 
651                                                                 originalval,
652                                                                 editobact->time,
653                                                                 editobact->flag,
654                                                                 blenderobject->trackflag,
655                                                                 blenderobject->upflag
656                                                                 );
657                                                         baseact = tmptrackact;
658                                                 break;
659                                         }
660                                 case ACT_EDOB_DYNAMICS:
661                                         {
662                                                 KX_SCA_DynamicActuator* tmpdynact 
663                                                         = new KX_SCA_DynamicActuator(gameobj, 
664                                                                 editobact->dyn_operation,
665                                                                 editobact->mass
666                                                                 );
667                                                         baseact = tmpdynact;
668                                         }
669                                 }
670                                 break;
671                         }
672                 case ACT_CONSTRAINT:
673                         {
674                                 float min = 0.0, max = 0.0;
675                                 char *prop = NULL;
676                                 KX_ConstraintActuator::KX_CONSTRAINTTYPE locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_NODEF;
677                                 bConstraintActuator *conact 
678                                         = (bConstraintActuator*) bact->data;
679                                 /* convert settings... degrees in the ui become radians  */ 
680                                 /* internally                                            */ 
681                                 if (conact->type == ACT_CONST_TYPE_ORI) {
682                                         min = (MT_2_PI * conact->minloc[0])/360.0;
683                                         max = (MT_2_PI * conact->maxloc[0])/360.0;
684                                         switch (conact->mode) {
685                                         case ACT_CONST_DIRPX:
686                                                 locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_ORIX;
687                                                 break;
688                                         case ACT_CONST_DIRPY:
689                                                 locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_ORIY;
690                                                 break;
691                                         case ACT_CONST_DIRPZ:
692                                                 locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_ORIZ;
693                                                 break;
694                                         }
695                                 } else if (conact->type == ACT_CONST_TYPE_DIST) {
696                                         switch (conact->mode) {
697                                         case ACT_CONST_DIRPX:
698                                                 locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_DIRPX;
699                                                 min = conact->minloc[0];
700                                                 max = conact->maxloc[0];
701                                                 break;
702                                         case ACT_CONST_DIRPY:
703                                                 locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_DIRPY;
704                                                 min = conact->minloc[1];
705                                                 max = conact->maxloc[1];
706                                                 break;
707                                         case ACT_CONST_DIRPZ:
708                                                 locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_DIRPZ;
709                                                 min = conact->minloc[2];
710                                                 max = conact->maxloc[2];
711                                                 break;
712                                         case ACT_CONST_DIRNX:
713                                                 locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_DIRNX;
714                                                 min = conact->minloc[0];
715                                                 max = conact->maxloc[0];
716                                                 break;
717                                         case ACT_CONST_DIRNY:
718                                                 locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_DIRNY;
719                                                 min = conact->minloc[1];
720                                                 max = conact->maxloc[1];
721                                                 break;
722                                         case ACT_CONST_DIRNZ:
723                                                 locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_DIRNZ;
724                                                 min = conact->minloc[2];
725                                                 max = conact->maxloc[2];
726                                                 break;
727                                         }
728                                         prop = conact->matprop;
729                                 } else if (conact->type == ACT_CONST_TYPE_FH) {
730                                         switch (conact->mode) {
731                                         case ACT_CONST_DIRPX:
732                                                 locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_FHPX;
733                                                 min = conact->minloc[0];
734                                                 max = conact->maxloc[0];
735                                                 break;
736                                         case ACT_CONST_DIRPY:
737                                                 locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_FHPY;
738                                                 min = conact->minloc[1];
739                                                 max = conact->maxloc[1];
740                                                 break;
741                                         case ACT_CONST_DIRPZ:
742                                                 locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_FHPZ;
743                                                 min = conact->minloc[2];
744                                                 max = conact->maxloc[2];
745                                                 break;
746                                         case ACT_CONST_DIRNX:
747                                                 locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_FHNX;
748                                                 min = conact->minloc[0];
749                                                 max = conact->maxloc[0];
750                                                 break;
751                                         case ACT_CONST_DIRNY:
752                                                 locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_FHNY;
753                                                 min = conact->minloc[1];
754                                                 max = conact->maxloc[1];
755                                                 break;
756                                         case ACT_CONST_DIRNZ:
757                                                 locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_FHNZ;
758                                                 min = conact->minloc[2];
759                                                 max = conact->maxloc[2];
760                                                 break;
761                                         }
762                                         prop = conact->matprop;
763                                 } else {
764                                         switch (conact->flag) {
765                                         case ACT_CONST_LOCX:
766                                                 locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_LOCX; 
767                                                 min = conact->minloc[0];
768                                                 max = conact->maxloc[0];
769                                                 break;
770                                         case ACT_CONST_LOCY:
771                                                 locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_LOCY; 
772                                                 min = conact->minloc[1];
773                                                 max = conact->maxloc[1];
774                                                 break;
775                                         case ACT_CONST_LOCZ:
776                                                 locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_LOCZ;
777                                                 min = conact->minloc[2];
778                                                 max = conact->maxloc[2];
779                                                 break;
780                                         case ACT_CONST_ROTX:
781                                                 locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_ROTX;
782                                                 min = MT_2_PI * conact->minrot[0] / 360.0;
783                                                 max = MT_2_PI * conact->maxrot[0] / 360.0;
784                                                 break;
785                                         case ACT_CONST_ROTY:
786                                                 locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_ROTY;
787                                                 min = MT_2_PI * conact->minrot[1] / 360.0;
788                                                 max = MT_2_PI * conact->maxrot[1] / 360.0;
789                                                 break;
790                                         case ACT_CONST_ROTZ:
791                                                 locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_ROTZ;
792                                                 min = MT_2_PI * conact->minrot[2] / 360.0;
793                                                 max = MT_2_PI * conact->maxrot[2] / 360.0;
794                                                 break;
795                                         default:
796                                                 ; /* error */ 
797                                         }
798                                 }
799                                 KX_ConstraintActuator *tmpconact 
800                                         = new KX_ConstraintActuator(gameobj,
801                                                 conact->damp,
802                                                 conact->rotdamp,
803                                                 min,
804                                                 max,
805                                                 conact->maxrot,
806                                                 locrot,
807                                                 conact->time,
808                                                 conact->flag,
809                                                 prop);
810                                 baseact = tmpconact;
811                                 break;
812                         }
813                 case ACT_GROUP:
814                         {
815                                 // deprecated
816                         }
817                         break;
818                 case ACT_SCENE:
819                         {
820                                 bSceneActuator *sceneact = (bSceneActuator *) bact->data;
821                                 STR_String nextSceneName("");
822                                 
823                                 KX_SceneActuator* tmpsceneact;
824                                 int mode = KX_SceneActuator::KX_SCENE_NODEF;
825                                 KX_Camera *cam = NULL;
826                                 //KX_Scene* scene = NULL;
827                                 switch (sceneact->type)
828                                 {
829                                 case ACT_SCENE_RESUME:
830                                 case ACT_SCENE_SUSPEND:
831                                 case ACT_SCENE_ADD_FRONT:
832                                 case ACT_SCENE_ADD_BACK:
833                                 case ACT_SCENE_REMOVE:
834                                 case ACT_SCENE_SET:
835                                         {
836                                                 switch (sceneact->type)
837                                                 {
838                                                 case ACT_SCENE_RESUME:
839                                                         mode = KX_SceneActuator::KX_SCENE_RESUME;
840                                                         break;
841                                                 case ACT_SCENE_SUSPEND:
842                                                         mode = KX_SceneActuator::KX_SCENE_SUSPEND;
843                                                         break;
844                                                 case ACT_SCENE_ADD_FRONT:
845                                                         mode = KX_SceneActuator::KX_SCENE_ADD_FRONT_SCENE;
846                                                         break;
847                                                 case ACT_SCENE_ADD_BACK:
848                                                         mode = KX_SceneActuator::KX_SCENE_ADD_BACK_SCENE;
849                                                         break;
850                                                 case ACT_SCENE_REMOVE:
851                                                         mode = KX_SceneActuator::KX_SCENE_REMOVE_SCENE;
852                                                         break;
853                                                 case ACT_SCENE_SET:
854                                                 default:
855                                                         mode = KX_SceneActuator::KX_SCENE_SET_SCENE;
856                                                         break;
857                                                 };
858                                                 
859                                                 if (sceneact->scene)
860                                                 {
861                                                         nextSceneName = sceneact->scene->id.name + 2; // this '2' is necessary to remove prefix 'SC'
862                                                 }
863                                                 
864                                                 break;
865                                         }
866                                 case ACT_SCENE_CAMERA:
867                                         mode = KX_SceneActuator::KX_SCENE_SET_CAMERA;
868                                         if (sceneact->camera)
869                                         {
870                                                 cam = (KX_Camera*) converter->FindGameObject(sceneact->camera);
871                                         }
872                                         break;
873                                 case ACT_SCENE_RESTART:
874                                         {
875                                                 
876                                                 mode =  KX_SceneActuator::KX_SCENE_RESTART;
877                                                 break;
878                                         }
879                                 default:
880                                         ; /* flag error */
881                                 }
882                                 tmpsceneact = new KX_SceneActuator(gameobj,
883                                                 mode,
884                                                 scene,
885                                                 ketsjiEngine,
886                                                 nextSceneName,
887                                                 cam);
888                                         baseact = tmpsceneact;
889                                 break;
890                         }
891                 case ACT_GAME:
892                         {
893                                 bGameActuator *gameact = (bGameActuator *) bact->data;
894                                 KX_GameActuator* tmpgameact;
895                                 STR_String filename = maggiename;
896                                 STR_String loadinganimationname = "";
897                                 int mode = KX_GameActuator::KX_GAME_NODEF;
898                                 switch (gameact->type)
899                                 {
900                                 case ACT_GAME_LOAD:
901                                         {
902                                                 mode = KX_GameActuator::KX_GAME_LOAD;
903                                                 filename = gameact->filename;
904                                                 loadinganimationname = gameact->loadaniname;
905                                                 break;
906                                         }
907                                 case ACT_GAME_START:
908                                         {
909                                                 mode = KX_GameActuator::KX_GAME_START;
910                                                 filename = gameact->filename;
911                                                 loadinganimationname = gameact->loadaniname;
912                                                 break;
913                                         }
914                                 case ACT_GAME_RESTART:
915                                         {
916                                                 mode = KX_GameActuator::KX_GAME_RESTART;
917                                                 break;
918                                         }
919                                 case ACT_GAME_QUIT:
920                                         {
921                                                 mode = KX_GameActuator::KX_GAME_QUIT;
922                                                 break;
923                                         }
924                                 case ACT_GAME_SAVECFG:
925                                         {
926                                                 mode = KX_GameActuator::KX_GAME_SAVECFG;
927                                                 break;
928                                         }
929                                 case ACT_GAME_LOADCFG:
930                                         {
931                                                 mode = KX_GameActuator::KX_GAME_LOADCFG;
932                                                 break;
933                                         }
934                                 default:
935                                         ; /* flag error */
936                                 }
937                                         tmpgameact = new KX_GameActuator(gameobj,
938                                                 mode,
939                                                 filename,
940                                                 loadinganimationname,
941                                                 scene,
942                                                 ketsjiEngine);
943                                         baseact = tmpgameact;
944
945                                 break;
946                         }
947                 case ACT_RANDOM:
948                         {
949                                 bRandomActuator *randAct 
950                                         = (bRandomActuator *) bact->data;
951                                 
952                                 unsigned long seedArg = randAct->seed;
953                                 SCA_RandomActuator::KX_RANDOMACT_MODE modeArg 
954                                         = SCA_RandomActuator::KX_RANDOMACT_NODEF;
955                                 SCA_RandomActuator *tmprandomact;
956                                 float paraArg1 = 0.0;
957                                 float paraArg2 = 0.0;
958                                 
959                                 switch  (randAct->distribution) {
960                                 case ACT_RANDOM_BOOL_CONST:
961                                         modeArg = SCA_RandomActuator::KX_RANDOMACT_BOOL_CONST;
962                                         paraArg1 = (float) randAct->int_arg_1;
963                                         break;
964                                 case ACT_RANDOM_BOOL_UNIFORM:
965                                         modeArg = SCA_RandomActuator::KX_RANDOMACT_BOOL_UNIFORM;
966                                         break;
967                                 case ACT_RANDOM_BOOL_BERNOUILLI:
968                                         paraArg1 = randAct->float_arg_1;
969                                         modeArg = SCA_RandomActuator::KX_RANDOMACT_BOOL_BERNOUILLI;
970                                         break;
971                                 case ACT_RANDOM_INT_CONST:
972                                         modeArg = SCA_RandomActuator::KX_RANDOMACT_INT_CONST;
973                                         paraArg1 = (float) randAct->int_arg_1;
974                                         break;
975                                 case ACT_RANDOM_INT_UNIFORM:
976                                         paraArg1 = (float) randAct->int_arg_1;
977                                         paraArg2 = (float) randAct->int_arg_2;
978                                         modeArg = SCA_RandomActuator::KX_RANDOMACT_INT_UNIFORM;
979                                         break;
980                                 case ACT_RANDOM_INT_POISSON:
981                                         paraArg1 = randAct->float_arg_1;
982                                         modeArg = SCA_RandomActuator::KX_RANDOMACT_INT_POISSON;
983                                         break;
984                                 case ACT_RANDOM_FLOAT_CONST:
985                                         paraArg1 = randAct->float_arg_1;
986                                         modeArg = SCA_RandomActuator::KX_RANDOMACT_FLOAT_CONST;
987                                         break;
988                                 case ACT_RANDOM_FLOAT_UNIFORM:
989                                         paraArg1 = randAct->float_arg_1;
990                                         paraArg2 = randAct->float_arg_2;
991                                         modeArg = SCA_RandomActuator::KX_RANDOMACT_FLOAT_UNIFORM;
992                                         break;
993                                 case ACT_RANDOM_FLOAT_NORMAL:
994                                         paraArg1 = randAct->float_arg_1;
995                                         paraArg2 = randAct->float_arg_2;
996                                         modeArg = SCA_RandomActuator::KX_RANDOMACT_FLOAT_NORMAL;
997                                         break;
998                                 case ACT_RANDOM_FLOAT_NEGATIVE_EXPONENTIAL:
999                                         paraArg1 = randAct->float_arg_1;
1000                                         modeArg = SCA_RandomActuator::KX_RANDOMACT_FLOAT_NEGATIVE_EXPONENTIAL;
1001                                         break;
1002                                 default:
1003                                         ; /* error */                           
1004                                 }
1005                                 tmprandomact = new SCA_RandomActuator(gameobj,
1006                                         seedArg,
1007                                         modeArg, 
1008                                         paraArg1,
1009                                         paraArg2,
1010                                         randAct->propname);
1011                                 baseact = tmprandomact;
1012                         }
1013                         break;
1014
1015                 case ACT_VISIBILITY:
1016                 {
1017                         bVisibilityActuator *vis_act = (bVisibilityActuator *) bact->data;
1018                         KX_VisibilityActuator * tmp_vis_act = NULL;
1019                         bool v = ((vis_act->flag & ACT_VISIBILITY_INVISIBLE) != 0);
1020                         bool recursive = ((vis_act->flag & ACT_VISIBILITY_RECURSIVE) != 0);
1021
1022                         tmp_vis_act = new KX_VisibilityActuator(gameobj, !v, recursive);
1023                         
1024                         baseact = tmp_vis_act;
1025                 }
1026                 break;
1027
1028                 case ACT_STATE:
1029                 {
1030                         bStateActuator *sta_act = (bStateActuator *) bact->data;
1031                         KX_StateActuator * tmp_sta_act = NULL;
1032
1033                         tmp_sta_act = 
1034                                 new KX_StateActuator(gameobj, sta_act->type, sta_act->mask);
1035                         
1036                         baseact = tmp_sta_act;
1037                 }
1038                 break;
1039
1040                 case ACT_2DFILTER:
1041                 {
1042                         bTwoDFilterActuator *_2dfilter = (bTwoDFilterActuator*) bact->data;
1043             SCA_2DFilterActuator *tmp = NULL;
1044
1045                         RAS_2DFilterManager::RAS_2DFILTER_MODE filtermode;
1046                         switch(_2dfilter->type)
1047                         {
1048                                 case ACT_2DFILTER_MOTIONBLUR:
1049                                         filtermode = RAS_2DFilterManager::RAS_2DFILTER_MOTIONBLUR;
1050                                         break;
1051                                 case ACT_2DFILTER_BLUR:
1052                                         filtermode = RAS_2DFilterManager::RAS_2DFILTER_BLUR;
1053                                         break;
1054                                 case ACT_2DFILTER_SHARPEN:
1055                                         filtermode = RAS_2DFilterManager::RAS_2DFILTER_SHARPEN;
1056                                         break;
1057                                 case ACT_2DFILTER_DILATION:
1058                                         filtermode = RAS_2DFilterManager::RAS_2DFILTER_DILATION;
1059                                         break;
1060                                 case ACT_2DFILTER_EROSION:
1061                                         filtermode = RAS_2DFilterManager::RAS_2DFILTER_EROSION;
1062                                         break;
1063                                 case ACT_2DFILTER_LAPLACIAN:
1064                                         filtermode = RAS_2DFilterManager::RAS_2DFILTER_LAPLACIAN;
1065                                         break;
1066                                 case ACT_2DFILTER_SOBEL:
1067                                         filtermode = RAS_2DFilterManager::RAS_2DFILTER_SOBEL;
1068                                         break;
1069                                 case ACT_2DFILTER_PREWITT:
1070                                         filtermode = RAS_2DFilterManager::RAS_2DFILTER_PREWITT;
1071                                         break;
1072                                 case ACT_2DFILTER_GRAYSCALE:
1073                                         filtermode = RAS_2DFilterManager::RAS_2DFILTER_GRAYSCALE;
1074                                         break;
1075                                 case ACT_2DFILTER_SEPIA:
1076                                         filtermode = RAS_2DFilterManager::RAS_2DFILTER_SEPIA;
1077                                         break;
1078                                 case ACT_2DFILTER_INVERT:
1079                                         filtermode = RAS_2DFilterManager::RAS_2DFILTER_INVERT;
1080                                         break;
1081                                 case ACT_2DFILTER_CUSTOMFILTER:
1082                                         filtermode = RAS_2DFilterManager::RAS_2DFILTER_CUSTOMFILTER;
1083                                         break;
1084                                 case ACT_2DFILTER_NOFILTER:
1085                                         filtermode = RAS_2DFilterManager::RAS_2DFILTER_NOFILTER;
1086                                         break;
1087                                 case ACT_2DFILTER_DISABLED:
1088                                         filtermode = RAS_2DFilterManager::RAS_2DFILTER_DISABLED;
1089                                         break;
1090                                 case ACT_2DFILTER_ENABLED:
1091                                         filtermode = RAS_2DFilterManager::RAS_2DFILTER_ENABLED;
1092                                         break;
1093                                 default:
1094                                         filtermode = RAS_2DFilterManager::RAS_2DFILTER_NOFILTER;
1095                                         break;
1096                         }
1097             
1098                         tmp = new SCA_2DFilterActuator(gameobj, filtermode, _2dfilter->flag,
1099                                 _2dfilter->float_arg,_2dfilter->int_arg,ketsjiEngine->GetRasterizer(),rendertools);
1100
1101                         if (_2dfilter->text)
1102                         {
1103                                 char *buf;
1104                                 // this is some blender specific code
1105                                 buf = txt_to_buf(_2dfilter->text);
1106                                 if (buf)
1107                                 {
1108                                         tmp->SetShaderText(STR_String(buf));
1109                                         MEM_freeN(buf);
1110                                 }
1111                         }
1112
1113             baseact = tmp;
1114                         
1115                 }
1116                 break;
1117                 case ACT_PARENT:
1118                         {
1119                                 bParentActuator *parAct = (bParentActuator *) bact->data;
1120                                 int mode = KX_ParentActuator::KX_PARENT_NODEF;
1121                                 KX_GameObject *tmpgob = NULL;
1122
1123                                 switch(parAct->type)
1124                                 {
1125                                         case ACT_PARENT_SET:
1126                                                 mode = KX_ParentActuator::KX_PARENT_SET;
1127                                                 tmpgob = converter->FindGameObject(parAct->ob);
1128                                                 break;
1129                                         case ACT_PARENT_REMOVE:
1130                                                 mode = KX_ParentActuator::KX_PARENT_REMOVE;
1131                                                 tmpgob = NULL;
1132                                                 break;
1133                                 }
1134         
1135                                 KX_ParentActuator *tmpparact
1136                                         = new KX_ParentActuator(gameobj,
1137                                         mode,
1138                                         tmpgob);
1139                                 baseact = tmpparact;
1140                                 break;
1141                         }
1142                 
1143                 default:
1144                         ; /* generate some error */
1145                 }
1146                 
1147                 if (baseact)
1148                 {
1149                         baseact->SetExecutePriority(executePriority++);
1150                         uniquename += "#ACT#";
1151                         uniqueint++;
1152                         CIntValue* uniqueval = new CIntValue(uniqueint);
1153                         uniquename += uniqueval->GetText();
1154                         uniqueval->Release();
1155                         baseact->SetName(STR_String(bact->name));
1156                         //gameobj->SetProperty(uniquename,baseact);
1157                         gameobj->AddActuator(baseact);
1158                         
1159                         converter->RegisterGameActuator(baseact, bact);
1160                         // done with baseact, release it
1161                         baseact->Release();
1162                 }
1163                 
1164                 bact = bact->next;
1165         }
1166 }
1167
1168