32 #include <OgreSceneManager.h> 33 #include <OgreSceneNode.h> 34 #include <OgreVector3.h> 35 #include <OgreQuaternion.h> 36 #include <OgreBillboardChain.h> 37 #include <OgreMaterialManager.h> 38 #include <OgreTechnique.h> 44 #define MAX_ELEMENTS (65536/4) 55 , max_points_per_line_(100)
58 , elements_in_current_chain_(0)
69 ss <<
"BillboardLineMaterial" << count++;
70 material_ = Ogre::MaterialManager::getSingleton().create( ss.str(), Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME );
72 material_->getTechnique(0)->setLightingEnabled(
false);
80 V_Chain::iterator it =
chains_.begin();
81 V_Chain::iterator end =
chains_.end();
82 for (;it != end; ++it)
89 Ogre::MaterialManager::getSingleton().remove(
material_->getName());
96 ss <<
"BillboardLine chain" << count++;
97 Ogre::BillboardChain* chain =
scene_manager_->createBillboardChain(ss.str());
98 chain->setMaterialName(
material_->getName() );
108 V_Chain::iterator it =
chains_.begin();
109 V_Chain::iterator end =
chains_.end();
110 for (; it != end; ++it)
112 (*it)->clearAllChains();
135 for (uint32_t i =
chains_.size(); i < num_chains; ++i)
142 V_Chain::iterator it =
chains_.begin();
143 V_Chain::iterator end =
chains_.end();
144 for (;it != end; ++it)
154 if (lines_left == 0) {
159 (*it)->setNumberOfChains(lines_left);
216 Ogre::BillboardChain::Element e;
227 for (uint32_t line = 0; line <
num_lines_; ++line)
231 for ( uint32_t i = 0; i < element_count; ++i )
234 Ogre::BillboardChain::Element e = c->getChainElement(line %
lines_per_chain_, i);
237 c->updateChainElement(line % lines_per_chain_, i, e);
261 material_->getTechnique(0)->setSceneBlending( Ogre::SBT_TRANSPARENT_ALPHA );
262 material_->getTechnique(0)->setDepthWriteEnabled(
false );
266 material_->getTechnique(0)->setSceneBlending( Ogre::SBT_REPLACE );
267 material_->getTechnique(0)->setDepthWriteEnabled(
true );
270 color_ = Ogre::ColourValue( r, g, b, a );
272 for (uint32_t line = 0; line <
num_lines_; ++line)
276 for ( uint32_t i = 0; i < element_count; ++i )
279 Ogre::BillboardChain::Element e = c->getChainElement(line %
lines_per_chain_, i);
282 c->updateChainElement(line % lines_per_chain_, i, e);
Ogre::MaterialPtr material_
uint32_t elements_in_current_chain_
void addPoint(const Ogre::Vector3 &point)
uint32_t lines_per_chain_
virtual void setPosition(const Ogre::Vector3 &position)
Set the position of this object.
Base class for visible objects, providing a minimal generic interface.
virtual void setColor(float r, float g, float b, float a)
Set the color of the object. Values are in the range [0, 1].
virtual void setOrientation(const Ogre::Quaternion &orientation)
Set the orientation of the object.
virtual const Ogre::Vector3 & getPosition()
Get the local position of this object.
BillboardLine(Ogre::SceneManager *manager, Ogre::SceneNode *parent_node=NULL)
Constructor.
void setNumLines(uint32_t num)
void setMaxPointsPerLine(uint32_t max)
Ogre::BillboardChain * createChain()
virtual const Ogre::Quaternion & getOrientation()
Get the local orientation of this object.
uint32_t max_points_per_line_
virtual void setScale(const Ogre::Vector3 &scale)
Set the scale of the object. Always relative to the identity orientation of the object.
Ogre::SceneManager * scene_manager_
Ogre scene manager this object is part of.
void setLineWidth(float width)
Ogre::SceneNode * scene_node_