MCPcopy Create free account
hub / github.com/carbonengine/trinity / SetupAudio

Method SetupAudio

trinity/Eve/SpaceObjectFactory/EveSOF.cpp:2040–2080  ·  view source on GitHub ↗

-------------------------------------------------------------------------------- Description: add audio children to the space object --------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

2038// add audio children to the space object
2039// --------------------------------------------------------------------------------
2040void EveSOF::SetupAudio( ITr2SoundEmitterOwnerPtr newObj, const EveSOFDNAPtr dna, const Matrix& parentOffset ) const
2041{
2042 auto& hullEmitters = dna->GetHullSoundEmitters();
2043
2044 Quaternion parentRotation;
2045 Vector3 tmp, tmp2;
2046 Decompose( tmp, parentRotation, tmp2, parentOffset );
2047
2048 for( auto cit = begin( hullEmitters ); cit != end( hullEmitters ); ++cit )
2049 {
2050 TriObserverLocalPtr observer;
2051 observer.CreateInstance();
2052 observer->m_name = cit->name;
2053 observer->SetPosition( XMVector3TransformCoord( cit->position, parentOffset ) );
2054
2055 // Convert rotation to a front value
2056 Vector3 front;
2057 static const Vector3 zAxis( 0.f, 0.f, 1.f );
2058 Quaternion rot = cit->rotation * parentRotation;
2059 TriVectorRotateQuaternion( &front, &zAxis, &rot );
2060
2061 observer->SetFront( front );
2062
2063 IBluePlacementObserverPtr emitter;
2064 BeClasses->CreateInstanceFromName( "AudEmitter", BlueInterfaceIID<IBluePlacementObserver>(), reinterpret_cast<void**>( &emitter.p ) );
2065 if( !emitter )
2066 {
2067 CCP_LOGERR( "EveSOF: failed to create an audio emitter" );
2068 continue;
2069 }
2070 observer->SetObserver( emitter );
2071 newObj->AddObserver( observer );
2072
2073 ITr2AudEmitterPtr theRealEmitter;
2074 if( emitter->QueryInterface( BlueInterfaceIID<ITr2AudEmitter>(), reinterpret_cast<void**>( &theRealEmitter.p ), BEQI_SILENT ) && theRealEmitter )
2075 {
2076 theRealEmitter->Initialize( cit->name.c_str(), cit->prefix.c_str(), XMVector3TransformCoord( cit->position, parentOffset ) );
2077 theRealEmitter->SetAttenuationScalingFactor( cit->attenuationScalingFactor );
2078 }
2079 }
2080}
2081
2082
2083// --------------------------------------------------------------------------------

Callers

nothing calls this directly

Calls 10

CreateInstanceMethod · 0.80
SetFrontMethod · 0.80
SetObserverMethod · 0.80
QueryInterfaceMethod · 0.80
beginFunction · 0.50
endFunction · 0.50
SetPositionMethod · 0.45
AddObserverMethod · 0.45
InitializeMethod · 0.45

Tested by

no test coverage detected