Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 31, 2010, 9:02:48 AM (14 years ago)
Author:
scheusso
Message:

some changes regarding lod:

  • added lodtemplate in different levels
  • trying to avoid sigabrt's because of models with too much lod levels
File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/presentation3/src/orxonox/graphics/Model.cc

    r7024 r7036  
    4242    CreateFactory(Model);
    4343
    44     Model::Model(BaseObject* creator) : StaticEntity(creator)
     44    Model::Model(BaseObject* creator) :
     45        StaticEntity(creator), bCastShadows_(true), lodLevel_(5), bLodEnabled_(true), numLodLevels_(10), lodReductionRate_(.15)
    4546    {
    4647        RegisterObject(Model);
    4748
    48         this->bCastShadows_ = true;
    49 
    5049        this->registerVariables();
    51         //LoD
    52         this->lodLevel_=5;
    5350    }
    5451
     
    10299               
    103100                //LOD
    104                 if(this->mesh_.getEntity()->getMesh()->getNumLodLevels()==1
    105                     &&this->meshSrc_!="laserbeam.mesh")
     101                if( this->mesh_.getEntity()->getMesh()->getNumLodLevels()==1 )
    106102                {
    107103                    Level* level = this->getLevel();
     
    109105                    assert( level != 0 );
    110106                   
    111                     if( level->getLodInfo(this->meshSrc_)!=0 )
    112                         setLodLevel(level->getLodInfo(this->meshSrc_)->getLodLevel());
    113                     if( level->getLodInfo(this->meshSrc_)==0 || level->getLodInfo(this->meshSrc_)->getEnabled() )
     107                    MeshLodInformation* lodInfo = level->getLodInfo(this->meshSrc_);
     108                    if( lodInfo )
    114109                    {
    115 
     110                        setLodLevel(lodInfo->getLodLevel());
     111                        this->bLodEnabled_ = lodInfo->getEnabled();
     112                        this->numLodLevels_ = lodInfo->getNumLevels();
     113                        this->lodReductionRate_ = lodInfo->getReductionRate();
     114                    }
     115                    if( this->numLodLevels_>10 )
     116                    {
     117                        CCOUT(2) << "More than 10 LoD levels requested. Creating only 10." << endl;
     118                        this->numLodLevels_ = 10;
     119                    }
     120                    if( this->bLodEnabled_ )
     121                    {
    116122                        float volume = this->mesh_.getEntity()->getBoundingBox().volume();
    117123    //                     float scaleFactor = 1;
     
    139145                            float factor = volume/3/lodLevel_;
    140146                           
    141                             COUT(4)<<"LodLevel set with factor: "<<factor<<std::endl;
     147                            COUT(4) << "LodLevel set with factor: " << factor << endl;
    142148
    143149                            distList.push_back(70.0f*factor);
     
    151157                            distList.push_back(310.0f*factor);
    152158                            distList.push_back(330.0f*factor);
    153 
    154                             float reductionValue = 0.15f;
     159                            while(distList.size()>this->numLodLevels_)
     160                                distList.pop_back();
    155161
    156162                           
    157163                            //Generiert LOD-Levels
    158                             this->mesh_.getEntity()->getMesh()->generateLodLevels(distList, Ogre::ProgressiveMesh::VRQ_PROPORTIONAL, reductionValue);
     164                            this->mesh_.getEntity()->getMesh()->generateLodLevels(distList, Ogre::ProgressiveMesh::VRQ_PROPORTIONAL, this->lodReductionRate_);
    159165                        }
    160166                        else
     
    166172                                what = "<0";
    167173                           
    168                             COUT(4)<<"LodLevel not set because lodLevel("<<lodLevel_<<") was "<<what<<"."<<std::endl;
     174                            COUT(4)<<"LodLevel not set because lodLevel("<<lodLevel_<<") was "<<what<<"." << endl;
    169175                        }
    170176                    }
     177                    else
     178                        COUT(4) << "LodLevel for " << this->meshSrc_ << " not set because is disabled." << endl;
    171179                }
    172180            }
Note: See TracChangeset for help on using the changeset viewer.