Beispiel #1
0
void BillboardLine::setColor( float r, float g, float b, float a )
{
  if ( a < 0.9998 )
  {
    material_->getTechnique(0)->setSceneBlending( Ogre::SBT_TRANSPARENT_ALPHA );
    material_->getTechnique(0)->setDepthWriteEnabled( false );
  }
  else
  {
    material_->getTechnique(0)->setSceneBlending( Ogre::SBT_REPLACE );
    material_->getTechnique(0)->setDepthWriteEnabled( true );
  }

  color_ = Ogre::ColourValue( r, g, b, a );

  for (uint32_t line = 0; line < num_lines_; ++line)
  {
    uint32_t element_count = num_elements_[line];

    for ( uint32_t i = 0; i < element_count; ++i )
    {
      Ogre::BillboardChain* c = chains_[line / lines_per_chain_];
      Ogre::BillboardChain::Element e = c->getChainElement(line % lines_per_chain_, i);

      e.colour = color_;
      c->updateChainElement(line % lines_per_chain_, i, e);
    }
  }
}
Beispiel #2
0
Ogre::BillboardChain* BillboardLine::createChain()
{
  std::stringstream ss;
  static int count = 0;
  ss << "BillboardLine chain" << count++;
  Ogre::BillboardChain* chain = scene_manager_->createBillboardChain(ss.str());
  chain->setMaterialName( material_->getName() );
  scene_node_->attachObject( chain );

  chains_.push_back(chain);

  return chain;
}
void ResourceGroupReloader::UpdateMaterialRenderableVisitor::visit(
	Ogre::Renderable *rend, Ogre::ushort lodIndex, bool isDebug, Ogre::Any *pAny)
{
	const Ogre::MaterialPtr mat = rend->getMaterial();
	if(!mat.isNull())
	{
		std::string newMatName = mat->getName();
		Ogre::MaterialPtr newMat = Ogre::MaterialManager::getSingleton().getByName(newMatName);
		if(newMat.isNull())
		{
			// this can happen if there was error during the reloading of the material.
			// in that case, we keep the ancient one.
			// Ice::Log::Instance().LogMessage(newMatName+" : new material is null!");
			return;
		}

		// unfortunately, the renderable gives access only to a const MaterialPtr.
		// and there is no 'setMaterial' or 'setMaterialName' method on renderables.
		// so I have to try to down cast with known classes...
		{   
			Ogre::SubEntity* lRend = dynamic_cast<Ogre::SubEntity*>(rend);
			if(lRend){lRend->setMaterialName(newMatName);return;} 
		}
		{
			Ogre::SimpleRenderable* lRend = dynamic_cast<Ogre::SimpleRenderable*>(rend);
			if(lRend){lRend->setMaterial(newMatName);return;} 
		}
		{
			Ogre::ShadowRenderable* lRend = dynamic_cast<Ogre::ShadowRenderable*>(rend);
			if(lRend){lRend->setMaterial(newMat);return;} 
		}
		{   
			Ogre::BillboardChain* lRend = dynamic_cast<Ogre::BillboardChain*>(rend);
			if(lRend){lRend->setMaterialName(newMatName);return;} 
		}
		{   
			Ogre::BillboardSet* lRend = dynamic_cast<Ogre::BillboardSet*>(rend);
			if(lRend){lRend->setMaterialName(newMatName);return;} 
		}
		{   
			Ogre::OverlayElement* lRend = dynamic_cast<Ogre::OverlayElement*>(rend);
			if(lRend){lRend->setMaterialName(newMatName);return;} 
		}
	}else{
		// was there for debug...
		// Ice::Log::Instance().LogMessage("material of renderable is null!");
	}
}
Beispiel #4
0
void BillboardLine::setLineWidth( float width )
{
  width_ = width;

  for (uint32_t line = 0; line < num_lines_; ++line)
  {
    uint32_t element_count = num_elements_[line];

    for ( uint32_t i = 0; i < element_count; ++i )
    {
      Ogre::BillboardChain* c = chains_[line / lines_per_chain_];
      Ogre::BillboardChain::Element e = c->getChainElement(line % lines_per_chain_, i);

      e.width = width_;
      c->updateChainElement(line % lines_per_chain_, i, e);
    }
  }
}