Example #1
0
void IconButton::draw(DrawingContext& drawingContext) {
    //Update slidy button effect
    updateSlidyButtonEffect();

    // Draw the button
    std::shared_ptr<const Material> material = nullptr;

    // Determine button color
    if (!isEnabled()) {
        material = std::make_shared<const Material>(nullptr, DISABLED_BUTTON_COLOUR, true);
    } else if (_mouseOver) {
        material = std::make_shared<const Material>(nullptr, HOVER_BUTTON_COLOUR, true);
    } else {
        material = std::make_shared<const Material>(nullptr, DEFAULT_BUTTON_COLOUR, true);
    }
    material->apply();
    _gameEngine->getUIManager()->drawQuad2d(getDerivedBounds());

    // Draw icon
    int iconSize = getHeight() - 4;
    material = std::make_shared<const Material>(_icon.get_ptr(), _iconTint, true);
    _gameEngine->getUIManager()->drawImage(Point2f(getDerivedPosition().x() + getWidth() - getHeight() - 2,
                                                   getDerivedPosition().y() + 2), Vector2f(iconSize, iconSize), material);

    // Draw text on left side in button
    if (_buttonTextRenderer) {
        _buttonTextRenderer->render(getDerivedPosition().x() + 5, getDerivedPosition().y() + (getHeight() - _buttonTextHeight) / 2);
    }
}
Example #2
0
void InventorySlot::draw(DrawingContext& drawingContext) {
    std::shared_ptr<Object> item = _inventory.getItem(_slotNumber);

    // grab the icon reference
    std::shared_ptr<const Texture> icon_ref;


    if (item) {
        icon_ref = item->getIcon();
    } else {
        icon_ref = TextureManager::get().getTexture("mp_data/nullicon");
    }

    bool selected = false;
    if (_player) {
        selected = _player->getSelectedInventorySlot() == _slotNumber;
    }

    //Draw the icon
    draw_game_icon(icon_ref, getDerivedPosition().x(), getDerivedPosition().y(), selected ? COLOR_WHITE : NOSPARKLE, update_wld, getWidth());

    //Draw ammo
    if (item) {
        if (0 != item->ammomax && item->ammoknown) {
            if (!item->getProfile()->isStackable() || item->getAmmo() > 1) {
                // Show amount of ammo left
                _gameEngine->getUIManager()->getFont(UIManager::FONT_GAME)->drawTextBox(std::to_string(item->getAmmo()), getDerivedPosition().x(), getDerivedPosition().y(), getWidth(), getHeight(), 0);
            }
        }
    }
}
	//----------------------------------------------------------------------- 
	void CircleEmitter::_initParticlePosition(Particle* particle)
	{
		Real angle = 0;
		if (mRandom)
		{
			// Choose a random position on the circle.
			angle = Math::RangeRandom(0, Math::TWO_PI);
		}
		else
		{
			// Follow the contour of the circle.
			mCircleAngle += mStep;
			mCircleAngle = mCircleAngle > Math::TWO_PI ? mCircleAngle - Math::TWO_PI : mCircleAngle;
			angle = mCircleAngle;
		}

		mX = Math::Cos(angle);
		mZ = Math::Sin(angle);
		ParticleSystem* sys = mParentTechnique->getParentSystem();
		if (sys)
		{
			// Take both orientation of the node and its own orientation, based on the normal, into account
			particle->position = getDerivedPosition() + 
				sys->getDerivedOrientation() * mOrientation * (_mEmitterScale * Vector3(mX * mRadius, 0, mZ * mRadius));
		}
		else
		{
			particle->position = getDerivedPosition() + _mEmitterScale * ( mOrientation * Vector3(mX * mRadius, 0, mZ * mRadius) );
		}
		particle->originalPosition = particle->position;
	}
