Ignore:
Timestamp:
03/31/06 17:29:32 (19 years ago)
Author:
igarcia
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/src/LBBCManager.cpp

    r709 r721  
    77        : BBC::Manager()  
    88{ 
    9         //mCf.load("lbbc.cfg");  
    10          
    11         mBillboardCloudSerializer = new KdTreeClusterSerializer(); 
     9        mBillboardCloudSerializer = new KMeansClusterSerializer(); 
    1210        mLeafDistributionSerializer = new LeafDistributionSerializer(); 
    1311        mLeafDistributionGenerator = new LeafDistributionGenerator(); 
    14         mBillboardCloudGenerator = new KdTreeClusterGenerator(); 
     12        mBillboardCloudGenerator = new KMeansClusterGenerator(); 
    1513        mBillboardCloudUVMapper = new BBC::BillboardCloudUVMapper(); 
    1614        mOgreMeshSerializer = new BBC::OgreMeshSerializer(); 
     
    1917Manager::~Manager()  
    2018{ 
    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 
    2952} 
    3053 
    3154SampleConfigFile* Manager::getSampleConfigFile() 
    3255{ 
    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 
     59void Manager::setSampleConfigFile(SampleConfigFile *sampleConfigFile) 
     60{ 
     61        mSampleConfigFile = sampleConfigFile; 
     62} 
     63 
     64void Manager::loadSampleConfigFile(Ogre::String sampleConfigFile) 
     65{ 
     66        mSampleConfigFile = new SampleConfigFile(); 
     67        mSampleConfigFile->load(sampleConfigFile); 
     68} 
     69 
     70void Manager::runSampleConfigFile() 
     71{ 
    4072        mLeaves = new Leaves(); 
    41  
    42         Ogre::Mesh* leavesMesh = BBC::Manager::getSingleton().loadMesh( 
    43                                                                 mSampleCf.getEntitiesMeshPrefixFilename() + ".mesh");    
    4473         
    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()) 
    4881        { 
    4982                generateEntityDistribution(); 
     
    5487        } 
    5588         
    56         if (mSampleCf.getEntityClustersGeneration()) 
     89        if (mSampleConfigFile->getEntityClustersGeneration()) 
    5790        { 
    5891                generateEntityClusters(); 
    5992        } 
    60         if (mSampleCf.getBillboardCloudGeneration()) 
     93 
     94        if (mSampleConfigFile->getBillboardCloudGeneration()) 
    6195        { 
    6296                generateBillboardCloud(); 
     
    67101{ 
    68102        mLeafDistributionGenerator->setDistribution(mLeaves->getDistribution()); 
    69         mLeafDistributionGenerator->getEntity()->setMesh(mLeaves->getMesh());    
     103        mLeafDistributionGenerator->getEntity()->setMesh(mLeaves->getEntity()->getMesh());       
    70104        mLeafDistributionGenerator->generate(); 
    71105} 
     
    73107void Manager::saveEntityDistributionSplitted() 
    74108{ 
    75         BBC::Entity *entity; 
    76         entity = new BBC::Entity(); 
    77  
    78         if (mSampleCf.getEntityDistributionSplitted() || mSampleCf.getEntityDistributionMerged()) 
     109        BBC::EntityPtr entity; 
     110        entity = BBC::EntityPtr(new BBC::Entity()); 
     111 
     112        if (mSampleConfigFile->getEntityDistributionSplitted() || mSampleConfigFile->getEntityDistributionMerged()) 
    79113        { 
    80114                BBC::EntityDistribution *entityDistribution;             
    81115                unsigned int numSerializedEntities = 0; 
    82  
    83116                 
    84117                entityDistribution = mLeaves->getDistribution(); 
    85118                for (unsigned int iEntity = 0; iEntity < entityDistribution->getNumEntities(); iEntity++) 
    86119                {                                
    87                                 BBC::SubEntity *subEntity = entityDistribution->getEntity(iEntity)->getSubEntity(0); 
     120                                BBC::SubEntityPtr subEntity = entityDistribution->getEntity(iEntity)->getSubEntity(0); 
    88121 
    89122                                if (iEntity == 0) 
    90123                                { 
    91                                         // Delete the default constructed subentity... 
     124                                        // delete the default constructed subentity... 
    92125                                        entity->removeSubEntity(0); 
    93126 
     
    100133                                } 
    101134 
    102                                 entity->getSubEntity(numSerializedEntities)->setMaterialName(mSampleCf.getEntityDistributionMergedMaterialPrefixName()); 
     135                                entity->getSubEntity(numSerializedEntities)->setMaterialName(mSampleConfigFile->getEntityDistributionMergedMaterialPrefixName()); 
    103136                                numSerializedEntities++;                         
    104137                }                
     
    106139                entity->setSubEntitiesDistinctVertexColours(); 
    107140                 
    108                 if (mSampleCf.getEntityDistributionSplitted()) 
     141                if (mSampleConfigFile->getEntityDistributionSplitted()) 
    109142                { 
    110143                        mOgreMeshSerializer->setEntity(entity); 
    111                         mOgreMeshSerializer->exportMesh(mSampleCf.getEntityClustersFolder() + 
    112                                 mSampleCf.getEntityClustersMeshPrefixFilename() + "Splitted.mesh", false, false); 
     144                        mOgreMeshSerializer->exportMesh(mSampleConfigFile->getEntityClustersFolder() + 
     145                                mSampleConfigFile->getEntityClustersMeshPrefixFilename() + "Splitted.mesh", false, false); 
    113146                         
    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 (mSampleCf.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()) 
    120153        { 
    121154                entity->mergeSubEntities(); 
    122                 entity->getSubEntity(0)->setMaterialName(mSampleCf.getEntityDistributionMergedMaterialPrefixName()); 
     155                entity->getSubEntity(0)->setMaterialName(mSampleConfigFile->getEntityDistributionMergedMaterialPrefixName()); 
    123156         
    124157                mOgreMeshSerializer->setEntity(entity); 
    125                 mOgreMeshSerializer->exportMesh(mSampleCf.getEntityClustersFolder() + 
    126                         mSampleCf.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"); 
    132165        } 
    133166} 
     
    136169{ 
    137170        TiXmlDocument *document = mLeafDistributionSerializer->create( 
    138                                                                         mSampleCf.getEntityDistributionFolder() + 
    139                                                                         mSampleCf.getEntityDistributionXMLPrefixFilename() + ".xml"); 
     171                                                                        mSampleConfigFile->getEntityDistributionFolder() + 
     172                                                                        mSampleConfigFile->getEntityDistributionXMLPrefixFilename() + ".xml"); 
    140173        mLeafDistributionSerializer->setLeafDistribution(mLeaves->getDistribution()); 
    141174        mLeafDistributionSerializer->writeLeafDistribution(document);    
     
    146179{ 
    147180        TiXmlDocument *document = mLeafDistributionSerializer->load( 
    148                                                                         mSampleCf.getEntityDistributionFolder() + 
    149                                                                         mSampleCf.getEntityDistributionXMLPrefixFilename() + ".xml"); 
     181                                                                        mSampleConfigFile->getEntityDistributionFolder() + 
     182                                                                        mSampleConfigFile->getEntityDistributionXMLPrefixFilename() + ".xml"); 
    150183        mLeafDistributionSerializer->setLeafDistribution(mLeaves->getDistribution()); 
    151         mLeafDistributionSerializer->getEntity()->setMesh(mLeaves->getMesh()); 
     184        mLeafDistributionSerializer->getEntity()->setMesh(mLeaves->getEntity()->getMesh()); 
    152185        mLeafDistributionSerializer->readLeafDistribution(document); 
    153186 
    154         BBC::Entity *entity; 
     187        BBC::EntityPtr entity; 
    155188        BBC::EntityDistribution *entityDistribution; 
    156189 
    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); 
    160193 
    161194        entity->loadMesh(false); 
     
    164197        for (unsigned int iSubEntity = 0; iSubEntity < entity->getNumSubEntities(); iSubEntity++) 
    165198        {        
    166                 BBC::Entity *entitySample; 
    167                 BBC::SubEntity *subEntity; 
    168                 BBC::SubEntity *subEntitySample; 
     199                BBC::EntityPtr entitySample; 
     200                BBC::SubEntityPtr subEntity; 
     201                BBC::SubEntityPtr subEntitySample; 
    169202                         
    170203                subEntity = entity->getSubEntity(iSubEntity); 
     
    180213void Manager::generateEntityDistribution() 
    181214{ 
    182         if (mSampleCf.getEntityDistributionGeneration()) 
     215        if (mSampleConfigFile->getEntityDistributionGeneration()) 
    183216        { 
    184217                createEntityDistribution(); 
     
    192225        for (unsigned int iSubEntity = 0; iSubEntity < mLeaves->getBillboardCloud()->getEntity()->getNumSubEntities(); iSubEntity++) 
    193226        { 
    194                 BBC::SubEntity *subEntity = mLeaves->getBillboardCloud()->getEntity()->getSubEntity(iSubEntity); 
    195                 subEntity->setMaterialName(mSampleCf.getBillboardCloudMaterialPrefixFilename()); 
     227                BBC::SubEntityPtr subEntity = mLeaves->getBillboardCloud()->getEntity()->getSubEntity(iSubEntity); 
     228                subEntity->setMaterialName(mSampleConfigFile->getBillboardCloudMaterialPrefixFilename()); 
    196229        } 
    197230        mOgreMeshSerializer->setEntity(mLeaves->getBillboardCloud()->getEntity()); 
    198231    
    199232        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"); 
    204239} 
    205240 
     
    209244        for (unsigned int iSubEntity = 0; iSubEntity < mLeaves->getBillboardCloud()->getEntity()->getNumSubEntities(); iSubEntity++) 
    210245        { 
    211                 BBC::SubEntity *subEntity = mLeaves->getBillboardCloud()->getEntity()->getSubEntity(iSubEntity); 
    212                 subEntity->setMaterialName(mSampleCf.getBillboardCloudMaterialPrefixFilename()); 
     246                BBC::SubEntityPtr subEntity = mLeaves->getBillboardCloud()->getEntity()->getSubEntity(iSubEntity); 
     247                subEntity->setMaterialName(mSampleConfigFile->getBillboardCloudMaterialPrefixFilename()); 
    213248        } 
    214249 
    215250        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"); 
    220260} 
    221261 
    222262void Manager::saveBillboardCloudMerged() 
    223263{        
    224         //mLeaves->getBillboardCloud()->getEntity()->getSubEntity(0)->setMaterialName(mSampleCf.getBillboardCloudMaterialPrefixFilename()); 
     264        //mLeaves->getBillboardCloud()->getEntity()->getSubEntity(0)->setMaterialName(mSampleConfigFile->getBillboardCloudMaterialPrefixFilename()); 
    225265        //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"); 
     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"); 
    231271         
    232272 
    233273        for (unsigned int iSubEntity = 0; iSubEntity < mLeaves->getBillboardCloud()->getEntity()->getNumSubEntities(); iSubEntity++) 
    234274        { 
    235                 BBC::SubEntity *subEntity = mLeaves->getBillboardCloud()->getEntity()->getSubEntity(iSubEntity); 
    236                 subEntity->setMaterialName(mSampleCf.getBillboardCloudMaterialPrefixFilename()); 
     275                BBC::SubEntityPtr subEntity = mLeaves->getBillboardCloud()->getEntity()->getSubEntity(iSubEntity); 
     276                subEntity->setMaterialName(mSampleConfigFile->getBillboardCloudMaterialPrefixFilename()); 
    237277        } 
    238278        mOgreMeshSerializer->setEntity(mLeaves->getBillboardCloud()->getEntity()); 
    239279    
    240280        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"); 
    245287} 
    246288 
     
    249291        //saveBillboardCloud() 
    250292        TiXmlDocument *document2 = mBillboardCloudSerializer->create( 
    251                                                                         mSampleCf.getBillboardCloudFolder() +  
    252                                                                         mSampleCf.getBillboardCloudXMLPrefixFilename() + ".xml"); 
     293                                                                        mSampleConfigFile->getBillboardCloudFolder() +  
     294                                                                        mSampleConfigFile->getBillboardCloudXMLPrefixFilename() + ".xml"); 
    253295        mBillboardCloudSerializer->setBillboardCloud(mLeaves->getBillboardCloud()); 
    254296        mBillboardCloudSerializer->writeBillboardCloud(document2);       
     
    258300void Manager::saveEntityClusters() 
    259301{ 
    260         BBC::BillboardClusterData *billboardClusterData; 
    261         BBC::EntityCluster *entityCluster; 
     302        BBC::BillboardClusterDataPtr billboardClusterData; 
     303        BBC::EntityClusterPtr entityCluster; 
    262304        unsigned int numSerializedBillboards = 0;        
    263305 
    264         if (mSampleCf.getEntityClustersSplittedClusters()) 
     306        if (mSampleConfigFile->getEntityClustersSplittedClusters()) 
    265307        { 
    266308 
     
    272314                        if (entityCluster->getNumEntitiesClusterData() > 0) 
    273315                        {                                        
    274                                 BBC::Entity *entityClusterized = entityCluster->getEntity(); 
    275                                 entityClusterized->getSubEntity(0)->setMaterialName(mSampleCf.getEntityClustersMaterialPrefixFilename()); 
     316                                BBC::EntityPtr entityClusterized = entityCluster->getEntity(); 
     317                                entityClusterized->getSubEntity(0)->setMaterialName(mSampleConfigFile->getEntityClustersMaterialPrefixFilename()); 
    276318                                mOgreMeshSerializer->setEntity(entityClusterized); 
    277                                 mOgreMeshSerializer->exportMesh(mSampleCf.getEntityDistributionFolder() + 
    278                                         mSampleCf.getEntityClustersMeshPrefixFilename() + 
    279                                         Ogre::StringConverter::toString(numSerializedBillboards) + ".mesh", !(mSampleCf.getEntityClustersSplittedClusters()), false); 
    280                                 mMeshSerializer->exportMesh(entityClusterized->getMesh(), 
    281                                         mSampleCf.getEntityClustersFolder() + 
    282                                         mSampleCf.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() + 
    283325                                        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"); 
    285329 
    286330                                numSerializedBillboards++; 
     
    290334        numSerializedBillboards = 0; 
    291335 
    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()); 
    296340 
    297341                for (unsigned int iBillboard = 0; iBillboard < mLeaves->getBillboardCloud()->getNumBillboards(); iBillboard++) 
     
    302346                        if (entityCluster->getNumEntitiesClusterData() > 0) 
    303347                        {                        
    304                                 BBC::Entity *entityClusterized = entityCluster->getEntity(); 
    305                                 entityClusterized->getSubEntity(0)->setMaterialName(mSampleCf.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); 
    307351 
    308352                                if (numSerializedBillboards == 0) 
    309353                                { 
    310                                         // Delete the default constructed subentity... 
     354                                        // delete the default constructed subentity... 
    311355                                        entity->removeSubEntity(0); 
    312356 
     
    326370 
    327371                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        } 
    339382} 
    340383 
     
    343386        mBillboardCloudGenerator->setDistribution(mLeaves->getDistribution()); 
    344387        mBillboardCloudGenerator->setBillboardCloud(mLeaves->getBillboardCloud()); 
    345         mBillboardCloudGenerator->setMaxNumBillboards(mSampleCf.getEntityClustersMaxClusters()); 
    346         ((KdTreeClusterGenerator*)mBillboardCloudGenerator)->setAlpha(mSampleCf.getEntityClustersAlpha()); 
    347         ((KdTreeClusterGenerator*)mBillboardCloudGenerator)->setNumIterations(mSampleCf.getEntityClustersNumIterations()); 
    348         ((KdTreeClusterGenerator*)mBillboardCloudGenerator)->generate(); 
     388        mBillboardCloudGenerator->setMaxNumBillboards(mSampleConfigFile->getEntityClustersMaxClusters()); 
     389        ((KMeansClusterGenerator*)mBillboardCloudGenerator)->setAlpha(mSampleConfigFile->getEntityClustersAlpha()); 
     390        ((KMeansClusterGenerator*)mBillboardCloudGenerator)->setNumIterations(mSampleConfigFile->getEntityClustersNumIterations()); 
     391        ((KMeansClusterGenerator*)mBillboardCloudGenerator)->generate(); 
    349392} 
    350393 
    351394void Manager::saveSingleEntity() 
    352395{ 
    353         if (mSampleCf.getEntitySampleMeshGeneration()) 
    354         { 
    355                 BBC::Entity *entityLeaf = mLeaves->getDistribution()->getEntity(2); 
    356                 entityLeaf->getSubEntity(0)->setMaterialName(mSampleCf.getEntityClustersMaterialPrefixFilename()); 
     396        if (mSampleConfigFile->getEntitySampleMeshGeneration()) 
     397        { 
     398                BBC::EntityPtr entityLeaf = mLeaves->getDistribution()->getEntity(2); 
     399                entityLeaf->getSubEntity(0)->setMaterialName(mSampleConfigFile->getEntityClustersMaterialPrefixFilename()); 
    357400                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 
    361405        } 
    362406} 
     
    364408void Manager::generateEntityClusters() 
    365409{ 
    366         Ogre::LogManager::getSingleton().logMessage("EntityClustersMeshPrefixName:" + mSampleCf.getEntityClustersMeshPrefixFilename()); 
     410        Ogre::LogManager::getSingleton().logMessage("EntityClustersMeshPrefixName:" + mSampleConfigFile->getEntityClustersMeshPrefixFilename()); 
    367411        createEntityClusters(); 
    368412        saveEntityClusters(); 
     
    372416void Manager::generateBillboardCloud() 
    373417{ 
    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        { 
    394420                mLeaves->getBillboardCloud()->generateBillboardCloud(false); 
     421 
    395422                mLeaves->getBillboardCloud()->initializeBillboardCloudGroups(1); 
    396                  
    397                 if (mSampleCf.getBillboardCloudDiffuseColorTextureAtlasGeneration()) 
    398                 { 
    399                         mBillboardCloudUVMapper->clear(); 
     423 
     424                if (mSampleConfigFile->getBillboardCloudDiffuseColorTextureAtlasGeneration()) 
     425                { 
     426                        mBillboardCloudUVMapper->shutdown(); 
    400427                        mBillboardCloudUVMapper->setBillboardCloud(mLeaves->getBillboardCloud()); 
    401                         mBillboardCloudUVMapper->setTextureWidth(mSampleCf.getBillboardCloudDiffuseColorTextureSize()); 
    402                         mBillboardCloudUVMapper->setTextureHeight(mSampleCf.getBillboardCloudDiffuseColorTextureSize()); 
    403                         mBillboardCloudUVMapper->setTextureAtlasWidth(mSampleCf.getBillboardCloudDiffuseColorTextureAtlasSize()); 
    404                         mBillboardCloudUVMapper->setTextureAtlasHeight(mSampleCf.getBillboardCloudDiffuseColorTextureAtlasSize()); 
     428                        mBillboardCloudUVMapper->setTextureWidth(mSampleConfigFile->getBillboardCloudDiffuseColorTextureSize()); 
     429                        mBillboardCloudUVMapper->setTextureHeight(mSampleConfigFile->getBillboardCloudDiffuseColorTextureSize()); 
     430                        mBillboardCloudUVMapper->setTextureAtlasWidth(mSampleConfigFile->getBillboardCloudDiffuseColorTextureAtlasSize()); 
     431                        mBillboardCloudUVMapper->setTextureAtlasHeight(mSampleConfigFile->getBillboardCloudDiffuseColorTextureAtlasSize()); 
    405432                        mBillboardCloudUVMapper->initialize(); 
    406                         mBillboardCloudUVMapper->generateTextureAtlasTextureCoords(false, mSampleCf.getBillboardCloudGroupedBillboards(), 1);  
     433 
     434                        mBillboardCloudUVMapper->generateTextureAtlasTextureCoords(false, mSampleConfigFile->getBillboardCloudGroupedBillboards(), 1);  
    407435                } 
    408436 
     
    410438 
    411439                saveBillboardCloudMerged(); 
    412         } 
    413  
    414         if (mSampleCf.getBillboardCloudGroupedBillboards()) 
     440 
     441        } 
     442 
     443        if (mSampleConfigFile->getBillboardCloudGroupedBillboards()) 
    415444        {                                
    416445                mLeaves->getBillboardCloud()->generateBillboardCloud(false); 
    417                 mLeaves->getBillboardCloud()->initializeBillboardCloudGroups(mSampleCf.getBillboardCloudGroups()); 
    418                  
    419                 if (mSampleCf.getBillboardCloudDiffuseColorTextureAtlasGeneration()) 
    420                 { 
    421                         mBillboardCloudUVMapper->clear(); 
     446                mLeaves->getBillboardCloud()->initializeBillboardCloudGroups(mSampleConfigFile->getBillboardCloudGroups()); 
     447                 
     448                if (mSampleConfigFile->getBillboardCloudDiffuseColorTextureAtlasGeneration()) 
     449                { 
     450                        mBillboardCloudUVMapper->shutdown(); 
    422451                        mBillboardCloudUVMapper->setBillboardCloud(mLeaves->getBillboardCloud()); 
    423                         mBillboardCloudUVMapper->setTextureWidth(mSampleCf.getBillboardCloudDiffuseColorTextureSize()); 
    424                         mBillboardCloudUVMapper->setTextureHeight(mSampleCf.getBillboardCloudDiffuseColorTextureSize()); 
    425                         mBillboardCloudUVMapper->setTextureAtlasWidth(mSampleCf.getBillboardCloudDiffuseColorTextureAtlasSize()); 
    426                         mBillboardCloudUVMapper->setTextureAtlasHeight(mSampleCf.getBillboardCloudDiffuseColorTextureAtlasSize()); 
     452                        mBillboardCloudUVMapper->setTextureWidth(mSampleConfigFile->getBillboardCloudDiffuseColorTextureSize()); 
     453                        mBillboardCloudUVMapper->setTextureHeight(mSampleConfigFile->getBillboardCloudDiffuseColorTextureSize()); 
     454                        mBillboardCloudUVMapper->setTextureAtlasWidth(mSampleConfigFile->getBillboardCloudDiffuseColorTextureAtlasSize()); 
     455                        mBillboardCloudUVMapper->setTextureAtlasHeight(mSampleConfigFile->getBillboardCloudDiffuseColorTextureAtlasSize()); 
    427456                        mBillboardCloudUVMapper->initialize(); 
    428                         mBillboardCloudUVMapper->generateTextureAtlasTextureCoords(false, mSampleCf.getBillboardCloudGroupedBillboards(), mSampleCf.getBillboardCloudGroups());  
     457                        mBillboardCloudUVMapper->generateTextureAtlasTextureCoords(false, mSampleConfigFile->getBillboardCloudGroupedBillboards(), mSampleConfigFile->getBillboardCloudGroups());  
    429458                } 
    430459 
     
    434463        } 
    435464 
    436         if (mSampleCf.getBillboardCloudSplittedBillboards()) 
     465        if (mSampleConfigFile->getBillboardCloudSplittedBillboards()) 
    437466        {                
    438                 mLeaves->getBillboardCloud()->generateBillboardCloud(!mSampleCf.getBillboardCloudSplittedBillboards()); 
    439                 if (mSampleCf.getBillboardCloudDiffuseColorTextureAtlasGeneration()) 
    440                 { 
    441                         mBillboardCloudUVMapper->clear(); 
     467                mLeaves->getBillboardCloud()->generateBillboardCloud(false); 
     468                if (mSampleConfigFile->getBillboardCloudDiffuseColorTextureAtlasGeneration()) 
     469                { 
     470                        mBillboardCloudUVMapper->shutdown(); 
    442471                        mBillboardCloudUVMapper->setBillboardCloud(mLeaves->getBillboardCloud()); 
    443                         mBillboardCloudUVMapper->setTextureWidth(mSampleCf.getBillboardCloudDiffuseColorTextureSize()); 
    444                         mBillboardCloudUVMapper->setTextureHeight(mSampleCf.getBillboardCloudDiffuseColorTextureSize()); 
    445                         mBillboardCloudUVMapper->setTextureAtlasWidth(mSampleCf.getBillboardCloudDiffuseColorTextureAtlasSize()); 
    446                         mBillboardCloudUVMapper->setTextureAtlasHeight(mSampleCf.getBillboardCloudDiffuseColorTextureAtlasSize()); 
     472                        mBillboardCloudUVMapper->setTextureWidth(mSampleConfigFile->getBillboardCloudDiffuseColorTextureSize()); 
     473                        mBillboardCloudUVMapper->setTextureHeight(mSampleConfigFile->getBillboardCloudDiffuseColorTextureSize()); 
     474                        mBillboardCloudUVMapper->setTextureAtlasWidth(mSampleConfigFile->getBillboardCloudDiffuseColorTextureAtlasSize()); 
     475                        mBillboardCloudUVMapper->setTextureAtlasHeight(mSampleConfigFile->getBillboardCloudDiffuseColorTextureAtlasSize()); 
    447476                        mBillboardCloudUVMapper->initialize(); 
    448                         mBillboardCloudUVMapper->generateTextureAtlasTextureCoords(!mSampleCf.getBillboardCloudSplittedBillboards(),false);  
     477                        mBillboardCloudUVMapper->generateTextureAtlasTextureCoords(!mSampleConfigFile->getBillboardCloudSplittedBillboards(),false);  
    449478                } 
    450479                saveBillboardCloudSplitted(); 
Note: See TracChangeset for help on using the changeset viewer.