bool operator()()
        {
            Ogre::SceneManager* sm = GraphicsManager::get().sceneManager();

            Ogre::SceneNode* sceneNode =
                    positionComponent->sceneNode()->createChildSceneNode(
                            Ogre::StringConverter::toString(
                                    component->localId()),
                            offset, 
                            offsetRotation);

            Ogre::ParticleSystem* ps = sm->createParticleSystem(
                    Ogre::StringConverter::toString(component->localId()), 
                    fileName);

            sceneNode->attachObject(ps);

            component->m_sceneNode = sceneNode;
            component->m_particleSystem = ps;

            ThreadPool::get().schedule(boost::bind(
                    &ComponentContainer::componentAttachedCallback,
                    component->parent(), component));

            return true;
        }
Esempio n. 2
0
void gkOgreParticleObject::createInstanceImpl()
{
	gkParticleObject::createInstanceImpl();

	GK_ASSERT(!m_psys);

	try
	{
		Ogre::SceneManager* manager = m_scene->getManager();

		const gkString& pname = m_particleProps.m_settings;
		
		m_psys = manager->createParticleSystem(getName(), m_particleProps.m_settings);
		if (m_psys)
		{
			m_psys->setUserAny(Ogre::Any(this));
			m_node->attachObject(m_psys);

			gkOgreParticleResource* resource = gkParticleManager::getSingleton().getByName<gkOgreParticleResource>(
				gkResourceName(pname, getGroupName()));

			if (resource && resource->isTemplateOwner())
			{
				m_psys->setRenderer(gkOgreParticleRenderer::NAME);
		
				if (resource->getParticleProperties().m_render == gkParticleSettingsProperties::R_HALO)
					m_psys->setMaterialName(gkParticleManager::getSingleton().createOrRetrieveHaloMaterial(m_particleProps.m_material));
				else
					m_psys->setMaterialName(m_particleProps.m_material);
			} //else create by .particle script
		}
	}
	catch (Ogre::Exception& e)
	{
		gkLogMessage("gkOgreParticleObject: " << e.getDescription());
	}
}