Example #4
0
void CSoundObject::updateData(F64 time){
	CVector3 pos = getDerivedPosition();
	CSceneObject::updateData(time);
    CVector3 vel = (getDerivedPosition() - pos) / (time * 16.0f);
	setVelocity(vel);
    //gcon.printf("Velocity : %f\n", vel.length());
	updateSound();
}
Example #5
0
void InternalWindow::drawContainer(DrawingContext& drawingContext) {
    std::shared_ptr<const Material> material;
    //Draw background first
    material = std::make_shared<const Material>(_background.get(), Colour4f(Colour3f::white(), 0.9f), true);
    _gameEngine->getUIManager()->drawImage(Point2f(getDerivedPosition().x(), getDerivedPosition().y()),
                                           Vector2f(getWidth(), getHeight()), material);

    //Draw window title
    _titleBar->draw(drawingContext);

    //Draw the close button
    _closeButton->draw(drawingContext);
}
Example #6
0
 Box SceneNode::getBoundingBox(bool derived_position)
 {
     if (derived_position)
         return { getDerivedPosition(), bounding_box };
     else
         return { getPosition(), bounding_box };
 }
Example #7
0
//----------------------------------------------------------------------- 
void PUCircleEmitter::initParticlePosition(PUParticle3D* particle)
{
    float angle = 0;
    if (_random)
    {
        // Choose a random position on the circle.
        angle = cocos2d::random(0.0, M_PI * 2.0);
    }
    else
    {
        // Follow the contour of the circle.
        _circleAngle += _step;
        _circleAngle = _circleAngle > M_PI * 2.0f ? _circleAngle - (M_PI * 2.0) : _circleAngle;
        angle = _circleAngle;
    }

    _x = cosf(angle);
    _z = sinf(angle);
    //ParticleSystem* sys = mParentTechnique->getParentSystem();
    //if (sys)
    {
        // Take both orientation of the node and its own orientation, based on the normal, into account
        Mat4 rotMat;
        Mat4::createRotation(static_cast<PUParticleSystem3D *>(_particleSystem)->getDerivedOrientation() * _orientation, &rotMat);
        particle->position = getDerivedPosition() + 
            /*sys->getDerivedOrientation() * */rotMat * (Vec3(_x * _radius * _emitterScale.x, 0, _z * _radius * _emitterScale.z));
    }
    //else
    //{
    //	particle->position = getDerivedPosition() + _emitterScale * ( mOrientation * Vec3(mX * mRadius, 0, mZ * mRadius) );
    //}
    particle->originalPosition = particle->position;
}
Example #8
0
void PUEmitter::prepare()
{
    if (!_emitsEntity){
        if (_emitsType == PUParticle3D::PT_EMITTER){
            auto emitter = static_cast<PUParticleSystem3D *>(_particleSystem)->getEmitter(_emitsName);
            if (emitter){
                emitter->setMarkedForEmission(true);
                _emitsEntity = emitter;
            }
        }
        else if (_emitsType == PUParticle3D::PT_TECHNIQUE){
            PUParticleSystem3D *system = static_cast<PUParticleSystem3D *>(_particleSystem)->getParentParticleSystem();
            if (system){
                auto children = system->getChildren();
                for (auto it : children){
                    if (it->getName() == _emitsName)
                    {
                        static_cast<PUParticleSystem3D *>(it)->setMarkedForEmission(true);
                        _emitsEntity = it;
                        break;
                    }
                }
            }
        }
    }

    _latestPosition = getDerivedPosition(); // V1.3.1
}
Example #9
0
//-----------------------------------------------------------------------
void CCPUBoxEmitter::initParticlePosition(PUParticle3D* particle)
{
    //ParticleSystem* sys = mParentTechnique->getParentSystem();

    //if (sys)
    {
        Mat4 rotMat;
        Mat4::createRotation(static_cast<PUParticleSystem3D *>(_particleSystem)->getDerivedOrientation(), &rotMat);
        particle->position = getDerivedPosition() + 
            rotMat *
            (/*_emitterScale **/
            Vec3(CCRANDOM_MINUS1_1() * _xRange * _emitterScale.x,
            CCRANDOM_MINUS1_1() * _yRange * _emitterScale.y,
            CCRANDOM_MINUS1_1() * _zRange * _emitterScale.z));
    }
    //else
    //{
    //	particle->position = getDerivedPosition() + 
    //		_emitterScale *
    //		Vector3(Math::SymmetricRandom() * _xRange,
    //		Math::SymmetricRandom() * _yRange,
    //		Math::SymmetricRandom() * _zRange);
    //}

    particle->originalPosition = particle->position;
}
    /* Update function (currently used for making sure the origin stuff for the
        extra culling frustum is up to date */
    void PCZCamera::update(void)
    {
        // make sure the extra culling frustum origin stuff is up to date
		if (mProjType == PT_PERSPECTIVE)
		//if (!mCustomViewMatrix)
		{
			mExtraCullingFrustum.setUseOriginPlane(true);
			mExtraCullingFrustum.setOrigin(getDerivedPosition());
			mExtraCullingFrustum.setOriginPlane(getDerivedDirection(), getDerivedPosition());
		}
		else
		{
			// In ortho mode, we don't want to cull things behind camera.
			// This helps for back casting which is useful for texture shadow projection on directional light.
			mExtraCullingFrustum.setUseOriginPlane(false);
		}
    }
