Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Oct 27, 2008, 4:08:51 AM (16 years ago)
Author:
landauf
Message:

many changes, most important: BaseObject takes now a pointer to it's creator which is needed to build a level hierarchy (with different scenes)

Location:
code/branches/objecthierarchy/src/orxonox/tools
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • code/branches/objecthierarchy/src/orxonox/tools/BillboardSet.cc

    r1755 r2019  
    3131
    3232#include <sstream>
    33 
     33#include <cassert>
    3434#include <OgreSceneManager.h>
    3535
     
    4646    }
    4747
    48     void BillboardSet::setBillboardSet(const std::string& file, int count)
     48    void BillboardSet::setBillboardSet(Ogre::SceneManager* scenemanager, const std::string& file, int count)
    4949    {
     50        assert(scenemanager);
     51
    5052        std::ostringstream name;
    5153        name << (BillboardSet::billboardSetCounter_s++);
    52         this->billboardSet_ = GraphicsEngine::getInstance().getLevelSceneManager()->createBillboardSet("Billboard" + name.str(), count);
     54        this->billboardSet_ = scenemanager->createBillboardSet("Billboard" + name.str(), count);
    5355        this->billboardSet_->createBillboard(Vector3::ZERO);
    5456        this->billboardSet_->setMaterialName(file);
     57
     58        this->scenemanager_ = scenemanager;
    5559    }
    5660
    57     void BillboardSet::setBillboardSet(const std::string& file, const ColourValue& colour, int count)
     61    void BillboardSet::setBillboardSet(Ogre::SceneManager* scenemanager, const std::string& file, const ColourValue& colour, int count)
    5862    {
     63        assert(scenemanager);
     64
    5965        std::ostringstream name;
    6066        name << (BillboardSet::billboardSetCounter_s++);
    61         this->billboardSet_ = GraphicsEngine::getInstance().getLevelSceneManager()->createBillboardSet("Billboard" + name.str(), count);
     67        this->billboardSet_ = scenemanager->createBillboardSet("Billboard" + name.str(), count);
    6268        this->billboardSet_->createBillboard(Vector3::ZERO, colour);
    6369        this->billboardSet_->setMaterialName(file);
     70
     71        this->scenemanager_ = scenemanager;
    6472    }
    6573
    66     void BillboardSet::setBillboardSet(const std::string& file, const Vector3& position, int count)
     74    void BillboardSet::setBillboardSet(Ogre::SceneManager* scenemanager, const std::string& file, const Vector3& position, int count)
    6775    {
     76        assert(scenemanager);
     77
    6878        std::ostringstream name;
    6979        name << (BillboardSet::billboardSetCounter_s++);
    70         this->billboardSet_ = GraphicsEngine::getInstance().getLevelSceneManager()->createBillboardSet("Billboard" + name.str(), count);
     80        this->billboardSet_ = scenemanager->createBillboardSet("Billboard" + name.str(), count);
    7181        this->billboardSet_->createBillboard(position);
    7282        this->billboardSet_->setMaterialName(file);
     83
     84        this->scenemanager_ = scenemanager;
    7385    }
    7486
    75     void BillboardSet::setBillboardSet(const std::string& file, const ColourValue& colour, const Vector3& position, int count)
     87    void BillboardSet::setBillboardSet(Ogre::SceneManager* scenemanager, const std::string& file, const ColourValue& colour, const Vector3& position, int count)
    7688    {
     89        assert(scenemanager);
     90
    7791        std::ostringstream name;
    7892        name << (BillboardSet::billboardSetCounter_s++);
    79         this->billboardSet_ = GraphicsEngine::getInstance().getLevelSceneManager()->createBillboardSet("Billboard" + name.str(), count);
     93        this->billboardSet_ = scenemanager->createBillboardSet("Billboard" + name.str(), count);
    8094        this->billboardSet_->createBillboard(position, colour);
    8195        this->billboardSet_->setMaterialName(file);
     96
     97        this->scenemanager_ = scenemanager;
    8298    }
    8399
    84100    BillboardSet::~BillboardSet()
    85101    {
    86         if (this->billboardSet_)
    87             GraphicsEngine::getInstance().getLevelSceneManager()->destroyBillboardSet(this->billboardSet_);
     102        if (this->billboardSet_ && this->scenemanager_)
     103            this->scenemanager_->destroyBillboardSet(this->billboardSet_);
    88104    }
    89105}
  • code/branches/objecthierarchy/src/orxonox/tools/BillboardSet.h

    r1602 r2019  
    4444            BillboardSet();
    4545            ~BillboardSet();
    46             void setBillboardSet(const std::string& file, int count = 1);
    47             void setBillboardSet(const std::string& file, const ColourValue& colour, int count = 1);
    48             void setBillboardSet(const std::string& file, const Vector3& position, int count = 1);
    49             void setBillboardSet(const std::string& file, const ColourValue& colour, const Vector3& position, int count = 1);
     46            void setBillboardSet(Ogre::SceneManager* scenemanager, const std::string& file, int count = 1);
     47            void setBillboardSet(Ogre::SceneManager* scenemanager, const std::string& file, const ColourValue& colour, int count = 1);
     48            void setBillboardSet(Ogre::SceneManager* scenemanager, const std::string& file, const Vector3& position, int count = 1);
     49            void setBillboardSet(Ogre::SceneManager* scenemanager, const std::string& file, const ColourValue& colour, const Vector3& position, int count = 1);
    5050
    5151            inline Ogre::BillboardSet* getBillboardSet()
     
    6363            static unsigned int billboardSetCounter_s;
    6464            Ogre::BillboardSet* billboardSet_;
     65            Ogre::SceneManager* scenemanager_;
    6566    };
    6667}
  • code/branches/objecthierarchy/src/orxonox/tools/Light.cc

    r1755 r2019  
    3131
    3232#include <sstream>
     33#include <cassert>
    3334
    3435#include <OgreSceneManager.h>
     
    4546    }
    4647
    47     void Light::setLight(Ogre::Light::LightTypes type, const ColourValue& diffuse, const ColourValue& specular)
     48    void Light::setLight(Ogre::SceneManager* scenemanager, Ogre::Light::LightTypes type, const ColourValue& diffuse, const ColourValue& specular)
    4849    {
     50        assert(scenemanager);
     51
    4952        std::ostringstream name;
    5053        name << (Light::lightCounter_s++);
    51         this->light_ = GraphicsEngine::getInstance().getLevelSceneManager()->createLight("Light" + name.str());
     54        this->light_ = scenemanager->createLight("Light" + name.str());
    5255        this->light_->setType(type);
    5356        this->light_->setDiffuseColour(diffuse);
    5457        this->light_->setSpecularColour(specular);
     58
     59        this->scenemanager_ = scenemanager;
    5560    }
    5661
    5762    Light::~Light()
    5863    {
    59         if (this->light_)
    60             GraphicsEngine::getInstance().getLevelSceneManager()->destroyLight(this->light_);
     64        if (this->light_ && this->scenemanager_)
     65            this->scenemanager_->destroyLight(this->light_);
    6166    }
    6267}
  • code/branches/objecthierarchy/src/orxonox/tools/Light.h

    r1505 r2019  
    4545            Light();
    4646            ~Light();
    47             void setLight(Ogre::Light::LightTypes type = Ogre::Light::LT_POINT, const ColourValue& diffuse = ColourValue(1.0, 1.0, 1.0), const ColourValue& specular = ColourValue(1.0, 1.0, 1.0));
     47            void setLight(Ogre::SceneManager* scenemanager, Ogre::Light::LightTypes type = Ogre::Light::LT_POINT, const ColourValue& diffuse = ColourValue(1.0, 1.0, 1.0), const ColourValue& specular = ColourValue(1.0, 1.0, 1.0));
    4848
    4949            inline Ogre::Light* getLight()
     
    5656            static unsigned int lightCounter_s;
    5757            Ogre::Light* light_;
     58            Ogre::SceneManager* scenemanager_;
    5859    };
    5960}
  • code/branches/objecthierarchy/src/orxonox/tools/Mesh.cc

    r2006 r2019  
    3232#include <sstream>
    3333#include <OgreSceneManager.h>
     34#include <cassert>
    3435
    3536#include "core/Core.h"
     
    5051    Mesh::~Mesh()
    5152    {
    52         if (this->entity_ && Core::showsGraphics())
    53             GraphicsEngine::getInstance().getLevelSceneManager()->destroyEntity(this->entity_);
     53        if (this->entity_ && this->scenemanager_)
     54            this->scenemanager_->destroyEntity(this->entity_);
    5455    }
    5556
    56     void Mesh::setMeshSource(const std::string& meshsource)
     57    void Mesh::setMeshSource(Ogre::SceneManager* scenemanager, const std::string& meshsource)
    5758    {
    58         if (Core::showsGraphics())
     59        assert(scenemanager);
     60
     61        this->scenemanager_ = scenemanager;
     62
     63        if (this->entity_)
     64            this->scenemanager_->destroyEntity(this->entity_);
     65
     66        try
    5967        {
    60             if (this->entity_)
    61                 GraphicsEngine::getInstance().getLevelSceneManager()->destroyEntity(this->entity_);
    62 
    63             try
    64             {
    65                 this->entity_ = GraphicsEngine::getInstance().getLevelSceneManager()->createEntity("Mesh" + convertToString(Mesh::meshCounter_s++), meshsource);
    66                 this->entity_->setCastShadows(this->bCastShadows_);
    67             }
    68             catch (...)
    69             {
    70                 COUT(1) << "Error: Couln't load mesh \"" << meshsource << "\"" << std::endl;
    71             }
     68            this->entity_ = this->scenemanager_->createEntity("Mesh" + convertToString(Mesh::meshCounter_s++), meshsource);
     69            this->entity_->setCastShadows(this->bCastShadows_);
     70        }
     71        catch (...)
     72        {
     73            COUT(1) << "Error: Couln't load mesh \"" << meshsource << "\"" << std::endl;
    7274        }
    7375    }
     
    8587            return this->entity_->getName();
    8688        else
    87             return blankString;
     89            return BLANKSTRING;
    8890    }
    8991
  • code/branches/objecthierarchy/src/orxonox/tools/Mesh.h

    r2006 r2019  
    4343            ~Mesh();
    4444
    45             void setMeshSource(const std::string& file);
     45            void setMeshSource(Ogre::SceneManager* scenemanager, const std::string& file);
    4646
    4747            inline Ogre::Entity* getEntity()
     
    6161            Ogre::Entity* entity_;
    6262            bool bCastShadows_;
     63            Ogre::SceneManager* scenemanager_;
    6364    };
    6465}
  • code/branches/objecthierarchy/src/orxonox/tools/ParticleInterface.cc

    r1755 r2019  
    3737#include <OgreParticleEmitter.h>
    3838#include <OgreSceneManager.h>
     39#include <cassert>
    3940
    4041#include "GraphicsEngine.h"
     
    4748  ParticleInterface* ParticleInterface::currentParticleInterface_s = 0;
    4849
    49   ParticleInterface::ParticleInterface(const std::string& templateName, LODParticle::LOD detaillevel)
     50  ParticleInterface::ParticleInterface(Ogre::SceneManager* scenemanager, const std::string& templateName, LODParticle::LOD detaillevel)
    5051  {
    5152    RegisterRootObject(ParticleInterface);
    5253
     54    assert(scenemanager);
     55
     56    this->scenemanager_ = scenemanager;
    5357    this->sceneNode_ = 0;
    5458    this->bEnabled_ = true;
    5559    this->detaillevel_ = (unsigned int)detaillevel;
    56     this->particleSystem_ = GraphicsEngine::getInstance().getLevelSceneManager()->createParticleSystem("particles" + getConvertedValue<unsigned int, std::string>(ParticleInterface::counter_s++), templateName);
     60    this->particleSystem_ = this->scenemanager_->createParticleSystem("particles" + getConvertedValue<unsigned int, std::string>(ParticleInterface::counter_s++), templateName);
    5761    //this->particleSystem_->setSpeedFactor(Orxonox::getInstance().getTimeFactor());
    5862    this->particleSystem_->setSpeedFactor(1.0f);
     
    7276  {
    7377    this->particleSystem_->removeAllEmitters();
    74     GraphicsEngine::getInstance().getLevelSceneManager()->destroyParticleSystem(particleSystem_);
     78    this->scenemanager_->destroyParticleSystem(particleSystem_);
    7579  }
    7680
  • code/branches/objecthierarchy/src/orxonox/tools/ParticleInterface.h

    r1563 r2019  
    4848  {
    4949    public:
    50       ParticleInterface(const std::string& templateName, LODParticle::LOD detaillevel);
     50      ParticleInterface(Ogre::SceneManager* scenemanager, const std::string& templateName, LODParticle::LOD detaillevel);
    5151      ~ParticleInterface();
    5252
     
    9292      bool bEnabled_;
    9393      unsigned int detaillevel_;                            //!< Detail level of this particle effect (0: off, 1: low, 2: normal, 3: high)
     94      Ogre::SceneManager* scenemanager_;
    9495  };
    9596}
Note: See TracChangeset for help on using the changeset viewer.