예제 #1
0
//-----------------------------------------------------------------------
bool PUOnTimeObserver::observe (PUParticle3D* particle, float timeElapsed)
{
    if (_compare == CO_GREATER_THAN)
    {
        if (_sinceStartSystem)
        {
            // Validate whether time since start of the particle system > threshold
            return (_particleSystem->getTimeElapsedSinceStart() > _threshold);
        }
        else
        {
            // Validate whether time since start of the particle emission > threshold
            return (particle && (particle->totalTimeToLive - particle->timeToLive) > _threshold);
        }
    }
    else if (_compare == CO_LESS_THAN)
    {
        if (_sinceStartSystem)
        {
            // Validate whether time since start of the particle system < threshold
            return (_particleSystem->getTimeElapsedSinceStart() < _threshold);
        }
        else
        {
            // Validate whether time since start of the particle emission < threshold
            return (particle && (particle->totalTimeToLive - particle->timeToLive) < _threshold);
        }
    }
    else
    {
        // Equals
        if (_sinceStartSystem)
        {
            // Validate whether time since start of the particle system == threshold
            return almostEquals(_particleSystem->getTimeElapsedSinceStart(), _threshold, 0.01f);
        }
        else
        {
            // Validate whether time since start of the particle emission == threshold
            return particle && almostEquals((particle->totalTimeToLive - particle->timeToLive), _threshold, 0.01f);
        }
    }

    return false;
}
	//-----------------------------------------------------------------------
	bool OnTimeObserver::_observe (ParticleTechnique* particleTechnique, Particle* particle, Real timeElapsed)
	{
		if (mCompare == CO_GREATER_THAN)
		{
			if (mSinceStartSystem)
			{
				// Validate whether time since start of the particle system > threshold
				return (mParentTechnique->getParentSystem()->getTimeElapsedSinceStart() > mThreshold);
			}
			else
			{
				// Validate whether time since start of the particle emission > threshold
				return (particle && (particle->totalTimeToLive - particle->timeToLive) > mThreshold);
			}
		}
		else if (mCompare == CO_LESS_THAN)
		{
			if (mSinceStartSystem)
			{
				// Validate whether time since start of the particle system < threshold
				return (mParentTechnique->getParentSystem()->getTimeElapsedSinceStart() < mThreshold);
			}
			else
			{
				// Validate whether time since start of the particle emission < threshold
				return (particle && (particle->totalTimeToLive - particle->timeToLive) < mThreshold);
			}
		}
		else
		{
			// Equals
			if (mSinceStartSystem)
			{
				// Validate whether time since start of the particle system == threshold
				return almostEquals(mParentTechnique->getParentSystem()->getTimeElapsedSinceStart(), mThreshold, 0.01f);
			}
			else
			{
				// Validate whether time since start of the particle emission == threshold
				return particle && almostEquals((particle->totalTimeToLive - particle->timeToLive), mThreshold, 0.01f);
			}
		}

		return false;
	}
예제 #3
0
//-----------------------------------------------------------------------
bool PUOnVelocityObserver::observe (PUParticle3D* particle, float timeElapsed)
{
    if (!particle)
        return false;

    // Compensate for the scaled velocity
    float scaleVelocity = _particleSystem->getParticleSystemScaleVelocity();
    if (_compare == CO_GREATER_THAN)
    {
        // Changed in V 1.3.1
        return (particle->calculateVelocity()) > (scaleVelocity * _threshold);
    }
    else if (_compare == CO_LESS_THAN)
    {
        return (particle->calculateVelocity()) < (scaleVelocity * _threshold);
    }
    else
    {
        // Equals
        return almostEquals(particle->calculateVelocity(), (scaleVelocity * _threshold), 0.01f);
    }

    return false;
}
	//-----------------------------------------------------------------------
	bool OnVelocityObserver::_observe (ParticleTechnique* particleTechnique, Particle* particle, Real timeElapsed)
	{
		if (!particle)
			return false;

		// Compensate for the scaled velocity
		Real scaleVelocity = particleTechnique->getParentSystem()->getScaleVelocity();
		if (mCompare == CO_GREATER_THAN)
		{
			// Changed in V 1.3.1
			return (particle->calculateVelocity()) > (scaleVelocity * mThreshold);
		}
		else if (mCompare == CO_LESS_THAN)
		{
			return (particle->calculateVelocity()) < (scaleVelocity * mThreshold);
		}
		else
		{
			// Equals
			return almostEquals(particle->calculateVelocity(), (scaleVelocity * mThreshold), 0.01f);
		}

		return false;
	}