//----------------------------------------------------------------------- void EntityRenderer::_updateRenderQueue(Ogre::RenderQueue* queue, ParticlePool* pool) { // Always perform this one ParticleRenderer::_updateRenderQueue(queue, pool); if (!mVisible) return; // Fast check to determine whether there are visual particles if (pool->isEmpty(Particle::PT_VISUAL)) return; VisualParticle* particle = static_cast<VisualParticle*>(pool->getFirst(Particle::PT_VISUAL)); while (!pool->end(Particle::PT_VISUAL)) { if (particle) { if (!particle->visualData && !mVisualData.empty()) { particle->visualData = mVisualData.back(); mVisualData.pop_back(); } if (particle->visualData) { Ogre::SceneNode* node = (static_cast<EntityRendererVisualData*>(particle->visualData))->node; if (node) { node->_setDerivedPosition(particle->position); if (mEntityOrientationType == ENT_ORIENTED_SHAPE) { // Use the orientation of the particle itself node->setOrientation(particle->orientation); } else if (mEntityOrientationType == ENT_ORIENTED_SELF) { // Rotate towards the direction node->setOrientation(Vector3::UNIT_X.getRotationTo(particle->direction)); } else if (mEntityOrientationType == ENT_ORIENTED_SELF_MIRRORED) { // Rotate towards the negative direction node->setOrientation(Vector3::UNIT_X.getRotationTo(-particle->direction)); } node->setVisible(true); node->setScale(particle->width / mBoxWidth, particle->height / mBoxHeight, particle->depth / mBoxDepth); if (mZRotated) { _rotateTexture(particle, static_cast<Ogre::Entity*>(node->getAttachedObject(0))); // We know for sure there is only one and it is an Entity* } } } } particle = static_cast<VisualParticle*>(pool->getNext(Particle::PT_VISUAL)); } }
//----------------------------------------------------------------------- void RibbonTrailRenderer::_updateRenderQueue(Ogre::RenderQueue* queue, ParticlePool* pool) { // Always perform this one ParticleRenderer::_updateRenderQueue(queue, pool); if (!mVisible) return; Particle* particle = static_cast<Particle*>(pool->getFirst()); RibbonTrailRendererVisualData* visualData = 0; while (!pool->end()) { if (particle) { if (!particle->visualData && !mVisualData.empty()) { particle->visualData = mVisualData.back(); mVisualData.pop_back(); visualData = static_cast<RibbonTrailRendererVisualData*>(particle->visualData); } visualData = static_cast<RibbonTrailRendererVisualData*>(particle->visualData); if (visualData) { Ogre::SceneNode* node = visualData->node; node->_setDerivedPosition(particle->position); // Set the width of the trail if required if (particle->particleType == Particle::PT_VISUAL) { VisualParticle* visualParticle = static_cast<VisualParticle*>(particle); if (visualParticle->ownDimensions) { mTrail->setInitialWidth(visualData->index, visualParticle->width); } } visualData->setVisible(true); } } particle = static_cast<Particle*>(pool->getNext()); } }
//----------------------------------------------------------------------- // void LightRenderer::_updateRenderQueue(Ogre::RenderQueue* queue, ParticlePool* pool) // { // ParticleRenderer::_updateRenderQueue(queue, pool); // } //----------------------------------------------------------------------- void LightRenderer::_processParticle(ParticleTechnique* particleTechnique, Particle* particle, Real timeElapsed, bool firstParticle) { if (!mVisible) return; VisualParticle* visualParticle = static_cast<VisualParticle*>(particle); LightRendererVisualData* visualData = static_cast<LightRendererVisualData*>(particle->visualData); // Check whether the particle has visual data if (!visualData && !mVisualData.empty()) { visualParticle->visualData = mVisualData.back(); mVisualData.pop_back(); } visualData = static_cast<LightRendererVisualData*>(particle->visualData); if (!visualData) return; // Update the node Ogre::SceneNode* node = visualData->node; if (!node) return; node->_setDerivedPosition(visualParticle->position); node->setDirection(visualParticle->direction, Ogre::Node::TS_WORLD); // Needed for direction of spotlight Ogre::Light* light = visualData->light; if (!light) return; // Update the light: The light gets the diffuse colour from the particle, so Colour Affectors etc. can be used. light->setDiffuseColour(visualParticle->colour.r, visualParticle->colour.g, visualParticle->colour.b); // Update the counters (if needed) if (mFlashFrequency > 0.0f) { visualData->flashFrequencyCount += timeElapsed; if (visualData->flashFrequencyCount > mFlashFrequency) { visualData->flashFrequencyCount -= mFlashFrequency; // Update the light if (mFlashRandom) { if (Math::UnitRandom() > 0.5f) { light->setVisible(!light->isVisible()); } } else { light->setVisible(true); visualData->flashLengthCount = 0.0f; } } if (!mFlashRandom && light->isVisible()) { visualData->flashLengthCount += timeElapsed; if (visualData->flashLengthCount > mFlashLength) { light->setVisible(false); visualData->flashLengthCount -= mFlashLength; } } } else { light->setVisible(true); } }