Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Mar 6, 2016, 3:32:26 PM (9 years ago)
Author:
landauf
Message:

orxonox now compiles with ogre 1.9 (but still needs some other changes)

Location:
code/branches/ogre1.9/src/orxonox/graphics
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • code/branches/ogre1.9/src/orxonox/graphics/Camera.cc

    r9667 r11129  
    6262
    6363        this->camera_ = this->getScene()->getSceneManager()->createCamera(getUniqueNumberString());
    64         static_cast<Ogre::MovableObject*>(this->camera_)->setUserAny(Ogre::Any(static_cast<OrxonoxClass*>(this)));
     64        Ogre::MovableObject* movable = static_cast<Ogre::MovableObject*>(this->camera_);
     65#if OGRE_VERSION >= 0x010900
     66        movable->getUserObjectBindings().setUserAny(Ogre::Any(static_cast<OrxonoxClass*>(this)));
     67#else
     68        movable->setUserAny(Ogre::Any(static_cast<OrxonoxClass*>(this)));
     69#endif
    6570        this->cameraNode_ = this->getScene()->getRootSceneNode()->createChildSceneNode();
    6671        this->attachNode(this->cameraNode_);
  • code/branches/ogre1.9/src/orxonox/graphics/Model.cc

    r11080 r11129  
    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"
     
    196201            {
    197202                float volume = this->mesh_.getEntity()->getBoundingBox().volume();
    198 /*
    199                 float scaleFactor = 1;
    200 
    201                 BaseObject* creatorPtr = this;
    202 
    203                 while(creatorPtr!=nullptr&&orxonox_cast<WorldEntity*>(creatorPtr))
    204                 {
    205                     scaleFactor *= getBiggestScale(((WorldEntity*) creatorPtr)->getScale3D());
    206                     creatorPtr = creatorPtr->getCreator();
    207                 }
    208                 orxout() << "name: " << this->meshSrc_ << "scaleFactor: " << scaleFactor << ", volume: " << volume << endl;
    209 */
    210203                orxout(verbose, context::lod) << "Setting lodLevel for " << this->meshSrc_<< " with lodLevel_: " << this->lodLevel_ <<" and volume: "<< volume << ":" << endl;
    211204
    212 #if OGRE_VERSION >= 0x010800
     205#if OGRE_VERSION >= 0x010900
     206                Ogre::LodConfig::LodLevelList distList;
     207#elif OGRE_VERSION >= 0x010800
    213208                Ogre::ProgressiveMesh::LodValueList distList;
    214209#elif OGRE_VERSION >= 0x010700
     
    220215                if( lodLevel_>0 )
    221216                {
    222 //                    float factor = scaleFactor*5/lodLevel_;
    223217                    float factor = pow(volume, 2.0f / 3.0f) * 15.0f / lodLevel_;
    224218
    225219                    orxout(verbose, context::lod) << "LodLevel set with factor: " << factor << endl;
    226220
    227                     distList.push_back(70.0f*factor);
    228                     distList.push_back(140.0f*factor);
    229                     distList.push_back(170.0f*factor);
    230                     distList.push_back(200.0f*factor);
    231                     distList.push_back(230.0f*factor);
    232                     distList.push_back(250.0f*factor);
    233                     distList.push_back(270.0f*factor);
    234                     distList.push_back(290.0f*factor);
    235                     distList.push_back(310.0f*factor);
    236                     distList.push_back(330.0f*factor);
     221                    addLodDistanceToList(distList, 70.0f*factor);
     222                    addLodDistanceToList(distList, 140.0f*factor);
     223                    addLodDistanceToList(distList, 170.0f*factor);
     224                    addLodDistanceToList(distList, 200.0f*factor);
     225                    addLodDistanceToList(distList, 230.0f*factor);
     226                    addLodDistanceToList(distList, 250.0f*factor);
     227                    addLodDistanceToList(distList, 270.0f*factor);
     228                    addLodDistanceToList(distList, 290.0f*factor);
     229                    addLodDistanceToList(distList, 310.0f*factor);
     230                    addLodDistanceToList(distList, 330.0f*factor);
    237231                    while(distList.size()>this->numLodLevels_)
    238232                        distList.pop_back();
     
    240234
    241235                    //Generiert LOD-Levels
    242 #if OGRE_VERSION >= 0x010800
     236#if OGRE_VERSION >= 0x010900
     237                    Ogre::LodConfig config;
     238                    config.mesh = this->mesh_.getEntity()->getMesh();
     239                    config.levels = distList;
     240                    config.strategy = Ogre::DistanceLodSphereStrategy::getSingletonPtr();
     241
     242                    Ogre::ProgressiveMeshGenerator generator;
     243                    generator.generateLodLevels(config);
     244#elif OGRE_VERSION >= 0x010800
    243245                    Ogre::ProgressiveMesh::generateLodLevels(this->mesh_.getEntity()->getMesh().get(), distList, Ogre::ProgressiveMesh::VRQ_PROPORTIONAL,
    244246                        this->lodReductionRate_);
     
    263265#endif
    264266    }
     267
     268    template <class T>
     269    void Model::addLodDistanceToList(T& list, float distance)
     270    {
     271#if OGRE_VERSION >= 0x010900
     272        list.push_back({distance, Ogre::LodLevel::VRM_COLLAPSE_COST, this->lodReductionRate_, 0, false});
     273#else
     274        list.push_back(distance);
     275#endif
     276    }
    265277}
  • code/branches/ogre1.9/src/orxonox/graphics/Model.h

    r11128 r11129  
    114114            void enableLod();
    115115
     116            template <class T>
     117            void addLodDistanceToList(T& list, float distance);
     118
    116119            inline void setLodLevel(float lodLevel)
    117120                { this->lodLevel_ =  lodLevel; }
Note: See TracChangeset for help on using the changeset viewer.