Example #11
0
void PUBoxCollider::preUpdateAffector( float deltaTime )
{
    PUBaseCollider::preUpdateAffector(deltaTime);
    // Calculate the affectors' center position in worldspace, set the box and calculate the bounds
    // Applied scaling in V 1.3.1.
    populateAlignedBox(_box, getDerivedPosition(), _affectorScale.x * _width, _affectorScale.y * _height, _affectorScale.z * _depth);
    calculateBounds();
}
	//-----------------------------------------------------------------------
	void MeshSurfaceEmitter::_initParticlePosition(Particle* particle)
	{
		Triangle::PositionAndNormal pAndN;
		pAndN.position = Vector3::ZERO;
		pAndN.normal = Vector3::ZERO;
		mDirectionSet = false;

		if (mMeshInfo)
		{
			getDerivedPosition();
			mTriangleIndex = mMeshInfo->getRandomTriangleIndex (); // Get a random triangle index
			pAndN = mMeshInfo->getRandomPositionAndNormal(mTriangleIndex); // Determine position and normal
			ParticleSystem* sys = mParentTechnique->getParentSystem();
			if (mAutoDirection)
			{
				if (pAndN.normal != Vector3::ZERO)
				{
					// Set position and direction of the particle
					if (sys)
					{
						particle->position = mDerivedPosition + sys->getDerivedOrientation() * (_mEmitterScale * pAndN.position);
					}
					else
					{
						particle->position = mDerivedPosition + _mEmitterScale * pAndN.position;
					}

					// The value of the direction vector that has been set does not have a meaning
					Radian angle(mDynamicAttributeHelper.calculate(mDynAngle, mParentTechnique->getParentSystem()->getTimeElapsedSinceStart()));
					if (angle != Radian(0))
					{
						particle->direction = (pAndN.normal).randomDeviant(angle, mUpVector);
					}
					else
					{
						particle->direction = pAndN.normal;
					}

					particle->originalDirection = particle->direction;
					mDirectionSet = true;
				}
			}
			else
			{
				// Set position of the particle
				if (sys)
				{
					particle->position = mDerivedPosition + sys->getDerivedOrientation() * (_mEmitterScale * pAndN.position);
				}
				else
				{
					particle->position = mDerivedPosition + _mEmitterScale * pAndN.position;
				}
			}
	
			particle->originalPosition = particle->position;
		}
	}
	//-----------------------------------------------------------------------
	void LineEmitter::_initParticlePosition(Particle* particle)
	{
		// Remark: Don´t take the orientation of the node into account. The mEnd position is leading.
		if (mAutoDirection || (_mScaledMaxDeviation > 0.0f && !mFirst))
		{
			// Generate a random vector perpendicular on the line if this is required
			mPerpendicular = mEnd.crossProduct(Vector3(Math::RangeRandom(-1, 1), 
				Math::RangeRandom(-1, 1), 
				Math::RangeRandom(-1, 1)));
			mPerpendicular.normalise();
		}

		// If mMaxIncrement has been set, the particle emission follows a trajectory path along the line
		Real fraction = 0.0f;
		if (_mScaledMaxIncrement > 0.0f)
		{
			if (!mFirst)
			{
				mIncrement += (_mScaledMinIncrement + Math::UnitRandom() * _mScaledMaxIncrement);
				if (mIncrement >= _mScaledLength)
				{
					mIncrementsLeft = false;
				}
				fraction = mIncrement / _mScaledLength;
			}
		}
		else
		{
			fraction = Math::UnitRandom();
		}

		// If the deviation has been set, generate a position with a certain distance from the line
		getDerivedPosition();
		if (_mScaledMaxDeviation > 0.0f && mIncrementsLeft)
		{
			if (!mFirst)
			{
				Vector3 basePosition = mDerivedPosition + fraction * _mScaledEnd;
				particle->position = basePosition + _mScaledMaxDeviation * Math::UnitRandom() * mPerpendicular;
				particle->originalPosition = basePosition;	// Position is without deviation from the line,
															// to make affectors a bit faster/easier.
			}
			else
			{
				particle->position = mDerivedPosition;
				particle->originalPosition = particle->position;
			}
		}
		else
		{
			particle->position = mDerivedPosition + fraction * _mScaledEnd;
			particle->originalPosition = particle->position;
		}

		mFirst = false;
	}
