4 * ***** BEGIN GPL LICENSE BLOCK *****
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.
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.
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
21 * All rights reserved.
23 * The Original Code is: all of this file.
25 * Contributor(s): none yet.
27 * ***** END GPL LICENSE BLOCK *****
28 * Convert Blender actuators for use in the GameEngine
31 #if defined(WIN32) && !defined(FREE_WINDOWS)
32 #pragma warning (disable : 4786)
35 #define BLENDER_HACK_DTIME 0.02
37 #include "MEM_guardedalloc.h"
39 #include "KX_BlenderSceneConverter.h"
40 #include "KX_ConvertActuators.h"
41 #include "AUD_C-API.h"
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"
49 // Ketsji specific logicbricks
50 #include "KX_SceneActuator.h"
51 #include "KX_IpoActuator.h"
52 #include "KX_SoundActuator.h"
53 #include "KX_ObjectActuator.h"
54 #include "KX_TrackToActuator.h"
55 #include "KX_ConstraintActuator.h"
56 #include "KX_CameraActuator.h"
57 #include "KX_GameActuator.h"
58 #include "KX_StateActuator.h"
59 #include "KX_VisibilityActuator.h"
60 #include "KX_SCA_AddObjectActuator.h"
61 #include "KX_SCA_EndObjectActuator.h"
62 #include "KX_SCA_ReplaceMeshActuator.h"
63 #include "KX_ParentActuator.h"
64 #include "KX_SCA_DynamicActuator.h"
67 #include "KX_KetsjiEngine.h"
70 #include "KX_GameObject.h"
72 /* This little block needed for linking to Blender... */
74 #include "BLI_blenlib.h"
76 #define FILE_MAX 240 // repeated here to avoid dependency from BKE_utildefines.h
78 #include "KX_NetworkMessageActuator.h"
81 #include "BLI_winstuff.h"
84 #include "DNA_object_types.h"
85 #include "DNA_sound_types.h"
86 #include "DNA_scene_types.h"
87 #include "DNA_actuator_types.h"
88 #include "DNA_packedFile_types.h"
89 #include "BL_ActionActuator.h"
90 #include "BL_ShapeActionActuator.h"
91 #include "BL_ArmatureActuator.h"
92 /* end of blender include block */
94 #include "BL_BlenderDataConversion.h"
97 KX_BLENDERTRUNC needed to round 'almost' zero values to zero, else velocities etc. are incorrectly set
100 #define KX_BLENDERTRUNC(x) (( x < 0.0001 && x > -0.0001 ) ? 0.0 : x)
102 void BL_ConvertActuators(char* maggiename,
103 struct Object* blenderobject,
104 KX_GameObject* gameobj,
105 SCA_LogicManager* logicmgr,
107 KX_KetsjiEngine* ketsjiEngine,
108 int activeLayerBitInfo,
109 bool isInActiveLayer,
110 RAS_IRenderTools* rendertools,
111 KX_BlenderSceneConverter* converter
117 int executePriority = 0;
118 bActuator* bact = (bActuator*) blenderobject->actuators.first;
124 gameobj->ReserveActuator(actcount);
125 bact = (bActuator*) blenderobject->actuators.first;
128 STR_String uniquename = bact->name;
129 STR_String& objectname = gameobj->GetName();
131 SCA_IActuator* baseact = NULL;
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;
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;
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! */
165 KX_LocalFlags bitLocalFlag;
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)
177 obref = converter->FindGameObject(obact->reference);
180 KX_ObjectActuator* tmpbaseact = new KX_ObjectActuator(gameobj,
183 torquevec.getValue(),
186 linvelvec.getValue(),
187 angvelvec.getValue(),
191 baseact = tmpbaseact;
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 : "");
201 BL_ActionActuator* tmpbaseact = new BL_ActionActuator(
208 actact->type, // + 1, because Blender starts to count at zero,
213 // Ketsji at 1, because zero is reserved for "NoDef"
219 printf ("Discarded action actuator from non-armature object [%s]\n", blenderobject->id.name+2);
221 case ACT_SHAPEACTION:
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 : "");
228 BL_ShapeActionActuator* tmpbaseact = new BL_ShapeActionActuator(
235 actact->type, // + 1, because Blender starts to count at zero,
239 // Ketsji at 1, because zero is reserved for "NoDef"
245 printf ("Discarded shape action actuator from non-mesh object [%s]\n", blenderobject->id.name+2);
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;
254 bool ipo_as_force = (ipoact->flag & ACT_IPOFORCE);
255 bool local = (ipoact->flag & ACT_IPOLOCAL);
256 bool ipo_add = (ipoact->flag & ACT_IPOADD);
258 KX_IpoActuator* tmpbaseact = new KX_IpoActuator(
265 ipoact->type + 1, // + 1, because Blender starts to count at zero,
266 // Ketsji at 1, because zero is reserved for "NoDef"
270 baseact = tmpbaseact;
279 bCameraActuator *camact = (bCameraActuator *) bact->data;
281 KX_GameObject *tmpgob = converter->FindGameObject(camact->ob);
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,
298 bMessageActuator *msgAct = (bMessageActuator *) bact->data;
301 * Get the name of the properties that objects must own that
302 * we're sending to, if present
304 STR_String toPropName = (msgAct->toPropName
305 ? (char*) msgAct->toPropName
309 * Get the Message Subject to send.
311 STR_String subject = (msgAct->subject
312 ? (char*) msgAct->subject
318 int bodyType = msgAct->bodyType;
321 * Get the body (text message or property name whose value
322 * we'll be sending, might be empty
324 STR_String body = (msgAct->body
325 ? (char*) msgAct->body
328 KX_NetworkMessageActuator *tmpmsgact =
329 new KX_NetworkMessageActuator(
330 gameobj, // actuator controlling object
331 scene->GetNetworkScene(), // needed for replication
345 bSoundActuator* soundact = (bSoundActuator*) bact->data;
346 /* get type, and possibly a start and end frame */
347 KX_SoundActuator::KX_SOUNDACT_TYPE
348 soundActuatorType = KX_SoundActuator::KX_SOUNDACT_NODEF;
350 switch(soundact->type) {
351 case ACT_SND_PLAY_STOP_SOUND:
352 soundActuatorType = KX_SoundActuator::KX_SOUNDACT_PLAYSTOP;
354 case ACT_SND_PLAY_END_SOUND:
355 soundActuatorType = KX_SoundActuator::KX_SOUNDACT_PLAYEND;
357 case ACT_SND_LOOP_STOP_SOUND:
358 soundActuatorType = KX_SoundActuator::KX_SOUNDACT_LOOPSTOP;
360 case ACT_SND_LOOP_END_SOUND:
361 soundActuatorType = KX_SoundActuator::KX_SOUNDACT_LOOPEND;
363 case ACT_SND_LOOP_BIDIRECTIONAL_SOUND:
364 soundActuatorType = KX_SoundActuator::KX_SOUNDACT_LOOPBIDIRECTIONAL;
366 case ACT_SND_LOOP_BIDIRECTIONAL_STOP_SOUND:
367 soundActuatorType = KX_SoundActuator::KX_SOUNDACT_LOOPBIDIRECTIONAL_STOP;
371 /* This is an error!!! */
372 soundActuatorType = KX_SoundActuator::KX_SOUNDACT_NODEF;
375 if (soundActuatorType != KX_SoundActuator::KX_SOUNDACT_NODEF)
377 bSound* sound = soundact->sound;
378 bool is3d = soundact->flag & ACT_SND_3D_SOUND ? true : false;
379 AUD_Sound* snd_sound = NULL;
380 KX_3DSoundSettings settings;
381 settings.cone_inner_angle = soundact->sound3D.cone_inner_angle;
382 settings.cone_outer_angle = soundact->sound3D.cone_outer_angle;
383 settings.cone_outer_gain = soundact->sound3D.cone_outer_gain;
384 settings.max_distance = soundact->sound3D.max_distance;
385 settings.max_gain = soundact->sound3D.max_gain;
386 settings.min_gain = soundact->sound3D.min_gain;
387 settings.reference_distance = soundact->sound3D.reference_distance;
388 settings.rolloff_factor = soundact->sound3D.rolloff_factor;
392 std::cout << "WARNING: Sound actuator \"" << bact->name <<
393 "\" from object \"" << blenderobject->id.name+2 <<
394 "\" has no sound datablock." << std::endl;
397 snd_sound = sound->playback_handle;
398 KX_SoundActuator* tmpsoundact =
399 new KX_SoundActuator(gameobj,
402 exp((soundact->pitch / 12.0) * log(2.0)),
407 tmpsoundact->SetName(bact->name);
408 baseact = tmpsoundact;
414 bPropertyActuator* propact = (bPropertyActuator*) bact->data;
415 SCA_IObject* destinationObj = NULL;
418 here the destinationobject is searched. problem with multiple scenes: other scenes
419 have not been converted yet, so the destobj will not be found, so the prop will
422 - convert everything when possible and not realtime only when needed.
423 - let the object-with-property report itself to the act when converted
426 destinationObj = converter->FindGameObject(propact->ob);
428 SCA_PropertyActuator* tmppropact = new SCA_PropertyActuator(
433 propact->type+1); // + 1 because Ketsji Logic starts
434 // with 0 for KX_ACT_PROP_NODEF
435 baseact = tmppropact;
438 case ACT_EDIT_OBJECT:
440 bEditObjectActuator *editobact
441 = (bEditObjectActuator *) bact->data;
442 /* There are four different kinds of 'edit object' thingies */
443 /* The alternative to this lengthy conversion is packing */
444 /* several actuators in one, which is not very nice design.. */
445 switch (editobact->type) {
446 case ACT_EDOB_ADD_OBJECT:
449 // does the 'original' for replication exists, and
450 // is it in a non-active layer ?
451 SCA_IObject* originalval = NULL;
454 if (editobact->ob->lay & activeLayerBitInfo)
456 fprintf(stderr, "Warning, object \"%s\" from AddObject actuator \"%s\" is not in a hidden layer.\n", objectname.Ptr(), uniquename.Ptr());
459 originalval = converter->FindGameObject(editobact->ob);
463 KX_SCA_AddObjectActuator* tmpaddact =
464 new KX_SCA_AddObjectActuator(
469 editobact->linVelocity,
470 (editobact->localflag & ACT_EDOB_LOCAL_LINV)!=0,
471 editobact->angVelocity,
472 (editobact->localflag & ACT_EDOB_LOCAL_ANGV)!=0
475 //editobact->ob to gameobj
479 case ACT_EDOB_END_OBJECT:
481 KX_SCA_EndObjectActuator* tmpendact
482 = new KX_SCA_EndObjectActuator(gameobj,scene);
486 case ACT_EDOB_REPLACE_MESH:
488 RAS_MeshObject *tmpmesh = NULL;
490 tmpmesh = BL_ConvertMesh(
497 KX_SCA_ReplaceMeshActuator* tmpreplaceact
498 = new KX_SCA_ReplaceMeshActuator(
502 (editobact->flag & ACT_EDOB_REPLACE_MESH_NOGFX)==0,
503 (editobact->flag & ACT_EDOB_REPLACE_MESH_PHYS)!=0
507 baseact = tmpreplaceact;
510 case ACT_EDOB_TRACK_TO:
512 SCA_IObject* originalval = NULL;
514 originalval = converter->FindGameObject(editobact->ob);
516 KX_TrackToActuator* tmptrackact
517 = new KX_TrackToActuator(gameobj,
521 blenderobject->trackflag,
522 blenderobject->upflag
524 baseact = tmptrackact;
527 case ACT_EDOB_DYNAMICS:
529 KX_SCA_DynamicActuator* tmpdynact
530 = new KX_SCA_DynamicActuator(gameobj,
531 editobact->dyn_operation,
541 float min = 0.0, max = 0.0;
543 KX_ConstraintActuator::KX_CONSTRAINTTYPE locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_NODEF;
544 bConstraintActuator *conact
545 = (bConstraintActuator*) bact->data;
546 /* convert settings... degrees in the ui become radians */
548 if (conact->type == ACT_CONST_TYPE_ORI) {
549 min = (MT_2_PI * conact->minloc[0])/360.0;
550 max = (MT_2_PI * conact->maxloc[0])/360.0;
551 switch (conact->mode) {
552 case ACT_CONST_DIRPX:
553 locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_ORIX;
555 case ACT_CONST_DIRPY:
556 locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_ORIY;
558 case ACT_CONST_DIRPZ:
559 locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_ORIZ;
562 } else if (conact->type == ACT_CONST_TYPE_DIST) {
563 switch (conact->mode) {
564 case ACT_CONST_DIRPX:
565 locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_DIRPX;
566 min = conact->minloc[0];
567 max = conact->maxloc[0];
569 case ACT_CONST_DIRPY:
570 locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_DIRPY;
571 min = conact->minloc[1];
572 max = conact->maxloc[1];
574 case ACT_CONST_DIRPZ:
575 locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_DIRPZ;
576 min = conact->minloc[2];
577 max = conact->maxloc[2];
579 case ACT_CONST_DIRNX:
580 locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_DIRNX;
581 min = conact->minloc[0];
582 max = conact->maxloc[0];
584 case ACT_CONST_DIRNY:
585 locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_DIRNY;
586 min = conact->minloc[1];
587 max = conact->maxloc[1];
589 case ACT_CONST_DIRNZ:
590 locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_DIRNZ;
591 min = conact->minloc[2];
592 max = conact->maxloc[2];
595 prop = conact->matprop;
596 } else if (conact->type == ACT_CONST_TYPE_FH) {
597 switch (conact->mode) {
598 case ACT_CONST_DIRPX:
599 locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_FHPX;
600 min = conact->minloc[0];
601 max = conact->maxloc[0];
603 case ACT_CONST_DIRPY:
604 locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_FHPY;
605 min = conact->minloc[1];
606 max = conact->maxloc[1];
608 case ACT_CONST_DIRPZ:
609 locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_FHPZ;
610 min = conact->minloc[2];
611 max = conact->maxloc[2];
613 case ACT_CONST_DIRNX:
614 locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_FHNX;
615 min = conact->minloc[0];
616 max = conact->maxloc[0];
618 case ACT_CONST_DIRNY:
619 locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_FHNY;
620 min = conact->minloc[1];
621 max = conact->maxloc[1];
623 case ACT_CONST_DIRNZ:
624 locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_FHNZ;
625 min = conact->minloc[2];
626 max = conact->maxloc[2];
629 prop = conact->matprop;
631 switch (conact->flag) {
633 locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_LOCX;
634 min = conact->minloc[0];
635 max = conact->maxloc[0];
638 locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_LOCY;
639 min = conact->minloc[1];
640 max = conact->maxloc[1];
643 locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_LOCZ;
644 min = conact->minloc[2];
645 max = conact->maxloc[2];
648 locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_ROTX;
649 min = MT_2_PI * conact->minrot[0] / 360.0;
650 max = MT_2_PI * conact->maxrot[0] / 360.0;
653 locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_ROTY;
654 min = MT_2_PI * conact->minrot[1] / 360.0;
655 max = MT_2_PI * conact->maxrot[1] / 360.0;
658 locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_ROTZ;
659 min = MT_2_PI * conact->minrot[2] / 360.0;
660 max = MT_2_PI * conact->maxrot[2] / 360.0;
666 KX_ConstraintActuator *tmpconact
667 = new KX_ConstraintActuator(gameobj,
687 bSceneActuator *sceneact = (bSceneActuator *) bact->data;
688 STR_String nextSceneName("");
690 KX_SceneActuator* tmpsceneact;
691 int mode = KX_SceneActuator::KX_SCENE_NODEF;
692 KX_Camera *cam = NULL;
693 //KX_Scene* scene = NULL;
694 switch (sceneact->type)
696 case ACT_SCENE_RESUME:
697 case ACT_SCENE_SUSPEND:
698 case ACT_SCENE_ADD_FRONT:
699 case ACT_SCENE_ADD_BACK:
700 case ACT_SCENE_REMOVE:
703 switch (sceneact->type)
705 case ACT_SCENE_RESUME:
706 mode = KX_SceneActuator::KX_SCENE_RESUME;
708 case ACT_SCENE_SUSPEND:
709 mode = KX_SceneActuator::KX_SCENE_SUSPEND;
711 case ACT_SCENE_ADD_FRONT:
712 mode = KX_SceneActuator::KX_SCENE_ADD_FRONT_SCENE;
714 case ACT_SCENE_ADD_BACK:
715 mode = KX_SceneActuator::KX_SCENE_ADD_BACK_SCENE;
717 case ACT_SCENE_REMOVE:
718 mode = KX_SceneActuator::KX_SCENE_REMOVE_SCENE;
722 mode = KX_SceneActuator::KX_SCENE_SET_SCENE;
728 nextSceneName = sceneact->scene->id.name + 2; // this '2' is necessary to remove prefix 'SC'
733 case ACT_SCENE_CAMERA:
734 mode = KX_SceneActuator::KX_SCENE_SET_CAMERA;
735 if (sceneact->camera)
737 cam = (KX_Camera*) converter->FindGameObject(sceneact->camera);
740 case ACT_SCENE_RESTART:
743 mode = KX_SceneActuator::KX_SCENE_RESTART;
749 tmpsceneact = new KX_SceneActuator(gameobj,
755 baseact = tmpsceneact;
760 bGameActuator *gameact = (bGameActuator *) bact->data;
761 KX_GameActuator* tmpgameact;
762 STR_String filename = maggiename;
763 STR_String loadinganimationname = "";
764 int mode = KX_GameActuator::KX_GAME_NODEF;
765 switch (gameact->type)
769 mode = KX_GameActuator::KX_GAME_LOAD;
770 filename = gameact->filename;
771 loadinganimationname = gameact->loadaniname;
776 mode = KX_GameActuator::KX_GAME_START;
777 filename = gameact->filename;
778 loadinganimationname = gameact->loadaniname;
781 case ACT_GAME_RESTART:
783 mode = KX_GameActuator::KX_GAME_RESTART;
788 mode = KX_GameActuator::KX_GAME_QUIT;
791 case ACT_GAME_SAVECFG:
793 mode = KX_GameActuator::KX_GAME_SAVECFG;
796 case ACT_GAME_LOADCFG:
798 mode = KX_GameActuator::KX_GAME_LOADCFG;
804 tmpgameact = new KX_GameActuator(gameobj,
807 loadinganimationname,
810 baseact = tmpgameact;
816 bRandomActuator *randAct
817 = (bRandomActuator *) bact->data;
819 unsigned long seedArg = randAct->seed;
822 seedArg = (int)(ketsjiEngine->GetRealTime()*100000.0);
823 seedArg ^= (intptr_t)randAct;
825 SCA_RandomActuator::KX_RANDOMACT_MODE modeArg
826 = SCA_RandomActuator::KX_RANDOMACT_NODEF;
827 SCA_RandomActuator *tmprandomact;
828 float paraArg1 = 0.0;
829 float paraArg2 = 0.0;
831 switch (randAct->distribution) {
832 case ACT_RANDOM_BOOL_CONST:
833 modeArg = SCA_RandomActuator::KX_RANDOMACT_BOOL_CONST;
834 paraArg1 = (float) randAct->int_arg_1;
836 case ACT_RANDOM_BOOL_UNIFORM:
837 modeArg = SCA_RandomActuator::KX_RANDOMACT_BOOL_UNIFORM;
839 case ACT_RANDOM_BOOL_BERNOUILLI:
840 paraArg1 = randAct->float_arg_1;
841 modeArg = SCA_RandomActuator::KX_RANDOMACT_BOOL_BERNOUILLI;
843 case ACT_RANDOM_INT_CONST:
844 modeArg = SCA_RandomActuator::KX_RANDOMACT_INT_CONST;
845 paraArg1 = (float) randAct->int_arg_1;
847 case ACT_RANDOM_INT_UNIFORM:
848 paraArg1 = (float) randAct->int_arg_1;
849 paraArg2 = (float) randAct->int_arg_2;
850 modeArg = SCA_RandomActuator::KX_RANDOMACT_INT_UNIFORM;
852 case ACT_RANDOM_INT_POISSON:
853 paraArg1 = randAct->float_arg_1;
854 modeArg = SCA_RandomActuator::KX_RANDOMACT_INT_POISSON;
856 case ACT_RANDOM_FLOAT_CONST:
857 paraArg1 = randAct->float_arg_1;
858 modeArg = SCA_RandomActuator::KX_RANDOMACT_FLOAT_CONST;
860 case ACT_RANDOM_FLOAT_UNIFORM:
861 paraArg1 = randAct->float_arg_1;
862 paraArg2 = randAct->float_arg_2;
863 modeArg = SCA_RandomActuator::KX_RANDOMACT_FLOAT_UNIFORM;
865 case ACT_RANDOM_FLOAT_NORMAL:
866 paraArg1 = randAct->float_arg_1;
867 paraArg2 = randAct->float_arg_2;
868 modeArg = SCA_RandomActuator::KX_RANDOMACT_FLOAT_NORMAL;
870 case ACT_RANDOM_FLOAT_NEGATIVE_EXPONENTIAL:
871 paraArg1 = randAct->float_arg_1;
872 modeArg = SCA_RandomActuator::KX_RANDOMACT_FLOAT_NEGATIVE_EXPONENTIAL;
877 tmprandomact = new SCA_RandomActuator(gameobj,
883 baseact = tmprandomact;
889 bVisibilityActuator *vis_act = (bVisibilityActuator *) bact->data;
890 KX_VisibilityActuator * tmp_vis_act = NULL;
891 bool v = ((vis_act->flag & ACT_VISIBILITY_INVISIBLE) != 0);
892 bool o = ((vis_act->flag & ACT_VISIBILITY_OCCLUSION) != 0);
893 bool recursive = ((vis_act->flag & ACT_VISIBILITY_RECURSIVE) != 0);
895 tmp_vis_act = new KX_VisibilityActuator(gameobj, !v, o, recursive);
897 baseact = tmp_vis_act;
903 bStateActuator *sta_act = (bStateActuator *) bact->data;
904 KX_StateActuator * tmp_sta_act = NULL;
907 new KX_StateActuator(gameobj, sta_act->type, sta_act->mask);
909 baseact = tmp_sta_act;
915 bTwoDFilterActuator *_2dfilter = (bTwoDFilterActuator*) bact->data;
916 SCA_2DFilterActuator *tmp = NULL;
918 RAS_2DFilterManager::RAS_2DFILTER_MODE filtermode;
919 switch(_2dfilter->type)
921 case ACT_2DFILTER_MOTIONBLUR:
922 filtermode = RAS_2DFilterManager::RAS_2DFILTER_MOTIONBLUR;
924 case ACT_2DFILTER_BLUR:
925 filtermode = RAS_2DFilterManager::RAS_2DFILTER_BLUR;
927 case ACT_2DFILTER_SHARPEN:
928 filtermode = RAS_2DFilterManager::RAS_2DFILTER_SHARPEN;
930 case ACT_2DFILTER_DILATION:
931 filtermode = RAS_2DFilterManager::RAS_2DFILTER_DILATION;
933 case ACT_2DFILTER_EROSION:
934 filtermode = RAS_2DFilterManager::RAS_2DFILTER_EROSION;
936 case ACT_2DFILTER_LAPLACIAN:
937 filtermode = RAS_2DFilterManager::RAS_2DFILTER_LAPLACIAN;
939 case ACT_2DFILTER_SOBEL:
940 filtermode = RAS_2DFilterManager::RAS_2DFILTER_SOBEL;
942 case ACT_2DFILTER_PREWITT:
943 filtermode = RAS_2DFilterManager::RAS_2DFILTER_PREWITT;
945 case ACT_2DFILTER_GRAYSCALE:
946 filtermode = RAS_2DFilterManager::RAS_2DFILTER_GRAYSCALE;
948 case ACT_2DFILTER_SEPIA:
949 filtermode = RAS_2DFilterManager::RAS_2DFILTER_SEPIA;
951 case ACT_2DFILTER_INVERT:
952 filtermode = RAS_2DFilterManager::RAS_2DFILTER_INVERT;
954 case ACT_2DFILTER_CUSTOMFILTER:
955 filtermode = RAS_2DFilterManager::RAS_2DFILTER_CUSTOMFILTER;
957 case ACT_2DFILTER_NOFILTER:
958 filtermode = RAS_2DFilterManager::RAS_2DFILTER_NOFILTER;
960 case ACT_2DFILTER_DISABLED:
961 filtermode = RAS_2DFilterManager::RAS_2DFILTER_DISABLED;
963 case ACT_2DFILTER_ENABLED:
964 filtermode = RAS_2DFilterManager::RAS_2DFILTER_ENABLED;
967 filtermode = RAS_2DFilterManager::RAS_2DFILTER_NOFILTER;
971 tmp = new SCA_2DFilterActuator(gameobj, filtermode, _2dfilter->flag,
972 _2dfilter->float_arg,_2dfilter->int_arg,ketsjiEngine->GetRasterizer(),scene);
977 // this is some blender specific code
978 buf = txt_to_buf(_2dfilter->text);
981 tmp->SetShaderText(buf);
992 bParentActuator *parAct = (bParentActuator *) bact->data;
993 int mode = KX_ParentActuator::KX_PARENT_NODEF;
994 bool addToCompound = true;
996 KX_GameObject *tmpgob = NULL;
1000 case ACT_PARENT_SET:
1001 mode = KX_ParentActuator::KX_PARENT_SET;
1002 tmpgob = converter->FindGameObject(parAct->ob);
1003 addToCompound = !(parAct->flag & ACT_PARENT_COMPOUND);
1004 ghost = !(parAct->flag & ACT_PARENT_GHOST);
1006 case ACT_PARENT_REMOVE:
1007 mode = KX_ParentActuator::KX_PARENT_REMOVE;
1012 KX_ParentActuator *tmpparact
1013 = new KX_ParentActuator(gameobj,
1018 baseact = tmpparact;
1024 bArmatureActuator* armAct = (bArmatureActuator*) bact->data;
1025 KX_GameObject *tmpgob = converter->FindGameObject(armAct->target);
1026 KX_GameObject *subgob = converter->FindGameObject(armAct->subtarget);
1027 BL_ArmatureActuator* tmparmact = new BL_ArmatureActuator(gameobj, armAct->type, armAct->posechannel, armAct->constraint, tmpgob, subgob, armAct->weight);
1028 baseact = tmparmact;
1032 ; /* generate some error */
1037 baseact->SetExecutePriority(executePriority++);
1038 uniquename += "#ACT#";
1040 CIntValue* uniqueval = new CIntValue(uniqueint);
1041 uniquename += uniqueval->GetText();
1042 uniqueval->Release();
1043 baseact->SetName(bact->name);
1044 //gameobj->SetProperty(uniquename,baseact);
1045 gameobj->AddActuator(baseact);
1047 converter->RegisterGameActuator(baseact, bact);
1048 // done with baseact, release it