Initializing Wwise Motion and the rumble plugin is demonstrated in the IntegrationDemo project that can be found in the sdk samples (WwiseSDK\samples\IntegrationDemo). You can also refer to the SDK documentation in the section “Integrating Wwise Motion”.
First thing to do is to register the plugins. The Rumble motion device plugin is necessary so the engine knows how to interface with the device. The Motion Generator source plugin is an ordinary Wwise source plugin, specialized in generating data for the rumble controllers.
AK::MotionEngine::RegisterMotionDevice(
AKCOMPANYID_AUDIOKINETIC, /*Plugin’s
company ID*/
AKMOTIONDEVICEID_RUMBLE, /*Plugin’s device ID*/
AkCreateRumblePlugin ); /*Creation
function*/
AK::SoundEngine::RegisterPlugin(
AkPluginTypeMotionSource, /*Plugin type. This one is for motion devices*/
AKCOMPANYID_AUDIOKINETIC, /*Plugin’s company ID*/
AKSOURCEID_MOTIONGENERATOR, /*Plugin’s device ID*/
AkCreateMotionGenerator, /*Creation function*/
AkCreateMotionGeneratorParams); /*Parameters creation function*/
The
next step in the initialization of rumble is to tell which player uses what
device types. For consoles (XBox/PS3/Wii)
this is done this way:
//Player 0 is
using a rumble device.
AK::MotionEngine::AddPlayerMotionDevice(
0, /*Player
0 (first player slot)*/
AKCOMPANYID_AUDIOKINETIC, /*Device company ID*/
AKMOTIONDEVICEID_RUMBLE ); /*Plugin Id*/
For PC games, the game controllers hardware can be interfaced using 2 technologies DirectInput and XInput. Both are supported by Wwise but the initalization is done sligthly differently. In the case of DirectInput, the IDirectInputDevice8 that your game use for the input functions must be provided. The following is sample code (from IntegrationDemo project) that detect if DirectInput or XInput controllers are connected, if both are supported in your PC game.
AkDirectInputDevice::InitControllers(platformInitSettings.hWnd);
if ( !AkDirectInputDevice::GetControllers().m_nXInputControllerCount
)
{
AK::MotionEngine::AddPlayerMotionDevice(
0, AKCOMPANYID_AUDIOKINETIC, AKMOTIONDEVICEID_RUMBLE, AkDirectInputDevice::GetFirstDirectInputController()
);
}
else
{
AK::MotionEngine::AddPlayerMotionDevice(
0, AKCOMPANYID_AUDIOKINETIC, AKMOTIONDEVICEID_RUMBLE );
}
The final initalization step
is to setup the Wwise engine’s listeners. Read more on listeners in the Wwise SDK
documentation, section “Integrating Listeners”.
Usually, listeners will represent the position of a player in the game. The same concept is applied to audio and
motion. The listener hears audio and
feels motion from a certain position in the 3D space. Motion processing is disabled by default on
listeners, you need to enable it.
//Player 0 is represented by Wwise’s listener 0.
AK::MotionEngine::SetPlayerListener(
0 /*Player ID*/,
0 /*Listener ID*/);
//Tell the listener 0 to listen to both audio and motion events.
AK::SoundEngine::SetListenerPipeline(
0, /*Listener
ID*/
true, /*Listen to Audio events*/
true ); /*Listen to Motion events*/
This completes the initialization of rumble for one player. To make a specific controller rumble, you need to have a MotionFX object in your project and an event to play it, exactly the same way as it is done in audio.