Example #14
0
//-----------------------------------------------------------------------
void PULineEmitter::initParticlePosition(PUParticle3D* particle)
{
    // Remark: Don't take the orientation of the node into account. The mEnd position is leading.
    if (_autoDirection || (_scaledMaxDeviation > 0.0f && !_first))
    {
        // Generate a random vector perpendicular on the line if this is required
        Vec3::cross(_end, Vec3(CCRANDOM_MINUS1_1(), 
            CCRANDOM_MINUS1_1(), 
            CCRANDOM_MINUS1_1()), &_perpendicular);
        _perpendicular.normalize();
    }

    // If mMaxIncrement has been set, the particle emission follows a trajectory path along the line
    float fraction = 0.0f;
    if (_scaledMaxIncrement > 0.0f)
    {
        if (!_first)
        {
            _increment += (_scaledMinIncrement + CCRANDOM_0_1() * _scaledMaxIncrement);
            if (_increment >= _scaledLength)
            {
                _incrementsLeft = false;
            }
            fraction = _increment / _scaledLength;
        }
    }
    else
    {
        fraction = CCRANDOM_0_1();
    }

    // If the deviation has been set, generate a position with a certain distance from the line
    getDerivedPosition();
    if (_scaledMaxDeviation > 0.0f && _incrementsLeft)
    {
        if (!_first)
        {
            Vec3 basePosition = _derivedPosition + fraction * _scaledEnd;
            particle->position = basePosition + _scaledMaxDeviation * CCRANDOM_0_1() * _perpendicular;
            particle->originalPosition = basePosition;	// Position is without deviation from the line,
            // to make affectors a bit faster/easier.
        }
        else
        {
            particle->position = _derivedPosition;
            particle->originalPosition = particle->position;
        }
    }
    else
    {
        particle->position = _derivedPosition + fraction * _scaledEnd;
        particle->originalPosition = particle->position;
    }

    _first = false;
}
Example #15
0
void CSoundListener::updateSound(){
    const CVector3 &v = getDerivedPosition();
	alListener3f(AL_POSITION, v.x, v.y, v.z);
	alListenerfv(AL_VELOCITY, &getVelocity().x);
	CVector3 ori[2];
	CQuaternion q = getDerivedOrientation();
	ori[0] = q * CVector3(0, 0, -1);
	ori[1] = q * CVector3(0, 1, 0);
	alListenerfv(AL_ORIENTATION, &ori[0].x);	
}
	//-----------------------------------------------------------------------
	void BoxCollider::_preProcessParticles(ParticleTechnique* particleTechnique, Real timeElapsed)
	{
		// Call parent
		BaseCollider::_preProcessParticles(particleTechnique, timeElapsed);

		// Calculate the affectors' center position in worldspace, set the box and calculate the bounds
		// Applied scaling in V 1.3.1.
		populateAlignedBox(mBox, getDerivedPosition(), _mAffectorScale.x * mWidth, _mAffectorScale.y * mHeight, _mAffectorScale.z * mDepth);
		_calculateBounds();
	}
