Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6691


Ignore:
Timestamp:
Apr 12, 2010, 3:48:24 PM (14 years ago)
Author:
kolibri7
Message:

implementing the XMLPort function for LoD; getting some erreors from gcc…

Location:
code/branches/lod
Files:
4 added
5 edited

Legend:

Unmodified
Added
Removed
  • code/branches/lod/src/orxonox/Level.cc

    r6417 r6691  
    3232#include "core/CoreIncludes.h"
    3333#include "core/Loader.h"
    34 #include "core/Template.h"
     34#include "core/template.h"
    3535#include "core/XMLFile.h"
    3636#include "core/XMLPort.h"
     
    7373        XMLPortParam(Level, "gametype", setGametypeString, getGametypeString, xmlelement, mode).defaultValues("Gametype");
    7474
    75         XMLPortObjectExtended(Level, BaseObject, "", addObject, getObject, xmlelement, mode, true, false);
    76     }
     75        XMLPortObjectExtended(Level, BaseObject, "", addObject, getObject, xmlelement, mode, true, false);           
     76        XMLPortObject(Level, MeshLodInformation, "lodinformation", addLodInfo, getLodInfo, xmlelement, mode);
     77}
    7778
    7879    void Level::registerVariables()
     
    138139        return 0;
    139140    }
     141   
     142    //LoD
     143    void Level::addLodInfo(const MeshLodInformation* lodInformation)
     144    {
     145//              std::pair<std::map<std::string,MeshLodInformation*>::iterator,bool> it
     146//                  = new std::pair<lodInformation->getMeshName(),lodInformation>;
     147        this->lodInformation_.insert(std::pair<lodInformation->getMeshName(),lodInformation>);
     148    }
     149
     150    MeshLodInformation* Level::getLodInfo(string meshName) const
     151    {
     152        if(this->lodInformation_.find(meshName)!=std::map::end)
     153            return this->lodInformation_.find(meshName);
     154       
     155        return 0;
     156       
     157       
     158        /*
     159        unsigned int i = 0;
     160        for (std::map<MeshLodInformation*>::const_iterator it = this->lodInformation_.begin(); it != this->lodInformation_.end(); ++it)
     161        {
     162            if (i == index)
     163                return (*it);
     164            ++i;
     165        }
     166        return 0;*/
     167    }
    140168
    141169    void Level::playerEntered(PlayerInfo* player)
  • code/branches/lod/src/orxonox/Level.h

    r5929 r6691  
    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
     
    6062            BaseObject* getObject(unsigned int index) const;
    6163
     64            void addLodInfo(const MeshLodInformation* object);
     65            MeshLodInformation* getLodInfo(unsigned int index) const;
     66
    6267            void setGametypeString(const std::string& gametype);
    6368            inline const std::string& getGametypeString() const
     
    6671            void networkcallback_applyXMLFile();
    6772
    68             std::string            description_;
    69             std::string            gametype_;
    70             std::string            xmlfilename_;
    71             XMLFile*               xmlfile_;
    72             std::list<BaseObject*> objects_;
     73            std::string                    description_;
     74            std::string                    gametype_;
     75            std::string                    xmlfilename_;
     76            XMLFile*                       xmlfile_;
     77            std::list<BaseObject*>         objects_;
     78            std::map<std::string,MeshLodInformation*>  lodInformation_;
    7379    };
    7480}
  • code/branches/lod/src/orxonox/graphics/CMakeLists.txt

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

    r5781 r6691  
    5858    {
    5959        SUPER(Model, XMLPort, xmlelement, mode);
    60 
     60               
     61                //LoD
     62        XMLPortParam(Model, "lodLevel", setLodLevel, getLodLevel, xmlelement, mode).defaultValues(5);
     63               
    6164        XMLPortParam(Model, "mesh", setMeshSource, getMeshSource, xmlelement, mode);
    6265        XMLPortParam(Model, "shadow", setCastShadows, getCastShadows, xmlelement, mode).defaultValues(true);
     
    7578            if (this->mesh_.getEntity())
    7679                this->detachOgreObject(this->mesh_.getEntity());
    77 
     80           
    7881            this->mesh_.setMeshSource(this->getScene()->getSceneManager(), this->meshSrc_);
    7982
     
    8386                this->mesh_.getEntity()->setCastShadows(this->bCastShadows_);
    8487                this->mesh_.setVisible(this->isVisible());
     88               
     89                //LOD
     90                if(this->mesh_.getEntity()->getMesh()->getNumLodLevels()==1
     91                    &&this->meshSrc_!="laserbeam.mesh"
     92                    &&this->lodLevel_!=0)
     93                {
     94                    float scaleFactor = this->getScale();
     95                    COUT(0) << this->meshSrc_<< " lodLevel_: " << this->lodLevel_ <<" scale: "<< scaleFactor << std::endl;
     96                    //Für Asteroiden perfekt
     97
     98#if OGRE_VERSION >= 0x010700
     99                    Ogre::Mesh::LodValueList distList;
     100#else
     101                    Ogre::Mesh::LodDistanceList distList;
     102#endif
     103
     104                    distList.push_back(70.0f*scaleFactor);
     105                    distList.push_back(140.0f*scaleFactor);
     106                    distList.push_back(170.0f*scaleFactor);
     107                    distList.push_back(200.0f*scaleFactor);
     108                    distList.push_back(230.0f*scaleFactor);
     109                    distList.push_back(250.0f*scaleFactor);
     110                    distList.push_back(270.0f*scaleFactor);
     111                    distList.push_back(290.0f*scaleFactor);
     112                    distList.push_back(310.0f*scaleFactor);
     113                    distList.push_back(330.0f*scaleFactor);
     114
     115                    float reductionValue = 0.2f;
     116
     117                   
     118                    //Generiert LOD-Levels
     119                    this->mesh_.getEntity()->getMesh()->generateLodLevels(distList, Ogre::ProgressiveMesh::VRQ_PROPORTIONAL, reductionValue);
     120                }
    85121            }
    86122        }
  • code/branches/lod/src/orxonox/graphics/Model.h

    r5781 r6691  
    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(unsigned short lodLevel)
     70                                { this->lodLevel_ =  lodLevel; }
     71                        inline unsigned short getLodLevel() const
     72                                { return this->lodLevel_; }
    6773
    6874            std::string meshSrc_;
    6975            Mesh mesh_;
    7076            bool bCastShadows_;
     77                       
     78                        //LoD
     79                        unsigned short lodLevel_;
    7180    };
    7281}
Note: See TracChangeset for help on using the changeset viewer.