Changeset 709 for GTP/trunk/Lib
- Timestamp:
- 03/17/06 19:36:46 (19 years ago)
- Location:
- GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE
- Files:
-
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCBillboardCloud.h
r700 r709 6 6 #include <BBCEntityCluster.h> 7 7 #include <BBCEntity.h> 8 9 #include <vector>10 8 11 9 namespace BBC { … … 19 17 20 18 protected: 21 vector<Billboard*> mBillboardList; 22 19 std::vector<Billboard*> mBillboardList; 20 21 std::vector<BillboardGroup*> mBillboardGroupList; 23 22 24 23 public: 25 24 std::vector<Billboard*>* getBillboardList(); 26 25 27 void setBillboardList(vector<Billboard*> &value);26 void setBillboardList(std::vector<Billboard*> &value); 28 27 29 28 void addBillboard(Billboard* value); … … 36 35 37 36 void generateBillboardCloud(bool mergeBillboards); 37 38 void initializeBillboardCloudGroups(unsigned int numberGroups); 39 40 void generateBillboardCloudGroups(); 41 42 unsigned int getNumBillboardGroups(); 43 44 BillboardGroup* getBillboardGroup(unsigned int iBillboardGroup); 45 46 void addBillboardGroup(BillboardGroup *value); 47 48 void removeBillboardGroup(unsigned int value); 38 49 39 50 protected: -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCBillboardCloudUVMapper.h
r700 r709 10 10 class BillboardCloudUVMapper { 11 11 protected: 12 IMG::Bsp mBsp;12 std::vector<IMG::Bsp*> mBspList; 13 13 14 IMG::ClusterList mClusterList;14 std::vector<IMG::ClusterList*> mClusterLists; 15 15 16 16 unsigned short int mTextureWidth; … … 44 44 unsigned short int getTextureHeight(); 45 45 46 void BillboardCloudUVMapper::generateTextureAtlasTextureCoords(bool mergeBillboards); 46 void generateTextureAtlasTextureCoords(bool mergeBillboards, bool groupedBillboards = false, unsigned int numberGroups = 1); 47 48 void addTextureAtlasTextureCoords(bool mergeBillboards, bool groupedBillboards, unsigned int numGeneratedBillboardClouds, unsigned int iBillboardGroup); 47 49 48 50 void setBillboardCloud(BillboardCloud *billboardCloud); 51 52 BillboardCloud* getBillboardCloud(); 49 53 50 BillboardCloud* getBillboardCloud(); 54 void addTextureInBsp(unsigned int iBillboardGroup, unsigned int iBillboard); 55 56 void addBsp(IMG::Bsp *bsp); 57 58 IMG::Bsp* getBsp(unsigned int iBsp); 59 60 void removeBsp(unsigned int iBsp); 61 62 void addClusterList(IMG::ClusterList *clusterList); 63 64 IMG::ClusterList* getClusterList(unsigned int iClusterList); 65 66 void removeClusterList(unsigned int iClusterList); 67 68 void clear(); 69 70 unsigned int getNumClusterLists(); 71 72 unsigned int getNumBsp(); 51 73 52 74 BillboardCloudUVMapper(); -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCBillboardGroup.h
r700 r709 2 2 #define _BILLBOARDGROUP_H 3 3 4 5 #include <vector> 6 using namespace std; 4 #include <BBCPrerequisites.h> 7 5 8 6 namespace BBC { … … 10 8 class BillboardGroup { 11 9 protected: 12 vector<int> mBillboardHandleList;10 std::vector<unsigned int> mBillboardHandleList; 13 11 14 12 public: 15 int getBillboardHandle();13 unsigned int getBillboardHandle(unsigned int iBillboard); 16 14 17 void setBillboardHandle(); 15 void addBillboardHandle(unsigned int iBillboardHandle); 16 17 unsigned int getNumBillboards(); 18 18 19 19 }; -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/IMG/IMGClusterList.h
r700 r709 20 20 21 21 //return the pointer to the list of voxels 22 inline int GetSize() const { return list.size(); }22 inline unsigned int GetSize() const { return list.size(); } 23 23 24 24 //return the number of elements of list -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/LBBC/LBBCManager.h
r700 r709 46 46 void generateBillboardCloud(); 47 47 48 void saveBillboardCloudGrouped(); 49 48 50 void saveBillboardCloudSplitted(); 49 51 -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/LBBC/LBBCSampleConfigFile.h
r700 r709 78 78 unsigned int getBillboardCloudIndirectTextureAtlasSize(); 79 79 80 unsigned int getBillboardCloudGroups(); 81 82 bool getBillboardCloudGroupedBillboards(); 83 80 84 }; 81 85 -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/scripts/IBRBillboardCloudTreeGeneratorCommandLine.vcproj
r698 r709 82 82 Name="VCLinkerTool" 83 83 AdditionalDependencies="odbc32.lib kernel32.lib odbccp32.lib IBRBillboardCloudTreeGenerator.lib OgreMain.lib" 84 OutputFile="$(OutDir)/IBRBillboardCloud GeneratorCmd.exe"84 OutputFile="$(OutDir)/IBRBillboardCloudTreeGeneratorCmd.exe" 85 85 LinkIncremental="1" 86 86 AdditionalLibraryDirectories="../bin/$(ConfigurationName);$(OGRE_PATH)/OgreMain/lib/$(ConfigurationName)" -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/src/BBCBillboardCloud.cpp
r699 r709 1 1 2 2 #include "BBCBillboardCloud.h" 3 #include "BBCBillboard.h"4 3 5 4 namespace BBC { … … 18 17 } 19 18 19 for (unsigned int iBillboardGroup = 0; iBillboardGroup < getNumBillboardGroups(); iBillboardGroup++) 20 { 21 BillboardGroup *billboardGroup = getBillboardGroup(iBillboardGroup); 22 delete billboardGroup; 23 } 24 20 25 delete mEntity; 21 26 } 22 27 23 vector<Billboard*>* BillboardCloud::getBillboardList() { 24 return &mBillboardList; 25 } 26 void BillboardCloud::setBillboardList(vector<Billboard*> &value) { 27 mBillboardList = value; 28 std::vector<Billboard*>* BillboardCloud::getBillboardList() 29 { 30 return &mBillboardList; 31 } 32 33 void BillboardCloud::setBillboardList(std::vector<Billboard*> &value) 34 { 35 mBillboardList = value; 28 36 } 29 37 … … 63 71 void BillboardCloud::generateBillboardCloud(bool mergeBillboards) 64 72 { 73 if (mEntity != NULL) 74 { 75 delete mEntity; 76 mEntity = new Entity(); 77 } 78 65 79 unsigned int numGeneratedBillboardClouds = 0; 66 80 for (unsigned int iBillboard = 0; iBillboard < getNumBillboards(); iBillboard++) … … 92 106 Ogre::Vector3 indices = Ogre::Vector3(0,1,2); 93 107 subEntity = mEntity->getSubEntity(numGeneratedBillboardClouds); 94 subEntity->addTextureCoordSet(2); 108 subEntity->addTextureCoordSet(2); 109 110 Ogre::LogManager::getSingleton().logMessage("BBC-SubEntity(" + Ogre::StringConverter::toString(numGeneratedBillboardClouds) + ") - Num.Tex.Coord.Sets:" + Ogre::StringConverter::toString(subEntity->getNumTexCoordSets())); 111 95 112 subEntity->addFaceVerticesIDs(indices); 96 113 subEntity->addFaceVerticesIDs(indices + Ogre::Vector3(3,3,3)); … … 133 150 } 134 151 135 } 152 void BillboardCloud::initializeBillboardCloudGroups(unsigned int numberGroups) 153 { 154 155 Ogre::LogManager::getSingleton().logMessage("Ini.Num.Billboard Groups:" + Ogre::StringConverter::toString(getNumBillboardGroups())); 156 157 while (getNumBillboardGroups() > 0) 158 { 159 BillboardGroup *billboardGroup = getBillboardGroup(getNumBillboardGroups()-1); 160 removeBillboardGroup(getNumBillboardGroups()-1); 161 } 162 163 Ogre::LogManager::getSingleton().logMessage("Clear.Num.Billboard Groups:" + Ogre::StringConverter::toString(getNumBillboardGroups())); 164 165 unsigned int iBillboardGroup; 166 for (iBillboardGroup = 0; iBillboardGroup < numberGroups; iBillboardGroup++) 167 { 168 BillboardGroup *billboardGroup = new BillboardGroup(); 169 addBillboardGroup(billboardGroup); 170 } 171 172 Ogre::LogManager::getSingleton().logMessage("New.Num.Billboard Groups:" + Ogre::StringConverter::toString(getNumBillboardGroups())); 173 std::cin.get(); 174 std::cin.get(); 175 176 unsigned int numGeneratedBillboardClouds = 0; 177 for (unsigned int iBillboard = 0; iBillboard < getNumBillboards(); iBillboard++) 178 { 179 Billboard *billboard = this->getBillboard(iBillboard); 180 EntityCluster *entityCluster = billboard->getBillboardClusterData()->getEntityCluster(); 181 182 if (entityCluster->getNumEntitiesClusterData() > 0) 183 { 184 numGeneratedBillboardClouds++; 185 } 186 } 187 188 unsigned int numberBillboardsEachGroup = numGeneratedBillboardClouds / numberGroups; 189 unsigned int numberBillboardsAddedFirstGroup = numGeneratedBillboardClouds % numberGroups; 190 191 Ogre::LogManager::getSingleton().logMessage("Num.Billboards:" + Ogre::StringConverter::toString(numGeneratedBillboardClouds)); 192 Ogre::LogManager::getSingleton().logMessage("Num.Billboards Each Group:" + Ogre::StringConverter::toString(numberBillboardsEachGroup)); 193 Ogre::LogManager::getSingleton().logMessage("Num.Billboards Added First Group:" + Ogre::StringConverter::toString(numberBillboardsAddedFirstGroup)); 194 195 iBillboardGroup = 0; 196 unsigned int iBillboardsInGroup = 0; 197 for (unsigned int iBillboard = 0; iBillboard < getNumBillboards(); iBillboard++) 198 { 199 Billboard *billboard = this->getBillboard(iBillboard); 200 EntityCluster *entityCluster = billboard->getBillboardClusterData()->getEntityCluster(); 201 202 if (entityCluster->getNumEntitiesClusterData() > 0) 203 { 204 if ((iBillboardGroup == 0) && (iBillboardsInGroup < (numberBillboardsEachGroup + numberBillboardsAddedFirstGroup))) 205 { 206 getBillboardGroup(iBillboardGroup)->addBillboardHandle(billboard->getBillboardHandle()); 207 iBillboardsInGroup++; 208 } 209 else 210 { 211 if ((iBillboardGroup > 0) && (iBillboardsInGroup < numberBillboardsEachGroup)) 212 { 213 getBillboardGroup(iBillboardGroup)->addBillboardHandle(billboard->getBillboardHandle()); 214 iBillboardsInGroup++; 215 } 216 else 217 { 218 iBillboardGroup++; 219 iBillboardsInGroup = 0; 220 221 getBillboardGroup(iBillboardGroup)->addBillboardHandle(billboard->getBillboardHandle()); 222 iBillboardsInGroup++; 223 } 224 } 225 } 226 } 227 } 228 229 void BillboardCloud::generateBillboardCloudGroups() 230 { 231 SubEntity *subEntityGroup; 232 SubEntity *subEntity; 233 Entity *entity = new Entity(); 234 unsigned int numGeneratedBillboardClouds = 0; 235 236 for (unsigned int iBillboardGroup = 0; iBillboardGroup < this->getNumBillboardGroups(); iBillboardGroup++) 237 { 238 if (iBillboardGroup > 0) 239 { 240 entity->createSubEntity(); 241 Ogre::LogManager::getSingleton().logMessage("BillboardGroup:" + Ogre::StringConverter::toString(iBillboardGroup) + "--" + Ogre::StringConverter::toString(getBillboardGroup(iBillboardGroup)->getNumBillboards())); 242 } 243 244 subEntityGroup = entity->getSubEntity(iBillboardGroup); 245 246 BillboardGroup *billboardGroup = this->getBillboardGroup(iBillboardGroup); 247 248 Ogre::LogManager::getSingleton().logMessage("BBCG-Num.Billboards:" + Ogre::StringConverter::toString(billboardGroup->getNumBillboards())); 249 std::cin.get(); 250 std::cin.get(); 251 252 for (unsigned int iBillboard = 0; iBillboard < billboardGroup->getNumBillboards(); iBillboard++) 253 { 254 unsigned int billboardHandle = billboardGroup->getBillboardHandle(iBillboard); 255 Billboard *billboard = this->getBillboard(billboardHandle); 256 EntityCluster *entityCluster = billboard->getBillboardClusterData()->getEntityCluster(); 257 258 if (entityCluster->getNumEntitiesClusterData() > 0) 259 { 260 subEntity = mEntity->getSubEntity(numGeneratedBillboardClouds); 261 262 while (subEntityGroup->getNumTexCoordSets() < subEntity->getNumTexCoordSets()) 263 { 264 subEntityGroup->addTextureCoordSet(subEntity->getTexCoordDimensions(subEntityGroup->getNumTexCoordSets())); 265 } 266 267 unsigned int offset = subEntityGroup->getNumFaces() * 3; 268 Ogre::Vector3 indicesA = Ogre::Vector3(offset, offset + 1, offset + 2); 269 subEntityGroup->addFaceVerticesIDs(indicesA); 270 offset = subEntityGroup->getNumFaces()*3; 271 Ogre::Vector3 indicesB = Ogre::Vector3(offset, offset + 1, offset + 2); 272 subEntityGroup->addFaceVerticesIDs(indicesB); 273 274 UniqueVertex vFaceA1,vFaceA2,vFaceA3; 275 // Face A of the billboard quad 276 vFaceA1.position = billboard->getBillboardClusterData()->getQuadTopLeftCorner(); 277 vFaceA1.normal = billboard->getBillboardClusterData()->getNormal(); 278 279 vFaceA2.position = billboard->getBillboardClusterData()->getQuadTopRightCorner(); 280 vFaceA2.normal = billboard->getBillboardClusterData()->getNormal(); 281 282 vFaceA3.position = billboard->getBillboardClusterData()->getQuadBottomRightCorner(); 283 vFaceA3.normal = billboard->getBillboardClusterData()->getNormal(); 284 285 // Face B of the billboard quad 286 UniqueVertex vFaceB1,vFaceB2,vFaceB3; 287 vFaceB1.position = billboard->getBillboardClusterData()->getQuadBottomRightCorner(); 288 vFaceB1.normal = billboard->getBillboardClusterData()->getNormal(); 289 290 vFaceB2.position = billboard->getBillboardClusterData()->getQuadBottomLeftCorner(); 291 vFaceB2.normal = billboard->getBillboardClusterData()->getNormal(); 292 293 vFaceB3.position = billboard->getBillboardClusterData()->getQuadTopLeftCorner(); 294 vFaceB3.normal = billboard->getBillboardClusterData()->getNormal(); 295 296 Ogre::LogManager::getSingleton().logMessage("BBCG-SubEntity(" + Ogre::StringConverter::toString(numGeneratedBillboardClouds) + ") - Num.Tex.Coord.Sets:"+ Ogre::StringConverter::toString(subEntity->getNumTexCoordSets())); 297 298 for (unsigned int iTexCoordSet = 0; iTexCoordSet < subEntityGroup->getNumTexCoordSets(); iTexCoordSet++) 299 { 300 vFaceA1.uv[iTexCoordSet] = subEntity->getUniqueVertex(0).uv[iTexCoordSet]; 301 vFaceA2.uv[iTexCoordSet] = subEntity->getUniqueVertex(1).uv[iTexCoordSet]; 302 vFaceA3.uv[iTexCoordSet] = subEntity->getUniqueVertex(2).uv[iTexCoordSet]; 303 vFaceB1.uv[iTexCoordSet] = subEntity->getUniqueVertex(3).uv[iTexCoordSet]; 304 vFaceB2.uv[iTexCoordSet] = subEntity->getUniqueVertex(4).uv[iTexCoordSet]; 305 vFaceB3.uv[iTexCoordSet] = subEntity->getUniqueVertex(5).uv[iTexCoordSet]; 306 } 307 308 subEntityGroup->addUniqueVertex(vFaceA1); 309 subEntityGroup->addUniqueVertex(vFaceA2); 310 subEntityGroup->addUniqueVertex(vFaceA3); 311 subEntityGroup->addUniqueVertex(vFaceB1); 312 subEntityGroup->addUniqueVertex(vFaceB2); 313 subEntityGroup->addUniqueVertex(vFaceB3); 314 315 numGeneratedBillboardClouds++; 316 } 317 } 318 } 319 320 delete mEntity; 321 mEntity = entity; 322 entity->setSubEntitiesDistinctVertexColours(); 323 } 324 325 unsigned int BillboardCloud::getNumBillboardGroups() 326 { 327 return mBillboardGroupList.size(); 328 } 329 330 BillboardGroup* BillboardCloud::getBillboardGroup(unsigned int iBillboardGroup) 331 { 332 return mBillboardGroupList[iBillboardGroup]; 333 } 334 335 void BillboardCloud::addBillboardGroup(BillboardGroup *value) 336 { 337 mBillboardGroupList.push_back(value); 338 } 339 340 void BillboardCloud::removeBillboardGroup(unsigned int value) 341 { 342 BillboardGroup *billboardGroup = mBillboardGroupList[value]; 343 mBillboardGroupList.erase(mBillboardGroupList.begin() + value); 344 delete billboardGroup; 345 } 346 347 } -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/src/BBCBillboardCloudUVMapper.cpp
r699 r709 1 1 2 2 3 #include "BBCBillboardCloudUVMapper.h" … … 7 8 namespace BBC { 8 9 9 void BillboardCloudUVMapper::initialize() 10 { 11 IMG::Box2d *box = new IMG::Box2d; 12 IMG::NodeBsp *node = new IMG::NodeBsp; 13 box->SetBoundBox(0, 0, mTextureAtlasWidth, mTextureAtlasHeight); 14 node->SetBound(box); 15 mBsp.SetRoot(node); 10 BillboardCloudUVMapper::BillboardCloudUVMapper() 11 { 12 } 13 14 BillboardCloudUVMapper::~BillboardCloudUVMapper() 15 { 16 clear(); 17 } 18 19 void BillboardCloudUVMapper::initialize() 20 { 21 } 22 23 void BillboardCloudUVMapper::clear() 24 { 25 Ogre::LogManager::getSingleton().logMessage("Init.BSP:" + Ogre::StringConverter::toString(getNumBsp())); 26 27 while (getNumBsp() > 0) 28 { 29 removeBsp(getNumBsp()-1); 30 } 31 32 Ogre::LogManager::getSingleton().logMessage("Clear.BSP:" + Ogre::StringConverter::toString(getNumBsp())); 33 34 Ogre::LogManager::getSingleton().logMessage("Init.CL:" + Ogre::StringConverter::toString(getNumClusterLists())); 35 36 //while (getNumClusterLists() > 0) 37 //{ 38 // removeBsp(getNumClusterLists()-1); 39 //} 40 mClusterLists.clear(); 41 42 Ogre::LogManager::getSingleton().logMessage("Clear.CL:" + Ogre::StringConverter::toString(getNumClusterLists())); 43 } 44 45 unsigned int BillboardCloudUVMapper::getNumClusterLists() 46 { 47 return mClusterLists.size(); 48 } 49 50 unsigned int BillboardCloudUVMapper::getNumBsp() 51 { 52 return mBspList.size(); 53 } 54 55 void BillboardCloudUVMapper::addBsp(IMG::Bsp *bsp) 56 { 57 mBspList.push_back(bsp); 58 } 59 60 IMG::Bsp* BillboardCloudUVMapper::getBsp(unsigned int iBsp) 61 { 62 return mBspList[iBsp]; 63 } 64 65 void BillboardCloudUVMapper::removeBsp(unsigned int iBsp) 66 { 67 IMG::Bsp *bsp = mBspList[iBsp]; 68 mBspList.erase(mBspList.begin() + iBsp); 69 delete bsp; 70 } 71 72 void BillboardCloudUVMapper::addClusterList(IMG::ClusterList *clusterList) 73 { 74 mClusterLists.push_back(clusterList); 75 } 76 77 IMG::ClusterList* BillboardCloudUVMapper::getClusterList(unsigned int iClusterList) 78 { 79 return mClusterLists[iClusterList]; 80 } 81 82 void BillboardCloudUVMapper::removeClusterList(unsigned int iClusterList) 83 { 84 //mClusterLists.erase(mClusterLists.begin() + iClusterList); 16 85 } 17 86 … … 56 125 } 57 126 58 void BillboardCloudUVMapper::generateTextureAtlasTextureCoords(bool mergeBillboards) 127 void BillboardCloudUVMapper::addTextureAtlasTextureCoords(bool mergeBillboards, bool groupedBillboards, unsigned int numGeneratedBillboardClouds, unsigned int iBillboardGroup) 128 { 129 unsigned int iUniqueVertex = 0; 130 131 Ogre::LogManager::getSingleton().logMessage("iBBC:" + Ogre::StringConverter::toString(numGeneratedBillboardClouds) + "-" + "iBBCG:" + Ogre::StringConverter::toString(iBillboardGroup)); 132 133 Ogre::LogManager::getSingleton().logMessage("SizeCLList:" + Ogre::StringConverter::toString(getClusterList(iBillboardGroup)->GetSize()) + " -- numBBC:" + Ogre::StringConverter::toString(numGeneratedBillboardClouds)); 134 135 IMG::Cluster *cluster = getClusterList(iBillboardGroup)->Get(getClusterList(iBillboardGroup)->GetSize()-1); 136 IMG::Box2d *box = cluster->GetBspNodeBound(); 137 Ogre::Vector2 max = box->GetMaximum(); 138 Ogre::Vector2 min = box->GetMinimum(); 139 Ogre::LogManager::getSingleton().logMessage("Max:" + Ogre::StringConverter::toString(Ogre::Vector3(max[0],max[1],0)) + 140 "\tMin:" + Ogre::StringConverter::toString(Ogre::Vector3(min[0],min[1],0)) + 141 "\tSize(" + Ogre::StringConverter::toString(max[0]-min[0]) + 142 "," + Ogre::StringConverter::toString(max[1]-min[1]) + ")"); 143 144 SubEntity *subEntity; 145 146 Ogre::Vector2 texCoords01,texCoords02,texCoords03,texCoords04; 147 texCoords01[0] = min[0] / mTextureAtlasWidth; 148 texCoords01[1] = min[1] / mTextureAtlasHeight; 149 150 texCoords02[0] = max[0] / mTextureAtlasWidth; 151 texCoords02[1] = min[1] / mTextureAtlasHeight; 152 153 texCoords03[0] = max[0] / mTextureAtlasWidth; 154 texCoords03[1] = max[1] / mTextureAtlasHeight; 155 156 texCoords04[0] = min[0] / mTextureAtlasWidth; 157 texCoords04[1] = max[1] / mTextureAtlasHeight; 158 159 if (groupedBillboards) 160 { 161 Ogre::LogManager::getSingleton().logMessage("DontMerge"); 162 subEntity = subEntity = mBillboardCloud->getEntity()->getSubEntity(iBillboardGroup); 163 164 // Face A 165 //(0,0,0); 166 //(1,0,0); 167 //(1,1,0); 168 subEntity->setTexCoord(iUniqueVertex, subEntity->getNumTexCoordSets()-1, Ogre::Vector3(texCoords01[0],texCoords01[1],0)); 169 subEntity->setTexCoord(iUniqueVertex+1, subEntity->getNumTexCoordSets()-1, Ogre::Vector3(texCoords02[0],texCoords02[1],0)); 170 subEntity->setTexCoord(iUniqueVertex+2, subEntity->getNumTexCoordSets()-1, Ogre::Vector3(texCoords03[0],texCoords03[1],0)); 171 172 Ogre::ColourValue subEntityColour01 = Ogre::ColourValue(0, texCoords01[0],texCoords01[1]); 173 Ogre::ColourValue subEntityColour02 = Ogre::ColourValue(0, texCoords02[0],texCoords02[1]); 174 Ogre::ColourValue subEntityColour03 = Ogre::ColourValue(0, texCoords03[0],texCoords03[1]); 175 176 subEntity->setVertexColour(iUniqueVertex, subEntityColour01.getAsRGBA()); 177 subEntity->setVertexColour(iUniqueVertex+1, subEntityColour02.getAsRGBA()); 178 subEntity->setVertexColour(iUniqueVertex+2, subEntityColour03.getAsRGBA()); 179 180 // Face B 181 //(1,1,0); 182 //(0,1,0); 183 //(0,0,0); 184 subEntity->setTexCoord(iUniqueVertex+3, subEntity->getNumTexCoordSets()-1, Ogre::Vector3(texCoords03[0],texCoords03[1],0)); 185 subEntity->setTexCoord(iUniqueVertex+4, subEntity->getNumTexCoordSets()-1, Ogre::Vector3(texCoords04[0],texCoords04[1],0)); 186 subEntity->setTexCoord(iUniqueVertex+5, subEntity->getNumTexCoordSets()-1, Ogre::Vector3(texCoords01[0],texCoords01[1],0)); 187 188 Ogre::ColourValue subEntityColour04 = Ogre::ColourValue(0, texCoords03[0],texCoords03[1]); 189 Ogre::ColourValue subEntityColour05 = Ogre::ColourValue(0, texCoords04[0],texCoords04[1]); 190 Ogre::ColourValue subEntityColour06 = Ogre::ColourValue(0, texCoords01[0],texCoords01[1]); 191 192 subEntity->setVertexColour(iUniqueVertex+3, subEntityColour04.getAsRGBA()); 193 subEntity->setVertexColour(iUniqueVertex+4, subEntityColour05.getAsRGBA()); 194 subEntity->setVertexColour(iUniqueVertex+5, subEntityColour06.getAsRGBA()); 195 196 iUniqueVertex = iUniqueVertex + 6; 197 } 198 else 199 { 200 if (!mergeBillboards) 201 { 202 Ogre::LogManager::getSingleton().logMessage("DontMerge"); 203 204 subEntity = mBillboardCloud->getEntity()->getSubEntity(numGeneratedBillboardClouds); 205 subEntity->addTextureCoordSet(2); 206 subEntity->enableVertexColours(true); 207 // Face A 208 //(0,0,0); 209 //(1,0,0); 210 //(1,1,0); 211 212 subEntity->setTexCoord(0, subEntity->getNumTexCoordSets()-1, Ogre::Vector3(texCoords01[0],texCoords01[1], 0)); 213 subEntity->setTexCoord(1, subEntity->getNumTexCoordSets()-1, Ogre::Vector3(texCoords02[0],texCoords02[1], 0)); 214 subEntity->setTexCoord(2, subEntity->getNumTexCoordSets()-1, Ogre::Vector3(texCoords03[0],texCoords03[1], 0)); 215 216 Ogre::ColourValue subEntityColour01 = Ogre::ColourValue(0, texCoords01[0],texCoords01[1]); 217 Ogre::ColourValue subEntityColour02 = Ogre::ColourValue(0, texCoords02[0],texCoords02[1]); 218 Ogre::ColourValue subEntityColour03 = Ogre::ColourValue(0, texCoords03[0],texCoords03[1]); 219 220 subEntity->setVertexColour(0, subEntityColour01.getAsRGBA()); 221 subEntity->setVertexColour(1, subEntityColour02.getAsRGBA()); 222 subEntity->setVertexColour(2, subEntityColour03.getAsRGBA()); 223 224 // Face B 225 //(1,1,0); 226 //(0,1,0); 227 //(0,0,0); 228 subEntity->setTexCoord(3, subEntity->getNumTexCoordSets()-1, Ogre::Vector3(texCoords03[0],texCoords03[1],0)); 229 subEntity->setTexCoord(4, subEntity->getNumTexCoordSets()-1, Ogre::Vector3(texCoords04[0],texCoords04[1],0)); 230 subEntity->setTexCoord(5, subEntity->getNumTexCoordSets()-1, Ogre::Vector3(texCoords01[0],texCoords01[1],0)); 231 232 Ogre::ColourValue subEntityColour04 = Ogre::ColourValue(0, texCoords03[0],texCoords03[1]); 233 Ogre::ColourValue subEntityColour05 = Ogre::ColourValue(0, texCoords04[0],texCoords04[1]); 234 Ogre::ColourValue subEntityColour06 = Ogre::ColourValue(0, texCoords01[0],texCoords01[1]); 235 236 subEntity->setVertexColour(3, subEntityColour04.getAsRGBA()); 237 subEntity->setVertexColour(4, subEntityColour05.getAsRGBA()); 238 subEntity->setVertexColour(5, subEntityColour06.getAsRGBA()); 239 240 } 241 else 242 { 243 Ogre::LogManager::getSingleton().logMessage("Merge"); 244 245 subEntity = mBillboardCloud->getEntity()->getSubEntity(0); 246 247 // Face A 248 //(0,0,0); 249 //(1,0,0); 250 //(1,1,0); 251 subEntity->setTexCoord(iUniqueVertex, subEntity->getNumTexCoordSets()-1, Ogre::Vector3(texCoords01[0],texCoords01[1],0)); 252 subEntity->setTexCoord(iUniqueVertex+1, subEntity->getNumTexCoordSets()-1, Ogre::Vector3(texCoords02[0],texCoords02[1],0)); 253 subEntity->setTexCoord(iUniqueVertex+2, subEntity->getNumTexCoordSets()-1, Ogre::Vector3(texCoords03[0],texCoords03[1],0)); 254 255 Ogre::ColourValue subEntityColour01 = Ogre::ColourValue(0, texCoords01[0],texCoords01[1]); 256 Ogre::ColourValue subEntityColour02 = Ogre::ColourValue(0, texCoords02[0],texCoords02[1]); 257 Ogre::ColourValue subEntityColour03 = Ogre::ColourValue(0, texCoords03[0],texCoords03[1]); 258 259 subEntity->setVertexColour(iUniqueVertex, subEntityColour01.getAsRGBA()); 260 subEntity->setVertexColour(iUniqueVertex+1, subEntityColour02.getAsRGBA()); 261 subEntity->setVertexColour(iUniqueVertex+2, subEntityColour03.getAsRGBA()); 262 263 // Face B 264 //(1,1,0); 265 //(0,1,0); 266 //(0,0,0); 267 subEntity->setTexCoord(iUniqueVertex+3, subEntity->getNumTexCoordSets()-1, Ogre::Vector3(texCoords03[0],texCoords03[1],0)); 268 subEntity->setTexCoord(iUniqueVertex+4, subEntity->getNumTexCoordSets()-1, Ogre::Vector3(texCoords04[0],texCoords04[1],0)); 269 subEntity->setTexCoord(iUniqueVertex+5, subEntity->getNumTexCoordSets()-1, Ogre::Vector3(texCoords01[0],texCoords01[1],0)); 270 271 Ogre::ColourValue subEntityColour04 = Ogre::ColourValue(0, texCoords03[0],texCoords03[1]); 272 Ogre::ColourValue subEntityColour05 = Ogre::ColourValue(0, texCoords04[0],texCoords04[1]); 273 Ogre::ColourValue subEntityColour06 = Ogre::ColourValue(0, texCoords01[0],texCoords01[1]); 274 275 subEntity->setVertexColour(iUniqueVertex+3, subEntityColour04.getAsRGBA()); 276 subEntity->setVertexColour(iUniqueVertex+4, subEntityColour05.getAsRGBA()); 277 subEntity->setVertexColour(iUniqueVertex+5, subEntityColour06.getAsRGBA()); 278 279 iUniqueVertex = iUniqueVertex + 6; 280 } 281 Ogre::LogManager::getSingleton().logMessage("EndAdd"); 282 } 283 } 284 285 void BillboardCloudUVMapper::addTextureInBsp(unsigned int iBillboardGroup, unsigned int iBillboard) 286 { 287 IMG::NodeBsp *nodeDest; 288 IMG::Cluster cluster; 289 Ogre::LogManager::getSingleton().logMessage("w:" + Ogre::StringConverter::toString(mTextureWidth)); 290 Ogre::LogManager::getSingleton().logMessage("h:" + Ogre::StringConverter::toString(mTextureHeight)); 291 nodeDest = getBsp(iBillboardGroup)->Insert(mTextureWidth,mTextureHeight,iBillboard); 292 293 cluster.SetBspNodeBound(nodeDest->GetBound()); 294 //cluster.Finish(); 295 getClusterList(iBillboardGroup)->Insert(&cluster); 296 } 297 298 void BillboardCloudUVMapper::generateTextureAtlasTextureCoords(bool mergeBillboards, bool groupedBillboards, unsigned int numGroups) 59 299 { 300 unsigned int numBillboardGroups; 301 bool enabledTextureCoordSet = false; 302 unsigned int numGeneratedBillboardClouds = 0; 60 303 61 304 for (unsigned int iBillboard = 0; iBillboard < mBillboardCloud->getNumBillboards(); iBillboard++) 62 305 { 63 Ogre::LogManager::getSingleton().logMessage("id:" + Ogre::StringConverter::toString(iBillboard)); 306 Billboard *billboard = mBillboardCloud->getBillboard(iBillboard); 307 EntityCluster *entityCluster = billboard->getBillboardClusterData()->getEntityCluster(); 308 309 if (entityCluster->getNumEntitiesClusterData() > 0) 310 { 311 if (mergeBillboards) 312 { 313 if (!enabledTextureCoordSet) 314 { 315 SubEntity *subEntity = mBillboardCloud->getEntity()->getSubEntity(0); 316 subEntity->addTextureCoordSet(2); 317 subEntity->enableVertexColours(true); 318 enabledTextureCoordSet = true; 319 } 320 } 321 else 322 { 323 if (groupedBillboards) 324 { 325 SubEntity *subEntity = mBillboardCloud->getEntity()->getSubEntity(numGeneratedBillboardClouds); 326 subEntity->addTextureCoordSet(2); 327 subEntity->enableVertexColours(true); 328 } 329 } 330 331 numGeneratedBillboardClouds++; 332 } 333 } 334 335 if (groupedBillboards) 336 { 337 numBillboardGroups = numGroups; 338 } 339 else 340 { 341 if (mergeBillboards) 342 { 343 numBillboardGroups = 1; 344 } 345 else // (!mergeBillboards) 346 { 347 numBillboardGroups = 1; 348 } 349 } 350 351 unsigned int iBillboardsInGroup = 0; 352 unsigned int numberBillboardsEachGroup = numGeneratedBillboardClouds / numGroups; 353 unsigned int numberBillboardsAddedFirstGroup = numGeneratedBillboardClouds % numGroups; 354 numGeneratedBillboardClouds = 0; 355 unsigned int iBillboardGroup; 356 for (iBillboardGroup = 0; iBillboardGroup < numBillboardGroups; iBillboardGroup++) 357 { 358 359 IMG::NodeBsp *node = new IMG::NodeBsp; 360 IMG::Bsp *bsp = new IMG::Bsp(); 361 IMG::Box2d *box = new IMG::Box2d; 362 IMG::ClusterList *clusterList = new IMG::ClusterList(); 363 364 box->SetBoundBox(0, 0, mTextureAtlasWidth, mTextureAtlasHeight); 365 node->SetBound(box); 366 bsp->SetRoot(node); 367 addBsp(bsp); 368 addClusterList(clusterList); 369 370 } 371 372 iBillboardGroup = 0; 373 for (unsigned int iBillboard = 0; iBillboard < mBillboardCloud->getNumBillboards(); iBillboard++) 374 { 375 Ogre::LogManager::getSingleton().logMessage("id:" + Ogre::StringConverter::toString(mBillboardCloud->getBillboard(iBillboard)->getBillboardHandle())); 376 64 377 BillboardClusterData *billboardClusterData = mBillboardCloud->getBillboard(iBillboard)->getBillboardClusterData(); 65 378 … … 72 385 Ogre::LogManager::getSingleton().logMessage("entityCluster"); 73 386 74 IMG::NodeBsp *nodeDest; 75 IMG::Cluster cluster; 76 Ogre::LogManager::getSingleton().logMessage("w:" + Ogre::StringConverter::toString(mTextureWidth)); 77 Ogre::LogManager::getSingleton().logMessage("h:" + Ogre::StringConverter::toString(mTextureHeight)); 78 nodeDest = mBsp.Insert(mTextureWidth,mTextureHeight,iBillboard); 79 80 cluster.SetBspNodeBound(nodeDest->GetBound()); 81 //cluster.Finish(); 82 mClusterList.Insert(&cluster); 387 if ((iBillboardGroup == 0) && (iBillboardsInGroup < (numberBillboardsEachGroup + numberBillboardsAddedFirstGroup))) 388 { 389 Ogre::LogManager::getSingleton().logMessage("\nA"); 390 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)); 391 392 addTextureInBsp(iBillboardGroup, iBillboard); 393 394 addTextureAtlasTextureCoords(mergeBillboards, groupedBillboards, numGeneratedBillboardClouds, iBillboardGroup); 395 iBillboardsInGroup++; 396 } 397 else 398 { 399 if ((iBillboardGroup > 0) && (iBillboardsInGroup < numberBillboardsEachGroup)) 400 { 401 Ogre::LogManager::getSingleton().logMessage("\nB"); 402 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)); 403 404 addTextureInBsp(iBillboardGroup, iBillboard); 405 406 addTextureAtlasTextureCoords(mergeBillboards, groupedBillboards, numGeneratedBillboardClouds, iBillboardGroup); 407 iBillboardsInGroup++; 408 } 409 else 410 { 411 iBillboardGroup++; 412 iBillboardsInGroup = 0; 413 414 Ogre::LogManager::getSingleton().logMessage("\nC IG:" + Ogre::StringConverter::toString(iBillboardsInGroup-1) + " SizeCLList(" + Ogre::StringConverter::toString(iBillboardGroup-1) + "):" + Ogre::StringConverter::toString(getClusterList(iBillboardGroup-1)->GetSize())); 415 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)); 416 417 addTextureInBsp(iBillboardGroup, iBillboard); 418 419 addTextureAtlasTextureCoords(mergeBillboards, groupedBillboards, numGeneratedBillboardClouds, iBillboardGroup); 420 iBillboardsInGroup++; 421 } 422 } 423 424 numGeneratedBillboardClouds++; 83 425 } 84 426 } 85 } 86 87 //mBsp.Print(); 88 89 unsigned int numGeneratedBillboardClouds = 0; 90 bool enabledTextureCoordSet = false; 91 unsigned int iUniqueVertex = 0; 92 93 for (unsigned int iBillboard = 0; iBillboard < mBillboardCloud->getNumBillboards(); iBillboard++) 94 { 95 Billboard *billboard = mBillboardCloud->getBillboard(iBillboard); 96 EntityCluster *entityCluster = billboard->getBillboardClusterData()->getEntityCluster(); 97 98 if (entityCluster->getNumEntitiesClusterData() > 0) 99 { 100 IMG::Cluster *cluster = mClusterList.Get(numGeneratedBillboardClouds); 101 IMG::Box2d *box = cluster->GetBspNodeBound(); 102 Ogre::Vector2 max = box->GetMaximum(); 103 Ogre::Vector2 min = box->GetMinimum(); 104 Ogre::LogManager::getSingleton().logMessage("Max:" + Ogre::StringConverter::toString(Ogre::Vector3(max[0],max[1],0)) + 105 "\tMin:" + Ogre::StringConverter::toString(Ogre::Vector3(min[0],min[1],0)) + 106 "\tSize(" + Ogre::StringConverter::toString(max[0]-min[0]) + 107 "," + Ogre::StringConverter::toString(max[1]-min[1]) + ")"); 108 109 110 SubEntity *subEntity; 111 112 Ogre::Vector2 texCoords01,texCoords02,texCoords03,texCoords04; 113 texCoords01[0] = min[0] / mTextureAtlasWidth; 114 texCoords01[1] = min[1] / mTextureAtlasHeight; 115 116 texCoords02[0] = max[0] / mTextureAtlasWidth; 117 texCoords02[1] = min[1] / mTextureAtlasHeight; 118 119 texCoords03[0] = max[0] / mTextureAtlasWidth; 120 texCoords03[1] = max[1] / mTextureAtlasHeight; 121 122 texCoords04[0] = min[0] / mTextureAtlasWidth; 123 texCoords04[1] = max[1] / mTextureAtlasHeight; 124 125 if (!mergeBillboards) 126 { 127 subEntity = mBillboardCloud->getEntity()->getSubEntity(numGeneratedBillboardClouds); 128 subEntity->addTextureCoordSet(2); 129 subEntity->enableVertexColours(true); 130 // Face A 131 //(0,0,0); 132 //(1,0,0); 133 //(1,1,0); 134 135 subEntity->setTexCoord(0, subEntity->getNumTexCoordSets()-1, Ogre::Vector3(texCoords01[0],texCoords01[1], 0)); 136 subEntity->setTexCoord(1, subEntity->getNumTexCoordSets()-1, Ogre::Vector3(texCoords02[0],texCoords02[1], 0)); 137 subEntity->setTexCoord(2, subEntity->getNumTexCoordSets()-1, Ogre::Vector3(texCoords03[0],texCoords03[1], 0)); 138 139 Ogre::ColourValue subEntityColour01 = Ogre::ColourValue(0, texCoords01[0],texCoords01[1]); 140 Ogre::ColourValue subEntityColour02 = Ogre::ColourValue(0, texCoords02[0],texCoords02[1]); 141 Ogre::ColourValue subEntityColour03 = Ogre::ColourValue(0, texCoords03[0],texCoords03[1]); 142 143 subEntity->setVertexColour(0, subEntityColour01.getAsRGBA()); 144 subEntity->setVertexColour(1, subEntityColour02.getAsRGBA()); 145 subEntity->setVertexColour(2, subEntityColour03.getAsRGBA()); 146 147 // Face B 148 //(1,1,0); 149 //(0,1,0); 150 //(0,0,0); 151 subEntity->setTexCoord(3, subEntity->getNumTexCoordSets()-1, Ogre::Vector3(texCoords03[0],texCoords03[1],0)); 152 subEntity->setTexCoord(4, subEntity->getNumTexCoordSets()-1, Ogre::Vector3(texCoords04[0],texCoords04[1],0)); 153 subEntity->setTexCoord(5, subEntity->getNumTexCoordSets()-1, Ogre::Vector3(texCoords01[0],texCoords01[1],0)); 154 155 Ogre::ColourValue subEntityColour04 = Ogre::ColourValue(0, texCoords03[0],texCoords03[1]); 156 Ogre::ColourValue subEntityColour05 = Ogre::ColourValue(0, texCoords04[0],texCoords04[1]); 157 Ogre::ColourValue subEntityColour06 = Ogre::ColourValue(0, texCoords01[0],texCoords01[1]); 158 159 subEntity->setVertexColour(3, subEntityColour04.getAsRGBA()); 160 subEntity->setVertexColour(4, subEntityColour05.getAsRGBA()); 161 subEntity->setVertexColour(5, subEntityColour06.getAsRGBA()); 162 163 } 164 else 165 { 166 subEntity = mBillboardCloud->getEntity()->getSubEntity(0); 167 if (!enabledTextureCoordSet) 168 { 169 subEntity->addTextureCoordSet(2); 170 subEntity->enableVertexColours(true); 171 enabledTextureCoordSet = true; 172 } 173 174 // Face A 175 //(0,0,0); 176 //(1,0,0); 177 //(1,1,0); 178 179 subEntity->setTexCoord(iUniqueVertex, subEntity->getNumTexCoordSets()-1, Ogre::Vector3(texCoords01[0],texCoords01[1],0)); 180 subEntity->setTexCoord(iUniqueVertex+1, subEntity->getNumTexCoordSets()-1, Ogre::Vector3(texCoords02[0],texCoords02[1],0)); 181 subEntity->setTexCoord(iUniqueVertex+2, subEntity->getNumTexCoordSets()-1, Ogre::Vector3(texCoords03[0],texCoords03[1],0)); 182 183 Ogre::ColourValue subEntityColour01 = Ogre::ColourValue(0, texCoords01[0],texCoords01[1]); 184 Ogre::ColourValue subEntityColour02 = Ogre::ColourValue(0, texCoords02[0],texCoords02[1]); 185 Ogre::ColourValue subEntityColour03 = Ogre::ColourValue(0, texCoords03[0],texCoords03[1]); 186 187 subEntity->setVertexColour(iUniqueVertex, subEntityColour01.getAsRGBA()); 188 subEntity->setVertexColour(iUniqueVertex+1, subEntityColour02.getAsRGBA()); 189 subEntity->setVertexColour(iUniqueVertex+2, subEntityColour03.getAsRGBA()); 190 191 192 // Face B 193 //(1,1,0); 194 //(0,1,0); 195 //(0,0,0); 196 subEntity->setTexCoord(iUniqueVertex+3, subEntity->getNumTexCoordSets()-1, Ogre::Vector3(texCoords03[0],texCoords03[1],0)); 197 subEntity->setTexCoord(iUniqueVertex+4, subEntity->getNumTexCoordSets()-1, Ogre::Vector3(texCoords04[0],texCoords04[1],0)); 198 subEntity->setTexCoord(iUniqueVertex+5, subEntity->getNumTexCoordSets()-1, Ogre::Vector3(texCoords01[0],texCoords01[1],0)); 199 200 Ogre::ColourValue subEntityColour04 = Ogre::ColourValue(0, texCoords03[0],texCoords03[1]); 201 Ogre::ColourValue subEntityColour05 = Ogre::ColourValue(0, texCoords04[0],texCoords04[1]); 202 Ogre::ColourValue subEntityColour06 = Ogre::ColourValue(0, texCoords01[0],texCoords01[1]); 203 204 subEntity->setVertexColour(iUniqueVertex+3, subEntityColour04.getAsRGBA()); 205 subEntity->setVertexColour(iUniqueVertex+4, subEntityColour05.getAsRGBA()); 206 subEntity->setVertexColour(iUniqueVertex+5, subEntityColour06.getAsRGBA()); 207 208 iUniqueVertex = iUniqueVertex + 6; 209 } 210 numGeneratedBillboardClouds++; 211 } 212 } 213 427 } 428 //mBsp.Print(); 214 429 } 215 430 … … 224 439 } 225 440 226 BillboardCloudUVMapper::BillboardCloudUVMapper() 227 { 228 } 229 230 BillboardCloudUVMapper::~BillboardCloudUVMapper() 231 { 232 } 233 234 } 441 } -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/src/BBCBillboardGroup.cpp
r699 r709 4 4 namespace BBC { 5 5 6 int BillboardGroup::getBillboardHandle()6 unsigned int BillboardGroup::getBillboardHandle(unsigned int iBillboard) 7 7 { 8 return 0;8 return mBillboardHandleList[iBillboard]; 9 9 } 10 10 11 void BillboardGroup:: setBillboardHandle()11 void BillboardGroup::addBillboardHandle(unsigned int iBillboardHandle) 12 12 { 13 mBillboardHandleList.push_back(iBillboardHandle); 13 14 } 14 15 16 unsigned int BillboardGroup::getNumBillboards() 17 { 18 return mBillboardHandleList.size(); 19 } 15 20 16 21 } -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/src/BBCSubEntity.cpp
r699 r709 91 91 enableTextureCoords(true); 92 92 } 93 93 94 94 95 unsigned int SubEntity::getNumTexCoordSets() -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/src/IMGBsp.cpp
r699 r709 4 4 namespace IMG { 5 5 6 Bsp::~Bsp() { 6 Bsp::~Bsp() 7 { 8 delete root; 7 9 } 8 10 -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/src/IMGClusterList.cpp
r699 r709 191 191 } 192 192 193 ClusterList::~ClusterList() { 193 ClusterList::~ClusterList() 194 { 195 list.clear(); 194 196 } 195 197 -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/src/LBBCLeafDistributionGenerator.cpp
r699 r709 67 67 //Ogre::LogManager::getSingleton().logMessage("face B: " + Ogre::StringConverter::toString(iF02)); 68 68 //Ogre::LogManager::getSingleton().logMessage("indices B:" + Ogre::StringConverter::toString(vFace02)); 69 //cin.get();70 69 71 70 if ((iF01 != iF02) && … … 114 113 //Ogre::LogManager::getSingleton().logMessage("face stored: " + Ogre::StringConverter::toString(iF01)); 115 114 //Ogre::LogManager::getSingleton().logMessage("face stored: " + Ogre::StringConverter::toString(leaf->getFace(0))); 116 //cin.get();117 115 } 118 116 else … … 138 136 //Ogre::LogManager::getSingleton().logMessage("face stored: " + Ogre::StringConverter::toString(iF02)); 139 137 //Ogre::LogManager::getSingleton().logMessage("face stored: " + Ogre::StringConverter::toString(leaf->getFace(0))); 140 //cin.get();141 138 } 142 139 else … … 155 152 //Ogre::LogManager::getSingleton().logMessage("face stored: " + Ogre::StringConverter::toString(iF01)); 156 153 //Ogre::LogManager::getSingleton().logMessage("face stored: " + Ogre::StringConverter::toString(leaf->getFace(0))); 157 //cin.get();158 154 } 159 155 } -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/src/LBBCManager.cpp
r699 r709 188 188 } 189 189 190 void Manager::saveBillboardCloudGrouped() 191 { 192 for (unsigned int iSubEntity = 0; iSubEntity < mLeaves->getBillboardCloud()->getEntity()->getNumSubEntities(); iSubEntity++) 193 { 194 BBC::SubEntity *subEntity = mLeaves->getBillboardCloud()->getEntity()->getSubEntity(iSubEntity); 195 subEntity->setMaterialName(mSampleCf.getBillboardCloudMaterialPrefixFilename()); 196 } 197 mOgreMeshSerializer->setEntity(mLeaves->getBillboardCloud()->getEntity()); 198 199 Ogre::LogManager::getSingleton().logMessage("Num.SubEntities:" + Ogre::StringConverter::toString(mLeaves->getBillboardCloud()->getEntity()->getNumSubEntities())); 200 mOgreMeshSerializer->exportMesh(mSampleCf.getBillboardCloudFolder() + 201 mSampleCf.getBillboardCloudMeshPrefixFilename() + "Grouped.mesh",false, false); 202 mMeshSerializer->exportMesh(mLeaves->getBillboardCloud()->getEntity()->getMesh(), mSampleCf.getBillboardCloudFolder() + mSampleCf.getBillboardCloudMeshPrefixFilename() + "Grouped.mesh"); 203 mXMLMeshSerializer->exportMesh(mLeaves->getBillboardCloud()->getEntity()->getMesh(), mSampleCf.getBillboardCloudFolder() + mSampleCf.getBillboardCloudMeshPrefixFilename() + "Grouped.mesh.xml"); 204 } 205 206 190 207 void Manager::saveBillboardCloudSplitted() 191 { 192 //exportBillboardCloudMesh() 208 { 209 for (unsigned int iSubEntity = 0; iSubEntity < mLeaves->getBillboardCloud()->getEntity()->getNumSubEntities(); iSubEntity++) 210 { 211 BBC::SubEntity *subEntity = mLeaves->getBillboardCloud()->getEntity()->getSubEntity(iSubEntity); 212 subEntity->setMaterialName(mSampleCf.getBillboardCloudMaterialPrefixFilename()); 213 } 214 193 215 mOgreMeshSerializer->setEntity(mLeaves->getBillboardCloud()->getEntity()); 194 216 mOgreMeshSerializer->exportMesh(mSampleCf.getBillboardCloudFolder() + 195 217 mSampleCf.getBillboardCloudMeshPrefixFilename() + "Splitted.mesh",false, false); 196 218 mMeshSerializer->exportMesh(mLeaves->getBillboardCloud()->getEntity()->getMesh(), mSampleCf.getBillboardCloudFolder() + mSampleCf.getBillboardCloudMeshPrefixFilename() + "Splitted.mesh"); 219 mXMLMeshSerializer->exportMesh(mLeaves->getBillboardCloud()->getEntity()->getMesh(), mSampleCf.getBillboardCloudFolder() + mSampleCf.getBillboardCloudMeshPrefixFilename() + "Splitted.mesh.xml"); 197 220 } 198 221 199 222 void Manager::saveBillboardCloudMerged() 200 223 { 201 mLeaves->getBillboardCloud()->getEntity()->getSubEntity(0)->setMaterialName(mSampleCf.getBillboardCloudMaterialPrefixFilename()); 224 //mLeaves->getBillboardCloud()->getEntity()->getSubEntity(0)->setMaterialName(mSampleCf.getBillboardCloudMaterialPrefixFilename()); 225 //mOgreMeshSerializer->setEntity(mLeaves->getBillboardCloud()->getEntity()); 226 //mOgreMeshSerializer->exportMesh(mSampleCf.getBillboardCloudFolder() + 227 // mSampleCf.getBillboardCloudMeshPrefixFilename() + "Merged.mesh", mSampleCf.getBillboardCloudMergedBillboards(), false); 228 //mMeshSerializer->exportMesh(mLeaves->getBillboardCloud()->getEntity()->getMesh(), 229 // mSampleCf.getBillboardCloudFolder() + mSampleCf.getBillboardCloudMeshPrefixFilename() + "Merged.mesh"); 230 //mXMLMeshSerializer->exportMesh(mLeaves->getBillboardCloud()->getEntity()->getMesh(), mSampleCf.getBillboardCloudFolder() + mSampleCf.getBillboardCloudMeshPrefixFilename() + "Merged.mesh.xml"); 231 232 233 for (unsigned int iSubEntity = 0; iSubEntity < mLeaves->getBillboardCloud()->getEntity()->getNumSubEntities(); iSubEntity++) 234 { 235 BBC::SubEntity *subEntity = mLeaves->getBillboardCloud()->getEntity()->getSubEntity(iSubEntity); 236 subEntity->setMaterialName(mSampleCf.getBillboardCloudMaterialPrefixFilename()); 237 } 202 238 mOgreMeshSerializer->setEntity(mLeaves->getBillboardCloud()->getEntity()); 239 240 Ogre::LogManager::getSingleton().logMessage("Num.SubEntities:" + Ogre::StringConverter::toString(mLeaves->getBillboardCloud()->getEntity()->getNumSubEntities())); 203 241 mOgreMeshSerializer->exportMesh(mSampleCf.getBillboardCloudFolder() + 204 mSampleCf.getBillboardCloudMeshPrefixFilename() + "Merged.mesh", mSampleCf.getBillboardCloudMergedBillboards(), false); 205 mMeshSerializer->exportMesh(mLeaves->getBillboardCloud()->getEntity()->getMesh(), 206 mSampleCf.getBillboardCloudFolder() + mSampleCf.getBillboardCloudMeshPrefixFilename() 207 208 + "Merged.mesh"); 242 mSampleCf.getBillboardCloudMeshPrefixFilename() + "Merged.mesh",false, false); 243 mMeshSerializer->exportMesh(mLeaves->getBillboardCloud()->getEntity()->getMesh(), mSampleCf.getBillboardCloudFolder() + mSampleCf.getBillboardCloudMeshPrefixFilename() + "Merged.mesh"); 244 mXMLMeshSerializer->exportMesh(mLeaves->getBillboardCloud()->getEntity()->getMesh(), mSampleCf.getBillboardCloudFolder() + mSampleCf.getBillboardCloudMeshPrefixFilename() + "Merged.mesh.xml"); 209 245 } 210 246 … … 338 374 if (mSampleCf.getBillboardCloudMergedBillboards()) 339 375 { 340 mLeaves->getBillboardCloud()->generateBillboardCloud(mSampleCf.getBillboardCloudMergedBillboards()); 376 //mLeaves->getBillboardCloud()->generateBillboardCloud(mSampleCf.getBillboardCloudMergedBillboards()); 377 //mLeaves->getBillboardCloud()->initializeBillboardCloudGroups(1); 378 379 //if (mSampleCf.getBillboardCloudDiffuseColorTextureAtlasGeneration()) 380 //{ 381 // mBillboardCloudUVMapper->clear(); 382 // mBillboardCloudUVMapper->setBillboardCloud(mLeaves->getBillboardCloud()); 383 // mBillboardCloudUVMapper->setTextureWidth(mSampleCf.getBillboardCloudDiffuseColorTextureSize()); 384 // mBillboardCloudUVMapper->setTextureHeight(mSampleCf.getBillboardCloudDiffuseColorTextureSize()); 385 // mBillboardCloudUVMapper->setTextureAtlasWidth(mSampleCf.getBillboardCloudDiffuseColorTextureAtlasSize()); 386 // mBillboardCloudUVMapper->setTextureAtlasHeight(mSampleCf.getBillboardCloudDiffuseColorTextureAtlasSize()); 387 // mBillboardCloudUVMapper->initialize(); 388 // mBillboardCloudUVMapper->generateTextureAtlasTextureCoords(false, mSampleCf.getBillboardCloudGroupedBillboards(), 1); 389 //} 390 391 //mLeaves->getBillboardCloud()->generateBillboardCloudGroups(); 392 //saveBillboardCloudMerged(); 393 394 mLeaves->getBillboardCloud()->generateBillboardCloud(false); 395 mLeaves->getBillboardCloud()->initializeBillboardCloudGroups(1); 396 341 397 if (mSampleCf.getBillboardCloudDiffuseColorTextureAtlasGeneration()) 342 398 { 399 mBillboardCloudUVMapper->clear(); 343 400 mBillboardCloudUVMapper->setBillboardCloud(mLeaves->getBillboardCloud()); 344 401 mBillboardCloudUVMapper->setTextureWidth(mSampleCf.getBillboardCloudDiffuseColorTextureSize()); … … 347 404 mBillboardCloudUVMapper->setTextureAtlasHeight(mSampleCf.getBillboardCloudDiffuseColorTextureAtlasSize()); 348 405 mBillboardCloudUVMapper->initialize(); 349 mBillboardCloudUVMapper->generateTextureAtlasTextureCoords(mSampleCf.getBillboardCloudMergedBillboards()); 350 } 406 mBillboardCloudUVMapper->generateTextureAtlasTextureCoords(false, mSampleCf.getBillboardCloudGroupedBillboards(), 1); 407 } 408 409 mLeaves->getBillboardCloud()->generateBillboardCloudGroups(); 410 351 411 saveBillboardCloudMerged(); 352 412 } 353 413 354 355 if (mSampleCf.getBillboardCloudSplittedBillboards()) 356 { 357 mLeaves->getBillboardCloud()->generateBillboardCloud(!mSampleCf.getBillboardCloudSplittedBillboards()); 414 if (mSampleCf.getBillboardCloudGroupedBillboards()) 415 { 416 mLeaves->getBillboardCloud()->generateBillboardCloud(false); 417 mLeaves->getBillboardCloud()->initializeBillboardCloudGroups(mSampleCf.getBillboardCloudGroups()); 418 358 419 if (mSampleCf.getBillboardCloudDiffuseColorTextureAtlasGeneration()) 359 420 { 421 mBillboardCloudUVMapper->clear(); 360 422 mBillboardCloudUVMapper->setBillboardCloud(mLeaves->getBillboardCloud()); 361 423 mBillboardCloudUVMapper->setTextureWidth(mSampleCf.getBillboardCloudDiffuseColorTextureSize()); … … 364 426 mBillboardCloudUVMapper->setTextureAtlasHeight(mSampleCf.getBillboardCloudDiffuseColorTextureAtlasSize()); 365 427 mBillboardCloudUVMapper->initialize(); 366 mBillboardCloudUVMapper->generateTextureAtlasTextureCoords(!mSampleCf.getBillboardCloudSplittedBillboards()); 428 mBillboardCloudUVMapper->generateTextureAtlasTextureCoords(false, mSampleCf.getBillboardCloudGroupedBillboards(), mSampleCf.getBillboardCloudGroups()); 429 } 430 431 mLeaves->getBillboardCloud()->generateBillboardCloudGroups(); 432 433 saveBillboardCloudGrouped(); 434 } 435 436 if (mSampleCf.getBillboardCloudSplittedBillboards()) 437 { 438 mLeaves->getBillboardCloud()->generateBillboardCloud(!mSampleCf.getBillboardCloudSplittedBillboards()); 439 if (mSampleCf.getBillboardCloudDiffuseColorTextureAtlasGeneration()) 440 { 441 mBillboardCloudUVMapper->clear(); 442 mBillboardCloudUVMapper->setBillboardCloud(mLeaves->getBillboardCloud()); 443 mBillboardCloudUVMapper->setTextureWidth(mSampleCf.getBillboardCloudDiffuseColorTextureSize()); 444 mBillboardCloudUVMapper->setTextureHeight(mSampleCf.getBillboardCloudDiffuseColorTextureSize()); 445 mBillboardCloudUVMapper->setTextureAtlasWidth(mSampleCf.getBillboardCloudDiffuseColorTextureAtlasSize()); 446 mBillboardCloudUVMapper->setTextureAtlasHeight(mSampleCf.getBillboardCloudDiffuseColorTextureAtlasSize()); 447 mBillboardCloudUVMapper->initialize(); 448 mBillboardCloudUVMapper->generateTextureAtlasTextureCoords(!mSampleCf.getBillboardCloudSplittedBillboards(),false); 367 449 } 368 450 saveBillboardCloudSplitted(); … … 377 459 } 378 460 379 //exportEntities() 380 /* 381 BBC::Entity *entityLeaves = new BBC::Entity(); 382 entityLeaves->setMesh(leavesMesh); 383 entityLeaves->loadMesh(true); 384 entityLeaves->getSubEntity(0)->setMaterialName(mSampleCf.getEntityClustersMaterialPrefixFilename() + ".material"); 385 mOgreMeshSerializer->setEntity(entityLeaves); 386 mOgreMeshSerializer->exportMesh(mSampleCf.getEntityDistributionFolder() + 387 mSampleCf.getEntitySampleMeshPrefixFilename() + "New.mesh", false, false); 388 mXMLMeshSerializer->exportMesh(entityLeaves->getMesh(), mSampleCf.getEntityDistributionFolder() + 389 mSampleCf.getEntitySampleMeshPrefixFilename() + "New.mesh.xml"); 390 */ 391 392 } 461 } -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/src/LBBCSampleConfigFile.cpp
r699 r709 177 177 } 178 178 179 unsigned int SampleConfigFile::getBillboardCloudGroups() 180 { 181 return Ogre::StringConverter::parseInt(getSetting("Billboard Cloud Groups")); 179 182 } 183 184 bool SampleConfigFile::getBillboardCloudGroupedBillboards() 185 { 186 return Ogre::StringConverter::parseBool(getSetting("Billboard Cloud Grouped Billboards")); 187 } 188 189 } -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/src/main.cpp
r699 r709 33 33 34 34 // Invalid option 35 cout<<"Invalid option "<<tmp<<endl;35 std::cout<<"Invalid option "<<tmp<<std::endl; 36 36 37 37 } … … 64 64 void help() 65 65 { 66 cout<<"Please specify the parameter: -cfg sample.cfg"<<endl;66 std::cout<<"Please specify the parameter: -cfg sample.cfg"<<std::endl; 67 67 } 68 68
Note: See TracChangeset
for help on using the changeset viewer.