Changeset 2044 for code/branches/objecthierarchy/src/orxonox/tools
- Timestamp:
- Oct 29, 2008, 11:37:19 AM (16 years ago)
- Location:
- code/branches/objecthierarchy/src/orxonox/tools
- Files:
-
- 2 deleted
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/objecthierarchy/src/orxonox/tools/BillboardSet.cc
r2023 r2044 32 32 #include <sstream> 33 33 #include <cassert> 34 34 35 #include <OgreSceneManager.h> 36 #include <OgreBillboard.h> 35 37 36 #include "util/Math.h" 38 #include "util/Convert.h" 39 #include "util/String.h" 37 40 38 41 namespace orxonox … … 45 48 } 46 49 50 BillboardSet::~BillboardSet() 51 { 52 this->destroyBillboardSet(); 53 } 54 47 55 void BillboardSet::setBillboardSet(Ogre::SceneManager* scenemanager, const std::string& file, int count) 48 56 { 49 assert(scenemanager); 50 51 std::ostringstream name; 52 name << (BillboardSet::billboardSetCounter_s++); 53 this->billboardSet_ = scenemanager->createBillboardSet("Billboard" + name.str(), count); 54 this->billboardSet_->createBillboard(Vector3::ZERO); 55 this->billboardSet_->setMaterialName(file); 56 57 this->scenemanager_ = scenemanager; 57 this->setBillboardSet(scenemanager, file, Vector3::ZERO, count); 58 58 } 59 59 60 60 void BillboardSet::setBillboardSet(Ogre::SceneManager* scenemanager, const std::string& file, const ColourValue& colour, int count) 61 61 { 62 assert(scenemanager); 63 64 std::ostringstream name; 65 name << (BillboardSet::billboardSetCounter_s++); 66 this->billboardSet_ = scenemanager->createBillboardSet("Billboard" + name.str(), count); 67 this->billboardSet_->createBillboard(Vector3::ZERO, colour); 68 this->billboardSet_->setMaterialName(file); 69 70 this->scenemanager_ = scenemanager; 62 this->setBillboardSet(scenemanager, file, colour, Vector3::ZERO, count); 71 63 } 72 64 … … 74 66 { 75 67 assert(scenemanager); 68 this->destroyBillboardSet(); 76 69 77 std::ostringstream name; 78 name << (BillboardSet::billboardSetCounter_s++); 79 this->billboardSet_ = scenemanager->createBillboardSet("Billboard" + name.str(), count); 80 this->billboardSet_->createBillboard(position); 81 this->billboardSet_->setMaterialName(file); 70 try 71 { 72 this->billboardSet_ = scenemanager->createBillboardSet("Billboard" + convertToString(BillboardSet::billboardSetCounter_s++), count); 73 this->billboardSet_->createBillboard(position); 74 this->billboardSet_->setMaterialName(file); 75 } 76 catch (...) 77 { 78 COUT(1) << "Error: Couln't load billboard \"" << file << "\"" << std::endl; 79 } 82 80 83 81 this->scenemanager_ = scenemanager; … … 87 85 { 88 86 assert(scenemanager); 87 this->destroyBillboardSet(); 89 88 90 std::ostringstream name; 91 name << (BillboardSet::billboardSetCounter_s++); 92 this->billboardSet_ = scenemanager->createBillboardSet("Billboard" + name.str(), count); 93 this->billboardSet_->createBillboard(position, colour); 94 this->billboardSet_->setMaterialName(file); 89 try 90 { 91 this->billboardSet_ = scenemanager->createBillboardSet("Billboard" + convertToString(BillboardSet::billboardSetCounter_s++), count); 92 this->billboardSet_->createBillboard(position, colour); 93 this->billboardSet_->setMaterialName(file); 94 } 95 catch (...) 96 { 97 COUT(1) << "Error: Couln't load billboard \"" << file << "\"" << std::endl; 98 } 95 99 96 100 this->scenemanager_ = scenemanager; 97 101 } 98 102 99 BillboardSet::~BillboardSet()103 void BillboardSet::destroyBillboardSet() 100 104 { 101 105 if (this->billboardSet_ && this->scenemanager_) 102 106 this->scenemanager_->destroyBillboardSet(this->billboardSet_); 103 107 } 108 109 const std::string& BillboardSet::getName() const 110 { 111 if (this->billboardSet_) 112 return this->billboardSet_->getName(); 113 else 114 return BLANKSTRING; 115 } 116 117 void BillboardSet::setVisible(bool visible) 118 { 119 if (this->billboardSet_) 120 this->billboardSet_->setVisible(visible); 121 } 122 123 bool BillboardSet::getVisible() const 124 { 125 if (this->billboardSet_) 126 return this->billboardSet_->getVisible(); 127 else 128 return false; 129 } 130 131 void BillboardSet::setColour(const ColourValue& colour) 132 { 133 if (this->billboardSet_) 134 { 135 for (int i = 0; i < this->billboardSet_->getNumBillboards(); ++i) 136 this->billboardSet_->getBillboard(i)->setColour(colour); 137 } 138 } 139 140 const ColourValue& BillboardSet::getColour() const 141 { 142 if (this->billboardSet_ && this->billboardSet_->getNumBillboards() > 0) 143 { 144 return this->billboardSet_->getBillboard(0)->getColour(); 145 } 146 else 147 return ColourValue::White; 148 } 149 150 void BillboardSet::setMaterial(const std::string& material) 151 { 152 if (this->billboardSet_) 153 this->billboardSet_->setMaterialName(material); 154 } 155 156 const std::string& BillboardSet::getMaterial() const 157 { 158 if (this->billboardSet_) 159 return this->billboardSet_->getMaterialName(); 160 else 161 return BLANKSTRING; 162 } 104 163 } -
code/branches/objecthierarchy/src/orxonox/tools/BillboardSet.h
r2019 r2044 44 44 BillboardSet(); 45 45 ~BillboardSet(); 46 46 47 void setBillboardSet(Ogre::SceneManager* scenemanager, const std::string& file, int count = 1); 47 48 void setBillboardSet(Ogre::SceneManager* scenemanager, const std::string& file, const ColourValue& colour, int count = 1); … … 52 53 { return this->billboardSet_; } 53 54 54 inline const std::string& getName() const 55 { return this->billboardSet_->getName(); } 55 const std::string& getName() const; 56 56 57 inline void setVisible(bool visible) 58 { this->billboardSet_->setVisible(visible); } 59 inline bool getVisible() const 60 { return this->billboardSet_->getVisible(); } 57 void setVisible(bool visible); 58 bool getVisible() const; 59 60 void setColour(const ColourValue& colour); 61 const ColourValue& getColour() const; 62 63 void setMaterial(const std::string& material); 64 const std::string& getMaterial() const; 61 65 62 66 private: 67 void destroyBillboardSet(); 68 63 69 static unsigned int billboardSetCounter_s; 64 70 Ogre::BillboardSet* billboardSet_;
Note: See TracChangeset
for help on using the changeset viewer.