[699] | 1 | |
---|
[709] | 2 | |
---|
[699] | 3 | #include "BBCBillboardCloudUVMapper.h" |
---|
| 4 | #include "BBCBillboardCloud.h" |
---|
| 5 | #include "BBCEntityCluster.h" |
---|
| 6 | #include "BBCBillboardClusterData.h" |
---|
| 7 | |
---|
| 8 | namespace BBC { |
---|
| 9 | |
---|
[709] | 10 | BillboardCloudUVMapper::BillboardCloudUVMapper() |
---|
[699] | 11 | { |
---|
| 12 | } |
---|
| 13 | |
---|
[709] | 14 | BillboardCloudUVMapper::~BillboardCloudUVMapper() |
---|
| 15 | { |
---|
[721] | 16 | shutdown(); |
---|
[709] | 17 | } |
---|
| 18 | |
---|
| 19 | void BillboardCloudUVMapper::initialize() |
---|
| 20 | { |
---|
| 21 | } |
---|
| 22 | |
---|
[721] | 23 | void BillboardCloudUVMapper::shutdown() |
---|
[709] | 24 | { |
---|
| 25 | while (getNumBsp() > 0) |
---|
| 26 | { |
---|
| 27 | removeBsp(getNumBsp()-1); |
---|
| 28 | } |
---|
| 29 | |
---|
[721] | 30 | while (getNumClusterLists() > 0) |
---|
| 31 | { |
---|
| 32 | removeClusterList(getNumClusterLists()-1); |
---|
| 33 | } |
---|
[709] | 34 | } |
---|
| 35 | |
---|
| 36 | unsigned int BillboardCloudUVMapper::getNumClusterLists() |
---|
| 37 | { |
---|
| 38 | return mClusterLists.size(); |
---|
| 39 | } |
---|
| 40 | |
---|
| 41 | unsigned int BillboardCloudUVMapper::getNumBsp() |
---|
| 42 | { |
---|
| 43 | return mBspList.size(); |
---|
| 44 | } |
---|
| 45 | |
---|
| 46 | void BillboardCloudUVMapper::addBsp(IMG::Bsp *bsp) |
---|
| 47 | { |
---|
| 48 | mBspList.push_back(bsp); |
---|
| 49 | } |
---|
| 50 | |
---|
| 51 | IMG::Bsp* BillboardCloudUVMapper::getBsp(unsigned int iBsp) |
---|
| 52 | { |
---|
| 53 | return mBspList[iBsp]; |
---|
| 54 | } |
---|
| 55 | |
---|
| 56 | void BillboardCloudUVMapper::removeBsp(unsigned int iBsp) |
---|
| 57 | { |
---|
| 58 | IMG::Bsp *bsp = mBspList[iBsp]; |
---|
| 59 | mBspList.erase(mBspList.begin() + iBsp); |
---|
| 60 | delete bsp; |
---|
| 61 | } |
---|
| 62 | |
---|
| 63 | void BillboardCloudUVMapper::addClusterList(IMG::ClusterList *clusterList) |
---|
| 64 | { |
---|
| 65 | mClusterLists.push_back(clusterList); |
---|
| 66 | } |
---|
| 67 | |
---|
| 68 | IMG::ClusterList* BillboardCloudUVMapper::getClusterList(unsigned int iClusterList) |
---|
| 69 | { |
---|
| 70 | return mClusterLists[iClusterList]; |
---|
| 71 | } |
---|
| 72 | |
---|
| 73 | void BillboardCloudUVMapper::removeClusterList(unsigned int iClusterList) |
---|
| 74 | { |
---|
[721] | 75 | IMG::ClusterList *clusterList = mClusterLists[iClusterList]; |
---|
| 76 | mClusterLists.erase(mClusterLists.begin() + iClusterList); |
---|
| 77 | delete clusterList; |
---|
[709] | 78 | } |
---|
| 79 | |
---|
[699] | 80 | void BillboardCloudUVMapper::setTextureWidth(unsigned short int width) |
---|
| 81 | { |
---|
| 82 | mTextureWidth = width; |
---|
| 83 | } |
---|
| 84 | |
---|
| 85 | unsigned short int BillboardCloudUVMapper::getTextureWidth() |
---|
| 86 | { |
---|
| 87 | return mTextureWidth; |
---|
| 88 | } |
---|
| 89 | |
---|
| 90 | void BillboardCloudUVMapper::setTextureHeight(unsigned short int height) |
---|
| 91 | { |
---|
| 92 | mTextureHeight = height; |
---|
| 93 | } |
---|
| 94 | |
---|
| 95 | unsigned short BillboardCloudUVMapper::getTextureHeight() |
---|
| 96 | { |
---|
| 97 | return mTextureHeight; |
---|
| 98 | } |
---|
| 99 | |
---|
| 100 | void BillboardCloudUVMapper::setTextureAtlasWidth(unsigned short int width) |
---|
| 101 | { |
---|
| 102 | mTextureAtlasWidth = width; |
---|
| 103 | } |
---|
| 104 | |
---|
| 105 | unsigned short int BillboardCloudUVMapper::getTextureAtlasWidth() |
---|
| 106 | { |
---|
| 107 | return mTextureAtlasWidth; |
---|
| 108 | } |
---|
| 109 | |
---|
| 110 | void BillboardCloudUVMapper::setTextureAtlasHeight(unsigned short int height) |
---|
| 111 | { |
---|
| 112 | mTextureAtlasHeight = height; |
---|
| 113 | } |
---|
| 114 | |
---|
| 115 | unsigned short BillboardCloudUVMapper::getTextureAtlasHeight() |
---|
| 116 | { |
---|
| 117 | return mTextureAtlasHeight; |
---|
| 118 | } |
---|
| 119 | |
---|
[745] | 120 | void BillboardCloudUVMapper::addTextureAtlasTextureCoords(bool mergeBillboards, bool groupedBillboards, unsigned int numGeneratedBillboardClouds, unsigned int iBillboardGroup, unsigned int iBillboard) |
---|
[721] | 121 | { |
---|
[709] | 122 | unsigned int iUniqueVertex = 0; |
---|
[699] | 123 | |
---|
[709] | 124 | Ogre::LogManager::getSingleton().logMessage("iBBC:" + Ogre::StringConverter::toString(numGeneratedBillboardClouds) + "-" + "iBBCG:" + Ogre::StringConverter::toString(iBillboardGroup)); |
---|
| 125 | |
---|
[731] | 126 | Ogre::LogManager::getSingleton().logMessage("SizeCLList:" + Ogre::StringConverter::toString(getClusterList(iBillboardGroup)->getSize()) + " -- numBBC:" + Ogre::StringConverter::toString(numGeneratedBillboardClouds)); |
---|
[709] | 127 | |
---|
[731] | 128 | IMG::Cluster *cluster = getClusterList(iBillboardGroup)->get(getClusterList(iBillboardGroup)->getSize()-1); |
---|
| 129 | IMG::Box2d *box = cluster->getBspNodeBound(); |
---|
| 130 | Ogre::Vector2 max = box->getMaximum(); |
---|
| 131 | Ogre::Vector2 min = box->getMinimum(); |
---|
[745] | 132 | |
---|
| 133 | Ogre::LogManager::getSingleton().logMessage("max:" + Ogre::StringConverter::toString(Ogre::Vector3(max[0], max[1], 0.0)) ); |
---|
| 134 | Ogre::LogManager::getSingleton().logMessage("min:" + Ogre::StringConverter::toString(Ogre::Vector3(min[0], min[1], 0.0)) ); |
---|
| 135 | |
---|
| 136 | Ogre::Vector2 umax; |
---|
| 137 | umax[0] = (max[0] / mTextureAtlasWidth); |
---|
| 138 | umax[1] = (max[1] / mTextureAtlasHeight); |
---|
| 139 | |
---|
| 140 | Ogre::Vector2 umin; |
---|
| 141 | umin[0] = (min[0] / mTextureAtlasWidth); |
---|
| 142 | umin[1] = (min[1] / mTextureAtlasHeight); |
---|
| 143 | |
---|
| 144 | umin = umin * 2.0 - 1.0; |
---|
| 145 | umax = umax * 2.0 - 1.0; |
---|
| 146 | |
---|
| 147 | Ogre::LogManager::getSingleton().logMessage("Umax:" + Ogre::StringConverter::toString(Ogre::Vector3(umax[0], umax[1], 0.0)) ); |
---|
| 148 | Ogre::LogManager::getSingleton().logMessage("Umin:" + Ogre::StringConverter::toString(Ogre::Vector3(umin[0], umin[1], 0.0)) ); |
---|
| 149 | |
---|
| 150 | mBillboardCloud->getBillboard(iBillboard)->getBillboardClusterData()->addBillboardUVMapMin(umin); |
---|
| 151 | mBillboardCloud->getBillboard(iBillboard)->getBillboardClusterData()->addBillboardUVMapMax(umax); |
---|
| 152 | |
---|
[721] | 153 | Ogre::LogManager::getSingleton().logMessage("Max:" + Ogre::StringConverter::toString(Ogre::Vector3(max[0],max[1],0)) + |
---|
| 154 | "\tMin:" + Ogre::StringConverter::toString(Ogre::Vector3(min[0],min[1],0)) + |
---|
| 155 | "\tSize(" + Ogre::StringConverter::toString(max[0]-min[0]) + |
---|
| 156 | "," + Ogre::StringConverter::toString(max[1]-min[1]) + ")"); |
---|
| 157 | |
---|
[745] | 158 | Ogre::LogManager::getSingleton().logMessage( |
---|
| 159 | "UMax:" + Ogre::StringConverter::toString(Ogre::Vector3(umax[0], umax[1],0)) + |
---|
| 160 | "\tUMin:" + Ogre::StringConverter::toString(Ogre::Vector3(umin[0], umin[1],0)) + |
---|
| 161 | "\tUSize(" + Ogre::StringConverter::toString(umax[0]-umin[0]) + |
---|
| 162 | "," + Ogre::StringConverter::toString(umax[1]-umin[1]) + ")"); |
---|
| 163 | |
---|
| 164 | std::cin.get(); |
---|
| 165 | |
---|
| 166 | |
---|
[721] | 167 | SubEntityPtr subEntity; |
---|
| 168 | |
---|
| 169 | Ogre::Vector2 texCoords01,texCoords02,texCoords03,texCoords04; |
---|
| 170 | texCoords01[0] = min[0] / mTextureAtlasWidth; |
---|
| 171 | texCoords01[1] = min[1] / mTextureAtlasHeight; |
---|
| 172 | |
---|
| 173 | texCoords02[0] = max[0] / mTextureAtlasWidth; |
---|
| 174 | texCoords02[1] = min[1] / mTextureAtlasHeight; |
---|
| 175 | |
---|
| 176 | texCoords03[0] = max[0] / mTextureAtlasWidth; |
---|
| 177 | texCoords03[1] = max[1] / mTextureAtlasHeight; |
---|
| 178 | |
---|
| 179 | texCoords04[0] = min[0] / mTextureAtlasWidth; |
---|
| 180 | texCoords04[1] = max[1] / mTextureAtlasHeight; |
---|
| 181 | |
---|
| 182 | if (groupedBillboards) |
---|
| 183 | { |
---|
| 184 | Ogre::LogManager::getSingleton().logMessage("DontMerge"); |
---|
| 185 | subEntity = mBillboardCloud->getEntity()->getSubEntity(iBillboardGroup); |
---|
| 186 | |
---|
| 187 | // Face A |
---|
| 188 | //(0,0,0); |
---|
| 189 | //(1,0,0); |
---|
| 190 | //(1,1,0); |
---|
| 191 | subEntity->setTexCoord(iUniqueVertex, subEntity->getNumTexCoordSets()-1, Ogre::Vector3(texCoords01[0],texCoords01[1],0)); |
---|
| 192 | subEntity->setTexCoord(iUniqueVertex+1, subEntity->getNumTexCoordSets()-1, Ogre::Vector3(texCoords02[0],texCoords02[1],0)); |
---|
| 193 | subEntity->setTexCoord(iUniqueVertex+2, subEntity->getNumTexCoordSets()-1, Ogre::Vector3(texCoords03[0],texCoords03[1],0)); |
---|
| 194 | |
---|
[709] | 195 | Ogre::ColourValue subEntityColour01 = Ogre::ColourValue(0, texCoords01[0],texCoords01[1]); |
---|
| 196 | Ogre::ColourValue subEntityColour02 = Ogre::ColourValue(0, texCoords02[0],texCoords02[1]); |
---|
| 197 | Ogre::ColourValue subEntityColour03 = Ogre::ColourValue(0, texCoords03[0],texCoords03[1]); |
---|
| 198 | |
---|
[721] | 199 | subEntity->setVertexColour(iUniqueVertex, subEntityColour01.getAsRGBA()); |
---|
| 200 | subEntity->setVertexColour(iUniqueVertex+1, subEntityColour02.getAsRGBA()); |
---|
| 201 | subEntity->setVertexColour(iUniqueVertex+2, subEntityColour03.getAsRGBA()); |
---|
| 202 | |
---|
| 203 | // Face B |
---|
| 204 | //(1,1,0); |
---|
| 205 | //(0,1,0); |
---|
| 206 | //(0,0,0); |
---|
| 207 | subEntity->setTexCoord(iUniqueVertex+3, subEntity->getNumTexCoordSets()-1, Ogre::Vector3(texCoords03[0],texCoords03[1],0)); |
---|
| 208 | subEntity->setTexCoord(iUniqueVertex+4, subEntity->getNumTexCoordSets()-1, Ogre::Vector3(texCoords04[0],texCoords04[1],0)); |
---|
| 209 | subEntity->setTexCoord(iUniqueVertex+5, subEntity->getNumTexCoordSets()-1, Ogre::Vector3(texCoords01[0],texCoords01[1],0)); |
---|
| 210 | |
---|
[709] | 211 | Ogre::ColourValue subEntityColour04 = Ogre::ColourValue(0, texCoords03[0],texCoords03[1]); |
---|
| 212 | Ogre::ColourValue subEntityColour05 = Ogre::ColourValue(0, texCoords04[0],texCoords04[1]); |
---|
| 213 | Ogre::ColourValue subEntityColour06 = Ogre::ColourValue(0, texCoords01[0],texCoords01[1]); |
---|
| 214 | |
---|
[721] | 215 | subEntity->setVertexColour(iUniqueVertex+3, subEntityColour04.getAsRGBA()); |
---|
| 216 | subEntity->setVertexColour(iUniqueVertex+4, subEntityColour05.getAsRGBA()); |
---|
| 217 | subEntity->setVertexColour(iUniqueVertex+5, subEntityColour06.getAsRGBA()); |
---|
| 218 | |
---|
| 219 | iUniqueVertex = iUniqueVertex + 6; |
---|
| 220 | } |
---|
| 221 | else |
---|
| 222 | { |
---|
| 223 | if (!mergeBillboards) |
---|
| 224 | { |
---|
| 225 | Ogre::LogManager::getSingleton().logMessage("DontMerge"); |
---|
| 226 | |
---|
| 227 | subEntity = mBillboardCloud->getEntity()->getSubEntity(numGeneratedBillboardClouds); |
---|
| 228 | subEntity->addTextureCoordSet(2); |
---|
| 229 | subEntity->enableVertexColours(true); |
---|
| 230 | // Face A |
---|
| 231 | //(0,0,0); |
---|
| 232 | //(1,0,0); |
---|
| 233 | //(1,1,0); |
---|
| 234 | |
---|
| 235 | subEntity->setTexCoord(0, subEntity->getNumTexCoordSets()-1, Ogre::Vector3(texCoords01[0],texCoords01[1], 0)); |
---|
| 236 | subEntity->setTexCoord(1, subEntity->getNumTexCoordSets()-1, Ogre::Vector3(texCoords02[0],texCoords02[1], 0)); |
---|
| 237 | subEntity->setTexCoord(2, subEntity->getNumTexCoordSets()-1, Ogre::Vector3(texCoords03[0],texCoords03[1], 0)); |
---|
| 238 | |
---|
[709] | 239 | Ogre::ColourValue subEntityColour01 = Ogre::ColourValue(0, texCoords01[0],texCoords01[1]); |
---|
| 240 | Ogre::ColourValue subEntityColour02 = Ogre::ColourValue(0, texCoords02[0],texCoords02[1]); |
---|
| 241 | Ogre::ColourValue subEntityColour03 = Ogre::ColourValue(0, texCoords03[0],texCoords03[1]); |
---|
[699] | 242 | |
---|
[721] | 243 | subEntity->setVertexColour(0, subEntityColour01.getAsRGBA()); |
---|
| 244 | subEntity->setVertexColour(1, subEntityColour02.getAsRGBA()); |
---|
| 245 | subEntity->setVertexColour(2, subEntityColour03.getAsRGBA()); |
---|
| 246 | |
---|
| 247 | // Face B |
---|
| 248 | //(1,1,0); |
---|
| 249 | //(0,1,0); |
---|
| 250 | //(0,0,0); |
---|
| 251 | subEntity->setTexCoord(3, subEntity->getNumTexCoordSets()-1, Ogre::Vector3(texCoords03[0],texCoords03[1],0)); |
---|
| 252 | subEntity->setTexCoord(4, subEntity->getNumTexCoordSets()-1, Ogre::Vector3(texCoords04[0],texCoords04[1],0)); |
---|
| 253 | subEntity->setTexCoord(5, subEntity->getNumTexCoordSets()-1, Ogre::Vector3(texCoords01[0],texCoords01[1],0)); |
---|
| 254 | |
---|
[709] | 255 | Ogre::ColourValue subEntityColour04 = Ogre::ColourValue(0, texCoords03[0],texCoords03[1]); |
---|
| 256 | Ogre::ColourValue subEntityColour05 = Ogre::ColourValue(0, texCoords04[0],texCoords04[1]); |
---|
| 257 | Ogre::ColourValue subEntityColour06 = Ogre::ColourValue(0, texCoords01[0],texCoords01[1]); |
---|
[699] | 258 | |
---|
[721] | 259 | subEntity->setVertexColour(3, subEntityColour04.getAsRGBA()); |
---|
| 260 | subEntity->setVertexColour(4, subEntityColour05.getAsRGBA()); |
---|
| 261 | subEntity->setVertexColour(5, subEntityColour06.getAsRGBA()); |
---|
| 262 | |
---|
| 263 | } |
---|
| 264 | else |
---|
| 265 | { |
---|
| 266 | Ogre::LogManager::getSingleton().logMessage("Merge"); |
---|
| 267 | |
---|
| 268 | subEntity = mBillboardCloud->getEntity()->getSubEntity(0); |
---|
| 269 | |
---|
| 270 | // Face A |
---|
| 271 | //(0,0,0); |
---|
| 272 | //(1,0,0); |
---|
| 273 | //(1,1,0); |
---|
| 274 | subEntity->setTexCoord(iUniqueVertex, subEntity->getNumTexCoordSets()-1, Ogre::Vector3(texCoords01[0],texCoords01[1],0)); |
---|
| 275 | subEntity->setTexCoord(iUniqueVertex+1, subEntity->getNumTexCoordSets()-1, Ogre::Vector3(texCoords02[0],texCoords02[1],0)); |
---|
| 276 | subEntity->setTexCoord(iUniqueVertex+2, subEntity->getNumTexCoordSets()-1, Ogre::Vector3(texCoords03[0],texCoords03[1],0)); |
---|
| 277 | |
---|
[709] | 278 | Ogre::ColourValue subEntityColour01 = Ogre::ColourValue(0, texCoords01[0],texCoords01[1]); |
---|
| 279 | Ogre::ColourValue subEntityColour02 = Ogre::ColourValue(0, texCoords02[0],texCoords02[1]); |
---|
| 280 | Ogre::ColourValue subEntityColour03 = Ogre::ColourValue(0, texCoords03[0],texCoords03[1]); |
---|
| 281 | |
---|
[721] | 282 | subEntity->setVertexColour(iUniqueVertex, subEntityColour01.getAsRGBA()); |
---|
| 283 | subEntity->setVertexColour(iUniqueVertex+1, subEntityColour02.getAsRGBA()); |
---|
| 284 | subEntity->setVertexColour(iUniqueVertex+2, subEntityColour03.getAsRGBA()); |
---|
| 285 | |
---|
| 286 | // Face B |
---|
| 287 | //(1,1,0); |
---|
| 288 | //(0,1,0); |
---|
| 289 | //(0,0,0); |
---|
| 290 | subEntity->setTexCoord(iUniqueVertex+3, subEntity->getNumTexCoordSets()-1, Ogre::Vector3(texCoords03[0],texCoords03[1],0)); |
---|
| 291 | subEntity->setTexCoord(iUniqueVertex+4, subEntity->getNumTexCoordSets()-1, Ogre::Vector3(texCoords04[0],texCoords04[1],0)); |
---|
| 292 | subEntity->setTexCoord(iUniqueVertex+5, subEntity->getNumTexCoordSets()-1, Ogre::Vector3(texCoords01[0],texCoords01[1],0)); |
---|
| 293 | |
---|
[709] | 294 | Ogre::ColourValue subEntityColour04 = Ogre::ColourValue(0, texCoords03[0],texCoords03[1]); |
---|
| 295 | Ogre::ColourValue subEntityColour05 = Ogre::ColourValue(0, texCoords04[0],texCoords04[1]); |
---|
| 296 | Ogre::ColourValue subEntityColour06 = Ogre::ColourValue(0, texCoords01[0],texCoords01[1]); |
---|
| 297 | |
---|
[721] | 298 | subEntity->setVertexColour(iUniqueVertex+3, subEntityColour04.getAsRGBA()); |
---|
| 299 | subEntity->setVertexColour(iUniqueVertex+4, subEntityColour05.getAsRGBA()); |
---|
| 300 | subEntity->setVertexColour(iUniqueVertex+5, subEntityColour06.getAsRGBA()); |
---|
| 301 | |
---|
| 302 | iUniqueVertex = iUniqueVertex + 6; |
---|
[709] | 303 | } |
---|
| 304 | Ogre::LogManager::getSingleton().logMessage("EndAdd"); |
---|
| 305 | } |
---|
| 306 | } |
---|
| 307 | |
---|
| 308 | void BillboardCloudUVMapper::addTextureInBsp(unsigned int iBillboardGroup, unsigned int iBillboard) |
---|
| 309 | { |
---|
[721] | 310 | IMG::NodeBspPtr nodeDest; |
---|
| 311 | IMG::Cluster cluster; |
---|
| 312 | Ogre::LogManager::getSingleton().logMessage("w:" + Ogre::StringConverter::toString(mTextureWidth)); |
---|
| 313 | Ogre::LogManager::getSingleton().logMessage("h:" + Ogre::StringConverter::toString(mTextureHeight)); |
---|
[731] | 314 | nodeDest = getBsp(iBillboardGroup)->insert(mTextureWidth,mTextureHeight,iBillboard); |
---|
[721] | 315 | |
---|
[731] | 316 | cluster.setBspNodeBound(nodeDest->getBound()); |
---|
| 317 | //cluster.finish(); |
---|
| 318 | getClusterList(iBillboardGroup)->insert(&cluster); |
---|
[709] | 319 | } |
---|
| 320 | |
---|
| 321 | void BillboardCloudUVMapper::generateTextureAtlasTextureCoords(bool mergeBillboards, bool groupedBillboards, unsigned int numGroups) |
---|
| 322 | { |
---|
| 323 | unsigned int numBillboardGroups; |
---|
| 324 | bool enabledTextureCoordSet = false; |
---|
| 325 | unsigned int numGeneratedBillboardClouds = 0; |
---|
| 326 | |
---|
| 327 | for (unsigned int iBillboard = 0; iBillboard < mBillboardCloud->getNumBillboards(); iBillboard++) |
---|
| 328 | { |
---|
[721] | 329 | BillboardPtr billboard = mBillboardCloud->getBillboard(iBillboard); |
---|
| 330 | EntityClusterPtr entityCluster = billboard->getBillboardClusterData()->getEntityCluster(); |
---|
[709] | 331 | |
---|
| 332 | if (entityCluster->getNumEntitiesClusterData() > 0) |
---|
| 333 | { |
---|
| 334 | if (mergeBillboards) |
---|
| 335 | { |
---|
[721] | 336 | if (!enabledTextureCoordSet) |
---|
| 337 | { |
---|
| 338 | SubEntityPtr subEntity = mBillboardCloud->getEntity()->getSubEntity(0); |
---|
| 339 | subEntity->addTextureCoordSet(2); |
---|
| 340 | subEntity->enableVertexColours(true); |
---|
| 341 | enabledTextureCoordSet = true; |
---|
[709] | 342 | } |
---|
| 343 | } |
---|
| 344 | else |
---|
[721] | 345 | { |
---|
| 346 | if (groupedBillboards) |
---|
| 347 | { |
---|
| 348 | SubEntityPtr subEntity = mBillboardCloud->getEntity()->getSubEntity(numGeneratedBillboardClouds); |
---|
| 349 | subEntity->addTextureCoordSet(2); |
---|
[709] | 350 | subEntity->enableVertexColours(true); |
---|
| 351 | } |
---|
| 352 | } |
---|
| 353 | |
---|
| 354 | numGeneratedBillboardClouds++; |
---|
| 355 | } |
---|
| 356 | } |
---|
| 357 | |
---|
| 358 | if (groupedBillboards) |
---|
| 359 | { |
---|
| 360 | numBillboardGroups = numGroups; |
---|
| 361 | } |
---|
| 362 | else |
---|
| 363 | { |
---|
| 364 | if (mergeBillboards) |
---|
| 365 | { |
---|
| 366 | numBillboardGroups = 1; |
---|
| 367 | } |
---|
| 368 | else // (!mergeBillboards) |
---|
| 369 | { |
---|
| 370 | numBillboardGroups = 1; |
---|
| 371 | } |
---|
| 372 | } |
---|
| 373 | |
---|
| 374 | unsigned int iBillboardsInGroup = 0; |
---|
| 375 | unsigned int numberBillboardsEachGroup = numGeneratedBillboardClouds / numGroups; |
---|
| 376 | unsigned int numberBillboardsAddedFirstGroup = numGeneratedBillboardClouds % numGroups; |
---|
| 377 | numGeneratedBillboardClouds = 0; |
---|
| 378 | unsigned int iBillboardGroup; |
---|
| 379 | for (iBillboardGroup = 0; iBillboardGroup < numBillboardGroups; iBillboardGroup++) |
---|
[721] | 380 | { |
---|
| 381 | IMG::Bsp *bsp = new IMG::Bsp(); |
---|
| 382 | IMG::ClusterList *clusterList = new IMG::ClusterList(); |
---|
| 383 | IMG::NodeBspPtr node = IMG::NodeBspPtr(new IMG::NodeBsp); |
---|
| 384 | |
---|
[731] | 385 | node->getBound()->setBoundBox(0, 0, mTextureAtlasWidth, mTextureAtlasHeight); |
---|
| 386 | bsp->setRoot(node); |
---|
[721] | 387 | |
---|
[709] | 388 | addBsp(bsp); |
---|
| 389 | addClusterList(clusterList); |
---|
[699] | 390 | |
---|
[709] | 391 | } |
---|
| 392 | |
---|
| 393 | iBillboardGroup = 0; |
---|
[721] | 394 | for (unsigned int iBillboard = 0; iBillboard < mBillboardCloud->getNumBillboards(); iBillboard++) |
---|
| 395 | { |
---|
| 396 | Ogre::LogManager::getSingleton().logMessage("id:" + Ogre::StringConverter::toString(mBillboardCloud->getBillboard(iBillboard)->getBillboardHandle())); |
---|
| 397 | |
---|
| 398 | BillboardClusterData *billboardClusterData = mBillboardCloud->getBillboard(iBillboard)->getBillboardClusterData().get(); |
---|
[709] | 399 | |
---|
| 400 | if (billboardClusterData != NULL) |
---|
| 401 | { |
---|
| 402 | Ogre::LogManager::getSingleton().logMessage("billboardData"); |
---|
[721] | 403 | EntityClusterPtr entityCluster = billboardClusterData->getEntityCluster(); |
---|
[709] | 404 | if (entityCluster->getNumEntitiesClusterData() > 0) |
---|
[721] | 405 | { |
---|
| 406 | Ogre::LogManager::getSingleton().logMessage("entityCluster"); |
---|
| 407 | |
---|
[709] | 408 | if ((iBillboardGroup == 0) && (iBillboardsInGroup < (numberBillboardsEachGroup + numberBillboardsAddedFirstGroup))) |
---|
| 409 | { |
---|
| 410 | Ogre::LogManager::getSingleton().logMessage("\nA"); |
---|
[731] | 411 | Ogre::LogManager::getSingleton().logMessage("IG:" + Ogre::StringConverter::toString(iBillboardsInGroup) + " SizeCLList(" + Ogre::StringConverter::toString(iBillboardGroup) + "):" + Ogre::StringConverter::toString(getClusterList(iBillboardGroup)->getSize()) + " -- numBBC:" + Ogre::StringConverter::toString(numGeneratedBillboardClouds)); |
---|
[699] | 412 | |
---|
[709] | 413 | addTextureInBsp(iBillboardGroup, iBillboard); |
---|
[745] | 414 | addTextureAtlasTextureCoords(mergeBillboards, groupedBillboards, numGeneratedBillboardClouds, iBillboardGroup, iBillboard); |
---|
[709] | 415 | iBillboardsInGroup++; |
---|
| 416 | } |
---|
| 417 | else |
---|
| 418 | { |
---|
| 419 | if ((iBillboardGroup > 0) && (iBillboardsInGroup < numberBillboardsEachGroup)) |
---|
| 420 | { |
---|
| 421 | Ogre::LogManager::getSingleton().logMessage("\nB"); |
---|
[731] | 422 | Ogre::LogManager::getSingleton().logMessage("IG:" + Ogre::StringConverter::toString(iBillboardsInGroup) + " SizeCLList(" + Ogre::StringConverter::toString(iBillboardGroup) + "):" + Ogre::StringConverter::toString(getClusterList(iBillboardGroup)->getSize()) + " -- numBBC:" + Ogre::StringConverter::toString(numGeneratedBillboardClouds)); |
---|
[709] | 423 | |
---|
| 424 | addTextureInBsp(iBillboardGroup, iBillboard); |
---|
[745] | 425 | addTextureAtlasTextureCoords(mergeBillboards, groupedBillboards, numGeneratedBillboardClouds, iBillboardGroup, iBillboard); |
---|
[709] | 426 | iBillboardsInGroup++; |
---|
| 427 | } |
---|
| 428 | else |
---|
| 429 | { |
---|
| 430 | iBillboardGroup++; |
---|
| 431 | iBillboardsInGroup = 0; |
---|
| 432 | |
---|
[731] | 433 | Ogre::LogManager::getSingleton().logMessage("\nC IG:" + Ogre::StringConverter::toString(iBillboardsInGroup-1) + " SizeCLList(" + Ogre::StringConverter::toString(iBillboardGroup-1) + "):" + Ogre::StringConverter::toString(getClusterList(iBillboardGroup-1)->getSize())); |
---|
| 434 | Ogre::LogManager::getSingleton().logMessage("IG:" + Ogre::StringConverter::toString(iBillboardsInGroup) + " SizeCLList(" + Ogre::StringConverter::toString(iBillboardGroup) + "):" + Ogre::StringConverter::toString(getClusterList(iBillboardGroup)->getSize()) + " -- numBBC:" + Ogre::StringConverter::toString(numGeneratedBillboardClouds)); |
---|
[709] | 435 | |
---|
| 436 | addTextureInBsp(iBillboardGroup, iBillboard); |
---|
[745] | 437 | addTextureAtlasTextureCoords(mergeBillboards, groupedBillboards, numGeneratedBillboardClouds, iBillboardGroup, iBillboard); |
---|
[709] | 438 | iBillboardsInGroup++; |
---|
| 439 | } |
---|
| 440 | } |
---|
[721] | 441 | |
---|
| 442 | numGeneratedBillboardClouds++; |
---|
| 443 | } |
---|
| 444 | } |
---|
| 445 | } |
---|
| 446 | //mBsp.Print(); |
---|
[699] | 447 | } |
---|
| 448 | |
---|
| 449 | void BillboardCloudUVMapper::setBillboardCloud(BillboardCloud *billboardCloud) |
---|
| 450 | { |
---|
| 451 | mBillboardCloud = billboardCloud; |
---|
| 452 | } |
---|
| 453 | |
---|
| 454 | BillboardCloud * BillboardCloudUVMapper::getBillboardCloud() |
---|
| 455 | { |
---|
| 456 | return mBillboardCloud; |
---|
| 457 | } |
---|
| 458 | |
---|
| 459 | } |
---|