예제 #1
0
void FlightSound::onEvent(Actor* initiator, unsigned int eventId, void* eventData)
{
    if( true || initiator == _parent )
    {
        Matrix4f parentPose = _parent->getPose();
        Vector3f soundPos( parentPose[3][0], parentPose[3][1], parentPose[3][2] );

        switch( eventId )
        {
        case EVENT_CANOPY_OPEN:
            if( !_flappingSound->isPlaying() )
            {
				_openSound->setGain(100.0f);
                _openSound->play();
                _flappingSound->play();
				_jetSound->play();
            }
            break;
        case EVENT_CANOPY_VELOCITY:
            _velocity = *( (float*)( eventData ) );
            break;
        }

        // canopy pitch lerp
        float canopyMinPitchVel   = 0.0f;
        float canopyMinPitchValue = 0.5f;
        float canopyMaxPitchVel   = 14.0f;
        float canopyMaxPitchValue = 2.0f;
        // canopy gain lerp
        float canopyMinGainVel   = 0.0f;
        float canopyMinGainValue = 0.0f;
        float canopyMaxGainVel   = 14.0f;
        float canopyMaxGainValue = 3.0f;

        // result
        _flappingPitch = lerp( canopyMinPitchVel, canopyMinPitchValue, canopyMaxPitchVel, canopyMaxPitchValue, _velocity );
        _flappingGain  = lerp( canopyMinGainVel, canopyMinGainValue, canopyMaxGainVel, canopyMaxGainValue, _velocity );        

		_flappingGain  = _velocity;
		_flappingPitch = 0.0f;

        // jet pitch lerp
        float jetMinPitchVel   = 0.0f;
        float jetMinPitchValue = 1.0f;
        float jetMaxPitchVel   = 50.0f;
        float jetMaxPitchValue = 2.0f;
        // jet gain lerp
        float jetMinGainVel   = 0.0f;
        float jetMinGainValue = 0.0f;
        float jetMaxGainVel   = 50.0f;
        float jetMaxGainValue = 2.0f;

        // result
        _jetPitch = lerp( jetMinPitchVel, jetMinPitchValue, jetMaxPitchVel, jetMaxPitchValue, _velocity );
        _jetGain  = lerp( jetMinGainVel, jetMinGainValue, jetMaxGainVel, jetMaxGainValue, _velocity );
        _jetPitch     *= _modifier;
    }
}
예제 #2
0
	bool ListenerEntity::HandleMessage(Message &message)
	{
		bool handled = Entity::HandleMessage(message);

		if (message.message == MessageID::POSITION_UPDATED || message.message == MessageID::ROTATION_UPDATED)
		{
			sf::Vector2f entityPos = GetGlobalPosition();
			sf::Vector3f soundPos(entityPos.x, entityPos.y, 0);
			sf::Listener::SetPosition(soundPos);

			return true;
		}

		return handled;
	}
