Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 10, 2008, 12:05:03 AM (16 years ago)
Author:
landauf
Message:

merged revisions 2111-2170 from objecthierarchy branch back to trunk.

Location:
code/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/orxonox/tools/BillboardSet.cc

    r2087 r2171  
    3636#include <OgreBillboard.h>
    3737
     38#include "core/Core.h"
    3839#include "util/Convert.h"
    3940#include "util/String.h"
     
    7071        try
    7172        {
    72             this->billboardSet_ = scenemanager->createBillboardSet("Billboard" + convertToString(BillboardSet::billboardSetCounter_s++), count);
    73             this->billboardSet_->createBillboard(position);
    74             this->billboardSet_->setMaterialName(file);
     73            if (Core::showsGraphics())
     74            {
     75                this->billboardSet_ = scenemanager->createBillboardSet("Billboard" + convertToString(BillboardSet::billboardSetCounter_s++), count);
     76                this->billboardSet_->createBillboard(position);
     77                this->billboardSet_->setMaterialName(file);
     78            }
    7579        }
    7680        catch (...)
    7781        {
    7882            COUT(1) << "Error: Couln't load billboard \"" << file << "\"" << std::endl;
     83            this->billboardSet_ = 0;
    7984        }
    8085
     
    8994        try
    9095        {
    91             this->billboardSet_ = scenemanager->createBillboardSet("Billboard" + convertToString(BillboardSet::billboardSetCounter_s++), count);
    92             this->billboardSet_->createBillboard(position, colour);
    93             this->billboardSet_->setMaterialName(file);
     96            if (Core::showsGraphics())
     97            {
     98                this->billboardSet_ = scenemanager->createBillboardSet("Billboard" + convertToString(BillboardSet::billboardSetCounter_s++), count);
     99                this->billboardSet_->createBillboard(position, colour);
     100                this->billboardSet_->setMaterialName(file);
     101            }
    94102        }
    95103        catch (...)
    96104        {
    97105            COUT(1) << "Error: Couln't load billboard \"" << file << "\"" << std::endl;
     106            this->billboardSet_ = 0;
    98107        }
    99108
     
    105114        if (this->billboardSet_ && this->scenemanager_)
    106115            this->scenemanager_->destroyBillboardSet(this->billboardSet_);
     116        this->billboardSet_ = 0;
    107117    }
    108118
  • code/trunk/src/orxonox/tools/Mesh.cc

    r2087 r2171  
    7373            {
    7474                COUT(1) << "Error: Couln't load mesh \"" << meshsource << "\"" << std::endl;
     75                this->entity_ = 0;
    7576            }
    7677        }
  • code/trunk/src/orxonox/tools/ParticleInterface.cc

    r2087 r2171  
    2828
    2929/**
    30 * @file ParticleInterface.cc
     30* @file
    3131* @brief class to control praticle effects
    3232*/
     
    4141
    4242#include "GraphicsEngine.h"
     43#include "core/Core.h"
    4344#include "core/CoreIncludes.h"
    4445#include "util/Convert.h"
     
    5758        this->scenemanager_ = scenemanager;
    5859        this->sceneNode_ = 0;
     60        this->particleSystem_ = 0;
    5961
    6062        this->bEnabled_ = true;
     
    6264        this->bAllowedByLOD_ = true;
    6365
    64         this->particleSystem_ = this->scenemanager_->createParticleSystem("particles" + getConvertedValue<unsigned int, std::string>(ParticleInterface::counter_s++), templateName);
    65         this->particleSystem_->setSpeedFactor(1.0f);
    66         //this->particleSystem_->setSpeedFactor(Orxonox::getInstance().getTimeFactor());
     66        if (Core::showsGraphics())
     67        {
     68            try
     69            {
     70                this->particleSystem_ = this->scenemanager_->createParticleSystem("particles" + getConvertedValue<unsigned int, std::string>(ParticleInterface::counter_s++), templateName);
     71                this->particleSystem_->setSpeedFactor(1.0f);
     72//                this->particleSystem_->setSpeedFactor(Orxonox::getInstance().getTimeFactor());
     73            }
     74            catch (...)
     75            {
     76                COUT(1) << "Error: Couln't load particle system \"" << templateName << "\"" << std::endl;
     77                this->particleSystem_ = 0;
     78            }
     79        }
    6780
    6881        this->setDetailLevel((unsigned int)detaillevel);
     
    7184    ParticleInterface::~ParticleInterface()
    7285    {
    73         this->particleSystem_->removeAllEmitters();
    74         this->detachFromSceneNode();
    75         this->scenemanager_->destroyParticleSystem(particleSystem_);
     86        if (this->particleSystem_)
     87        {
     88            this->particleSystem_->removeAllEmitters();
     89            this->detachFromSceneNode();
     90            this->scenemanager_->destroyParticleSystem(this->particleSystem_);
     91        }
    7692    }
    7793
     
    8197            this->detachFromSceneNode();
    8298
    83         this->sceneNode_ = sceneNode;
    84         this->sceneNode_->attachObject(this->particleSystem_);
     99        if (this->particleSystem_)
     100        {
     101            this->sceneNode_ = sceneNode;
     102            this->sceneNode_->attachObject(this->particleSystem_);
     103        }
    85104    }
    86105
     
    89108        if (this->sceneNode_)
    90109        {
    91             this->sceneNode_->detachObject(this->particleSystem_);
     110            if (this->particleSystem_)
     111                this->sceneNode_->detachObject(this->particleSystem_);
    92112            this->sceneNode_ = 0;
    93113        }
     
    96116    Ogre::ParticleEmitter* ParticleInterface::createNewEmitter()
    97117    {
    98         if (this->particleSystem_->getNumEmitters() > 0)
     118        if (this->particleSystem_ && this->particleSystem_->getNumEmitters() > 0)
    99119        {
    100120            Ogre::ParticleEmitter* newemitter = this->particleSystem_->addEmitter(this->particleSystem_->getEmitter(0)->getType());
     
    107127    Ogre::ParticleEmitter* ParticleInterface::getEmitter(unsigned int emitterNr) const
    108128    {
    109         if (emitterNr < this->particleSystem_->getNumEmitters())
     129        if (this->particleSystem_ && (emitterNr < this->particleSystem_->getNumEmitters()))
    110130            return this->particleSystem_->getEmitter(emitterNr);
    111131        else
     
    114134    void ParticleInterface::removeEmitter(unsigned int emitterNr)
    115135    {
    116         if (emitterNr < this->particleSystem_->getNumEmitters())
     136        if (this->particleSystem_ && (emitterNr < this->particleSystem_->getNumEmitters()))
    117137            this->particleSystem_->removeEmitter(emitterNr);
    118138    }
    119139    void ParticleInterface::removeAllEmitters()
    120140    {
    121         this->particleSystem_->removeAllEmitters();
     141        if (this->particleSystem_)
     142            this->particleSystem_->removeAllEmitters();
    122143    }
    123144    unsigned int ParticleInterface::getNumEmitters() const
    124145    {
    125         return this->particleSystem_->getNumEmitters();
     146        if (this->particleSystem_)
     147            return this->particleSystem_->getNumEmitters();
     148        else
     149            return 0;
    126150    }
    127151
    128152    Ogre::ParticleAffector* ParticleInterface::addAffector(const std::string& name)
    129153    {
    130         return this->particleSystem_->addAffector(name);
     154        if (this->particleSystem_)
     155            return this->particleSystem_->addAffector(name);
     156        else
     157            return 0;
    131158    }
    132159    Ogre::ParticleAffector* ParticleInterface::getAffector(unsigned int affectorNr) const
    133160    {
    134         if (affectorNr < this->particleSystem_->getNumAffectors())
     161        if (this->particleSystem_ && (affectorNr < this->particleSystem_->getNumAffectors()))
    135162            return this->particleSystem_->getAffector(affectorNr);
    136163        else
     
    139166    void ParticleInterface::removeAffector(unsigned int affectorNr)
    140167    {
    141         if (affectorNr < this->particleSystem_->getNumAffectors())
     168        if (this->particleSystem_ && (affectorNr < this->particleSystem_->getNumAffectors()))
    142169            this->particleSystem_->removeAffector(affectorNr);
    143170    }
    144171    void ParticleInterface::removeAllAffectors()
    145172    {
    146         this->particleSystem_->removeAllAffectors();
     173        if (this->particleSystem_)
     174            this->particleSystem_->removeAllAffectors();
    147175    }
    148176    unsigned int ParticleInterface::getNumAffectors() const
    149177    {
    150         return this->particleSystem_->getNumAffectors();
     178        if (this->particleSystem_)
     179            return this->particleSystem_->getNumAffectors();
     180        else
     181            return 0;
    151182    }
    152183
     
    155186        this->bEnabled_ = enable;
    156187
    157         for (unsigned int i = 0; i < this->particleSystem_->getNumEmitters(); i++)
    158             this->particleSystem_->getEmitter(i)->setEnabled(this->bEnabled_ && this->bAllowedByLOD_);
     188        if (this->particleSystem_)
     189            for (unsigned int i = 0; i < this->particleSystem_->getNumEmitters(); i++)
     190                this->particleSystem_->getEmitter(i)->setEnabled(this->bEnabled_ && this->bAllowedByLOD_);
    159191    }
    160192
     
    163195        this->bVisible_ = visible;
    164196
    165         this->particleSystem_->setVisible(this->bVisible_ && this->bAllowedByLOD_);
     197        if (this->particleSystem_)
     198            this->particleSystem_->setVisible(this->bVisible_ && this->bAllowedByLOD_);
    166199    }
    167200
     
    169202    {
    170203        this->detaillevel_ = level;
    171         this->detailLevelChanged(GraphicsEngine::getInstance().getDetailLevelParticle());
     204        if (GraphicsEngine::getInstancePtr())
     205            this->detailLevelChanged(GraphicsEngine::getInstance().getDetailLevelParticle());
    172206    }
    173207
     
    190224    void ParticleInterface::setSpeedFactor(float factor)
    191225    {
    192         //this->particleSystem_->setSpeedFactor(Orxonox::getInstance().getTimeFactor() * factor);
    193         this->particleSystem_->setSpeedFactor(1.0f * factor);
     226        if (this->particleSystem_)
     227        {
     228//            this->particleSystem_->setSpeedFactor(Orxonox::getInstance().getTimeFactor() * factor);
     229            this->particleSystem_->setSpeedFactor(1.0f * factor);
     230        }
    194231    }
    195232    float ParticleInterface::getSpeedFactor() const
    196233    {
    197         //return (this->particleSystem_->getSpeedFactor() / Orxonox::getInstance().getTimeFactor());
    198         return (this->particleSystem_->getSpeedFactor() / 1.0f);
     234        if (this->particleSystem_)
     235        {
     236//            return (this->particleSystem_->getSpeedFactor() / Orxonox::getInstance().getTimeFactor());
     237            return (this->particleSystem_->getSpeedFactor() / 1.0f);
     238        }
     239        else
     240            return 1.0f;
    199241    }
    200242
    201243    bool ParticleInterface::getKeepParticlesInLocalSpace() const
    202244    {
    203         return this->particleSystem_->getKeepParticlesInLocalSpace();
     245        if (this->particleSystem_)
     246            return this->particleSystem_->getKeepParticlesInLocalSpace();
     247        else
     248            return false;
    204249    }
    205250    void ParticleInterface::setKeepParticlesInLocalSpace(bool keep)
    206251    {
    207         this->particleSystem_->setKeepParticlesInLocalSpace(keep);
     252        if (this->particleSystem_)
     253            this->particleSystem_->setKeepParticlesInLocalSpace(keep);
    208254    }
    209255}
  • code/trunk/src/orxonox/tools/Timer.h

    r2087 r2171  
    2828
    2929/*!
    30     @file Timer.h
     30    @file
    3131    @brief Definition and Implementation of the Timer class.
    3232
Note: See TracChangeset for help on using the changeset viewer.