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 /** \file gameengine/Converter/KX_ConvertActuators.cpp
36 #if defined(WIN32) && !defined(FREE_WINDOWS)
37 #pragma warning (disable : 4786)
42 #include "MEM_guardedalloc.h"
44 #include "KX_BlenderSceneConverter.h"
45 #include "KX_ConvertActuators.h"
48 # include "AUD_C-API.h"
49 # include "AUD_ChannelMapperFactory.h"
53 //SCA logiclibrary native logicbricks
54 #include "SCA_PropertyActuator.h"
55 #include "SCA_LogicManager.h"
56 #include "SCA_RandomActuator.h"
57 #include "SCA_2DFilterActuator.h"
59 // Ketsji specific logicbricks
60 #include "KX_SceneActuator.h"
61 #include "KX_IpoActuator.h"
62 #include "KX_SoundActuator.h"
63 #include "KX_ObjectActuator.h"
64 #include "KX_TrackToActuator.h"
65 #include "KX_ConstraintActuator.h"
66 #include "KX_CameraActuator.h"
67 #include "KX_GameActuator.h"
68 #include "KX_StateActuator.h"
69 #include "KX_VisibilityActuator.h"
70 #include "KX_SCA_AddObjectActuator.h"
71 #include "KX_SCA_EndObjectActuator.h"
72 #include "KX_SCA_ReplaceMeshActuator.h"
73 #include "KX_ParentActuator.h"
74 #include "KX_SCA_DynamicActuator.h"
77 #include "KX_KetsjiEngine.h"
80 #include "KX_GameObject.h"
82 /* This little block needed for linking to Blender... */
84 #include "BLI_blenlib.h"
85 #include "BLI_math_base.h"
87 #define FILE_MAX 240 // repeated here to avoid dependency from BKE_utildefines.h
89 #include "KX_NetworkMessageActuator.h"
92 #include "BLI_winstuff.h"
95 #include "DNA_object_types.h"
96 #include "DNA_sound_types.h"
97 #include "DNA_scene_types.h"
98 #include "DNA_actuator_types.h"
99 #include "DNA_packedFile_types.h"
100 #include "BL_ActionActuator.h"
101 #include "BL_ShapeActionActuator.h"
102 #include "BL_ArmatureActuator.h"
103 #include "BL_Action.h"
104 /* end of blender include block */
106 #include "BL_BlenderDataConversion.h"
109 KX_BLENDERTRUNC needed to round 'almost' zero values to zero, else velocities etc. are incorrectly set
112 #define KX_BLENDERTRUNC(x) (( x < 0.0001 && x > -0.0001 ) ? 0.0 : x)
114 void BL_ConvertActuators(char* maggiename,
115 struct Object* blenderobject,
116 KX_GameObject* gameobj,
117 SCA_LogicManager* logicmgr,
119 KX_KetsjiEngine* ketsjiEngine,
120 int activeLayerBitInfo,
121 bool isInActiveLayer,
122 RAS_IRenderTools* rendertools,
123 KX_BlenderSceneConverter* converter
129 int executePriority = 0;
130 bActuator* bact = (bActuator*) blenderobject->actuators.first;
136 gameobj->ReserveActuator(actcount);
137 bact = (bActuator*) blenderobject->actuators.first;
140 STR_String uniquename = bact->name;
141 STR_String& objectname = gameobj->GetName();
143 SCA_IActuator* baseact = NULL;
148 bObjectActuator* obact = (bObjectActuator*) bact->data;
149 KX_GameObject* obref = NULL;
150 MT_Vector3 forcevec(KX_BLENDERTRUNC(obact->forceloc[0]),
151 KX_BLENDERTRUNC(obact->forceloc[1]),
152 KX_BLENDERTRUNC(obact->forceloc[2]));
153 MT_Vector3 torquevec(obact->forcerot[0],obact->forcerot[1],obact->forcerot[2]);
154 MT_Vector3 dlocvec ( KX_BLENDERTRUNC(obact->dloc[0]),
155 KX_BLENDERTRUNC(obact->dloc[1]),
156 KX_BLENDERTRUNC(obact->dloc[2]));
157 MT_Vector3 drotvec ( KX_BLENDERTRUNC(obact->drot[0]),obact->drot[1],obact->drot[2]);
158 MT_Vector3 linvelvec ( KX_BLENDERTRUNC(obact->linearvelocity[0]),
159 KX_BLENDERTRUNC(obact->linearvelocity[1]),
160 KX_BLENDERTRUNC(obact->linearvelocity[2]));
161 MT_Vector3 angvelvec ( KX_BLENDERTRUNC(obact->angularvelocity[0]),
162 KX_BLENDERTRUNC(obact->angularvelocity[1]),
163 KX_BLENDERTRUNC(obact->angularvelocity[2]));
164 short damping = obact->damping;
166 /* Blender uses a bit vector internally for the local-flags. In */
167 /* KX, we have four bools. The compiler should be smart enough */
168 /* to do the right thing. We need to explicitly convert here! */
170 KX_LocalFlags bitLocalFlag;
172 bitLocalFlag.Force = bool((obact->flag & ACT_FORCE_LOCAL)!=0);
173 bitLocalFlag.Torque = bool((obact->flag & ACT_TORQUE_LOCAL) !=0);//rlocal;
174 bitLocalFlag.DLoc = bool((obact->flag & ACT_DLOC_LOCAL)!=0);
175 bitLocalFlag.DRot = bool((obact->flag & ACT_DROT_LOCAL)!=0);
176 bitLocalFlag.LinearVelocity = bool((obact->flag & ACT_LIN_VEL_LOCAL)!=0);
177 bitLocalFlag.AngularVelocity = bool((obact->flag & ACT_ANG_VEL_LOCAL)!=0);
178 bitLocalFlag.ServoControl = bool(obact->type == ACT_OBJECT_SERVO);
179 bitLocalFlag.AddOrSetLinV = bool((obact->flag & ACT_ADD_LIN_VEL)!=0);
180 if (obact->reference && bitLocalFlag.ServoControl)
182 obref = converter->FindGameObject(obact->reference);
185 KX_ObjectActuator* tmpbaseact = new KX_ObjectActuator(gameobj,
188 torquevec.getValue(),
191 linvelvec.getValue(),
192 angvelvec.getValue(),
196 baseact = tmpbaseact;
201 bActionActuator* actact = (bActionActuator*) bact->data;
202 STR_String propname = (actact->name ? actact->name : "");
203 STR_String propframe = (actact->frameProp ? actact->frameProp : "");
208 if (actact->flag & ACT_IPOFORCE) ipo_flags |= BL_Action::ACT_IPOFLAG_FORCE;
209 if (actact->flag & ACT_IPOLOCAL) ipo_flags |= BL_Action::ACT_IPOFLAG_LOCAL;
210 if (actact->flag & ACT_IPOADD) ipo_flags |= BL_Action::ACT_IPOFLAG_ADD;
211 if (actact->flag & ACT_IPOCHILD) ipo_flags |= BL_Action::ACT_IPOFLAG_CHILD;
213 BL_ActionActuator* tmpbaseact = new BL_ActionActuator(
220 actact->type, // + 1, because Blender starts to count at zero,
224 actact->layer_weight,
228 // Ketsji at 1, because zero is reserved for "NoDef"
233 case ACT_SHAPEACTION:
235 if (blenderobject->type==OB_MESH){
236 bActionActuator* actact = (bActionActuator*) bact->data;
237 STR_String propname = (actact->name ? actact->name : "");
238 STR_String propframe = (actact->frameProp ? actact->frameProp : "");
240 BL_ShapeActionActuator* tmpbaseact = new BL_ShapeActionActuator(
247 actact->type, // + 1, because Blender starts to count at zero,
251 // Ketsji at 1, because zero is reserved for "NoDef"
257 printf ("Discarded shape action actuator from non-mesh object [%s]\n", blenderobject->id.name+2);
261 bIpoActuator* ipoact = (bIpoActuator*) bact->data;
262 bool ipochild = (ipoact->flag & ACT_IPOCHILD) !=0;
263 STR_String propname = ipoact->name;
264 STR_String frameProp = ipoact->frameProp;
266 bool ipo_as_force = (ipoact->flag & ACT_IPOFORCE);
267 bool local = (ipoact->flag & ACT_IPOLOCAL);
268 bool ipo_add = (ipoact->flag & ACT_IPOADD);
270 KX_IpoActuator* tmpbaseact = new KX_IpoActuator(
277 ipoact->type + 1, // + 1, because Blender starts to count at zero,
278 // Ketsji at 1, because zero is reserved for "NoDef"
282 baseact = tmpbaseact;
291 bCameraActuator *camact = (bCameraActuator *) bact->data;
293 KX_GameObject *tmpgob = converter->FindGameObject(camact->ob);
295 /* visifac, fac and axis are not copied from the struct... */
296 /* that's some internal state... */
297 KX_CameraActuator *tmpcamact
298 = new KX_CameraActuator(gameobj,
311 bMessageActuator *msgAct = (bMessageActuator *) bact->data;
314 * Get the name of the properties that objects must own that
315 * we're sending to, if present
317 STR_String toPropName = (msgAct->toPropName
318 ? (char*) msgAct->toPropName
322 * Get the Message Subject to send.
324 STR_String subject = (msgAct->subject
325 ? (char*) msgAct->subject
331 int bodyType = msgAct->bodyType;
334 * Get the body (text message or property name whose value
335 * we'll be sending, might be empty
337 STR_String body = (msgAct->body
338 ? (char*) msgAct->body
341 KX_NetworkMessageActuator *tmpmsgact =
342 new KX_NetworkMessageActuator(
343 gameobj, // actuator controlling object
344 scene->GetNetworkScene(), // needed for replication
358 bSoundActuator* soundact = (bSoundActuator*) bact->data;
359 /* get type, and possibly a start and end frame */
360 KX_SoundActuator::KX_SOUNDACT_TYPE
361 soundActuatorType = KX_SoundActuator::KX_SOUNDACT_NODEF;
363 switch(soundact->type) {
364 case ACT_SND_PLAY_STOP_SOUND:
365 soundActuatorType = KX_SoundActuator::KX_SOUNDACT_PLAYSTOP;
367 case ACT_SND_PLAY_END_SOUND:
368 soundActuatorType = KX_SoundActuator::KX_SOUNDACT_PLAYEND;
370 case ACT_SND_LOOP_STOP_SOUND:
371 soundActuatorType = KX_SoundActuator::KX_SOUNDACT_LOOPSTOP;
373 case ACT_SND_LOOP_END_SOUND:
374 soundActuatorType = KX_SoundActuator::KX_SOUNDACT_LOOPEND;
376 case ACT_SND_LOOP_BIDIRECTIONAL_SOUND:
377 soundActuatorType = KX_SoundActuator::KX_SOUNDACT_LOOPBIDIRECTIONAL;
379 case ACT_SND_LOOP_BIDIRECTIONAL_STOP_SOUND:
380 soundActuatorType = KX_SoundActuator::KX_SOUNDACT_LOOPBIDIRECTIONAL_STOP;
384 /* This is an error!!! */
385 soundActuatorType = KX_SoundActuator::KX_SOUNDACT_NODEF;
388 if (soundActuatorType != KX_SoundActuator::KX_SOUNDACT_NODEF)
390 bSound* sound = soundact->sound;
391 bool is3d = soundact->flag & ACT_SND_3D_SOUND ? true : false;
392 AUD_Reference<AUD_IFactory> snd_sound;
393 KX_3DSoundSettings settings;
394 settings.cone_inner_angle = soundact->sound3D.cone_inner_angle;
395 settings.cone_outer_angle = soundact->sound3D.cone_outer_angle;
396 settings.cone_outer_gain = soundact->sound3D.cone_outer_gain;
397 settings.max_distance = soundact->sound3D.max_distance;
398 settings.max_gain = soundact->sound3D.max_gain;
399 settings.min_gain = soundact->sound3D.min_gain;
400 settings.reference_distance = soundact->sound3D.reference_distance;
401 settings.rolloff_factor = soundact->sound3D.rolloff_factor;
405 std::cout << "WARNING: Sound actuator \"" << bact->name <<
406 "\" from object \"" << blenderobject->id.name+2 <<
407 "\" has no sound datablock." << std::endl;
411 snd_sound = *reinterpret_cast<AUD_Reference<AUD_IFactory>*>(sound->playback_handle);
413 // if sound shall be 3D but isn't mono, we have to make it mono!
416 AUD_Reference<AUD_IReader> reader = snd_sound->createReader();
417 if(reader->getSpecs().channels != AUD_CHANNELS_MONO)
419 AUD_DeviceSpecs specs;
420 specs.channels = AUD_CHANNELS_MONO;
421 specs.rate = AUD_RATE_INVALID;
422 specs.format = AUD_FORMAT_INVALID;
423 snd_sound = new AUD_ChannelMapperFactory(snd_sound, specs);
427 KX_SoundActuator* tmpsoundact =
428 new KX_SoundActuator(gameobj,
431 (float)(exp((soundact->pitch / 12.0) * M_LN2)),
436 tmpsoundact->SetName(bact->name);
437 baseact = tmpsoundact;
443 bPropertyActuator* propact = (bPropertyActuator*) bact->data;
444 SCA_IObject* destinationObj = NULL;
447 here the destinationobject is searched. problem with multiple scenes: other scenes
448 have not been converted yet, so the destobj will not be found, so the prop will
451 - convert everything when possible and not realtime only when needed.
452 - let the object-with-property report itself to the act when converted
455 destinationObj = converter->FindGameObject(propact->ob);
457 SCA_PropertyActuator* tmppropact = new SCA_PropertyActuator(
462 propact->type+1); // + 1 because Ketsji Logic starts
463 // with 0 for KX_ACT_PROP_NODEF
464 baseact = tmppropact;
467 case ACT_EDIT_OBJECT:
469 bEditObjectActuator *editobact
470 = (bEditObjectActuator *) bact->data;
471 /* There are four different kinds of 'edit object' thingies */
472 /* The alternative to this lengthy conversion is packing */
473 /* several actuators in one, which is not very nice design.. */
474 switch (editobact->type) {
475 case ACT_EDOB_ADD_OBJECT:
478 // does the 'original' for replication exists, and
479 // is it in a non-active layer ?
480 SCA_IObject* originalval = NULL;
483 if (editobact->ob->lay & activeLayerBitInfo)
485 fprintf(stderr, "Warning, object \"%s\" from AddObject actuator \"%s\" is not in a hidden layer.\n", objectname.Ptr(), uniquename.Ptr());
488 originalval = converter->FindGameObject(editobact->ob);
492 KX_SCA_AddObjectActuator* tmpaddact =
493 new KX_SCA_AddObjectActuator(
498 editobact->linVelocity,
499 (editobact->localflag & ACT_EDOB_LOCAL_LINV)!=0,
500 editobact->angVelocity,
501 (editobact->localflag & ACT_EDOB_LOCAL_ANGV)!=0
504 //editobact->ob to gameobj
508 case ACT_EDOB_END_OBJECT:
510 KX_SCA_EndObjectActuator* tmpendact
511 = new KX_SCA_EndObjectActuator(gameobj,scene);
515 case ACT_EDOB_REPLACE_MESH:
517 RAS_MeshObject *tmpmesh = NULL;
519 tmpmesh = BL_ConvertMesh(
526 KX_SCA_ReplaceMeshActuator* tmpreplaceact
527 = new KX_SCA_ReplaceMeshActuator(
531 (editobact->flag & ACT_EDOB_REPLACE_MESH_NOGFX)==0,
532 (editobact->flag & ACT_EDOB_REPLACE_MESH_PHYS)!=0
536 baseact = tmpreplaceact;
539 case ACT_EDOB_TRACK_TO:
541 SCA_IObject* originalval = NULL;
543 originalval = converter->FindGameObject(editobact->ob);
545 KX_TrackToActuator* tmptrackact
546 = new KX_TrackToActuator(gameobj,
550 blenderobject->trackflag,
551 blenderobject->upflag
553 baseact = tmptrackact;
556 case ACT_EDOB_DYNAMICS:
558 KX_SCA_DynamicActuator* tmpdynact
559 = new KX_SCA_DynamicActuator(gameobj,
560 editobact->dyn_operation,
570 float min = 0.0, max = 0.0;
572 KX_ConstraintActuator::KX_CONSTRAINTTYPE locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_NODEF;
573 bConstraintActuator *conact
574 = (bConstraintActuator*) bact->data;
575 /* convert settings... degrees in the ui become radians */
577 if (conact->type == ACT_CONST_TYPE_ORI) {
578 min = (float)((MT_2_PI * conact->minloc[0])/360.0);
579 max = (float)((MT_2_PI * conact->maxloc[0])/360.0);
580 switch (conact->mode) {
581 case ACT_CONST_DIRPX:
582 locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_ORIX;
584 case ACT_CONST_DIRPY:
585 locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_ORIY;
587 case ACT_CONST_DIRPZ:
588 locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_ORIZ;
591 } else if (conact->type == ACT_CONST_TYPE_DIST) {
592 switch (conact->mode) {
593 case ACT_CONST_DIRPX:
594 locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_DIRPX;
595 min = conact->minloc[0];
596 max = conact->maxloc[0];
598 case ACT_CONST_DIRPY:
599 locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_DIRPY;
600 min = conact->minloc[1];
601 max = conact->maxloc[1];
603 case ACT_CONST_DIRPZ:
604 locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_DIRPZ;
605 min = conact->minloc[2];
606 max = conact->maxloc[2];
608 case ACT_CONST_DIRNX:
609 locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_DIRNX;
610 min = conact->minloc[0];
611 max = conact->maxloc[0];
613 case ACT_CONST_DIRNY:
614 locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_DIRNY;
615 min = conact->minloc[1];
616 max = conact->maxloc[1];
618 case ACT_CONST_DIRNZ:
619 locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_DIRNZ;
620 min = conact->minloc[2];
621 max = conact->maxloc[2];
624 prop = conact->matprop;
625 } else if (conact->type == ACT_CONST_TYPE_FH) {
626 switch (conact->mode) {
627 case ACT_CONST_DIRPX:
628 locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_FHPX;
629 min = conact->minloc[0];
630 max = conact->maxloc[0];
632 case ACT_CONST_DIRPY:
633 locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_FHPY;
634 min = conact->minloc[1];
635 max = conact->maxloc[1];
637 case ACT_CONST_DIRPZ:
638 locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_FHPZ;
639 min = conact->minloc[2];
640 max = conact->maxloc[2];
642 case ACT_CONST_DIRNX:
643 locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_FHNX;
644 min = conact->minloc[0];
645 max = conact->maxloc[0];
647 case ACT_CONST_DIRNY:
648 locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_FHNY;
649 min = conact->minloc[1];
650 max = conact->maxloc[1];
652 case ACT_CONST_DIRNZ:
653 locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_FHNZ;
654 min = conact->minloc[2];
655 max = conact->maxloc[2];
658 prop = conact->matprop;
660 switch (conact->flag) {
662 locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_LOCX;
663 min = conact->minloc[0];
664 max = conact->maxloc[0];
667 locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_LOCY;
668 min = conact->minloc[1];
669 max = conact->maxloc[1];
672 locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_LOCZ;
673 min = conact->minloc[2];
674 max = conact->maxloc[2];
677 locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_ROTX;
678 min = conact->minrot[0] * (float)MT_RADS_PER_DEG;
679 max = conact->maxrot[0] * (float)MT_RADS_PER_DEG;
682 locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_ROTY;
683 min = conact->minrot[1] * (float)MT_RADS_PER_DEG;
684 max = conact->maxrot[1] * (float)MT_RADS_PER_DEG;
687 locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_ROTZ;
688 min = conact->minrot[2] * (float)MT_RADS_PER_DEG;
689 max = conact->maxrot[2] * (float)MT_RADS_PER_DEG;
695 KX_ConstraintActuator *tmpconact
696 = new KX_ConstraintActuator(gameobj,
716 bSceneActuator *sceneact = (bSceneActuator *) bact->data;
717 STR_String nextSceneName("");
719 KX_SceneActuator* tmpsceneact;
720 int mode = KX_SceneActuator::KX_SCENE_NODEF;
721 KX_Camera *cam = NULL;
722 //KX_Scene* scene = NULL;
723 switch (sceneact->type)
725 case ACT_SCENE_RESUME:
726 case ACT_SCENE_SUSPEND:
727 case ACT_SCENE_ADD_FRONT:
728 case ACT_SCENE_ADD_BACK:
729 case ACT_SCENE_REMOVE:
732 switch (sceneact->type)
734 case ACT_SCENE_RESUME:
735 mode = KX_SceneActuator::KX_SCENE_RESUME;
737 case ACT_SCENE_SUSPEND:
738 mode = KX_SceneActuator::KX_SCENE_SUSPEND;
740 case ACT_SCENE_ADD_FRONT:
741 mode = KX_SceneActuator::KX_SCENE_ADD_FRONT_SCENE;
743 case ACT_SCENE_ADD_BACK:
744 mode = KX_SceneActuator::KX_SCENE_ADD_BACK_SCENE;
746 case ACT_SCENE_REMOVE:
747 mode = KX_SceneActuator::KX_SCENE_REMOVE_SCENE;
751 mode = KX_SceneActuator::KX_SCENE_SET_SCENE;
757 nextSceneName = sceneact->scene->id.name + 2; // this '2' is necessary to remove prefix 'SC'
762 case ACT_SCENE_CAMERA:
763 mode = KX_SceneActuator::KX_SCENE_SET_CAMERA;
764 if (sceneact->camera)
766 cam = (KX_Camera*) converter->FindGameObject(sceneact->camera);
769 case ACT_SCENE_RESTART:
772 mode = KX_SceneActuator::KX_SCENE_RESTART;
778 tmpsceneact = new KX_SceneActuator(gameobj,
784 baseact = tmpsceneact;
789 bGameActuator *gameact = (bGameActuator *) bact->data;
790 KX_GameActuator* tmpgameact;
791 STR_String filename = maggiename;
792 STR_String loadinganimationname = "";
793 int mode = KX_GameActuator::KX_GAME_NODEF;
794 switch (gameact->type)
798 mode = KX_GameActuator::KX_GAME_LOAD;
799 filename = gameact->filename;
800 loadinganimationname = gameact->loadaniname;
805 mode = KX_GameActuator::KX_GAME_START;
806 filename = gameact->filename;
807 loadinganimationname = gameact->loadaniname;
810 case ACT_GAME_RESTART:
812 mode = KX_GameActuator::KX_GAME_RESTART;
817 mode = KX_GameActuator::KX_GAME_QUIT;
820 case ACT_GAME_SAVECFG:
822 mode = KX_GameActuator::KX_GAME_SAVECFG;
825 case ACT_GAME_LOADCFG:
827 mode = KX_GameActuator::KX_GAME_LOADCFG;
833 tmpgameact = new KX_GameActuator(gameobj,
836 loadinganimationname,
839 baseact = tmpgameact;
845 bRandomActuator *randAct
846 = (bRandomActuator *) bact->data;
848 unsigned long seedArg = randAct->seed;
851 seedArg = (int)(ketsjiEngine->GetRealTime()*100000.0);
852 seedArg ^= (intptr_t)randAct;
854 SCA_RandomActuator::KX_RANDOMACT_MODE modeArg
855 = SCA_RandomActuator::KX_RANDOMACT_NODEF;
856 SCA_RandomActuator *tmprandomact;
857 float paraArg1 = 0.0;
858 float paraArg2 = 0.0;
860 switch (randAct->distribution) {
861 case ACT_RANDOM_BOOL_CONST:
862 modeArg = SCA_RandomActuator::KX_RANDOMACT_BOOL_CONST;
863 paraArg1 = (float) randAct->int_arg_1;
865 case ACT_RANDOM_BOOL_UNIFORM:
866 modeArg = SCA_RandomActuator::KX_RANDOMACT_BOOL_UNIFORM;
868 case ACT_RANDOM_BOOL_BERNOUILLI:
869 paraArg1 = randAct->float_arg_1;
870 modeArg = SCA_RandomActuator::KX_RANDOMACT_BOOL_BERNOUILLI;
872 case ACT_RANDOM_INT_CONST:
873 modeArg = SCA_RandomActuator::KX_RANDOMACT_INT_CONST;
874 paraArg1 = (float) randAct->int_arg_1;
876 case ACT_RANDOM_INT_UNIFORM:
877 paraArg1 = (float) randAct->int_arg_1;
878 paraArg2 = (float) randAct->int_arg_2;
879 modeArg = SCA_RandomActuator::KX_RANDOMACT_INT_UNIFORM;
881 case ACT_RANDOM_INT_POISSON:
882 paraArg1 = randAct->float_arg_1;
883 modeArg = SCA_RandomActuator::KX_RANDOMACT_INT_POISSON;
885 case ACT_RANDOM_FLOAT_CONST:
886 paraArg1 = randAct->float_arg_1;
887 modeArg = SCA_RandomActuator::KX_RANDOMACT_FLOAT_CONST;
889 case ACT_RANDOM_FLOAT_UNIFORM:
890 paraArg1 = randAct->float_arg_1;
891 paraArg2 = randAct->float_arg_2;
892 modeArg = SCA_RandomActuator::KX_RANDOMACT_FLOAT_UNIFORM;
894 case ACT_RANDOM_FLOAT_NORMAL:
895 paraArg1 = randAct->float_arg_1;
896 paraArg2 = randAct->float_arg_2;
897 modeArg = SCA_RandomActuator::KX_RANDOMACT_FLOAT_NORMAL;
899 case ACT_RANDOM_FLOAT_NEGATIVE_EXPONENTIAL:
900 paraArg1 = randAct->float_arg_1;
901 modeArg = SCA_RandomActuator::KX_RANDOMACT_FLOAT_NEGATIVE_EXPONENTIAL;
906 tmprandomact = new SCA_RandomActuator(gameobj,
912 baseact = tmprandomact;
918 bVisibilityActuator *vis_act = (bVisibilityActuator *) bact->data;
919 KX_VisibilityActuator * tmp_vis_act = NULL;
920 bool v = ((vis_act->flag & ACT_VISIBILITY_INVISIBLE) != 0);
921 bool o = ((vis_act->flag & ACT_VISIBILITY_OCCLUSION) != 0);
922 bool recursive = ((vis_act->flag & ACT_VISIBILITY_RECURSIVE) != 0);
924 tmp_vis_act = new KX_VisibilityActuator(gameobj, !v, o, recursive);
926 baseact = tmp_vis_act;
932 bStateActuator *sta_act = (bStateActuator *) bact->data;
933 KX_StateActuator * tmp_sta_act = NULL;
936 new KX_StateActuator(gameobj, sta_act->type, sta_act->mask);
938 baseact = tmp_sta_act;
944 bTwoDFilterActuator *_2dfilter = (bTwoDFilterActuator*) bact->data;
945 SCA_2DFilterActuator *tmp = NULL;
947 RAS_2DFilterManager::RAS_2DFILTER_MODE filtermode;
948 switch(_2dfilter->type)
950 case ACT_2DFILTER_MOTIONBLUR:
951 filtermode = RAS_2DFilterManager::RAS_2DFILTER_MOTIONBLUR;
953 case ACT_2DFILTER_BLUR:
954 filtermode = RAS_2DFilterManager::RAS_2DFILTER_BLUR;
956 case ACT_2DFILTER_SHARPEN:
957 filtermode = RAS_2DFilterManager::RAS_2DFILTER_SHARPEN;
959 case ACT_2DFILTER_DILATION:
960 filtermode = RAS_2DFilterManager::RAS_2DFILTER_DILATION;
962 case ACT_2DFILTER_EROSION:
963 filtermode = RAS_2DFilterManager::RAS_2DFILTER_EROSION;
965 case ACT_2DFILTER_LAPLACIAN:
966 filtermode = RAS_2DFilterManager::RAS_2DFILTER_LAPLACIAN;
968 case ACT_2DFILTER_SOBEL:
969 filtermode = RAS_2DFilterManager::RAS_2DFILTER_SOBEL;
971 case ACT_2DFILTER_PREWITT:
972 filtermode = RAS_2DFilterManager::RAS_2DFILTER_PREWITT;
974 case ACT_2DFILTER_GRAYSCALE:
975 filtermode = RAS_2DFilterManager::RAS_2DFILTER_GRAYSCALE;
977 case ACT_2DFILTER_SEPIA:
978 filtermode = RAS_2DFilterManager::RAS_2DFILTER_SEPIA;
980 case ACT_2DFILTER_INVERT:
981 filtermode = RAS_2DFilterManager::RAS_2DFILTER_INVERT;
983 case ACT_2DFILTER_CUSTOMFILTER:
984 filtermode = RAS_2DFilterManager::RAS_2DFILTER_CUSTOMFILTER;
986 case ACT_2DFILTER_NOFILTER:
987 filtermode = RAS_2DFilterManager::RAS_2DFILTER_NOFILTER;
989 case ACT_2DFILTER_DISABLED:
990 filtermode = RAS_2DFilterManager::RAS_2DFILTER_DISABLED;
992 case ACT_2DFILTER_ENABLED:
993 filtermode = RAS_2DFilterManager::RAS_2DFILTER_ENABLED;
996 filtermode = RAS_2DFilterManager::RAS_2DFILTER_NOFILTER;
1000 tmp = new SCA_2DFilterActuator(gameobj, filtermode, _2dfilter->flag,
1001 _2dfilter->float_arg,_2dfilter->int_arg,ketsjiEngine->GetRasterizer(),scene);
1003 if (_2dfilter->text)
1006 // this is some blender specific code
1007 buf = txt_to_buf(_2dfilter->text);
1010 tmp->SetShaderText(buf);
1021 bParentActuator *parAct = (bParentActuator *) bact->data;
1022 int mode = KX_ParentActuator::KX_PARENT_NODEF;
1023 bool addToCompound = true;
1025 KX_GameObject *tmpgob = NULL;
1027 switch(parAct->type)
1029 case ACT_PARENT_SET:
1030 mode = KX_ParentActuator::KX_PARENT_SET;
1031 tmpgob = converter->FindGameObject(parAct->ob);
1032 addToCompound = !(parAct->flag & ACT_PARENT_COMPOUND);
1033 ghost = !(parAct->flag & ACT_PARENT_GHOST);
1035 case ACT_PARENT_REMOVE:
1036 mode = KX_ParentActuator::KX_PARENT_REMOVE;
1041 KX_ParentActuator *tmpparact
1042 = new KX_ParentActuator(gameobj,
1047 baseact = tmpparact;
1053 bArmatureActuator* armAct = (bArmatureActuator*) bact->data;
1054 KX_GameObject *tmpgob = converter->FindGameObject(armAct->target);
1055 KX_GameObject *subgob = converter->FindGameObject(armAct->subtarget);
1056 BL_ArmatureActuator* tmparmact = new BL_ArmatureActuator(gameobj, armAct->type, armAct->posechannel, armAct->constraint, tmpgob, subgob, armAct->weight);
1057 baseact = tmparmact;
1061 ; /* generate some error */
1066 baseact->SetExecutePriority(executePriority++);
1067 uniquename += "#ACT#";
1069 CIntValue* uniqueval = new CIntValue(uniqueint);
1070 uniquename += uniqueval->GetText();
1071 uniqueval->Release();
1072 baseact->SetName(bact->name);
1073 //gameobj->SetProperty(uniquename,baseact);
1074 gameobj->AddActuator(baseact);
1076 converter->RegisterGameActuator(baseact, bact);
1077 // done with baseact, release it