Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 20, 2010, 10:23:22 AM (14 years ago)
Author:
scheusso
Message:

merging lod branch into presentation3 merger branch

Location:
code/branches/presentation3
Files:
14 edited
5 copied

Legend:

Unmodified
Added
Removed
  • code/branches/presentation3

  • code/branches/presentation3/data/levels/empty_level.oxw

    r6560 r6926  
    22  include("stats.oxo")
    33  include("hudtemplates3.oxo")
     4  include("templates/lodinformation.oxt")
    45?>
    56
     
    1314 description  = "Just a few tests"
    1415>
     16  <templates>
     17    <Template link=lodtemplate_default />
     18  </templates>
     19
    1520  <Scene
    1621    ambientlight = "0.8, 0.8, 0.8"
  • code/branches/presentation3/data/levels/gametype_asteroids.oxw

    r6417 r6926  
    33  include("stats.oxo")
    44  include("templates/spaceship_assff.oxt")
     5  include("templates/lodinformation.oxt")
    56?>
    67
     
    1011 gametype     =  Asteroids
    1112>
     13  <templates>
     14    <Template link=lodtemplate_default />
     15  </templates>
     16
    1217<Scene
    1318 ambientlight = "0.5, 0.5, 0.5"
  • code/branches/presentation3/data/levels/gametype_underattack.oxw

    r5781 r6926  
    44  include("underattackhud.oxo")
    55  include("templates/spaceship_assff.oxt")
     6  include("templates/lodinformation.oxt")
    67?>
    78
     
    1112 gametype     = UnderAttack
    1213>
     14  <templates>
     15    <Template link=lodtemplate_default />
     16  </templates>
     17
    1318  <Scene
    1419   ambientlight = "0.5, 0.5, 0.5"
  • code/branches/presentation3/data/levels/teambasematchlevel.oxw

    r6417 r6926  
    55  include("templates/spaceship_assff.oxt")
    66  include("templates/spaceship_pirate.oxt")
     7  include("templates/lodinformation.oxt")
    78?>
    89
     
    1213 gametype     = TeamBaseMatch
    1314>
     15  <templates>
     16    <Template link=lodtemplate_default />
     17  </templates>
     18
    1419  <Scene
    1520   ambientlight = "0.5, 0.5, 0.5"
  • code/branches/presentation3/data/levels/teamdeathmatch.oxw

    r5781 r6926  
    55  include("templates/spaceship_H2.oxt")
    66  include("templates/spaceship_pirate.oxt")
     7  include("templates/lodinformation.oxt")
    78?>
    89
     
    1213 gametype     = TeamDeathmatch
    1314>
     15  <templates>
     16    <Template link=lodtemplate_default />
     17  </templates>
     18
    1419  <Scene
    1520   ambientlight = "0.7, 0.6, 0.6"
  • code/branches/presentation3/src/libraries/core/BaseObject.cc

    r6800 r6926  
    7575            this->setScene(this->creator_->getScene(), this->creator_->getSceneID());
    7676            this->setGametype(this->creator_->getGametype());
     77            this->setLevel(this->creator_->getLevel());
    7778        }
    7879        else
     
    8384            this->sceneID_ = OBJECTID_UNKNOWN;
    8485            this->gametype_ = 0;
     86            this->level_ = 0;
    8587        }
    8688    }
  • code/branches/presentation3/src/libraries/core/BaseObject.h

    r6800 r6926  
    5151    class Scene;
    5252    class Gametype;
     53    class Level;
    5354
    5455    //! The BaseObject is the parent of all classes representing an instance in the game.
     
    153154            inline Gametype* getOldGametype() const { return this->oldGametype_; }
    154155            virtual void changedGametype() {}
     156           
     157            inline void setLevel(const SmartPtr<Level>& level)
     158            {
     159                if (level != this->level_)
     160                {
     161                    this->level_ = level;
     162                    this->changedLevel();
     163                }
     164            }
     165            inline const SmartPtr<Level>& getLevel() const { return this->level_; }
     166            virtual void changedLevel() {}
    155167
    156168            void addEventSource(BaseObject* source, const std::string& state);
     
    209221            SmartPtr<Gametype>     gametype_;
    210222            Gametype*              oldGametype_;
     223            SmartPtr<Level>        level_;
    211224            std::set<Template*>    templates_;
    212225
  • code/branches/presentation3/src/orxonox/Level.cc

    r6746 r6926  
    4949        RegisterObject(Level);
    5050
     51       
    5152        this->registerVariables();
    5253        this->xmlfilename_ = this->getFilename();
     
    7273        XMLPortParam(Level, "description", setDescription, getDescription, xmlelement, mode);
    7374        XMLPortParam(Level, "gametype", setGametypeString, getGametypeString, xmlelement, mode).defaultValues("Gametype");
    74 
     75           
     76        XMLPortObject(Level, MeshLodInformation, "lodinformation", addLodInfo, getLodInfo, xmlelement, mode);
    7577        XMLPortObjectExtended(Level, BaseObject, "", addObject, getObject, xmlelement, mode, true, false);
    76     }
     78}
    7779
    7880    void Level::registerVariables()
     
    125127        this->objects_.push_back(object);
    126128        object->setGametype(this->getGametype());
     129    object->setLevel(this);
    127130    }
    128131
     
    136139            ++i;
    137140        }
     141        return 0;
     142    }
     143   
     144    void Level::addLodInfo(MeshLodInformation* lodInformation)
     145    {
     146        std::string meshName = lodInformation->getMeshName();
     147        this->lodInformation_.insert(std::make_pair(meshName,lodInformation));
     148    }
     149
     150    MeshLodInformation* Level::getLodInfo(std::string meshName) const
     151    {
     152        if(this->lodInformation_.find(meshName)!=this->lodInformation_.end())
     153            return this->lodInformation_.find(meshName)->second;
     154       
    138155        return 0;
    139156    }
  • code/branches/presentation3/src/orxonox/Level.h

    r5929 r6926  
    3434#include <list>
    3535#include <string>
     36#include <map>
    3637#include "core/BaseObject.h"
    3738#include "network/synchronisable/Synchronisable.h"
     39#include "graphics/MeshLodInformation.h"
    3840
    3941namespace orxonox
     
    5557            void playerEntered(PlayerInfo* player);
    5658            void playerLeft(PlayerInfo* player);
     59                       
     60            MeshLodInformation* getLodInfo(std::string meshName) const;
     61
    5762
    5863        private:
    5964            void addObject(BaseObject* object);
    6065            BaseObject* getObject(unsigned int index) const;
     66
     67            void addLodInfo(MeshLodInformation* object);
     68//            const MeshLodInformation* getLodInfo(std::string meshName) const;
     69//            MeshLodInformation* getLodInfo(unsigned int index) const;
    6170
    6271            void setGametypeString(const std::string& gametype);
     
    6675            void networkcallback_applyXMLFile();
    6776
    68             std::string            description_;
    69             std::string            gametype_;
    70             std::string            xmlfilename_;
    71             XMLFile*               xmlfile_;
    72             std::list<BaseObject*> objects_;
     77            std::string                    description_;
     78            std::string                    gametype_;
     79            std::string                    xmlfilename_;
     80            XMLFile*                       xmlfile_;
     81            std::list<BaseObject*>         objects_;
     82            std::map<std::string,MeshLodInformation*>  lodInformation_;
    7383    };
    7484}
  • code/branches/presentation3/src/orxonox/LevelManager.cc

    r6501 r6926  
    7070    void LevelManager::requestActivity(Level* level)
    7171    {
     72        COUT(0) << "pushing level into level list: " << level << endl;
    7273        this->levels_s.push_back(level);
    7374        if (this->levels_s.size() == 1)
     
    7778    void LevelManager::releaseActivity(Level* level)
    7879    {
     80        COUT(0) << "poping level from level list: " << level << endl;
    7981        if (this->levels_s.size() > 0)
    8082        {
  • code/branches/presentation3/src/orxonox/graphics/CMakeLists.txt

    r5929 r6926  
    44  FadingBillboard.cc
    55  GlobalShader.cc
     6  MeshLodInformation.cc
    67  Model.cc
    78  ParticleEmitter.cc
  • code/branches/presentation3/src/orxonox/graphics/Model.cc

    r5781 r6926  
    3535#include "core/XMLPort.h"
    3636#include "Scene.h"
     37#include "graphics/MeshLodInformation.h"
     38#include "Level.h"
    3739
    3840namespace orxonox
     
    4749
    4850        this->registerVariables();
     51        //LoD
     52        this->lodLevel_=5;
    4953    }
    5054
     
    5862    {
    5963        SUPER(Model, XMLPort, xmlelement, mode);
    60 
     64       
     65        XMLPortParam(Model, "lodLevel", setLodLevel, getLodLevel, xmlelement, mode);
     66       
    6167        XMLPortParam(Model, "mesh", setMeshSource, getMeshSource, xmlelement, mode);
    6268        XMLPortParam(Model, "shadow", setCastShadows, getCastShadows, xmlelement, mode).defaultValues(true);
     
    6975    }
    7076
     77    float Model::getBiggestScale(Vector3 scale3d)
     78    {
     79        float scaleFactor = scale3d.x;
     80        if(scale3d.y>scaleFactor)
     81            scaleFactor = scale3d.y;
     82        if(scale3d.z>scaleFactor)
     83            scaleFactor = scale3d.z;
     84        return scaleFactor;
     85    }
     86   
    7187    void Model::changedMesh()
    7288    {
     
    7591            if (this->mesh_.getEntity())
    7692                this->detachOgreObject(this->mesh_.getEntity());
    77 
     93           
    7894            this->mesh_.setMeshSource(this->getScene()->getSceneManager(), this->meshSrc_);
    7995
     
    8399                this->mesh_.getEntity()->setCastShadows(this->bCastShadows_);
    84100                this->mesh_.setVisible(this->isVisible());
     101               
     102                //LOD
     103                if(this->mesh_.getEntity()->getMesh()->getNumLodLevels()==1
     104                    &&this->meshSrc_!="laserbeam.mesh")
     105                {
     106                    float scaleFactor = 1;
     107                    BaseObject* creatorPtr = this;
     108                   
     109                    while(creatorPtr!=NULL&&orxonox_cast<WorldEntity*>(creatorPtr))
     110                    {
     111                        scaleFactor *= getBiggestScale(((WorldEntity*) creatorPtr)->getScale3D());
     112                        creatorPtr = creatorPtr->getCreator();
     113                    }
     114                   
     115                    Level* level_ = this->getLevel();
     116                   
     117                    MeshLodInformation* lodInfo = level_->getLodInfo(this->meshSrc_);
     118                   
     119                    if(lodInfo!=0)
     120                        setLodLevel(lodInfo->getLodLevel());
     121                   
     122                    COUT(0) << "Setting lodLevel for " << this->meshSrc_<< " with lodLevel_: " << this->lodLevel_ <<" and scale: "<< scaleFactor << ":" << std::endl;
     123
     124#if OGRE_VERSION >= 0x010700
     125                    Ogre::Mesh::LodValueList distList;
     126#else
     127                    Ogre::Mesh::LodDistanceList distList;
     128#endif
     129
     130                    if(lodLevel_>0&&lodLevel_<=5)
     131                    {
     132                        float factor = scaleFactor*5/lodLevel_;
     133                       
     134                        COUT(0)<<"LodLevel set with factor: "<<factor<<std::endl;
     135
     136                        distList.push_back(70.0f*factor);
     137                        distList.push_back(140.0f*factor);
     138                        distList.push_back(170.0f*factor);
     139                        distList.push_back(200.0f*factor);
     140                        distList.push_back(230.0f*factor);
     141                        distList.push_back(250.0f*factor);
     142                        distList.push_back(270.0f*factor);
     143                        distList.push_back(290.0f*factor);
     144                        distList.push_back(310.0f*factor);
     145                        distList.push_back(330.0f*factor);
     146
     147                        float reductionValue = 0.15f;
     148
     149                       
     150                        //Generiert LOD-Levels
     151                        this->mesh_.getEntity()->getMesh()->generateLodLevels(distList, Ogre::ProgressiveMesh::VRQ_PROPORTIONAL, reductionValue);
     152                    }
     153                    else
     154                    {
     155                        std::string what;
     156                        if(lodLevel_>5)
     157                            what = ">5";
     158                        else
     159                            what = "<0";
     160                       
     161                        COUT(0)<<"LodLevel not set because lodLevel("<<lodLevel_<<") was "<<what<<"."<<std::endl;
     162                    }
     163                }
    85164            }
    86165        }
  • code/branches/presentation3/src/orxonox/graphics/Model.h

    r5781 r6926  
    6161            inline bool getCastShadows() const
    6262                { return this->bCastShadows_; }
    63 
     63               
    6464        private:
    6565            void changedMesh();
    6666            void changedShadows();
     67           
     68            //LoD
     69            inline void setLodLevel(float lodLevel)
     70                { this->lodLevel_ =  lodLevel; }
     71            inline float getLodLevel() const
     72                { return this->lodLevel_; }
     73            float getBiggestScale(Vector3 scale3d);
    6774
    6875            std::string meshSrc_;
    6976            Mesh mesh_;
    7077            bool bCastShadows_;
     78           
     79            //LoD
     80            float lodLevel_;
    7181    };
    7282}
Note: See TracChangeset for help on using the changeset viewer.