Пример #1
0
void CSoundGroup::UploadPropertiesAndPlay(int theIndex, const CVector3D& position)
{
	bool	isOnscreen;
	ALfloat	initialRolllOff = 0.02f;
	ALfloat	itemRollOff = initialRolllOff;

	float 	offSet = RadiansOffCenter(position, isOnscreen, itemRollOff);

	if (isOnscreen || TestFlag(eDistanceless) || TestFlag(eOmnipresent))
	{
		if (snd_group.size() == 0)
			Reload();

		ISoundItem* hSound = snd_group[theIndex];
		CVector3D origin = g_Game->GetView()->GetCamera()->GetOrientation().GetTranslation();
		float sndDist = origin.Y;

		if (!TestFlag(eOmnipresent))
		{
			hSound->SetLocation(CVector3D((sndDist * sin(offSet)), 0, sndDist * cos(offSet)));
			if (TestFlag(eDistanceless))
				hSound->SetRollOff(initialRolllOff);
			else
				hSound->SetRollOff(itemRollOff);
		}

		if (TestFlag(eRandPitch))
			hSound->SetPitch(RandFloat(m_PitchLower, m_PitchUpper));
		else
			hSound->SetPitch(m_Pitch);

		ALfloat theGain = m_Gain;
		if (TestFlag(eRandGain))
			theGain = RandFloat(m_GainLower, m_GainUpper);

		hSound->SetCone(m_ConeInnerAngle, m_ConeOuterAngle, m_ConeOuterGain);

		g_SoundManager->PlayGroupItem(hSound, theGain);
	}
}
Пример #2
0
void CSoundGroup::UploadPropertiesAndPlay(size_t theIndex, const CVector3D& position, entity_id_t source)
{
#if CONFIG2_AUDIO
	if ( g_SoundManager )
	{
		bool	isOnscreen;
		ALfloat	initialRolllOff = 0.1f;
		ALfloat	itemRollOff = initialRolllOff;

		float 	offSet = RadiansOffCenter(position, isOnscreen, itemRollOff);

		if (isOnscreen || TestFlag(eDistanceless) || TestFlag(eOmnipresent))
		{
			if (snd_group.size() == 0)
				Reload();

			if ( snd_group.size() > theIndex )
			{
				if ( CSoundData* sndData = snd_group[theIndex] )
				{
					CVector3D origin = g_Game->GetView()->GetCamera()->GetOrientation().GetTranslation();
					float sndDist = origin.Y;
					float itemDist = ( position - origin ).Length();

					if ( (sndDist * 2) < itemDist )
						sndDist = itemDist;

					ISoundItem*	hSound = ((CSoundManager*)g_SoundManager)->ItemForEntity( source, sndData);

					if ( hSound )
					{
						if (!TestFlag(eOmnipresent))
						{
							if (TestFlag(eDistanceless))
								itemRollOff = 0;
							
							if ( sndData->IsStereo() )
								LOGWARNING( L"OpenAL: stereo sounds can't be positioned: %ls", sndData->GetFileName()->string().c_str() );

							hSound->SetLocation(CVector3D((sndDist * sin(offSet)), 0, - sndDist * cos(offSet)));
							hSound->SetRollOff(itemRollOff);
						}

						if (TestFlag(eRandPitch))
							hSound->SetPitch(RandFloat(m_PitchLower, m_PitchUpper));
						else
							hSound->SetPitch(m_Pitch);

						ALfloat theGain = m_Gain;
						if (TestFlag(eRandGain))
							theGain = RandFloat(m_GainLower, m_GainUpper);

						hSound->SetCone(m_ConeInnerAngle, m_ConeOuterAngle, m_ConeOuterGain);

						((CSoundManager*)g_SoundManager)->PlayGroupItem(hSound, theGain);
					}
				}
			}
		}
	}
#else // !CONFIG2_AUDIO
	UNUSED2(theIndex);
	UNUSED2(position);
	UNUSED2(source);
#endif // !CONFIG2_AUDIO
}