Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 21, 2013, 11:16:54 PM (10 years ago)
Author:
jo
Message:

presentationHS13 branch merged into trunk

Location:
code/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/orxonox/worldentities/BigExplosion.cc

    r9667 r9939  
    4343    RegisterClass(BigExplosion);
    4444
    45     BigExplosion::BigExplosion(Context* context) : StaticEntity(context)
     45    BigExplosion::BigExplosion(Context* context) : MobileEntity(context)
    4646    {
    4747        RegisterObject(BigExplosion);
     48
     49        if ( GameMode::showsGraphics() && ( !this->getScene() || !this->getScene()->getSceneManager() ) )
     50            ThrowException(AbortLoading, "Can't create BigExplosion, no scene or no scene manager given.");
     51
     52        this->bStop_ = false;
     53        this->LOD_ = LODParticle::Normal;
     54
     55        if ( GameMode::showsGraphics() )
     56        {
     57            try
     58            {
     59                this->init();
     60            }
     61            catch (const std::exception& ex)
     62            {
     63                orxout(internal_error) << "Couldn't load particle effect in BigExplosion: " << ex.what() << endl;
     64                this->initZero();
     65            }
     66        }
     67        else
     68        {
     69            this->initZero();
     70        }
     71
     72        if (GameMode::isMaster())
     73        {
     74            this->destroyTimer_.setTimer(rnd(2, 4), false, createExecutor(createFunctor(&BigExplosion::stop, this)));
     75        }
     76
     77        this->registerVariables();
     78    }
     79
     80    BigExplosion::BigExplosion(Context* context, Vector3 initVelocity) : MobileEntity(context)
     81    {
     82        RegisterObject(BigExplosion);
     83        this->setVelocity(initVelocity);
    4884
    4985        if ( GameMode::showsGraphics() && ( !this->getScene() || !this->getScene()->getSceneManager() ) )
     
    100136        this->debris4_->setSyncMode(0);
    101137
    102         this->explosion_ = new StaticEntity(this->getContext());
     138        this->explosion_ = new MobileEntity(this->getContext());
    103139        this->explosion_->setSyncMode(0);
    104140
     
    148184        this->debrisEntity4_->attach(debris4_);
    149185
     186        // ///////////////////////
     187        // TODO: particleSpawner is a static entity. It should probably be dynamic, for better explosions.
     188        //
    150189        ParticleSpawner* effect = new ParticleSpawner(this->getContext());
     190        orxout() << "vel " << this->getVelocity() << endl;
     191        // effect->setVelocity(this->getVelocity());
    151192        effect->setDestroyAfterLife(true);
    152193        effect->setSource("Orxonox/explosion2b");
     
    155196
    156197        ParticleSpawner* effect2 = new ParticleSpawner(this->getContext());
     198        // effect2->setVelocity(Vector3(rnd(-1, 1), rnd(-1, 1), rnd(-1, 1))*rnd(10, 200));
    157199        effect2->setDestroyAfterLife(true);
    158200        effect2->setSource("Orxonox/smoke6");
  • code/trunk/src/orxonox/worldentities/BigExplosion.h

    r9667 r9939  
    2222 *   Author:
    2323 *      Benjamin de Capitani
    24  *   Co-authors:
     24 *   Co-authors:§
    2525 *      ...
    2626 *
     
    3333
    3434#include "tools/Timer.h"
    35 #include "StaticEntity.h"
     35#include "MobileEntity.h"
    3636
    3737namespace orxonox
    3838{
    39     class _OrxonoxExport BigExplosion : public StaticEntity
     39    class _OrxonoxExport BigExplosion : public MobileEntity
    4040    {
    4141        public:
    4242            BigExplosion(Context* context);
     43            BigExplosion(Context* context, Vector3 initVelocity);
    4344            virtual ~BigExplosion();
    4445
     
    6061            bool                  bStop_;
    6162
    62             StaticEntity*         explosion_;
     63            MobileEntity*         explosion_;
    6364
    6465            MovableEntity*        debrisEntity1_;
  • code/trunk/src/orxonox/worldentities/pawns/Pawn.cc

    r9667 r9939  
    4646#include "weaponsystem/WeaponPack.h"
    4747#include "weaponsystem/WeaponSet.h"
     48#include "sound/WorldSound.h"
    4849
    4950#include "controllers/FormationController.h"
     
    100101
    101102        this->setSyncMode(ObjectDirection::Bidirectional); // needed to synchronise e.g. aimposition
     103
     104        if (GameMode::isMaster())
     105        {
     106            this->explosionSound_ = new WorldSound(this->getContext());
     107            this->explosionSound_->setVolume(1.0f);
     108        }
     109        else
     110        {
     111            this->explosionSound_ = 0;
     112        }
    102113    }
    103114
     
    109120                this->weaponSystem_->destroy();
    110121        }
     122
    111123    }
    112124
     
    135147        XMLPortParam(Pawn, "reloadwaittime", setReloadWaitTime, getReloadWaitTime, xmlelement, mode).defaultValues(1.0f);
    136148
     149        XMLPortParam(Pawn, "explosionSound",  setExplosionSound,  getExplosionSound,  xmlelement, mode);
     150
    137151        XMLPortParam ( RadarViewable, "radarname", setRadarName, getRadarName, xmlelement, mode );
    138152    }
     153
    139154
    140155    void Pawn::registerVariables()
     
    290305    void Pawn::kill()
    291306    {
    292         this->damage(this->health_);
     307        this->damage(this->health_);
    293308        this->death();
    294309    }
     
    314329        if (this->getGametype() && this->getGametype()->allowPawnDeath(this, this->lastHitOriginator_))
    315330        {
    316             // Set bAlive_ to false and wait for PawnManager to do the destruction
     331            explosionSound_->play();
     332                // Set bAlive_ to false and wait for PawnManager to do the destruction
    317333            this->bAlive_ = false;
    318334
     
    365381        this->setDestroyWhenPlayerLeft(false);
    366382
    367         BigExplosion* chunk = new BigExplosion(this->getContext());
     383        orxout() << "big explosion: " << this->getVelocity() << endl;
     384        BigExplosion* chunk = new BigExplosion(this->getContext(), this->getVelocity());
    368385        chunk->setPosition(this->getPosition());
     386        // chunk->setVelocity(this->getVelocity());
    369387
    370388    }
     
    376394            effect->setPosition(this->getPosition());
    377395            effect->setOrientation(this->getOrientation());
     396            effect->setVelocity(this->getVelocity());
    378397            effect->setDestroyAfterLife(true);
    379398            effect->setSource("Orxonox/explosion2b");
     
    384403            effect->setPosition(this->getPosition());
    385404            effect->setOrientation(this->getOrientation());
     405            effect->setVelocity(this->getVelocity());
    386406            effect->setDestroyAfterLife(true);
    387407            effect->setSource("Orxonox/smoke6");
     
    392412            effect->setPosition(this->getPosition());
    393413            effect->setOrientation(this->getOrientation());
     414            effect->setVelocity(this->getVelocity());
    394415            effect->setDestroyAfterLife(true);
    395416            effect->setSource("Orxonox/sparks");
     
    527548
    528549
     550    void Pawn::setExplosionSound(const std::string &explosionSound)
     551    {
     552        if(explosionSound_ )
     553            explosionSound_->setSource(explosionSound);
     554        else
     555            assert(0); // This should never happen, because soundpointer is only available on master
     556    }
     557
     558    const std::string& Pawn::getExplosionSound()
     559    {
     560        if( explosionSound_ )
     561            return explosionSound_->getSource();
     562        else
     563            assert(0);
     564        return BLANKSTRING;
     565    }
     566
    529567
    530568}
  • code/trunk/src/orxonox/worldentities/pawns/Pawn.h

    r9667 r9939  
    3636#include "interfaces/RadarViewable.h"
    3737#include "worldentities/ControllableEntity.h"
     38
    3839
    3940namespace orxonox // tolua_export
     
    178179            virtual void changedVisibility();
    179180
     181            void setExplosionSound(const std::string& engineSound);
     182            const std::string& getExplosionSound();
     183
    180184        protected:
    181185            virtual void preDestroy();
     
    231235
    232236            Vector3 aimPosition_;
     237
     238            WorldSound* explosionSound_;
     239
    233240    }; // tolua_export
    234241} // tolua_export
Note: See TracChangeset for help on using the changeset viewer.