Example #17
0
void ModelBoneProvider::updatePositionAndOrientation()
{
	if (mAttachPointWrapper && mAttachPointWrapper->TagPoint) {
		mAttachPointWrapper->TagPoint->setPosition(getDerivedPosition());
		mAttachPointWrapper->TagPoint->setOrientation(getDerivedOrientation());
	}
	for (ModelBoneProviderStore::const_iterator I = mChildren.begin(); I != mChildren.end(); ++I) {
		(*I)->updatePositionAndOrientation();
	}
}
	//-----------------------------------------------------------------------
	void SphereSurfaceEmitter::_initParticlePosition(Particle* particle)
	{
		// Generate a random unit vector to calculate a point on the sphere. This unit vector is
		// also used as direction vector if mAutoDirection has been set.
		mRandomVector = Vector3(Math::RangeRandom(-1, 1), 
			Math::RangeRandom(-1, 1),
			Math::RangeRandom(-1, 1));
		mRandomVector.normalise();
		ParticleSystem* sys = mParentTechnique->getParentSystem();
		if (sys)
		{
			particle->position = getDerivedPosition() + sys->getDerivedOrientation() * (_mEmitterScale * mRandomVector * mRadius);
		}
		else
		{
			particle->position = getDerivedPosition() + (_mEmitterScale * mRandomVector * mRadius);
		}
		particle->originalPosition = particle->position;
	}
	//-----------------------------------------------------------------------
	void VertexEmitter::_initParticlePosition(Particle* particle)
	{
		// Get the first one from the list.
		// The _calculateRequestedParticles() ensures that there are particles in the list.
		// All positions in mSpawnPositionList are in localspace
		ParticleSystem* sys = mParentTechnique->getParentSystem();
		if (sys)
		{
			particle->position = getDerivedPosition() +
				sys->getDerivedOrientation() * 
				(_mEmitterScale * *mSpawnPositionList.begin());
		}
		else
		{
			particle->position = getDerivedPosition() + _mEmitterScale * *mSpawnPositionList.begin();
		}
			
		mSpawnPositionList.pop_front();
		particle->originalPosition = particle->position;
	}
	//-----------------------------------------------------------------------
	SceneFloorInfo MovableObjectInformator::getFloorInfo(MovableObject* _obj)
	{
		Info* info = getInfo(_obj);
		if(!(info->flags & FLAG_FLOOR_INFO))
		{
			const Vector3& position = getDerivedPosition(_obj);
			info->floorInfo = mSceneManager->getFloorInfo(position);
			info->flags |= FLAG_FLOOR_INFO;
		}
		return info->floorInfo;
	}
