//-----------------------------------------------------------------------
	void BeamRenderer::_prepare(ParticleTechnique* technique)
	{
		if (!technique || mRendererInitialised)
			return;

		// Register itself to the technique
		if (mParentTechnique)
		{
			// Although it is safe to assume that technique == mParentTechnique, use the mParentTechnique, because the mParentTechnique is
			// also used for unregistering.
			mParentTechnique->addTechniqueListener(this);
		}

		mQuota = technique->getVisualParticleQuota();
		Ogre::SceneNode* parentNode = technique->getParentSystem()->getParentSceneNode();

		if (parentNode)
		{
			// Create BillboardChain
			Ogre::SceneManager* sceneManager = mParentTechnique->getParentSystem()->getSceneManager();
			std::stringstream ss; 
			ss << this;
			mBillboardChainName = "Beam" + ss.str();
			mBillboardChain = sceneManager->createBillboardChain(mBillboardChainName);
			mBillboardChain->setDynamic(true);
			mBillboardChain->setNumberOfChains(mQuota);
			mBillboardChain->setMaxChainElements(mMaxChainElements);
			mBillboardChain->setMaterialName(technique->getMaterialName());
			mBillboardChain->setRenderQueueGroup(mQueueId);
			mBillboardChain->setTextureCoordDirection(mTexCoordDirection);
			setUseVertexColours(mUseVertexColours);
			mBillboardChain->setOtherTextureCoordRange(0.0f, 1.0f);
			mBillboardChain->setVisible(true);

			// Create number of VisualData objects
			for (size_t i = 0; i < mQuota; i++)
			{
				for (size_t j = 0; j < mMaxChainElements; j++)
				{
					Ogre::BillboardChain::Element element;
					element = Ogre::BillboardChain::Element(Vector3::ZERO, _mRendererScale.x * mParentTechnique->getDefaultWidth(), 0.0f, ColourValue::White, Ogre::Quaternion::IDENTITY); // V1.51
					mBillboardChain->addChainElement(i, element);
				}
				BeamRendererVisualData* visualData = PU_NEW_T(BeamRendererVisualData, MEMCATEGORY_SCENE_OBJECTS)(i, mBillboardChain);
				for (size_t numDev = 0; numDev < mNumberOfSegments; ++numDev)
				{
					// Initialise the positions
					visualData->half[numDev] = Vector3::ZERO;
					visualData->destinationHalf[numDev] = Vector3::ZERO;
				}
				mAllVisualData.push_back(visualData); // Managed by this renderer
				mVisualData.push_back(visualData); // Used to assign to a particle
			}
			mRendererInitialised = true;
			parentNode->attachObject(mBillboardChain);
		}
	}
Пример #2
0
ProjectileManager::ProjectileManager()
	:bbc(0)
{
	Ogre::SceneManager* scenemgr = Interspace::getSingletonPtr()->getSceneManager();
	scenemgr->getRootSceneNode()->createChild("Projectiles");
	bbc = scenemgr->createBillboardChain("lasers");
	scenemgr->getSceneNode("Projectiles")->attachObject(bbc);
	bbc->setMaxChainElements(2);
	bbc->setNumberOfChains(1000);
	bbc->setMaterialName("laser");
}