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)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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
Note: See TracChangeset for help on using the changeset viewer.