//-----------------------------------------------------------------------
void PUPositionEmitter::initParticlePosition(PUParticle3D* particle)
{
    // Fast rejection
    if (_positionList.empty())
        return;

    /** Remark: Don't take the orientation of the node into account, because the positions shouldn't be affected by the rotated node.
    */
    if (_randomized)
    {
        size_t i = (size_t)(CCRANDOM_0_1() * (_positionList.size() - 1));
        particle->position = getDerivedPosition() + Vec3(_emitterScale.x * _positionList[i].x, _emitterScale.y * _positionList[i].y, _emitterScale.z * _positionList[i].z);
    }
    else if (_index < _positionList.size())
    {
        particle->position = getDerivedPosition() + Vec3(_emitterScale.x * _positionList[_index].x, _emitterScale.y * _positionList[_index].y, _emitterScale.z * _positionList[_index].z);
        _index++;
    }

    particle->originalPosition = particle->position;
}
	//-----------------------------------------------------------------------
	bool ParticleEmitter::makeParticleLocal(Particle* particle)
	{
		if (!particle)
			return true;

		if (!mKeepLocal || hasEventFlags(Particle::PEF_EXPIRED))
			return false;

		Vector3 diff = getDerivedPosition() - latestPosition;
		particle->position += diff;
		return true;
	}
	//-----------------------------------------------------------------------
	void PositionEmitter::_initParticlePosition(Particle* particle)
	{
		// Fast rejection
		if (mPositionList.empty())
			return;

		/** Remark: Don't take the orientation of the node into account, because the positions shouldn't be affected by the rotated node.
		*/
		if (mRandomized)
		{
			size_t i = (size_t)(Math::UnitRandom() * (mPositionList.size() - 1));
			particle->position = getDerivedPosition() + _mEmitterScale * mPositionList[i];
		}
		else if (mIndex < mPositionList.size())
		{
			particle->position = getDerivedPosition() + _mEmitterScale * mPositionList[mIndex];
			mIndex++;
		}

		particle->originalPosition = particle->position;
	}
Example #24
0
	//---------------------------------------------------------------------
	void Light::_calcTempSquareDist(const Vector3& worldPos)
	{
		if (mLightType == LT_DIRECTIONAL)
		{
			tempSquareDist = 0;
		}
		else
		{
			tempSquareDist = 
				(worldPos - getDerivedPosition()).squaredLength();
		}

	}
	//-----------------------------------------------------------------------
	void ParticleEmitter::_notifyStart (void)
	{
		latestPosition = getDerivedPosition(); // V1.3.1
		mForceEmission = mOriginalForceEmission;
		mForceEmissionExecuted = mOriginalForceEmissionExecuted;
		mRemainder = 0;
		mDurationRemain = 0;
		mRepeatDelayRemain = 0;
		setEnabled(mOriginalEnabled); // Also calls _initTimeBased

		// Generate the event
		_pushEmitterEvent(PU_EVT_EMITTER_STARTED);
	}
	//-----------------------------------------------------------------------
	void VortexAffector::_preProcessParticles(ParticleTechnique* particleTechnique, Real timeElapsed)
	{
		ParticleSystem* sys = mParentTechnique->getParentSystem();
		if (sys)
		{
			mRotation.FromAngleAxis(Radian(_calculateRotationSpeed() * timeElapsed), sys->getDerivedOrientation() * mRotationVector);
		}
		else
		{
			mRotation.FromAngleAxis(Radian(_calculateRotationSpeed() * timeElapsed), mRotationVector);
		}
		getDerivedPosition();
	}
