Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 2497


Ignore:
Timestamp:
Dec 17, 2008, 5:41:29 AM (16 years ago)
Author:
landauf
Message:
  • some changes, maybe fixed a crash, not sure
  • fixed strange camera behavior
Location:
code/branches/presentation/src/orxonox/objects
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • code/branches/presentation/src/orxonox/objects/weaponSystem/projectiles/BillboardProjectile.cc

    r2493 r2497  
    3232#include <OgreBillboardSet.h>
    3333
     34#include "core/Core.h"
    3435#include "core/CoreIncludes.h"
    3536#include "objects/Scene.h"
     
    4344        RegisterObject(BillboardProjectile);
    4445
    45         assert(this->getScene()->getSceneManager()); // getScene() was already checked by WorldEntity
     46        if (Core::showsGraphics())
     47        {
     48            assert(this->getScene()->getSceneManager()); // getScene() was already checked by WorldEntity
     49            this->billboard_.setBillboardSet(this->getScene()->getSceneManager(), "Examples/Flare", ColourValue(0.5, 0.5, 0.7, 0.8), 1);
     50            this->attachOgreObject(this->billboard_.getBillboardSet());
     51        }
    4652
    47         this->billboard_.setBillboardSet(this->getScene()->getSceneManager(), "Examples/Flare", ColourValue(0.5, 0.5, 0.7, 0.8), 1);
    48         this->attachOgreObject(this->billboard_.getBillboardSet());
    49         this->scale(0.2);
     53        this->setScale(0.2);
    5054    }
    5155
    5256    BillboardProjectile::~BillboardProjectile()
    5357    {
    54         //if (this->isInitialized() && this->owner_)
    55             //this->detachObject(this->billboard_.getBillboardSet());
     58        if (this->isInitialized() && Core::showsGraphics() && this->billboard_.getBillboardSet())
     59            this->detachOgreObject(this->billboard_.getBillboardSet());
    5660    }
    5761
     
    6468    {
    6569        SUPER(BillboardProjectile, changedVisibility);
     70
    6671        this->billboard_.setVisible(this->isVisible());
    6772    }
  • code/branches/presentation/src/orxonox/objects/weaponSystem/projectiles/ParticleProjectile.cc

    r2493 r2497  
    3333#include <OgreParticleEmitter.h>
    3434
    35 #include "../../worldentities/pawns/SpaceShip.h"
     35#include "core/Core.h"
    3636#include "core/CoreIncludes.h"
    3737#include "core/ConfigValueIncludes.h"
     
    4646        RegisterObject(ParticleProjectile);
    4747
    48         this->particles_ = new ParticleInterface(this->getScene()->getSceneManager(), "Orxonox/shot3_small", LODParticle::normal);
    49         this->attachOgreObject(this->particles_->getParticleSystem());
    50         this->particles_->setKeepParticlesInLocalSpace(0);
     48        if (Core::showsGraphics())
     49        {
     50            this->particles_ = new ParticleInterface(this->getScene()->getSceneManager(), "Orxonox/shot3_small", LODParticle::normal);
     51            this->attachOgreObject(this->particles_->getParticleSystem());
     52            this->particles_->setKeepParticlesInLocalSpace(0);
    5153
    52         this->particles_->getAllEmitters()->setDirection(-WorldEntity::FRONT);
    53         /*
    54         if (this->owner_)
    55         {
     54            this->particles_->getAllEmitters()->setDirection(-WorldEntity::FRONT);
    5655        }
    57 //        else
    58 //        {
    59 //            this->particles_ = 0;
    60 //        }
    61         */
    62 
    63         this->setConfigValues();
     56        else
     57            this->particles_ = 0;
    6458    }
    6559
     
    7367    }
    7468
    75     void ParticleProjectile::setConfigValues()
    76     {
    77         //SetConfigValue(speed_, 5000.0).description("The speed of a projectile in units per second").callback((Projectile*)this, &ParticleProjectile::speedChanged);
    78     }
    79 
    8069    void ParticleProjectile::changedVisibility()
    8170    {
    8271        SUPER(ParticleProjectile, changedVisibility);
    83         this->particles_->setEnabled(this->isVisible());
     72
     73        if (this->particles_)
     74            this->particles_->setEnabled(this->isVisible());
    8475    }
    8576}
  • code/branches/presentation/src/orxonox/objects/weaponSystem/projectiles/ParticleProjectile.h

    r2493 r2497  
    4444            virtual ~ParticleProjectile();
    4545            virtual void changedVisibility();
    46             void setConfigValues();
    4746
    4847        private:
  • code/branches/presentation/src/orxonox/objects/weaponSystem/projectiles/Projectile.cc

    r2494 r2497  
    4040#include "objects/worldentities/Model.h"
    4141#include "objects/worldentities/ParticleSpawner.h"
    42 #include "objects/worldentities/pawns/Pawn.h"
    4342#include "objects/collisionshapes/SphereCollisionShape.h"
    4443#include "core/Core.h"
     
    6362        this->attachCollisionShape(shape);
    6463
    65         if(!Core::isClient()) //only if not on client
     64        if(Core::isMaster())
    6665          this->destroyTimer_.setTimer(this->lifetime_, false, this, createExecutor(createFunctor(&Projectile::destroyObject)));
    6766    }
     
    9190    void Projectile::destroyObject()
    9291    {
    93         delete this;
     92        if (Core::isMaster())
     93            delete this;
    9494    }
    9595
    9696    bool Projectile::collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint)
    9797    {
    98         if (!this->bDestroy_)
     98        if (!this->bDestroy_ && Core::isMaster())
    9999        {
    100100            this->bDestroy_ = true;
    101             Pawn* victim = dynamic_cast<Pawn*>(otherObject);
    102             if (victim)
    103                 victim->damage(this->damage_, this->owner_);
    104 
    105101
    106102            if (this->owner_)
     
    123119                }
    124120            }
     121
     122            Pawn* victim = dynamic_cast<Pawn*>(otherObject);
     123            if (victim)
     124                victim->damage(this->damage_, this->owner_);
    125125        }
    126126        return false;
    127127    }
     128
     129    void Projectile::destroyedPawn(Pawn* pawn)
     130    {
     131        if (this->owner_ == pawn)
     132            this->owner_ = 0;
     133    }
    128134}
  • code/branches/presentation/src/orxonox/objects/weaponSystem/projectiles/Projectile.h

    r2494 r2497  
    3333
    3434#include "objects/worldentities/MovableEntity.h"
     35#include "objects/worldentities/pawns/Pawn.h"
    3536#include "tools/Timer.h"
    3637
    3738namespace orxonox
    3839{
    39     class _OrxonoxExport Projectile : public MovableEntity
     40    class _OrxonoxExport Projectile : public MovableEntity, public PawnListener
    4041    {
    4142        public:
     
    4849            virtual void tick(float dt);
    4950            virtual bool collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint);
     51            virtual void destroyedPawn(Pawn* pawn);
    5052
    5153            inline void setOwner(Pawn* owner)
  • code/branches/presentation/src/orxonox/objects/worldentities/Camera.cc

    r2493 r2497  
    112112            this->cameraNode_->translate(coeff * offset);
    113113
    114             this->cameraNode_->setOrientation(Quaternion::Slerp(coeff, this->cameraNode_->getWorldOrientation(), this->getWorldOrientation(), false));
     114            this->cameraNode_->setOrientation(Quaternion::Slerp(coeff, this->cameraNode_->getWorldOrientation(), this->getWorldOrientation(), true));
    115115            //this->cameraNode_->setOrientation(this->getWorldOrientation());
    116116        }
  • code/branches/presentation/src/orxonox/objects/worldentities/ParticleEmitter.cc

    r2485 r2497  
    102102    {
    103103        if (this->particles_)
     104        {
    104105            delete this->particles_;
     106            this->particles_ = 0;
     107        }
    105108
    106109        if (this->getScene() && this->getScene()->getSceneManager())
     
    119122            }
    120123        }
    121         else
    122             this->particles_ = 0;
    123124    }
    124125
  • code/branches/presentation/src/orxonox/objects/worldentities/WorldEntity.cc

    r2494 r2497  
    104104            this->node_->removeAllChildren();
    105105
     106            if (this->physicalBody_)
     107            {
     108                this->deactivatePhysics();
     109                delete this->physicalBody_;
     110            }
     111            delete this->collisionShape_;
     112
    106113            if (this->getScene()->getSceneManager())
    107114                this->getScene()->getSceneManager()->destroySceneNode(this->node_->getName());
    108 
    109             // TODO: Detach from parent and detach all children.
    110 
    111             if (this->physicalBody_)
    112             {
    113                 this->deactivatePhysics();
    114                 delete this->physicalBody_;
    115             }
    116             delete this->collisionShape_;
    117115        }
    118116    }
Note: See TracChangeset for help on using the changeset viewer.