Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Feb 21, 2018, 12:03:52 AM (6 years ago)
Author:
landauf
Message:

merged ogre1.9 (including cegui0.8) into new branch

Location:
code/branches/cegui0.8_ogre1.9
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/cegui0.8_ogre1.9

  • code/branches/cegui0.8_ogre1.9/src/orxonox/graphics/Model.cc

    r11783 r11795  
    3030
    3131#include <OgreEntity.h>
    32 #include <OgreProgressiveMesh.h>
     32#if OGRE_VERSION >= 0x010900
     33#   include <OgreProgressiveMeshGenerator.h>
     34#   include <OgreDistanceLodStrategy.h>
     35#else
     36#   include <OgreProgressiveMesh.h>
     37#endif
    3338
    3439#include "core/CoreIncludes.h"
     
    203208            {
    204209                float volume = this->mesh_.getEntity()->getBoundingBox().volume();
    205 /*
    206                 float scaleFactor = 1;
    207 
    208                 BaseObject* creatorPtr = this;
    209 
    210                 while(creatorPtr!=nullptr&&orxonox_cast<WorldEntity*>(creatorPtr))
    211                 {
    212                     scaleFactor *= getBiggestScale(((WorldEntity*) creatorPtr)->getScale3D());
    213                     creatorPtr = creatorPtr->getCreator();
    214                 }
    215                 orxout() << "name: " << this->meshSrc_ << "scaleFactor: " << scaleFactor << ", volume: " << volume << endl;
    216 */
    217210                orxout(verbose, context::lod) << "Setting lodLevel for " << this->meshSrc_<< " with lodLevel_: " << this->lodLevel_ <<" and volume: "<< volume << ":" << endl;
    218211
    219 #if OGRE_VERSION >= 0x010800
     212#if OGRE_VERSION >= 0x010900
     213                Ogre::LodConfig::LodLevelList distList;
     214#elif OGRE_VERSION >= 0x010800
    220215                Ogre::ProgressiveMesh::LodValueList distList;
    221216#elif OGRE_VERSION >= 0x010700
     
    227222                if( lodLevel_>0 )
    228223                {
    229 //                    float factor = scaleFactor*5/lodLevel_;
    230224                    float factor = pow(volume, 2.0f / 3.0f) * 15.0f / lodLevel_;
    231225
    232226                    orxout(verbose, context::lod) << "LodLevel set with factor: " << factor << endl;
    233227
    234                     distList.push_back(70.0f*factor);
    235                     distList.push_back(140.0f*factor);
    236                     distList.push_back(170.0f*factor);
    237                     distList.push_back(200.0f*factor);
    238                     distList.push_back(230.0f*factor);
    239                     distList.push_back(250.0f*factor);
    240                     distList.push_back(270.0f*factor);
    241                     distList.push_back(290.0f*factor);
    242                     distList.push_back(310.0f*factor);
    243                     distList.push_back(330.0f*factor);
     228                    addLodDistanceToList(distList, 70.0f*factor);
     229                    addLodDistanceToList(distList, 140.0f*factor);
     230                    addLodDistanceToList(distList, 170.0f*factor);
     231                    addLodDistanceToList(distList, 200.0f*factor);
     232                    addLodDistanceToList(distList, 230.0f*factor);
     233                    addLodDistanceToList(distList, 250.0f*factor);
     234                    addLodDistanceToList(distList, 270.0f*factor);
     235                    addLodDistanceToList(distList, 290.0f*factor);
     236                    addLodDistanceToList(distList, 310.0f*factor);
     237                    addLodDistanceToList(distList, 330.0f*factor);
    244238                    while(distList.size()>this->numLodLevels_)
    245239                        distList.pop_back();
     
    247241
    248242                    //Generiert LOD-Levels
    249 #if OGRE_VERSION >= 0x010800
     243#if OGRE_VERSION >= 0x010900
     244                    Ogre::LodConfig config;
     245                    config.mesh = this->mesh_.getEntity()->getMesh();
     246                    config.levels = distList;
     247                    config.strategy = Ogre::DistanceLodSphereStrategy::getSingletonPtr();
     248
     249                    Ogre::ProgressiveMeshGenerator generator;
     250                    generator.generateLodLevels(config);
     251#elif OGRE_VERSION >= 0x010800
    250252                    Ogre::ProgressiveMesh::generateLodLevels(this->mesh_.getEntity()->getMesh().get(), distList, Ogre::ProgressiveMesh::VRQ_PROPORTIONAL,
    251253                        this->lodReductionRate_);
     
    270272#endif
    271273    }
     274
     275    template <class T>
     276    void Model::addLodDistanceToList(T& list, float distance)
     277    {
     278#if OGRE_VERSION >= 0x010900
     279        list.push_back({distance, Ogre::LodLevel::VRM_COLLAPSE_COST, this->lodReductionRate_, 0, false});
     280#else
     281        list.push_back(distance);
     282#endif
     283    }
    272284}
Note: See TracChangeset for help on using the changeset viewer.