- Timestamp:
- 03/31/06 17:29:32 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/src/LBBCManager.cpp
r709 r721 7 7 : BBC::Manager() 8 8 { 9 //mCf.load("lbbc.cfg"); 10 11 mBillboardCloudSerializer = new KdTreeClusterSerializer(); 9 mBillboardCloudSerializer = new KMeansClusterSerializer(); 12 10 mLeafDistributionSerializer = new LeafDistributionSerializer(); 13 11 mLeafDistributionGenerator = new LeafDistributionGenerator(); 14 mBillboardCloudGenerator = new K dTreeClusterGenerator();12 mBillboardCloudGenerator = new KMeansClusterGenerator(); 15 13 mBillboardCloudUVMapper = new BBC::BillboardCloudUVMapper(); 16 14 mOgreMeshSerializer = new BBC::OgreMeshSerializer(); … … 19 17 Manager::~Manager() 20 18 { 21 // How to manage the destruction of BBC::Manager? 22 delete mBillboardCloudSerializer; 23 delete mLeafDistributionSerializer; 24 delete mLeafDistributionGenerator; 25 delete mBillboardCloudGenerator; 26 delete mBillboardCloudUVMapper; 27 delete mOgreMeshSerializer; 28 delete mLeaves; 19 if (mOgreMeshSerializer) 20 { 21 delete mOgreMeshSerializer; 22 } 23 if (mSampleConfigFile) 24 { 25 delete mSampleConfigFile; 26 } 27 if (mLeafDistributionSerializer) 28 { 29 delete mLeafDistributionSerializer; 30 } 31 if (mLeafDistributionGenerator) 32 { 33 delete mLeafDistributionGenerator; 34 } 35 if (mBillboardCloudGenerator) 36 { 37 delete mBillboardCloudGenerator; 38 } 39 if (mBillboardCloudUVMapper) 40 { 41 delete mBillboardCloudUVMapper; 42 } 43 if (mBillboardCloudSerializer) 44 { 45 delete mBillboardCloudSerializer; 46 } 47 if (mLeaves) 48 { 49 delete mLeaves; 50 } 51 29 52 } 30 53 31 54 SampleConfigFile* Manager::getSampleConfigFile() 32 55 { 33 return &mSampleCf; 34 } 35 void Manager::runSample(Ogre::String sampleConfigFile) 36 { 37 Ogre::LogManager::getSingleton().logMessage("Sample Config Filename:" + sampleConfigFile); 38 39 mSampleCf.load(sampleConfigFile); 56 return mSampleConfigFile; 57 } 58 59 void Manager::setSampleConfigFile(SampleConfigFile *sampleConfigFile) 60 { 61 mSampleConfigFile = sampleConfigFile; 62 } 63 64 void Manager::loadSampleConfigFile(Ogre::String sampleConfigFile) 65 { 66 mSampleConfigFile = new SampleConfigFile(); 67 mSampleConfigFile->load(sampleConfigFile); 68 } 69 70 void Manager::runSampleConfigFile() 71 { 40 72 mLeaves = new Leaves(); 41 42 Ogre::Mesh* leavesMesh = BBC::Manager::getSingleton().loadMesh(43 mSampleCf.getEntitiesMeshPrefixFilename() + ".mesh");44 73 45 mLeaves->setMesh(leavesMesh); 46 47 if (mSampleCf.getEntityDistributionGeneration()) 74 BBC::EntityPtr entityLeaves(new BBC::Entity); 75 BBC::MeshPtr meshLeaves(new BBC::Mesh(this->loadMesh(mSampleConfigFile->getEntitiesFolder(), mSampleConfigFile->getEntitiesMeshPrefixFilename() + ".mesh")) ); 76 entityLeaves->setMesh(meshLeaves); 77 mLeaves->setEntity(entityLeaves); 78 mLeaves->getEntity()->setMesh(meshLeaves); 79 80 if (mSampleConfigFile->getEntityDistributionGeneration()) 48 81 { 49 82 generateEntityDistribution(); … … 54 87 } 55 88 56 if (mSampleC f.getEntityClustersGeneration())89 if (mSampleConfigFile->getEntityClustersGeneration()) 57 90 { 58 91 generateEntityClusters(); 59 92 } 60 if (mSampleCf.getBillboardCloudGeneration()) 93 94 if (mSampleConfigFile->getBillboardCloudGeneration()) 61 95 { 62 96 generateBillboardCloud(); … … 67 101 { 68 102 mLeafDistributionGenerator->setDistribution(mLeaves->getDistribution()); 69 mLeafDistributionGenerator->getEntity()->setMesh(mLeaves->get Mesh());103 mLeafDistributionGenerator->getEntity()->setMesh(mLeaves->getEntity()->getMesh()); 70 104 mLeafDistributionGenerator->generate(); 71 105 } … … 73 107 void Manager::saveEntityDistributionSplitted() 74 108 { 75 BBC::Entity *entity;76 entity = new BBC::Entity();77 78 if (mSampleC f.getEntityDistributionSplitted() || mSampleCf.getEntityDistributionMerged())109 BBC::EntityPtr entity; 110 entity = BBC::EntityPtr(new BBC::Entity()); 111 112 if (mSampleConfigFile->getEntityDistributionSplitted() || mSampleConfigFile->getEntityDistributionMerged()) 79 113 { 80 114 BBC::EntityDistribution *entityDistribution; 81 115 unsigned int numSerializedEntities = 0; 82 83 116 84 117 entityDistribution = mLeaves->getDistribution(); 85 118 for (unsigned int iEntity = 0; iEntity < entityDistribution->getNumEntities(); iEntity++) 86 119 { 87 BBC::SubEntity *subEntity = entityDistribution->getEntity(iEntity)->getSubEntity(0);120 BBC::SubEntityPtr subEntity = entityDistribution->getEntity(iEntity)->getSubEntity(0); 88 121 89 122 if (iEntity == 0) 90 123 { 91 // Delete the default constructed subentity...124 // delete the default constructed subentity... 92 125 entity->removeSubEntity(0); 93 126 … … 100 133 } 101 134 102 entity->getSubEntity(numSerializedEntities)->setMaterialName(mSampleC f.getEntityDistributionMergedMaterialPrefixName());135 entity->getSubEntity(numSerializedEntities)->setMaterialName(mSampleConfigFile->getEntityDistributionMergedMaterialPrefixName()); 103 136 numSerializedEntities++; 104 137 } … … 106 139 entity->setSubEntitiesDistinctVertexColours(); 107 140 108 if (mSampleC f.getEntityDistributionSplitted())141 if (mSampleConfigFile->getEntityDistributionSplitted()) 109 142 { 110 143 mOgreMeshSerializer->setEntity(entity); 111 mOgreMeshSerializer->exportMesh(mSampleC f.getEntityClustersFolder() +112 mSampleC f.getEntityClustersMeshPrefixFilename() + "Splitted.mesh", false, false);144 mOgreMeshSerializer->exportMesh(mSampleConfigFile->getEntityClustersFolder() + 145 mSampleConfigFile->getEntityClustersMeshPrefixFilename() + "Splitted.mesh", false, false); 113 146 114 mMeshSerializer->exportMesh(entity->getMesh(), mSampleCf.getEntityDistributionFolder() + mSampleCf.getEntitiesMeshPrefixFilename() + "Splitted.mesh");115 // mXMLMeshSerializer->exportMesh(entity->getMesh(), mSampleCf.getEntityClustersFolder() + mSampleCf.getEntitiesMeshPrefixFilename() + "Splitted.mesh" + ".xml");116 } 117 } 118 119 if (mSampleC f.getEntityDistributionMerged())147 OBA::OgreBase::getSingleton().getMeshSerializer()->exportMesh(entity->getMesh()->get(), mSampleConfigFile->getEntityDistributionFolder() + mSampleConfigFile->getEntitiesMeshPrefixFilename() + "Splitted.mesh"); 148 //OBA::OgreBase::getSingleton().getXMLMeshSerializer()->exportMesh(entity->getMesh().get(), mSampleConfigFile->getEntityClustersFolder() + mSampleConfigFile->getEntitiesMeshPrefixFilename() + "Splitted.mesh" + ".xml"); 149 } 150 } 151 152 if (mSampleConfigFile->getEntityDistributionMerged()) 120 153 { 121 154 entity->mergeSubEntities(); 122 entity->getSubEntity(0)->setMaterialName(mSampleC f.getEntityDistributionMergedMaterialPrefixName());155 entity->getSubEntity(0)->setMaterialName(mSampleConfigFile->getEntityDistributionMergedMaterialPrefixName()); 123 156 124 157 mOgreMeshSerializer->setEntity(entity); 125 mOgreMeshSerializer->exportMesh(mSampleC f.getEntityClustersFolder() +126 mSampleC f.getEntityClustersMeshPrefixFilename() + "Merged.mesh", false, false);127 128 mMeshSerializer->exportMesh(entity->getMesh(), mSampleCf.getEntityDistributionFolder() + mSampleCf.getEntitiesMeshPrefixFilename() + "Merged.mesh");129 // mXMLMeshSerializer->exportMesh(entity->getMesh(), mSampleCf.getEntityClustersFolder() + mSampleCf.getEntitiesMeshPrefixFilename() + "Merged.mesh" + ".xml");130 131 delete entity;158 mOgreMeshSerializer->exportMesh(mSampleConfigFile->getEntityClustersFolder() + 159 mSampleConfigFile->getEntityClustersMeshPrefixFilename() + "Merged.mesh", false, false); 160 161 OBA::OgreBase::getSingleton().getMeshSerializer()->exportMesh((Ogre::Mesh*)entity->getMesh().get(), mSampleConfigFile->getEntityDistributionFolder() + mSampleConfigFile->getEntitiesMeshPrefixFilename() + "Merged.mesh"); 162 //OBA::OgreBase::getSingleton().getXMLMeshSerializer()->exportMesh(entity->getMesh(), mSampleConfigFile->getEntityClustersFolder() + mSampleConfigFile->getEntitiesMeshPrefixFilename() + "Merged.mesh" + ".xml"); 163 164 //Ogre::MeshManager::getSingleton().unload(mSampleConfigFile->getEntitiesMeshPrefixFilename() + "Merged.mesh"); 132 165 } 133 166 } … … 136 169 { 137 170 TiXmlDocument *document = mLeafDistributionSerializer->create( 138 mSampleC f.getEntityDistributionFolder() +139 mSampleC f.getEntityDistributionXMLPrefixFilename() + ".xml");171 mSampleConfigFile->getEntityDistributionFolder() + 172 mSampleConfigFile->getEntityDistributionXMLPrefixFilename() + ".xml"); 140 173 mLeafDistributionSerializer->setLeafDistribution(mLeaves->getDistribution()); 141 174 mLeafDistributionSerializer->writeLeafDistribution(document); … … 146 179 { 147 180 TiXmlDocument *document = mLeafDistributionSerializer->load( 148 mSampleC f.getEntityDistributionFolder() +149 mSampleC f.getEntityDistributionXMLPrefixFilename() + ".xml");181 mSampleConfigFile->getEntityDistributionFolder() + 182 mSampleConfigFile->getEntityDistributionXMLPrefixFilename() + ".xml"); 150 183 mLeafDistributionSerializer->setLeafDistribution(mLeaves->getDistribution()); 151 mLeafDistributionSerializer->getEntity()->setMesh(mLeaves->get Mesh());184 mLeafDistributionSerializer->getEntity()->setMesh(mLeaves->getEntity()->getMesh()); 152 185 mLeafDistributionSerializer->readLeafDistribution(document); 153 186 154 BBC::Entity *entity;187 BBC::EntityPtr entity; 155 188 BBC::EntityDistribution *entityDistribution; 156 189 157 Ogre::Mesh* leavesSplittedMesh = BBC::Manager::getSingleton().loadMesh(mSampleCf.getEntitiesMeshPrefixFilename() + "Splitted.mesh");158 entity = new BBC::Entity();159 entity->setMesh( leavesSplittedMesh);190 BBC::MeshPtr pMeshLeavesSplitted(new BBC::Mesh(this->loadMesh(mSampleConfigFile->getEntitiesFolder(), mSampleConfigFile->getEntitiesMeshPrefixFilename() + "Splitted.mesh"))); 191 entity = BBC::EntityPtr(new BBC::Entity()); 192 entity->setMesh(pMeshLeavesSplitted); 160 193 161 194 entity->loadMesh(false); … … 164 197 for (unsigned int iSubEntity = 0; iSubEntity < entity->getNumSubEntities(); iSubEntity++) 165 198 { 166 BBC::Entity *entitySample;167 BBC::SubEntity *subEntity;168 BBC::SubEntity *subEntitySample;199 BBC::EntityPtr entitySample; 200 BBC::SubEntityPtr subEntity; 201 BBC::SubEntityPtr subEntitySample; 169 202 170 203 subEntity = entity->getSubEntity(iSubEntity); … … 180 213 void Manager::generateEntityDistribution() 181 214 { 182 if (mSampleC f.getEntityDistributionGeneration())215 if (mSampleConfigFile->getEntityDistributionGeneration()) 183 216 { 184 217 createEntityDistribution(); … … 192 225 for (unsigned int iSubEntity = 0; iSubEntity < mLeaves->getBillboardCloud()->getEntity()->getNumSubEntities(); iSubEntity++) 193 226 { 194 BBC::SubEntity *subEntity = mLeaves->getBillboardCloud()->getEntity()->getSubEntity(iSubEntity);195 subEntity->setMaterialName(mSampleC f.getBillboardCloudMaterialPrefixFilename());227 BBC::SubEntityPtr subEntity = mLeaves->getBillboardCloud()->getEntity()->getSubEntity(iSubEntity); 228 subEntity->setMaterialName(mSampleConfigFile->getBillboardCloudMaterialPrefixFilename()); 196 229 } 197 230 mOgreMeshSerializer->setEntity(mLeaves->getBillboardCloud()->getEntity()); 198 231 199 232 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"); 233 mOgreMeshSerializer->exportMesh(mSampleConfigFile->getBillboardCloudFolder() + 234 mSampleConfigFile->getBillboardCloudMeshPrefixFilename() + "Grouped.mesh",false, false); 235 OBA::OgreBase::getSingleton().getMeshSerializer()->exportMesh(mLeaves->getBillboardCloud()->getEntity()->getMesh()->get(), mSampleConfigFile->getBillboardCloudFolder() + mSampleConfigFile->getBillboardCloudMeshPrefixFilename() + "Grouped.mesh"); 236 OBA::OgreBase::getSingleton().getXMLMeshSerializer()->exportMesh(mLeaves->getBillboardCloud()->getEntity()->getMesh()->get(), mSampleConfigFile->getBillboardCloudFolder() + mSampleConfigFile->getBillboardCloudMeshPrefixFilename() + "Grouped.mesh.xml"); 237 238 //Ogre::MeshManager::getSingleton().unload(mSampleConfigFile->getBillboardCloudMeshPrefixFilename() + "Grouped.mesh"); 204 239 } 205 240 … … 209 244 for (unsigned int iSubEntity = 0; iSubEntity < mLeaves->getBillboardCloud()->getEntity()->getNumSubEntities(); iSubEntity++) 210 245 { 211 BBC::SubEntity *subEntity = mLeaves->getBillboardCloud()->getEntity()->getSubEntity(iSubEntity);212 subEntity->setMaterialName(mSampleC f.getBillboardCloudMaterialPrefixFilename());246 BBC::SubEntityPtr subEntity = mLeaves->getBillboardCloud()->getEntity()->getSubEntity(iSubEntity); 247 subEntity->setMaterialName(mSampleConfigFile->getBillboardCloudMaterialPrefixFilename()); 213 248 } 214 249 215 250 mOgreMeshSerializer->setEntity(mLeaves->getBillboardCloud()->getEntity()); 216 mOgreMeshSerializer->exportMesh(mSampleCf.getBillboardCloudFolder() + 217 mSampleCf.getBillboardCloudMeshPrefixFilename() + "Splitted.mesh",false, false); 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"); 251 252 Ogre::LogManager::getSingleton().logMessage("Num.SubEntities:" + Ogre::StringConverter::toString(mLeaves->getBillboardCloud()->getEntity()->getNumSubEntities())); 253 254 mOgreMeshSerializer->exportMesh(mSampleConfigFile->getBillboardCloudFolder() + 255 mSampleConfigFile->getBillboardCloudMeshPrefixFilename() + "Splitted.mesh",false, false); 256 257 OBA::OgreBase::getSingleton().getMeshSerializer()->exportMesh(mLeaves->getBillboardCloud()->getEntity()->getMesh()->get(), mSampleConfigFile->getBillboardCloudFolder() + mSampleConfigFile->getBillboardCloudMeshPrefixFilename() + "Splitted.mesh"); 258 259 OBA::OgreBase::getSingleton().getXMLMeshSerializer()->exportMesh(mLeaves->getBillboardCloud()->getEntity()->getMesh()->get(), mSampleConfigFile->getBillboardCloudFolder() + mSampleConfigFile->getBillboardCloudMeshPrefixFilename() + "Splitted.mesh.xml"); 220 260 } 221 261 222 262 void Manager::saveBillboardCloudMerged() 223 263 { 224 //mLeaves->getBillboardCloud()->getEntity()->getSubEntity(0)->setMaterialName(mSampleC f.getBillboardCloudMaterialPrefixFilename());264 //mLeaves->getBillboardCloud()->getEntity()->getSubEntity(0)->setMaterialName(mSampleConfigFile->getBillboardCloudMaterialPrefixFilename()); 225 265 //mOgreMeshSerializer->setEntity(mLeaves->getBillboardCloud()->getEntity()); 226 //mOgreMeshSerializer->exportMesh(mSampleC f.getBillboardCloudFolder() +227 // mSampleC f.getBillboardCloudMeshPrefixFilename() + "Merged.mesh", mSampleCf.getBillboardCloudMergedBillboards(), false);228 // mMeshSerializer->exportMesh(mLeaves->getBillboardCloud()->getEntity()->getMesh(),229 // mSampleC f.getBillboardCloudFolder() + mSampleCf.getBillboardCloudMeshPrefixFilename() + "Merged.mesh");230 // mXMLMeshSerializer->exportMesh(mLeaves->getBillboardCloud()->getEntity()->getMesh(), mSampleCf.getBillboardCloudFolder() + mSampleCf.getBillboardCloudMeshPrefixFilename() + "Merged.mesh.xml");266 //mOgreMeshSerializer->exportMesh(mSampleConfigFile->getBillboardCloudFolder() + 267 // mSampleConfigFile->getBillboardCloudMeshPrefixFilename() + "Merged.mesh", mSampleConfigFile->getBillboardCloudMergedBillboards(), false); 268 //OBA::OgreBase::getSingleton().getMeshSerializer()->exportMesh(mLeaves->getBillboardCloud()->getEntity()->getMesh(), 269 // mSampleConfigFile->getBillboardCloudFolder() + mSampleConfigFile->getBillboardCloudMeshPrefixFilename() + "Merged.mesh"); 270 //OBA::OgreBase::getSingleton().getXMLMeshSerializer()->exportMesh(mLeaves->getBillboardCloud()->getEntity()->getMesh(), mSampleConfigFile->getBillboardCloudFolder() + mSampleConfigFile->getBillboardCloudMeshPrefixFilename() + "Merged.mesh.xml"); 231 271 232 272 233 273 for (unsigned int iSubEntity = 0; iSubEntity < mLeaves->getBillboardCloud()->getEntity()->getNumSubEntities(); iSubEntity++) 234 274 { 235 BBC::SubEntity *subEntity = mLeaves->getBillboardCloud()->getEntity()->getSubEntity(iSubEntity);236 subEntity->setMaterialName(mSampleC f.getBillboardCloudMaterialPrefixFilename());275 BBC::SubEntityPtr subEntity = mLeaves->getBillboardCloud()->getEntity()->getSubEntity(iSubEntity); 276 subEntity->setMaterialName(mSampleConfigFile->getBillboardCloudMaterialPrefixFilename()); 237 277 } 238 278 mOgreMeshSerializer->setEntity(mLeaves->getBillboardCloud()->getEntity()); 239 279 240 280 Ogre::LogManager::getSingleton().logMessage("Num.SubEntities:" + Ogre::StringConverter::toString(mLeaves->getBillboardCloud()->getEntity()->getNumSubEntities())); 241 mOgreMeshSerializer->exportMesh(mSampleCf.getBillboardCloudFolder() + 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"); 281 mOgreMeshSerializer->exportMesh(mSampleConfigFile->getBillboardCloudFolder() + 282 mSampleConfigFile->getBillboardCloudMeshPrefixFilename() + "Merged.mesh",false, false); 283 OBA::OgreBase::getSingleton().getMeshSerializer()->exportMesh(mLeaves->getBillboardCloud()->getEntity()->getMesh()->get(), mSampleConfigFile->getBillboardCloudFolder() + mSampleConfigFile->getBillboardCloudMeshPrefixFilename() + "Merged.mesh"); 284 OBA::OgreBase::getSingleton().getXMLMeshSerializer()->exportMesh(mLeaves->getBillboardCloud()->getEntity()->getMesh()->get(), mSampleConfigFile->getBillboardCloudFolder() + mSampleConfigFile->getBillboardCloudMeshPrefixFilename() + "Merged.mesh.xml"); 285 286 //Ogre::MeshManager::getSingleton().unload(mSampleConfigFile->getBillboardCloudMeshPrefixFilename() + "Merged.mesh"); 245 287 } 246 288 … … 249 291 //saveBillboardCloud() 250 292 TiXmlDocument *document2 = mBillboardCloudSerializer->create( 251 mSampleC f.getBillboardCloudFolder() +252 mSampleC f.getBillboardCloudXMLPrefixFilename() + ".xml");293 mSampleConfigFile->getBillboardCloudFolder() + 294 mSampleConfigFile->getBillboardCloudXMLPrefixFilename() + ".xml"); 253 295 mBillboardCloudSerializer->setBillboardCloud(mLeaves->getBillboardCloud()); 254 296 mBillboardCloudSerializer->writeBillboardCloud(document2); … … 258 300 void Manager::saveEntityClusters() 259 301 { 260 BBC::BillboardClusterData *billboardClusterData;261 BBC::EntityCluster *entityCluster;302 BBC::BillboardClusterDataPtr billboardClusterData; 303 BBC::EntityClusterPtr entityCluster; 262 304 unsigned int numSerializedBillboards = 0; 263 305 264 if (mSampleC f.getEntityClustersSplittedClusters())306 if (mSampleConfigFile->getEntityClustersSplittedClusters()) 265 307 { 266 308 … … 272 314 if (entityCluster->getNumEntitiesClusterData() > 0) 273 315 { 274 BBC::Entity *entityClusterized = entityCluster->getEntity();275 entityClusterized->getSubEntity(0)->setMaterialName(mSampleC f.getEntityClustersMaterialPrefixFilename());316 BBC::EntityPtr entityClusterized = entityCluster->getEntity(); 317 entityClusterized->getSubEntity(0)->setMaterialName(mSampleConfigFile->getEntityClustersMaterialPrefixFilename()); 276 318 mOgreMeshSerializer->setEntity(entityClusterized); 277 mOgreMeshSerializer->exportMesh(mSampleC f.getEntityDistributionFolder() +278 mSampleC f.getEntityClustersMeshPrefixFilename() +279 Ogre::StringConverter::toString(numSerializedBillboards) + ".mesh", !(mSampleC f.getEntityClustersSplittedClusters()), false);280 mMeshSerializer->exportMesh(entityClusterized->getMesh(),281 mSampleC f.getEntityClustersFolder() +282 mSampleC f.getEntityClustersMeshPrefixFilename() +319 mOgreMeshSerializer->exportMesh(mSampleConfigFile->getEntityDistributionFolder() + 320 mSampleConfigFile->getEntityClustersMeshPrefixFilename() + 321 Ogre::StringConverter::toString(numSerializedBillboards) + ".mesh", !(mSampleConfigFile->getEntityClustersSplittedClusters()), false); 322 OBA::OgreBase::getSingleton().getMeshSerializer()->exportMesh(entityClusterized->getMesh()->get(), 323 mSampleConfigFile->getEntityClustersFolder() + 324 mSampleConfigFile->getEntityClustersMeshPrefixFilename() + 283 325 Ogre::StringConverter::toString(numSerializedBillboards) + ".mesh"); 284 //mXMLMeshSerializer->exportMesh(entityClusterized->getMesh(), entityClusterized->getMesh()->getName() + ".xml"); 326 //OBA::OgreBase::getSingleton().getXMLMeshSerializer()->exportMesh(entityClusterized->getMesh(), entityClusterized->getMesh()->getName() + ".xml"); 327 328 //Ogre::MeshManager::getSingleton().unload(mSampleConfigFile->getEntityClustersMeshPrefixFilename() + Ogre::StringConverter::toString(numSerializedBillboards) + ".mesh"); 285 329 286 330 numSerializedBillboards++; … … 290 334 numSerializedBillboards = 0; 291 335 292 if (mSampleCf.getEntityClustersMergedClusters())293 { 294 BBC::Entity *entity;295 entity = new BBC::Entity();336 if (mSampleConfigFile->getEntityClustersMergedClusters()) 337 { 338 BBC::EntityPtr entity; 339 entity = BBC::EntityPtr(new BBC::Entity()); 296 340 297 341 for (unsigned int iBillboard = 0; iBillboard < mLeaves->getBillboardCloud()->getNumBillboards(); iBillboard++) … … 302 346 if (entityCluster->getNumEntitiesClusterData() > 0) 303 347 { 304 BBC::Entity *entityClusterized = entityCluster->getEntity();305 entityClusterized->getSubEntity(0)->setMaterialName(mSampleC f.getEntityClustersMaterialPrefixFilename());306 BBC::SubEntity *subEntity = entityClusterized->getSubEntity(0);348 BBC::EntityPtr entityClusterized = entityCluster->getEntity(); 349 entityClusterized->getSubEntity(0)->setMaterialName(mSampleConfigFile->getEntityClustersMaterialPrefixFilename()); 350 BBC::SubEntityPtr subEntity = entityClusterized->getSubEntity(0); 307 351 308 352 if (numSerializedBillboards == 0) 309 353 { 310 // Delete the default constructed subentity...354 // delete the default constructed subentity... 311 355 entity->removeSubEntity(0); 312 356 … … 326 370 327 371 mOgreMeshSerializer->setEntity(entity); 328 mOgreMeshSerializer->exportMesh(mSampleCf.getEntityClustersFolder() + 329 mSampleCf.getEntityClustersMeshPrefixFilename() + "Merged.mesh", false, false); 330 331 mMeshSerializer->exportMesh(entity->getMesh(), mSampleCf.getEntityClustersFolder() + mSampleCf.getEntityClustersMeshPrefixFilename() + "Merged.mesh"); 332 //mXMLMeshSerializer->exportMesh(entity->getMesh(), mSampleCf.getEntityClustersFolder() + mSampleCf.getEntityClustersMeshPrefixFilename() + "Merged.mesh" + ".xml"); 333 334 delete entity; 335 } 336 337 338 372 mOgreMeshSerializer->exportMesh(mSampleConfigFile->getEntityClustersFolder() + 373 mSampleConfigFile->getEntityClustersMeshPrefixFilename() + "Merged.mesh", false, false); 374 375 OBA::OgreBase::getSingleton().getMeshSerializer()->exportMesh(entity->getMesh()->get(), mSampleConfigFile->getEntityClustersFolder() + mSampleConfigFile->getEntityClustersMeshPrefixFilename() + "Merged.mesh"); 376 //OBA::OgreBase::getSingleton().getXMLMeshSerializer()->exportMesh(entity->getMesh(), mSampleConfigFile->getEntityClustersFolder() + mSampleConfigFile->getEntityClustersMeshPrefixFilename() + "Merged.mesh" + ".xml"); 377 378 //Ogre::MeshManager::getSingleton().unload(mSampleConfigFile->getEntityClustersMeshPrefixFilename() + "Merged.mesh"); 379 380 Ogre::LogManager::getSingleton().logMessage("Before deleting:" + mSampleConfigFile->getEntityClustersMeshPrefixFilename() + "Merged.mesh"); 381 } 339 382 } 340 383 … … 343 386 mBillboardCloudGenerator->setDistribution(mLeaves->getDistribution()); 344 387 mBillboardCloudGenerator->setBillboardCloud(mLeaves->getBillboardCloud()); 345 mBillboardCloudGenerator->setMaxNumBillboards(mSampleC f.getEntityClustersMaxClusters());346 ((K dTreeClusterGenerator*)mBillboardCloudGenerator)->setAlpha(mSampleCf.getEntityClustersAlpha());347 ((K dTreeClusterGenerator*)mBillboardCloudGenerator)->setNumIterations(mSampleCf.getEntityClustersNumIterations());348 ((K dTreeClusterGenerator*)mBillboardCloudGenerator)->generate();388 mBillboardCloudGenerator->setMaxNumBillboards(mSampleConfigFile->getEntityClustersMaxClusters()); 389 ((KMeansClusterGenerator*)mBillboardCloudGenerator)->setAlpha(mSampleConfigFile->getEntityClustersAlpha()); 390 ((KMeansClusterGenerator*)mBillboardCloudGenerator)->setNumIterations(mSampleConfigFile->getEntityClustersNumIterations()); 391 ((KMeansClusterGenerator*)mBillboardCloudGenerator)->generate(); 349 392 } 350 393 351 394 void Manager::saveSingleEntity() 352 395 { 353 if (mSampleC f.getEntitySampleMeshGeneration())354 { 355 BBC::Entity *entityLeaf = mLeaves->getDistribution()->getEntity(2);356 entityLeaf->getSubEntity(0)->setMaterialName(mSampleC f.getEntityClustersMaterialPrefixFilename());396 if (mSampleConfigFile->getEntitySampleMeshGeneration()) 397 { 398 BBC::EntityPtr entityLeaf = mLeaves->getDistribution()->getEntity(2); 399 entityLeaf->getSubEntity(0)->setMaterialName(mSampleConfigFile->getEntityClustersMaterialPrefixFilename()); 357 400 mOgreMeshSerializer->setEntity(entityLeaf); 358 mOgreMeshSerializer->exportMesh(mSampleCf.getEntityDistributionFolder() + 359 mSampleCf.getEntitySampleMeshPrefixFilename(), mSampleCf.getEntityClustersMergedClusters(), false); 360 //mXMLMeshSerializer->exportMesh(entityLeaf->getMesh(), entityLeaf->getMesh()->getName() + ".xml"); 401 mOgreMeshSerializer->exportMesh(mSampleConfigFile->getEntityDistributionFolder() + 402 mSampleConfigFile->getEntitySampleMeshPrefixFilename(), mSampleConfigFile->getEntityClustersMergedClusters(), false); 403 //OBA::OgreBase::getSingleton().getXMLMeshSerializer()->exportMesh(entityLeaf->getMesh(), entityLeaf->getMesh()->getName() + ".xml"); 404 361 405 } 362 406 } … … 364 408 void Manager::generateEntityClusters() 365 409 { 366 Ogre::LogManager::getSingleton().logMessage("EntityClustersMeshPrefixName:" + mSampleC f.getEntityClustersMeshPrefixFilename());410 Ogre::LogManager::getSingleton().logMessage("EntityClustersMeshPrefixName:" + mSampleConfigFile->getEntityClustersMeshPrefixFilename()); 367 411 createEntityClusters(); 368 412 saveEntityClusters(); … … 372 416 void Manager::generateBillboardCloud() 373 417 { 374 if (mSampleCf.getBillboardCloudMergedBillboards()) 375 { 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 418 if (mSampleConfigFile->getBillboardCloudMergedBillboards()) 419 { 394 420 mLeaves->getBillboardCloud()->generateBillboardCloud(false); 421 395 422 mLeaves->getBillboardCloud()->initializeBillboardCloudGroups(1); 396 397 if (mSampleC f.getBillboardCloudDiffuseColorTextureAtlasGeneration())398 { 399 mBillboardCloudUVMapper-> clear();423 424 if (mSampleConfigFile->getBillboardCloudDiffuseColorTextureAtlasGeneration()) 425 { 426 mBillboardCloudUVMapper->shutdown(); 400 427 mBillboardCloudUVMapper->setBillboardCloud(mLeaves->getBillboardCloud()); 401 mBillboardCloudUVMapper->setTextureWidth(mSampleC f.getBillboardCloudDiffuseColorTextureSize());402 mBillboardCloudUVMapper->setTextureHeight(mSampleC f.getBillboardCloudDiffuseColorTextureSize());403 mBillboardCloudUVMapper->setTextureAtlasWidth(mSampleC f.getBillboardCloudDiffuseColorTextureAtlasSize());404 mBillboardCloudUVMapper->setTextureAtlasHeight(mSampleC f.getBillboardCloudDiffuseColorTextureAtlasSize());428 mBillboardCloudUVMapper->setTextureWidth(mSampleConfigFile->getBillboardCloudDiffuseColorTextureSize()); 429 mBillboardCloudUVMapper->setTextureHeight(mSampleConfigFile->getBillboardCloudDiffuseColorTextureSize()); 430 mBillboardCloudUVMapper->setTextureAtlasWidth(mSampleConfigFile->getBillboardCloudDiffuseColorTextureAtlasSize()); 431 mBillboardCloudUVMapper->setTextureAtlasHeight(mSampleConfigFile->getBillboardCloudDiffuseColorTextureAtlasSize()); 405 432 mBillboardCloudUVMapper->initialize(); 406 mBillboardCloudUVMapper->generateTextureAtlasTextureCoords(false, mSampleCf.getBillboardCloudGroupedBillboards(), 1); 433 434 mBillboardCloudUVMapper->generateTextureAtlasTextureCoords(false, mSampleConfigFile->getBillboardCloudGroupedBillboards(), 1); 407 435 } 408 436 … … 410 438 411 439 saveBillboardCloudMerged(); 412 } 413 414 if (mSampleCf.getBillboardCloudGroupedBillboards()) 440 441 } 442 443 if (mSampleConfigFile->getBillboardCloudGroupedBillboards()) 415 444 { 416 445 mLeaves->getBillboardCloud()->generateBillboardCloud(false); 417 mLeaves->getBillboardCloud()->initializeBillboardCloudGroups(mSampleC f.getBillboardCloudGroups());418 419 if (mSampleC f.getBillboardCloudDiffuseColorTextureAtlasGeneration())420 { 421 mBillboardCloudUVMapper-> clear();446 mLeaves->getBillboardCloud()->initializeBillboardCloudGroups(mSampleConfigFile->getBillboardCloudGroups()); 447 448 if (mSampleConfigFile->getBillboardCloudDiffuseColorTextureAtlasGeneration()) 449 { 450 mBillboardCloudUVMapper->shutdown(); 422 451 mBillboardCloudUVMapper->setBillboardCloud(mLeaves->getBillboardCloud()); 423 mBillboardCloudUVMapper->setTextureWidth(mSampleC f.getBillboardCloudDiffuseColorTextureSize());424 mBillboardCloudUVMapper->setTextureHeight(mSampleC f.getBillboardCloudDiffuseColorTextureSize());425 mBillboardCloudUVMapper->setTextureAtlasWidth(mSampleC f.getBillboardCloudDiffuseColorTextureAtlasSize());426 mBillboardCloudUVMapper->setTextureAtlasHeight(mSampleC f.getBillboardCloudDiffuseColorTextureAtlasSize());452 mBillboardCloudUVMapper->setTextureWidth(mSampleConfigFile->getBillboardCloudDiffuseColorTextureSize()); 453 mBillboardCloudUVMapper->setTextureHeight(mSampleConfigFile->getBillboardCloudDiffuseColorTextureSize()); 454 mBillboardCloudUVMapper->setTextureAtlasWidth(mSampleConfigFile->getBillboardCloudDiffuseColorTextureAtlasSize()); 455 mBillboardCloudUVMapper->setTextureAtlasHeight(mSampleConfigFile->getBillboardCloudDiffuseColorTextureAtlasSize()); 427 456 mBillboardCloudUVMapper->initialize(); 428 mBillboardCloudUVMapper->generateTextureAtlasTextureCoords(false, mSampleC f.getBillboardCloudGroupedBillboards(), mSampleCf.getBillboardCloudGroups());457 mBillboardCloudUVMapper->generateTextureAtlasTextureCoords(false, mSampleConfigFile->getBillboardCloudGroupedBillboards(), mSampleConfigFile->getBillboardCloudGroups()); 429 458 } 430 459 … … 434 463 } 435 464 436 if (mSampleC f.getBillboardCloudSplittedBillboards())465 if (mSampleConfigFile->getBillboardCloudSplittedBillboards()) 437 466 { 438 mLeaves->getBillboardCloud()->generateBillboardCloud( !mSampleCf.getBillboardCloudSplittedBillboards());439 if (mSampleC f.getBillboardCloudDiffuseColorTextureAtlasGeneration())440 { 441 mBillboardCloudUVMapper-> clear();467 mLeaves->getBillboardCloud()->generateBillboardCloud(false); 468 if (mSampleConfigFile->getBillboardCloudDiffuseColorTextureAtlasGeneration()) 469 { 470 mBillboardCloudUVMapper->shutdown(); 442 471 mBillboardCloudUVMapper->setBillboardCloud(mLeaves->getBillboardCloud()); 443 mBillboardCloudUVMapper->setTextureWidth(mSampleC f.getBillboardCloudDiffuseColorTextureSize());444 mBillboardCloudUVMapper->setTextureHeight(mSampleC f.getBillboardCloudDiffuseColorTextureSize());445 mBillboardCloudUVMapper->setTextureAtlasWidth(mSampleC f.getBillboardCloudDiffuseColorTextureAtlasSize());446 mBillboardCloudUVMapper->setTextureAtlasHeight(mSampleC f.getBillboardCloudDiffuseColorTextureAtlasSize());472 mBillboardCloudUVMapper->setTextureWidth(mSampleConfigFile->getBillboardCloudDiffuseColorTextureSize()); 473 mBillboardCloudUVMapper->setTextureHeight(mSampleConfigFile->getBillboardCloudDiffuseColorTextureSize()); 474 mBillboardCloudUVMapper->setTextureAtlasWidth(mSampleConfigFile->getBillboardCloudDiffuseColorTextureAtlasSize()); 475 mBillboardCloudUVMapper->setTextureAtlasHeight(mSampleConfigFile->getBillboardCloudDiffuseColorTextureAtlasSize()); 447 476 mBillboardCloudUVMapper->initialize(); 448 mBillboardCloudUVMapper->generateTextureAtlasTextureCoords(!mSampleC f.getBillboardCloudSplittedBillboards(),false);477 mBillboardCloudUVMapper->generateTextureAtlasTextureCoords(!mSampleConfigFile->getBillboardCloudSplittedBillboards(),false); 449 478 } 450 479 saveBillboardCloudSplitted();
Note: See TracChangeset
for help on using the changeset viewer.