Example #1
0
const bool VCNRenderNode::UpdateWorldTransform()
{
	if ( VCNNode::UpdateWorldTransform() )
	{
		// Update mesh bounding sphere
		const VCNResID meshID = GetMeshID();
		if ( meshID != kInvalidResID )
		{
			VCNMesh* mesh = VCNResourceCore::GetInstance()->GetResource<VCNMesh>(meshID);
			const VCNSphere boundingSphere = mesh->GetBoundingSphere();

			// Transform the sphere relative to the render node
			const Vector3 ascSacle = GetWorldScale();
			const VCNFloat radius = boundingSphere.GetRadius() * std::max(ascSacle.x, std::max(ascSacle.y, ascSacle.z));

			mBoundingSphere.Set( radius, boundingSphere.GetCenter() * mWorld );
			mBoundingBox.vcMin = (mesh->GetBoundingBox().vcMin.MulComponents(ascSacle)) + GetWorldTranslation();
			mBoundingBox.vcMax = (mesh->GetBoundingBox().vcMax.MulComponents(ascSacle)) + GetWorldTranslation();
		}

		return true;
	}

	return false;
}
Example #2
0
bool psEntity::Play(SoundControl* &ctrl, csVector3 entityPosition)
{
    EntityState* entityState;

    // checking if a sound is still playing
    if(IsPlaying())
    {
        return false;
    }

    // checking if the state is defined
    entityState = states.Get(state, 0);
    if(entityState == 0)
    {
        return false;
    }

    // picking up randomly among resources
    if(!entityState->resources.IsEmpty())
    {
        int resourceNumber = SoundManager::randomGen.Get() * entityState->resources.GetSize();

        Debug4(LOG_SOUND, 0, "psEntity::Play() %s PLAYS %s meshid: %u",entityName.GetData(),entityState->resources[resourceNumber],GetMeshID());

        if(SoundSystemManager::GetSingleton().Play3DSound(entityState->resources[resourceNumber], DONT_LOOP, 0, 0,
                entityState->volume, ctrl, entityPosition, 0, minRange, maxRange,
                VOLUME_ZERO, CS_SND3D_ABSOLUTE, handle))
        {
            when = entityState->delay;
            handle->SetCallback(this, &StopCallback);
            return true;
        }
    }

    return false;
}
Example #3
0
bool psEntity::CanPlay(int time, float range) const
{
    EntityState* entityState;

    // checking if it is in the undefined state
    entityState = states.Get(state, 0);
    if(entityState == 0)
    {
        Debug3(LOG_SOUND, 0, "psEntity::CanPlay %s meshid: %u undefined state.", entityName.GetData(), GetMeshID());
        return false;
    }

    // checking time, range and delay
    if(range < minRange || range > maxRange)
    {
        Debug6(LOG_SOUND, 0, "psEntity::CanPlay %s meshid: %u range %f %f %f", entityName.GetData(),GetMeshID(), minRange, range, maxRange);
        return false;
    }
    else if(time < entityState->timeOfDayStart || entityState->timeOfDayEnd < time)
    {
        Debug6(LOG_SOUND, 0, "psEntity::CanPlay %s meshid: %u time of day %d %d %d", entityName.GetData(),GetMeshID(), entityState->timeOfDayStart,time,entityState->timeOfDayEnd);
        return false;
    }
    else if(when <= 0)
    {
        Debug4(LOG_SOUND, 0, "psEntity::CanPlay TRUE %s meshid: %u when <0 : %d", entityName.GetData(),GetMeshID(), when);
        return true;
    }
    Debug4(LOG_SOUND, 0, "psEntity::CanPlay %s meshid: %u when : %d", entityName.GetData(),GetMeshID(), when);

    return false;
}