예제 #3
0
void FlightSound::onUpdateActivity(float dt)
{
    Matrix4f parentPose = _parent->getPose();
    Vector3f soundPos( parentPose[3][0], parentPose[3][1], parentPose[3][2] );
    Vector3f soundVel = _parent->getVel();

    if( _flappingSound->isPlaying() )
    {
		// update revebation based on altitude
		updateReverbation(_flappingSound, parentPose[3][1]);

        _flappingSound->place( soundPos, soundVel );
		
		//getCore()->logMessage("soundvel: %2.2f", soundVel.length());
		//_flappingSound->setPitchShift(soundVel.length() / 2000.0f);

        if( Gameplay::iGameplay->pitchShiftIsEnabled() )
        {
            _flappingSound->setPitchShift( _flappingPitch * _scene->getTimeSpeed() );
        }
        _flappingSound->setGain( _flappingGain );
        _openSound->place( soundPos, soundVel );
	

        if( Gameplay::iGameplay->pitchShiftIsEnabled() )
        {
            _openSound->setPitchShift( _scene->getTimeSpeed() );
        }

		// jet sound
		// update revebation based on altitude
		updateReverbation(_flappingSound, parentPose[3][1]);

		_jetSound->place( soundPos, soundVel );
		_jetSound->setPitchShift( soundVel.length() / 1000.0f);
        if( Gameplay::iGameplay->pitchShiftIsEnabled() )
        {
            _jetSound->setPitchShift( _jetPitch * _scene->getTimeSpeed() );
        }
        _jetSound->setGain( _jetGain );
    }
}
예제 #4
0
void FlightSound::onUpdateActivity(float dt)
{
    Matrix4f parentPose = _parent->getPose();
    Vector3f soundPos( parentPose[3][0], parentPose[3][1], parentPose[3][2] );
    Vector3f soundVel = _parent->getVel();

    if( _flappingSound->isPlaying() )
    {
        _flappingSound->place( soundPos, soundVel );
        if( Gameplay::iGameplay->pitchShiftIsEnabled() )
        {
            _flappingSound->setPitchShift( _flappingPitch * _scene->getTimeSpeed() );
        }
        _flappingSound->setGain( _flappingGain );
        _openSound->place( soundPos, soundVel );
        if( Gameplay::iGameplay->pitchShiftIsEnabled() )
        {
            _openSound->setPitchShift( _scene->getTimeSpeed() );
        }
    }
}
예제 #5
0
void FootstepsSound::onUpdateActivity(float dt)
{
    Matrix4f parentPose = _parent->getPose();
    Vector3f soundPos( parentPose[3][0], parentPose[3][1], parentPose[3][2] );

    if( _walkSound->isPlaying() )
    {
        _walkSound->place( soundPos );
        if( Gameplay::iGameplay->pitchShiftIsEnabled() )
        {
            _walkSound->setPitchShift( _pitchShiftFactor * _pitchMultiplier * _scene->getTimeSpeed() );
        }
    }

    if( _turnSound->isPlaying() )
    {
        _turnSound->place( soundPos );
        if( Gameplay::iGameplay->pitchShiftIsEnabled() )
        {
            _turnSound->setPitchShift( _scene->getTurnPitch() * _scene->getTimeSpeed() );
        }
    }
}
예제 #6
0
void FootstepsSound::onEvent(Actor* initiator, unsigned int eventId, void* eventData)
{
    if( eventId == EVENT_SCENE_REVERBERATION_IS_CHANGED )
    {
        if( getScene()->getReverberation() )
        {
            getCore()->logMessage( "FootstepsSound reverberation changed" );
            _walkSound->setReverberation(
                getScene()->getReverberation()->inGain,
                getScene()->getReverberation()->reverbMixDB,
                getScene()->getReverberation()->reverbTime,
                getScene()->getReverberation()->hfTimeRatio
            );
            _turnSound->setReverberation(
                getScene()->getReverberation()->inGain,
                getScene()->getReverberation()->reverbMixDB,
                getScene()->getReverberation()->reverbTime,
                getScene()->getReverberation()->hfTimeRatio
            );
        }
    }

    if( initiator == _parent )
    {
        Matrix4f parentPose = _parent->getPose();
        Vector3f soundPos( parentPose[3][0], parentPose[3][1], parentPose[3][2] );

        switch( eventId )
        {        
        case EVENT_JUMPER_BEGIN_WALKFWD:
            if( !_walkSound->isPlaying() )
            {
                _pitchMultiplier = _scene->getWalkPitch();
                if( Gameplay::iGameplay->pitchShiftIsEnabled() )
                {
                    _walkSound->setPitchShift( _pitchShiftFactor * _pitchMultiplier * _scene->getTimeSpeed() );
                }
                _walkSound->place( soundPos );
                _walkSound->play();
            }
            break;
        case EVENT_JUMPER_END_WALKFWD:
            if( _walkSound->isPlaying() ) _walkSound->stop();
            break;
        case EVENT_JUMPER_BEGIN_WALKBCK:
            if( !_walkSound->isPlaying() )
            {
                _pitchMultiplier = _scene->getBackPitch();
                if( Gameplay::iGameplay->pitchShiftIsEnabled() )
                {
                    _walkSound->setPitchShift( _pitchShiftFactor * _pitchMultiplier * _scene->getTimeSpeed() );
                }
                _walkSound->place( soundPos );
                _walkSound->play();
            }
            break;
        case EVENT_JUMPER_END_WALKBCK:
            if( _walkSound->isPlaying() ) _walkSound->stop();
            break;
        case EVENT_JUMPER_BEGIN_TURN:
            if( !_turnSound->isPlaying() )
            {
                if( Gameplay::iGameplay->pitchShiftIsEnabled() )
                {
                    _turnSound->setPitchShift( _scene->getTurnPitch() * _scene->getTimeSpeed() );
                }
                _turnSound->place( soundPos );
                _turnSound->play();
            }
            break;
        case EVENT_JUMPER_END_TURN:
            if( _turnSound->isPlaying() ) _turnSound->stop();
            break;
        case EVENT_JUMPER_PITCHSHIFT:
            assert( eventData );
            _pitchShiftFactor = *( (float*)( eventData ) );
            if( _walkSound->isPlaying() ) 
            {
                if( Gameplay::iGameplay->pitchShiftIsEnabled() )
                {
                    _walkSound->setPitchShift( _pitchShiftFactor * _pitchMultiplier * _scene->getTimeSpeed() );
                }
            }
            break;
        }
    }
}