diff options
author | Benoit Bolsee <benoit.bolsee@online.be> | 2011-09-07 19:34:04 +0400 |
---|---|---|
committer | Benoit Bolsee <benoit.bolsee@online.be> | 2011-09-07 19:34:04 +0400 |
commit | dbd6658d737b1592a633ddf6397be14e50e434d9 (patch) | |
tree | 57081721d70622a3c3141909b258f9bce8a5b1e3 /source/gameengine/Converter/KX_ConvertActuators.cpp | |
parent | b5bd86e5907c3fa98546dabeda9703dfb15862f4 (diff) | |
parent | 884fc84793be1c5fdd6643ad267331381f8e1c6b (diff) |
svn merge -r 37306:39975 https://svn.blender.org/svnroot/bf-blender/trunk/blender
Diffstat (limited to 'source/gameengine/Converter/KX_ConvertActuators.cpp')
-rw-r--r-- | source/gameengine/Converter/KX_ConvertActuators.cpp | 95 |
1 files changed, 63 insertions, 32 deletions
diff --git a/source/gameengine/Converter/KX_ConvertActuators.cpp b/source/gameengine/Converter/KX_ConvertActuators.cpp index a8d5ab0b2ff..c73ffc2b932 100644 --- a/source/gameengine/Converter/KX_ConvertActuators.cpp +++ b/source/gameengine/Converter/KX_ConvertActuators.cpp @@ -43,7 +43,12 @@ #include "KX_BlenderSceneConverter.h" #include "KX_ConvertActuators.h" -#include "AUD_C-API.h" + +#ifdef WITH_AUDASPACE +# include "AUD_C-API.h" +# include "AUD_ChannelMapperFactory.h" +#endif + // Actuators //SCA logiclibrary native logicbricks #include "SCA_PropertyActuator.h" @@ -78,6 +83,7 @@ /* This little block needed for linking to Blender... */ #include "BKE_text.h" #include "BLI_blenlib.h" +#include "BLI_math_base.h" #define FILE_MAX 240 // repeated here to avoid dependency from BKE_utildefines.h @@ -96,6 +102,7 @@ #include "BL_ShapeActionActuator.h" #include "BL_ArmatureActuator.h" #include "RNA_access.h" +#include "BL_Action.h" /* end of blender include block */ #include "BL_BlenderDataConversion.h" @@ -193,30 +200,37 @@ void BL_ConvertActuators(char* maggiename, } case ACT_ACTION: { - if (blenderobject->type==OB_ARMATURE){ - bActionActuator* actact = (bActionActuator*) bact->data; - STR_String propname = (actact->name ? actact->name : ""); - STR_String propframe = (actact->frameProp ? actact->frameProp : ""); + bActionActuator* actact = (bActionActuator*) bact->data; + STR_String propname = (actact->name ? actact->name : ""); + STR_String propframe = (actact->frameProp ? actact->frameProp : ""); + + short ipo_flags = 0; + + // Convert flags + if (actact->flag & ACT_IPOFORCE) ipo_flags |= BL_Action::ACT_IPOFLAG_FORCE; + if (actact->flag & ACT_IPOLOCAL) ipo_flags |= BL_Action::ACT_IPOFLAG_LOCAL; + if (actact->flag & ACT_IPOADD) ipo_flags |= BL_Action::ACT_IPOFLAG_ADD; + if (actact->flag & ACT_IPOCHILD) ipo_flags |= BL_Action::ACT_IPOFLAG_CHILD; - BL_ActionActuator* tmpbaseact = new BL_ActionActuator( - gameobj, - propname, - propframe, - actact->sta, - actact->end, - actact->act, - actact->type, // + 1, because Blender starts to count at zero, - actact->blendin, - actact->priority, - actact->end_reset, - actact->stridelength - // Ketsji at 1, because zero is reserved for "NoDef" - ); - baseact= tmpbaseact; - break; - } - else - printf ("Discarded action actuator from non-armature object [%s]\n", blenderobject->id.name+2); + BL_ActionActuator* tmpbaseact = new BL_ActionActuator( + gameobj, + propname, + propframe, + actact->sta, + actact->end, + actact->act, + actact->type, // + 1, because Blender starts to count at zero, + actact->blendin, + actact->priority, + actact->layer, + actact->layer_weight, + ipo_flags, + actact->end_reset, + actact->stridelength + // Ketsji at 1, because zero is reserved for "NoDef" + ); + baseact= tmpbaseact; + break; } case ACT_SHAPEACTION: { @@ -288,7 +302,8 @@ void BL_ConvertActuators(char* maggiename, camact->height, camact->min, camact->max, - camact->axis=='x'); + camact->axis=='x', + camact->damping); baseact = tmpcamact; } break; @@ -376,7 +391,7 @@ void BL_ConvertActuators(char* maggiename, { bSound* sound = soundact->sound; bool is3d = soundact->flag & ACT_SND_3D_SOUND ? true : false; - AUD_Sound* snd_sound = NULL; + AUD_Reference<AUD_IFactory> snd_sound; KX_3DSoundSettings settings; settings.cone_inner_angle = soundact->sound3D.cone_inner_angle; settings.cone_outer_angle = soundact->sound3D.cone_outer_angle; @@ -394,12 +409,28 @@ void BL_ConvertActuators(char* maggiename, "\" has no sound datablock." << std::endl; } else - snd_sound = sound->playback_handle; + { + snd_sound = *reinterpret_cast<AUD_Reference<AUD_IFactory>*>(sound->playback_handle); + + // if sound shall be 3D but isn't mono, we have to make it mono! + if(is3d) + { + AUD_Reference<AUD_IReader> reader = snd_sound->createReader(); + if(reader->getSpecs().channels != AUD_CHANNELS_MONO) + { + AUD_DeviceSpecs specs; + specs.channels = AUD_CHANNELS_MONO; + specs.rate = AUD_RATE_INVALID; + specs.format = AUD_FORMAT_INVALID; + snd_sound = new AUD_ChannelMapperFactory(snd_sound, specs); + } + } + } KX_SoundActuator* tmpsoundact = new KX_SoundActuator(gameobj, snd_sound, soundact->volume, - (float)(exp((soundact->pitch / 12.0) * log(2.0))), + (float)(exp((soundact->pitch / 12.0) * M_LN2)), is3d, settings, soundActuatorType); @@ -913,7 +944,7 @@ void BL_ConvertActuators(char* maggiename, case ACT_2DFILTER: { bTwoDFilterActuator *_2dfilter = (bTwoDFilterActuator*) bact->data; - SCA_2DFilterActuator *tmp = NULL; + SCA_2DFilterActuator *tmp = NULL; RAS_2DFilterManager::RAS_2DFILTER_MODE filtermode; switch(_2dfilter->type) @@ -967,7 +998,7 @@ void BL_ConvertActuators(char* maggiename, filtermode = RAS_2DFilterManager::RAS_2DFILTER_NOFILTER; break; } - + tmp = new SCA_2DFilterActuator(gameobj, filtermode, _2dfilter->flag, _2dfilter->float_arg,_2dfilter->int_arg,ketsjiEngine->GetRasterizer(),scene); @@ -983,8 +1014,8 @@ void BL_ConvertActuators(char* maggiename, } } - baseact = tmp; - + baseact = tmp; + } break; case ACT_PARENT: |