Example #27
0
void InternalWindow::TitleBar::draw(DrawingContext& drawingContext) {
    std::shared_ptr<const Material> material;
    Point2f position;
    // Background of title bar
    position = getDerivedPosition();
    position -= Vector2f(BORDER_PIXELS * 2, 0.0f);
    material = std::make_shared<const Material>(_titleBarTexture.get(), Ego::Math::Colour4f::white(), true);
    _gameEngine->getUIManager()->drawImage(position, Vector2f(getWidth() + BORDER_PIXELS * 4, getHeight()), material);

    // Title string (centered on title bar)
    position = getDerivedPosition();
    position += Vector2f(getWidth() / 2.0f - _textWidth / 2.0f, 12);
    _font->drawText(_title, position.x(), position.y(), Colour4f(0.28f, 0.16f, 0.07f, 1.0f));

    //Skull texture (centered above top border of title bar)
    const int skullWidth = _titleSkullTexture.get_ptr()->getWidth() / 2;
    const int skullHeight = _titleSkullTexture.get_ptr()->getHeight() / 2;
    material = std::make_shared<const Material>(_titleSkullTexture.get(), Ego::Math::Colour4f::white(), true);
    position = getDerivedPosition();
    position += Vector2f(getWidth() / 2.0f - skullWidth / 2.0f, -skullHeight / 2.0f);
    _gameEngine->getUIManager()->drawImage(position, Vector2f(skullWidth, skullHeight), material);
}
Example #28
0
    //-----------------------------------------------------------------------
    void PCZLight::updateZones(PCZone * defaultZone, unsigned long frameCount)
    {
        //update the zones this light affects
        PCZone * homeZone;
        affectedZonesList.clear();
        mAffectsVisibleZone = false;
        PCZSceneNode * sn = (PCZSceneNode*)(this->getParentSceneNode());
        if (sn)
        {
            // start with the zone the light is in
            homeZone = sn->getHomeZone();
            if (homeZone)
            {
                affectedZonesList.push_back(homeZone);
                if (homeZone->getLastVisibleFrame() == frameCount)
                {
                    mAffectsVisibleZone = true;
                }
            }
            else
            {
                // error - scene node has no homezone!
                // just say it affects the default zone and leave it at that.
                affectedZonesList.push_back(defaultZone);
                if (defaultZone->getLastVisibleFrame() == frameCount)
                {
                    mAffectsVisibleZone = true;
                }
                return;
            }
        }
        else
        {
            // ERROR! not connected to a scene node,                 
            // just say it affects the default zone and leave it at that.
            affectedZonesList.push_back(defaultZone);
            if (defaultZone->getLastVisibleFrame() == frameCount)
            {
                mAffectsVisibleZone = true;
            }
            return;
        }

        // now check visibility of each portal in the home zone.  If visible to
        // the light then add the target zone of the portal to the list of
        // affected zones and recurse into the target zone
        static PCZFrustum portalFrustum;
        Vector3 v = getDerivedPosition();
        portalFrustum.setOrigin(v);
        homeZone->_checkLightAgainstPortals(this, frameCount, &portalFrustum, 0);
    }
	//-----------------------------------------------------------------------
	void FlockCenteringAffector::_preProcessParticles(ParticleTechnique* particleTechnique, Real timeElapsed)
	{
		if (mCount != 0)
		{
			// Calculate the average of the previous update
			mAverage = mSum / mCount;
		}
		else
		{
			mAverage = getDerivedPosition(); // Set to position of the affector
		}
		mSum = Vector3::ZERO;
		mCount = 0;
	}
	//-----------------------------------------------------------------------
	void BoxEmitter::_initParticlePosition(Particle* particle)
	{
		ParticleSystem* sys = mParentTechnique->getParentSystem();
		if (sys)
		{
			particle->position = getDerivedPosition() + 
				sys->getDerivedOrientation() *
				(_mEmitterScale *
				Vector3(Math::SymmetricRandom() * mXRange,
					Math::SymmetricRandom() * mYRange,
					Math::SymmetricRandom() * mZRange));
		}
		else
		{
			particle->position = getDerivedPosition() + 
				_mEmitterScale *
				Vector3(Math::SymmetricRandom() * mXRange,
					Math::SymmetricRandom() * mYRange,
					Math::SymmetricRandom() * mZRange);
		}

		particle->originalPosition = particle->position;
	}