interpreted request from Carsten - make message sensor work.
[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                                                                 );
666                                                         baseact = tmpdynact;
667                                         }
668                                 }
669                                 break;
670                         }
671                 case ACT_CONSTRAINT:
672                         {
673                                 float min = 0.0, max = 0.0;
674                                 char *prop = NULL;
675                                 KX_ConstraintActuator::KX_CONSTRAINTTYPE locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_NODEF;
676                                 bConstraintActuator *conact 
677                                         = (bConstraintActuator*) bact->data;
678                                 /* convert settings... degrees in the ui become radians  */ 
679                                 /* internally                                            */ 
680                                 if (conact->type == ACT_CONST_TYPE_ORI) {
681                                         min = (MT_2_PI * conact->minloc[0])/360.0;
682                                         max = (MT_2_PI * conact->maxloc[0])/360.0;
683                                         switch (conact->mode) {
684                                         case ACT_CONST_DIRPX:
685                                                 locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_ORIX;
686                                                 break;
687                                         case ACT_CONST_DIRPY:
688                                                 locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_ORIY;
689                                                 break;
690                                         case ACT_CONST_DIRPZ:
691                                                 locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_ORIZ;
692                                                 break;
693                                         }
694                                 } else if (conact->type == ACT_CONST_TYPE_DIST) {
695                                         switch (conact->mode) {
696                                         case ACT_CONST_DIRPX:
697                                                 locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_DIRPX;
698                                                 min = conact->minloc[0];
699                                                 max = conact->maxloc[0];
700                                                 break;
701                                         case ACT_CONST_DIRPY:
702                                                 locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_DIRPY;
703                                                 min = conact->minloc[1];
704                                                 max = conact->maxloc[1];
705                                                 break;
706                                         case ACT_CONST_DIRPZ:
707                                                 locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_DIRPZ;
708                                                 min = conact->minloc[2];
709                                                 max = conact->maxloc[2];
710                                                 break;
711                                         case ACT_CONST_DIRNX:
712                                                 locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_DIRNX;
713                                                 min = conact->minloc[0];
714                                                 max = conact->maxloc[0];
715                                                 break;
716                                         case ACT_CONST_DIRNY:
717                                                 locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_DIRNY;
718                                                 min = conact->minloc[1];
719                                                 max = conact->maxloc[1];
720                                                 break;
721                                         case ACT_CONST_DIRNZ:
722                                                 locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_DIRNZ;
723                                                 min = conact->minloc[2];
724                                                 max = conact->maxloc[2];
725                                                 break;
726                                         }
727                                         prop = conact->matprop;
728                                 } else if (conact->type == ACT_CONST_TYPE_FH) {
729                                         switch (conact->mode) {
730                                         case ACT_CONST_DIRPX:
731                                                 locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_FHPX;
732                                                 min = conact->minloc[0];
733                                                 max = conact->maxloc[0];
734                                                 break;
735                                         case ACT_CONST_DIRPY:
736                                                 locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_FHPY;
737                                                 min = conact->minloc[1];
738                                                 max = conact->maxloc[1];
739                                                 break;
740                                         case ACT_CONST_DIRPZ:
741                                                 locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_FHPZ;
742                                                 min = conact->minloc[2];
743                                                 max = conact->maxloc[2];
744                                                 break;
745                                         case ACT_CONST_DIRNX:
746                                                 locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_FHNX;
747                                                 min = conact->minloc[0];
748                                                 max = conact->maxloc[0];
749                                                 break;
750                                         case ACT_CONST_DIRNY:
751                                                 locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_FHNY;
752                                                 min = conact->minloc[1];
753                                                 max = conact->maxloc[1];
754                                                 break;
755                                         case ACT_CONST_DIRNZ:
756                                                 locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_FHNZ;
757                                                 min = conact->minloc[2];
758                                                 max = conact->maxloc[2];
759                                                 break;
760                                         }
761                                         prop = conact->matprop;
762                                 } else {
763                                         switch (conact->flag) {
764                                         case ACT_CONST_LOCX:
765                                                 locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_LOCX; 
766                                                 min = conact->minloc[0];
767                                                 max = conact->maxloc[0];
768                                                 break;
769                                         case ACT_CONST_LOCY:
770                                                 locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_LOCY; 
771                                                 min = conact->minloc[1];
772                                                 max = conact->maxloc[1];
773                                                 break;
774                                         case ACT_CONST_LOCZ:
775                                                 locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_LOCZ;
776                                                 min = conact->minloc[2];
777                                                 max = conact->maxloc[2];
778                                                 break;
779                                         case ACT_CONST_ROTX:
780                                                 locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_ROTX;
781                                                 min = MT_2_PI * conact->minrot[0] / 360.0;
782                                                 max = MT_2_PI * conact->maxrot[0] / 360.0;
783                                                 break;
784                                         case ACT_CONST_ROTY:
785                                                 locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_ROTY;
786                                                 min = MT_2_PI * conact->minrot[1] / 360.0;
787                                                 max = MT_2_PI * conact->maxrot[1] / 360.0;
788                                                 break;
789                                         case ACT_CONST_ROTZ:
790                                                 locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_ROTZ;
791                                                 min = MT_2_PI * conact->minrot[2] / 360.0;
792                                                 max = MT_2_PI * conact->maxrot[2] / 360.0;
793                                                 break;
794                                         default:
795                                                 ; /* error */ 
796                                         }
797                                 }
798                                 KX_ConstraintActuator *tmpconact 
799                                         = new KX_ConstraintActuator(gameobj,
800                                                 conact->damp,
801                                                 conact->rotdamp,
802                                                 min,
803                                                 max,
804                                                 conact->maxrot,
805                                                 locrot,
806                                                 conact->time,
807                                                 conact->flag,
808                                                 prop);
809                                 baseact = tmpconact;
810                                 break;
811                         }
812                 case ACT_GROUP:
813                         {
814                                 // deprecated
815                         }
816                         break;
817                 case ACT_SCENE:
818                         {
819                                 bSceneActuator *sceneact = (bSceneActuator *) bact->data;
820                                 STR_String nextSceneName("");
821                                 
822                                 KX_SceneActuator* tmpsceneact;
823                                 int mode = KX_SceneActuator::KX_SCENE_NODEF;
824                                 KX_Camera *cam = NULL;
825                                 //KX_Scene* scene = NULL;
826                                 switch (sceneact->type)
827                                 {
828                                 case ACT_SCENE_RESUME:
829                                 case ACT_SCENE_SUSPEND:
830                                 case ACT_SCENE_ADD_FRONT:
831                                 case ACT_SCENE_ADD_BACK:
832                                 case ACT_SCENE_REMOVE:
833                                 case ACT_SCENE_SET:
834                                         {
835                                                 switch (sceneact->type)
836                                                 {
837                                                 case ACT_SCENE_RESUME:
838                                                         mode = KX_SceneActuator::KX_SCENE_RESUME;
839                                                         break;
840                                                 case ACT_SCENE_SUSPEND:
841                                                         mode = KX_SceneActuator::KX_SCENE_SUSPEND;
842                                                         break;
843                                                 case ACT_SCENE_ADD_FRONT:
844                                                         mode = KX_SceneActuator::KX_SCENE_ADD_FRONT_SCENE;
845                                                         break;
846                                                 case ACT_SCENE_ADD_BACK:
847                                                         mode = KX_SceneActuator::KX_SCENE_ADD_BACK_SCENE;
848                                                         break;
849                                                 case ACT_SCENE_REMOVE:
850                                                         mode = KX_SceneActuator::KX_SCENE_REMOVE_SCENE;
851                                                         break;
852                                                 case ACT_SCENE_SET:
853                                                 default:
854                                                         mode = KX_SceneActuator::KX_SCENE_SET_SCENE;
855                                                         break;
856                                                 };
857                                                 
858                                                 if (sceneact->scene)
859                                                 {
860                                                         nextSceneName = sceneact->scene->id.name + 2; // this '2' is necessary to remove prefix 'SC'
861                                                 }
862                                                 
863                                                 break;
864                                         }
865                                 case ACT_SCENE_CAMERA:
866                                         mode = KX_SceneActuator::KX_SCENE_SET_CAMERA;
867                                         if (sceneact->camera)
868                                         {
869                                                 cam = (KX_Camera*) converter->FindGameObject(sceneact->camera);
870                                         }
871                                         break;
872                                 case ACT_SCENE_RESTART:
873                                         {
874                                                 
875                                                 mode =  KX_SceneActuator::KX_SCENE_RESTART;
876                                                 break;
877                                         }
878                                 default:
879                                         ; /* flag error */
880                                 }
881                                 tmpsceneact = new KX_SceneActuator(gameobj,
882                                                 mode,
883                                                 scene,
884                                                 ketsjiEngine,
885                                                 nextSceneName,
886                                                 cam);
887                                         baseact = tmpsceneact;
888                                 break;
889                         }
890                 case ACT_GAME:
891                         {
892                                 bGameActuator *gameact = (bGameActuator *) bact->data;
893                                 KX_GameActuator* tmpgameact;
894                                 STR_String filename = maggiename;
895                                 STR_String loadinganimationname = "";
896                                 int mode = KX_GameActuator::KX_GAME_NODEF;
897                                 switch (gameact->type)
898                                 {
899                                 case ACT_GAME_LOAD:
900                                         {
901                                                 mode = KX_GameActuator::KX_GAME_LOAD;
902                                                 filename = gameact->filename;
903                                                 loadinganimationname = gameact->loadaniname;
904                                                 break;
905                                         }
906                                 case ACT_GAME_START:
907                                         {
908                                                 mode = KX_GameActuator::KX_GAME_START;
909                                                 filename = gameact->filename;
910                                                 loadinganimationname = gameact->loadaniname;
911                                                 break;
912                                         }
913                                 case ACT_GAME_RESTART:
914                                         {
915                                                 mode = KX_GameActuator::KX_GAME_RESTART;
916                                                 break;
917                                         }
918                                 case ACT_GAME_QUIT:
919                                         {
920                                                 mode = KX_GameActuator::KX_GAME_QUIT;
921                                                 break;
922                                         }
923                                 case ACT_GAME_SAVECFG:
924                                         {
925                                                 mode = KX_GameActuator::KX_GAME_SAVECFG;
926                                                 break;
927                                         }
928                                 case ACT_GAME_LOADCFG:
929                                         {
930                                                 mode = KX_GameActuator::KX_GAME_LOADCFG;
931                                                 break;
932                                         }
933                                 default:
934                                         ; /* flag error */
935                                 }
936                                         tmpgameact = new KX_GameActuator(gameobj,
937                                                 mode,
938                                                 filename,
939                                                 loadinganimationname,
940                                                 scene,
941                                                 ketsjiEngine);
942                                         baseact = tmpgameact;
943
944                                 break;
945                         }
946                 case ACT_RANDOM:
947                         {
948                                 bRandomActuator *randAct 
949                                         = (bRandomActuator *) bact->data;
950                                 
951                                 unsigned long seedArg = randAct->seed;
952                                 SCA_RandomActuator::KX_RANDOMACT_MODE modeArg 
953                                         = SCA_RandomActuator::KX_RANDOMACT_NODEF;
954                                 SCA_RandomActuator *tmprandomact;
955                                 float paraArg1 = 0.0;
956                                 float paraArg2 = 0.0;
957                                 
958                                 switch  (randAct->distribution) {
959                                 case ACT_RANDOM_BOOL_CONST:
960                                         modeArg = SCA_RandomActuator::KX_RANDOMACT_BOOL_CONST;
961                                         paraArg1 = (float) randAct->int_arg_1;
962                                         break;
963                                 case ACT_RANDOM_BOOL_UNIFORM:
964                                         modeArg = SCA_RandomActuator::KX_RANDOMACT_BOOL_UNIFORM;
965                                         break;
966                                 case ACT_RANDOM_BOOL_BERNOUILLI:
967                                         paraArg1 = randAct->float_arg_1;
968                                         modeArg = SCA_RandomActuator::KX_RANDOMACT_BOOL_BERNOUILLI;
969                                         break;
970                                 case ACT_RANDOM_INT_CONST:
971                                         modeArg = SCA_RandomActuator::KX_RANDOMACT_INT_CONST;
972                                         paraArg1 = (float) randAct->int_arg_1;
973                                         break;
974                                 case ACT_RANDOM_INT_UNIFORM:
975                                         paraArg1 = (float) randAct->int_arg_1;
976                                         paraArg2 = (float) randAct->int_arg_2;
977                                         modeArg = SCA_RandomActuator::KX_RANDOMACT_INT_UNIFORM;
978                                         break;
979                                 case ACT_RANDOM_INT_POISSON:
980                                         paraArg1 = randAct->float_arg_1;
981                                         modeArg = SCA_RandomActuator::KX_RANDOMACT_INT_POISSON;
982                                         break;
983                                 case ACT_RANDOM_FLOAT_CONST:
984                                         paraArg1 = randAct->float_arg_1;
985                                         modeArg = SCA_RandomActuator::KX_RANDOMACT_FLOAT_CONST;
986                                         break;
987                                 case ACT_RANDOM_FLOAT_UNIFORM:
988                                         paraArg1 = randAct->float_arg_1;
989                                         paraArg2 = randAct->float_arg_2;
990                                         modeArg = SCA_RandomActuator::KX_RANDOMACT_FLOAT_UNIFORM;
991                                         break;
992                                 case ACT_RANDOM_FLOAT_NORMAL:
993                                         paraArg1 = randAct->float_arg_1;
994                                         paraArg2 = randAct->float_arg_2;
995                                         modeArg = SCA_RandomActuator::KX_RANDOMACT_FLOAT_NORMAL;
996                                         break;
997                                 case ACT_RANDOM_FLOAT_NEGATIVE_EXPONENTIAL:
998                                         paraArg1 = randAct->float_arg_1;
999                                         modeArg = SCA_RandomActuator::KX_RANDOMACT_FLOAT_NEGATIVE_EXPONENTIAL;
1000                                         break;
1001                                 default:
1002                                         ; /* error */                           
1003                                 }
1004                                 tmprandomact = new SCA_RandomActuator(gameobj,
1005                                         seedArg,
1006                                         modeArg, 
1007                                         paraArg1,
1008                                         paraArg2,
1009                                         randAct->propname);
1010                                 baseact = tmprandomact;
1011                         }
1012                         break;
1013
1014                 case ACT_VISIBILITY:
1015                 {
1016                         bVisibilityActuator *vis_act = (bVisibilityActuator *) bact->data;
1017                         KX_VisibilityActuator * tmp_vis_act = NULL;
1018                         bool v = ((vis_act->flag & ACT_VISIBILITY_INVISIBLE) != 0);
1019                         bool recursive = ((vis_act->flag & ACT_VISIBILITY_RECURSIVE) != 0);
1020
1021                         tmp_vis_act = new KX_VisibilityActuator(gameobj, !v, recursive);
1022                         
1023                         baseact = tmp_vis_act;
1024                 }
1025                 break;
1026
1027                 case ACT_STATE:
1028                 {
1029                         bStateActuator *sta_act = (bStateActuator *) bact->data;
1030                         KX_StateActuator * tmp_sta_act = NULL;
1031
1032                         tmp_sta_act = 
1033                                 new KX_StateActuator(gameobj, sta_act->type, sta_act->mask);
1034                         
1035                         baseact = tmp_sta_act;
1036                 }
1037                 break;
1038
1039                 case ACT_2DFILTER:
1040                 {
1041                         bTwoDFilterActuator *_2dfilter = (bTwoDFilterActuator*) bact->data;
1042             SCA_2DFilterActuator *tmp = NULL;
1043
1044                         RAS_2DFilterManager::RAS_2DFILTER_MODE filtermode;
1045                         switch(_2dfilter->type)
1046                         {
1047                                 case ACT_2DFILTER_MOTIONBLUR:
1048                                         filtermode = RAS_2DFilterManager::RAS_2DFILTER_MOTIONBLUR;
1049                                         break;
1050                                 case ACT_2DFILTER_BLUR:
1051                                         filtermode = RAS_2DFilterManager::RAS_2DFILTER_BLUR;
1052                                         break;
1053                                 case ACT_2DFILTER_SHARPEN:
1054                                         filtermode = RAS_2DFilterManager::RAS_2DFILTER_SHARPEN;
1055                                         break;
1056                                 case ACT_2DFILTER_DILATION:
1057                                         filtermode = RAS_2DFilterManager::RAS_2DFILTER_DILATION;
1058                                         break;
1059                                 case ACT_2DFILTER_EROSION:
1060                                         filtermode = RAS_2DFilterManager::RAS_2DFILTER_EROSION;
1061                                         break;
1062                                 case ACT_2DFILTER_LAPLACIAN:
1063                                         filtermode = RAS_2DFilterManager::RAS_2DFILTER_LAPLACIAN;
1064                                         break;
1065                                 case ACT_2DFILTER_SOBEL:
1066                                         filtermode = RAS_2DFilterManager::RAS_2DFILTER_SOBEL;
1067                                         break;
1068                                 case ACT_2DFILTER_PREWITT:
1069                                         filtermode = RAS_2DFilterManager::RAS_2DFILTER_PREWITT;
1070                                         break;
1071                                 case ACT_2DFILTER_GRAYSCALE:
1072                                         filtermode = RAS_2DFilterManager::RAS_2DFILTER_GRAYSCALE;
1073                                         break;
1074                                 case ACT_2DFILTER_SEPIA:
1075                                         filtermode = RAS_2DFilterManager::RAS_2DFILTER_SEPIA;
1076                                         break;
1077                                 case ACT_2DFILTER_INVERT:
1078                                         filtermode = RAS_2DFilterManager::RAS_2DFILTER_INVERT;
1079                                         break;
1080                                 case ACT_2DFILTER_CUSTOMFILTER:
1081                                         filtermode = RAS_2DFilterManager::RAS_2DFILTER_CUSTOMFILTER;
1082                                         break;
1083                                 case ACT_2DFILTER_NOFILTER:
1084                                         filtermode = RAS_2DFilterManager::RAS_2DFILTER_NOFILTER;
1085                                         break;
1086                                 case ACT_2DFILTER_DISABLED:
1087                                         filtermode = RAS_2DFilterManager::RAS_2DFILTER_DISABLED;
1088                                         break;
1089                                 case ACT_2DFILTER_ENABLED:
1090                                         filtermode = RAS_2DFilterManager::RAS_2DFILTER_ENABLED;
1091                                         break;
1092                                 default:
1093                                         filtermode = RAS_2DFilterManager::RAS_2DFILTER_NOFILTER;
1094                                         break;
1095                         }
1096             
1097                         tmp = new SCA_2DFilterActuator(gameobj, filtermode, _2dfilter->flag,
1098                                 _2dfilter->float_arg,_2dfilter->int_arg,ketsjiEngine->GetRasterizer(),rendertools);
1099
1100                         if (_2dfilter->text)
1101                         {
1102                                 char *buf;
1103                                 // this is some blender specific code
1104                                 buf = txt_to_buf(_2dfilter->text);
1105                                 if (buf)
1106                                 {
1107                                         tmp->SetShaderText(STR_String(buf));
1108                                         MEM_freeN(buf);
1109                                 }
1110                         }
1111
1112             baseact = tmp;
1113                         
1114                 }
1115                 break;
1116                 case ACT_PARENT:
1117                         {
1118                                 bParentActuator *parAct = (bParentActuator *) bact->data;
1119                                 int mode = KX_ParentActuator::KX_PARENT_NODEF;
1120                                 KX_GameObject *tmpgob = NULL;
1121
1122                                 switch(parAct->type)
1123                                 {
1124                                         case ACT_PARENT_SET:
1125                                                 mode = KX_ParentActuator::KX_PARENT_SET;
1126                                                 tmpgob = converter->FindGameObject(parAct->ob);
1127                                                 break;
1128                                         case ACT_PARENT_REMOVE:
1129                                                 mode = KX_ParentActuator::KX_PARENT_REMOVE;
1130                                                 tmpgob = NULL;
1131                                                 break;
1132                                 }
1133         
1134                                 KX_ParentActuator *tmpparact
1135                                         = new KX_ParentActuator(gameobj,
1136                                         mode,
1137                                         tmpgob);
1138                                 baseact = tmpparact;
1139                                 break;
1140                         }
1141                 
1142                 default:
1143                         ; /* generate some error */
1144                 }
1145                 
1146                 if (baseact)
1147                 {
1148                         baseact->SetExecutePriority(executePriority++);
1149                         uniquename += "#ACT#";
1150                         uniqueint++;
1151                         CIntValue* uniqueval = new CIntValue(uniqueint);
1152                         uniquename += uniqueval->GetText();
1153                         uniqueval->Release();
1154                         baseact->SetName(STR_String(bact->name));
1155                         //gameobj->SetProperty(uniquename,baseact);
1156                         gameobj->AddActuator(baseact);
1157                         
1158                         converter->RegisterGameActuator(baseact, bact);
1159                         // done with baseact, release it
1160                         baseact->Release();
1161                 }
1162                 
1163                 bact = bact->next;
1164         }
1165 }
1166
1167