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) 54 , max_points_per_line_(100)
57 , elements_in_current_chain_(0)
68 ss <<
"BillboardLineMaterial" << count++;
69 material_ = Ogre::MaterialManager::getSingleton().create(
70 ss.str(), Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
72 material_->getTechnique(0)->setLightingEnabled(
false);
79 V_Chain::iterator it =
chains_.begin();
80 V_Chain::iterator end =
chains_.end();
81 for (; it != end; ++it)
88 Ogre::MaterialManager::getSingleton().remove(
material_->getName());
95 ss <<
"BillboardLine chain" << count++;
96 Ogre::BillboardChain* chain =
scene_manager_->createBillboardChain(ss.str());
97 chain->setMaterialName(
material_->getName());
107 V_Chain::iterator it =
chains_.begin();
108 V_Chain::iterator end =
chains_.end();
109 for (; it != end; ++it)
111 (*it)->clearAllChains();
134 for (uint32_t i =
chains_.size(); i < num_chains; ++i)
141 V_Chain::iterator it =
chains_.begin();
142 V_Chain::iterator end =
chains_.end();
143 for (; it != end; ++it)
159 (*it)->setNumberOfChains(lines_left);
230 Ogre::BillboardChain::Element e;
241 for (uint32_t line = 0; line <
num_lines_; ++line)
245 for (uint32_t i = 0; i < element_count; ++i)
248 Ogre::BillboardChain::Element e = c->getChainElement(line %
lines_per_chain_, i);
251 c->updateChainElement(line % lines_per_chain_, i, e);
275 material_->getTechnique(0)->setSceneBlending(Ogre::SBT_TRANSPARENT_ALPHA);
276 material_->getTechnique(0)->setDepthWriteEnabled(
false);
280 material_->getTechnique(0)->setSceneBlending(Ogre::SBT_REPLACE);
281 material_->getTechnique(0)->setDepthWriteEnabled(
true);
284 color_ = Ogre::ColourValue(r, g, b, a);
286 for (uint32_t line = 0; line <
num_lines_; ++line)
290 for (uint32_t i = 0; i < element_count; ++i)
293 Ogre::BillboardChain::Element e = c->getChainElement(line %
lines_per_chain_, i);
296 c->updateChainElement(line % lines_per_chain_, i, e);
~BillboardLine() override
Ogre::MaterialPtr material_
uint32_t elements_in_current_chain_
void setPosition(const Ogre::Vector3 &position) override
Set the position of this object.
void addPoint(const Ogre::Vector3 &point)
void setOrientation(const Ogre::Quaternion &orientation) override
Set the orientation of the object.
uint32_t lines_per_chain_
Base class for visible objects, providing a minimal generic interface.
const Ogre::Vector3 & getPosition() override
Get the local position of this object.
void setColor(float r, float g, float b, float a) override
Set the color of the object. Values are in the range [0, 1].
void setNumLines(uint32_t num)
void setMaxPointsPerLine(uint32_t max)
const Ogre::Quaternion & getOrientation() override
Get the local orientation of this object.
Ogre::BillboardChain * createChain()
uint32_t max_points_per_line_
Ogre::SceneManager * scene_manager_
Ogre scene manager this object is part of.
BillboardLine(Ogre::SceneManager *manager, Ogre::SceneNode *parent_node=nullptr)
Constructor.
void setScale(const Ogre::Vector3 &scale) override
Set the scale of the object. Always relative to the identity orientation of the object.
void setLineWidth(float width)
Ogre::SceneNode * scene_node_