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