//-----------------------------------------------------------------------
	void ParticleEmitter::_initParticleDimensions(Particle* particle)
    {
		if (particle->particleType != Particle::PT_VISUAL)
			return;

		// Only continue if one of them is set
		VisualParticle* visualParticle = static_cast<VisualParticle*>(particle);
		if (mDynParticleAllDimensionsSet || mDynParticleWidthSet || mDynParticleHeightSet || mDynParticleDepthSet)
		{
			// Set all dimensions equal ...
			Real extend = 0;
			if (mDynParticleAllDimensionsSet && mDynParticleAllDimensions)
			{
				extend = mDynamicAttributeHelper.calculate(mDynParticleAllDimensions, mParentTechnique->getParentSystem()->getTimeElapsedSinceStart());
				visualParticle->setOwnDimensions(_mEmitterScale.x * extend, _mEmitterScale.y * extend, _mEmitterScale.z * extend);
				return;
			}

			// ... or set the dimensions independent from each other
			Real width = 0;
			Real height = 0;
			Real depth = 0;
			if (mDynParticleWidthSet && mDynParticleWidth)
			{
				width = mDynamicAttributeHelper.calculate(mDynParticleWidth, mParentTechnique->getParentSystem()->getTimeElapsedSinceStart());
			}
			if (mDynParticleHeightSet && mDynParticleHeight)
			{
				height = mDynamicAttributeHelper.calculate(mDynParticleHeight, mParentTechnique->getParentSystem()->getTimeElapsedSinceStart());
			}
			if (mDynParticleDepthSet && mDynParticleDepth)
			{
				depth = mDynamicAttributeHelper.calculate(mDynParticleDepth, mParentTechnique->getParentSystem()->getTimeElapsedSinceStart());
			}
	
			/** Set the width, height and depth if at least one of them is set.
			@remarks
				If one of the dimensions is 0, it will be overridden by the default value later on.
			*/
			if (mDynParticleWidthSet || mDynParticleHeightSet || mDynParticleDepthSet)
			{
				visualParticle->setOwnDimensions(_mEmitterScale.x * width, _mEmitterScale.y * height, _mEmitterScale.z * depth);
			}
		}
		else
		{
			// Just set the width, height and depth, but these are just the default settings; the particle doesn't
			// have own dimensions. Recalculate the bounding sphere radius.
			visualParticle->width = _mEmitterScale.x * mParentTechnique->getDefaultWidth();
			visualParticle->height = _mEmitterScale.y * mParentTechnique->getDefaultHeight();
			visualParticle->depth = _mEmitterScale.z * mParentTechnique->getDefaultDepth();
			visualParticle->_calculateBoundingSphereRadius();
		}
	}
	//-----------------------------------------------------------------------
	void ParticlePool::_increaseVisualParticlePool(size_t size, 
		Particle::ParticleBehaviourList& behaviours)
	{
		size_t oldSize = mVisualParticles.size();
		if (size < oldSize)
			return;

		// Create new visual particles
		VisualParticle* particle = 0;
		for (size_t i = oldSize; i < size; i++)
		{
			particle = PU_NEW_T(VisualParticle, MEMCATEGORY_SCENE_OBJECTS)();
			particle->copyBehaviours(behaviours);
			mVisualParticlesPool.addElement(particle);
			mVisualParticles.push_back(particle);
		}
	}
	//-----------------------------------------------------------------------
	void AlignAffector::_affect(ParticleTechnique* particleTechnique, Particle* particle, Real timeElapsed)
	{
		if (particle->particleType == Particle::PT_VISUAL)
		{
			// Set the orientation towards the previous particle, but rotation is undetermined.
			VisualParticle* visualParticle = static_cast<VisualParticle*>(particle);

			// Get difference
			Vector3 diff = (mPreviousParticle->position - particle->position);
			if (mResize)
			{
				visualParticle->setOwnDimensions (visualParticle->width, diff.length(), visualParticle->depth);
			}
			diff.normalise();
			visualParticle->orientation.x = diff.x;
			visualParticle->orientation.y = diff.y;
			visualParticle->orientation.z = diff.z;
		}

		mPreviousParticle = particle;
	}