Ejemplo n.º 1
0
/**
*  @brief
*    Returns the sound container this sound is in
*/
SCSound *SNMSound::GetSoundContainer() const
{
	// Get the PL sound container this scene node is in
	SceneContainer *pContainer = GetSceneNode().GetContainer();
	while (pContainer && !pContainer->IsInstanceOf("PLSound::SCSound"))
		pContainer = pContainer->GetContainer();

	// Done
	return (pContainer && pContainer->IsInstanceOf("PLSound::SCSound")) ? static_cast<SCSound*>(pContainer) : nullptr;
}
Ejemplo n.º 2
0
/**
*  @brief
*    Loads/reloads the sound
*/
void SNMSound::Load()
{
	// Destroy currently used sound source
	Source *pSS = static_cast<Source*>(m_pSoundSourceHandler->GetResource());
	if (pSS)
		delete pSS;

	// Get the PL sound container this scene node is in
	SceneContainer *pContainer = GetSceneNode().GetContainer();
	while (pContainer && !pContainer->IsInstanceOf("PLSound::SCSound"))
		pContainer = pContainer->GetContainer();
	if (pContainer) {
		SoundManager *pSoundManager = static_cast<SCSound*>(pContainer)->GetSoundManager();
		if (pSoundManager) {
			Source *pSoundSource = pSoundManager->CreateSoundSource(pSoundManager->CreateSoundBuffer(m_sSound, (GetFlags() & Stream) != 0));
			m_pSoundSourceHandler->SetResource(pSoundSource);
			pSoundSource->SetAttribute(Source::Position, GetSceneNode().GetTransform().GetPosition());
			pSoundSource->SetVolume(m_fVolume);
			pSoundSource->Set2D((GetFlags() & No3D) != 0);
			pSoundSource->SetLooping(!(GetFlags() & NoLoop));
			pSoundSource->SetPitch(m_fPitch);
			pSoundSource->SetReferenceDistance(m_fReferenceDistance);
			pSoundSource->SetMaxDistance(m_fMaxDistance);
			pSoundSource->SetRolloffFactor(m_fRolloffFactor);
			OnPosition();
			if (!(GetFlags() & NoStartPlayback))
				pSoundSource->Play();
		}
	}
}
Ejemplo n.º 3
0
/**
*  @brief
*    Returns the gravity vector
*/
Vector3 PGPhysics::GetGravity() const
{
	// Get the PL physics world this scene node is in
	SceneContainer *pContainer = GetContainer();
	while (pContainer && !pContainer->IsInstanceOf("PLPhysics::SCPhysicsWorld"))
		pContainer = pContainer->GetContainer();

	// Get the gravity vector
	Vector3 vGravity;
	if (pContainer && static_cast<SCPhysicsWorld*>(pContainer)->GetWorld())
		static_cast<SCPhysicsWorld*>(pContainer)->GetWorld()->GetGravity(vGravity);
	else
		vGravity.SetXYZ(0.0f, -9.81f, 0.0f);

	// Return the gravity vector
	return vGravity;
}