Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 25, 2009, 10:23:58 PM (14 years ago)
Author:
rgrieder
Message:

Merged presentation2 branch back to trunk.
Major new features:

  • Actual GUI with settings, etc.
  • Improved space ship steering (human interaction)
  • Rocket fire and more particle effects
  • Advanced sound framework
Location:
code/trunk
Files:
14 edited
2 copied

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/orxonox/worldentities/CMakeLists.txt

    r5781 r6417  
    77
    88  BigExplosion.cc
     9  EffectContainer.cc
    910  ExplosionChunk.cc
    1011  CameraPosition.cc
  • code/trunk/src/orxonox/worldentities/ControllableEntity.cc

    r5929 r6417  
    3636#include "core/GameMode.h"
    3737#include "core/XMLPort.h"
     38#include "network/NetworkFunction.h"
    3839
    3940#include "Scene.h"
     
    4748{
    4849    CreateFactory(ControllableEntity);
     50
     51    registerMemberNetworkFunction( ControllableEntity, fire );
     52    registerMemberNetworkFunction( ControllableEntity, setTargetInternal );
    4953
    5054    ControllableEntity::ControllableEntity(BaseObject* creator) : MobileEntity(creator)
     
    6266        this->camera_ = 0;
    6367        this->xmlcontroller_ = 0;
     68        this->controller_ = 0;
    6469        this->reverseCamera_ = 0;
    6570        this->bDestroyWhenPlayerLeft_ = false;
    6671        this->cameraPositionRootNode_ = this->node_->createChildSceneNode();
     72        this->currentCameraPosition_ = 0;
    6773        this->bMouseLook_ = false;
    6874        this->mouseLookSpeed_ = 200;
     
    169175            {
    170176                this->cameraPositions_.front()->attachCamera(this->camera_);
     177                this->currentCameraPosition_ = this->cameraPositions_.front().get();
    171178            }
    172179            else if (this->cameraPositions_.size() > 0)
     
    178185                        ++it;
    179186                        if (it != this->cameraPositions_.end())
     187                        {
    180188                            (*it)->attachCamera(this->camera_);
     189                            this->currentCameraPosition_ = *it;
     190                        }
    181191                        else
     192                        {
    182193                            (*this->cameraPositions_.begin())->attachCamera(this->camera_);
     194                            this->currentCameraPosition_ = *this->cameraPositions_.begin();
     195                        }
    183196                        break;
    184197                    }
     
    188201            {
    189202                this->camera_->attachToNode(this->cameraPositionRootNode_);
     203                this->currentCameraPosition_ = 0;
    190204            }
    191205        }
     
    198212        if (!this->bMouseLook_)
    199213            this->cameraPositionRootNode_->setOrientation(Quaternion::IDENTITY);
     214        if (this->getCamera())
     215        {
     216            if (!this->bMouseLook_&& this->currentCameraPosition_->getDrag())
     217                this->getCamera()->setDrag(true);
     218            else
     219                this->getCamera()->setDrag(false);
     220        }
    200221    }
    201222
     
    216237        if (this->bMouseLook_)
    217238            this->cameraPositionRootNode_->roll(Radian(value.y * this->mouseLookSpeed_), Ogre::Node::TS_LOCAL);
     239    }
     240
     241    void ControllableEntity::fire(unsigned int firemode)
     242    {
     243        if(GameMode::isMaster())
     244        {
     245            this->fired(firemode);
     246        }
     247        else
     248        {
     249            callMemberNetworkFunction(ControllableEntity, fire, this->getObjectID(), 0, firemode);
     250        }
     251    }
     252
     253    void ControllableEntity::setTarget( WorldEntity* target )
     254    {
     255        this->target_ = target;
     256        if ( !GameMode::isMaster() )
     257        {
     258            if ( target != 0 )
     259            {
     260                callMemberNetworkFunction(ControllableEntity, setTargetInternal, this->getObjectID(), 0, target->getObjectID() );
     261            }
     262           else
     263           {
     264                callMemberNetworkFunction(ControllableEntity, setTargetInternal, this->getObjectID(), 0, OBJECTID_UNKNOWN );
     265           }
     266        }
     267    }
     268
     269    void ControllableEntity::setTargetInternal( uint32_t targetID )
     270    {
     271        this->setTarget( orxonox_cast<WorldEntity*>(Synchronisable::getSynchronisable(targetID)) );
    218272    }
    219273
     
    279333            this->camera_ = new Camera(this);
    280334            this->camera_->requestFocus();
    281             if (this->cameraPositionTemplate_ != "")
     335            if (!this->cameraPositionTemplate_.empty())
    282336                this->addTemplate(this->cameraPositionTemplate_);
    283337            if (this->cameraPositions_.size() > 0)
     338            {
    284339                this->cameraPositions_.front()->attachCamera(this->camera_);
     340                this->currentCameraPosition_ = this->cameraPositions_.front();
     341            }
    285342            else
     343            {
    286344                this->camera_->attachToNode(this->cameraPositionRootNode_);
     345                this->currentCameraPosition_ = 0;
     346            }
    287347        }
    288348
    289349        if (!this->hud_ && GameMode::showsGraphics())
    290350        {
    291             if (this->hudtemplate_ != "")
     351            if (!this->hudtemplate_.empty())
    292352            {
    293353                this->hud_ = new OverlayGroup(this);
  • code/trunk/src/orxonox/worldentities/ControllableEntity.h

    r5929 r6417  
    8484                { this->rotateRoll(Vector2(value, 0)); }
    8585
    86             virtual void fire(unsigned int firemode) {}
     86            void fire(unsigned int firemode);
     87            virtual void fired(unsigned int firemode) {}
    8788            virtual void reload() {}
    8889
     
    139140            inline Controller* getXMLController() const
    140141                { return this->xmlcontroller_; }
     142
     143            inline Controller* getController() const
     144                { return this->controller_; }
     145            inline void setController(Controller* val)
     146                { this->controller_ = val; }
     147
     148            virtual void setTarget( WorldEntity* target );
     149            virtual WorldEntity* getTarget()
     150                { return this->target_.get(); }
     151            void setTargetInternal( uint32_t targetID );
    141152
    142153        protected:
     
    199210            Ogre::SceneNode* cameraPositionRootNode_;
    200211            std::list<SmartPtr<CameraPosition> > cameraPositions_;
     212            CameraPosition* currentCameraPosition_;
    201213            std::string cameraPositionTemplate_;
    202214            Controller* xmlcontroller_;
     215            Controller* controller_;
    203216            CameraPosition* reverseCamera_;
     217            WeakPtr<WorldEntity> target_;
    204218    };
    205219}
  • code/trunk/src/orxonox/worldentities/MovableEntity.cc

    r5929 r6417  
    7979            if (victim)
    8080            {
    81                 victim->damage(this->collisionDamage_ * (victim->getVelocity() - this->getVelocity()).length());
     81                float damage = this->collisionDamage_ * (victim->getVelocity() - this->getVelocity()).length();
     82                victim->hit(0, contactPoint, damage);
    8283            }
    8384        }
  • code/trunk/src/orxonox/worldentities/MovableEntity.h

    r5929 r6417  
    7070
    7171            inline void setEnableCollisionDamage(bool c)
    72             { 
    73                 this->enableCollisionDamage_ = c; 
     72            {
     73                this->enableCollisionDamage_ = c;
    7474                this->enableCollisionCallback();
    75             } 
     75            }
    7676
    7777            inline bool getEnableCollisionDamage()
  • code/trunk/src/orxonox/worldentities/StaticEntity.cc

    r5781 r6417  
    4242    {
    4343        RegisterObject(StaticEntity);
    44        
     44
    4545        this->setPriority(Priority::VeryLow);
    4646
  • code/trunk/src/orxonox/worldentities/WorldEntity.cc

    r5929 r6417  
    472472    //! Attaches an Ogre::MovableObject to this WorldEntity.
    473473    void WorldEntity::attachOgreObject(Ogre::MovableObject* object)
    474         { this->node_->attachObject(object); }
     474    {
     475        this->node_->attachObject(object);
     476        object->setUserObject(this);
     477    }
     478
    475479    void WorldEntity::attachOgreObject(Ogre::BillboardSet* object)
    476         { this->node_->attachObject(object); }
     480        { this->attachOgreObject(static_cast<Ogre::MovableObject*>(object)); }
    477481    void WorldEntity::attachOgreObject(Ogre::Camera* object)
    478         { this->node_->attachObject(object); }
     482        { this->attachOgreObject(static_cast<Ogre::MovableObject*>(object)); }
    479483    void WorldEntity::attachOgreObject(Ogre::Entity* object)
    480         { this->node_->attachObject(object); }
     484        { this->attachOgreObject(static_cast<Ogre::MovableObject*>(object)); }
    481485    void WorldEntity::attachOgreObject(Ogre::ParticleSystem* object)
    482         { this->node_->attachObject(object); }
     486        { this->attachOgreObject(static_cast<Ogre::MovableObject*>(object)); }
    483487
    484488    //! Detaches an Ogre::MovableObject from this WorldEntity.
    485489    void WorldEntity::detachOgreObject(Ogre::MovableObject* object)
    486         { this->node_->detachObject(object); }
     490    {
     491        object->setUserObject(NULL);
     492        this->node_->detachObject(object);
     493    }
     494
    487495    void WorldEntity::detachOgreObject(Ogre::BillboardSet* object)
    488         { this->node_->detachObject(object); }
     496        { this->detachOgreObject(static_cast<Ogre::MovableObject*>(object)); }
    489497    void WorldEntity::detachOgreObject(Ogre::Camera* object)
    490         { this->node_->detachObject(object); }
     498        { this->detachOgreObject(static_cast<Ogre::MovableObject*>(object)); }
    491499    void WorldEntity::detachOgreObject(Ogre::Entity* object)
    492         { this->node_->detachObject(object); }
     500        { this->detachOgreObject(static_cast<Ogre::MovableObject*>(object)); }
    493501    void WorldEntity::detachOgreObject(Ogre::ParticleSystem* object)
    494         { this->node_->detachObject(object); }
     502        { this->detachOgreObject(static_cast<Ogre::MovableObject*>(object)); }
    495503
    496504    //! Detaches an Ogre::MovableObject (by string) from this WorldEntity.
     
    646654    /**
    647655    @brief
    648         Makes this WorldEntity look a specific target location.
     656        Makes this WorldEntity look at a specific target location.
    649657    @param relativeTo
    650658        @see WorldEntity::TransformSpace
     
    806814    void WorldEntity::setCollisionTypeStr(const std::string& typeStr)
    807815    {
    808         std::string typeStrLower = getLowercase(typeStr);
     816        const std::string& typeStrLower = getLowercase(typeStr);
    809817        CollisionType type;
    810818        if (typeStrLower == "dynamic")
     
    913921    }
    914922
    915     //! Copies our own parameters for restitution, angular factor, dampings and friction to the bullet rigid body.
     923    //! Copies our own parameters for restitution, angular factor, damping and friction to the bullet rigid body.
    916924    void WorldEntity::internalSetPhysicsProps()
    917925    {
  • code/trunk/src/orxonox/worldentities/WorldEntity.h

    r5781 r6417  
    3333#include "OrxonoxPrereqs.h"
    3434
     35#include <OgreUserDefinedObject.h>
    3536#ifdef ORXONOX_RELEASE
    3637#  include <OgreSceneNode.h>
     
    5556
    5657        The basic task of the WorldEntity is provide a location, a direction and a scaling and the possibility
    57         to create an entire hierarchy of derivated objects.
     58        to create an entire hierarchy of derived objects.
    5859        It is also the basis for the physics interface to the Bullet physics engine.
    5960        Every WorldEntity can have a specific collision type: @see CollisionType
     
    6364        There is also support for attaching WorldEntities with physics to each other. Currently, the collision shape
    6465        of both objects simply get merged into one larger shape (for static collision type).
    65         The phyiscal body that is internally stored and administrated has the following supported properties:
    66         - Restitution, angular factor, linear damping, angular damping, fricition, mass and collision shape.
     66        The physical body that is internally stored and administrated has the following supported properties:
     67        - Restitution, angular factor, linear damping, angular damping, friction, mass and collision shape.
    6768        You can get more information at the corresponding set function.
    6869
    6970        Collision shapes: These are controlled by the internal WorldEntityCollisionShape. @see WorldEntityCollisionShape.
    7071    */
    71     class _OrxonoxExport WorldEntity : public BaseObject, public Synchronisable, public btMotionState
     72    class _OrxonoxExport WorldEntity : public BaseObject, public Synchronisable, public btMotionState, public Ogre::UserDefinedObject
    7273    {
    7374        friend class Scene;
     
    318319                Sets an artificial parameter that tells how much torque is applied when you apply a non-central force.
    319320
    320                 Normally the angular factor is 1, which means it's physically 'correct'. Howerver if you have a player
     321                Normally the angular factor is 1, which means it's physically 'correct'. However if you have a player
    321322                character that should not rotate when hit sideways, you can set the angular factor to 0.
    322323            */
     
    394395                You can override this function in a derived class to constrain the collision to e.g. None or Dynamic.
    395396                A projectile may not prove very useful if there is no physical body. Simply set the CollisionType
    396                 in its constructor and override this method. But be careful that a derived classe's virtual functions
     397                in its constructor and override this method. But be careful that a derived class's virtual functions
    397398                don't yet exist in the constructor if a base class.
    398399            */
  • code/trunk/src/orxonox/worldentities/pawns/Pawn.cc

    r5929 r6417  
    3838#include "PawnManager.h"
    3939#include "infos/PlayerInfo.h"
     40#include "controllers/Controller.h"
    4041#include "gametypes/Gametype.h"
    4142#include "graphics/ParticleSpawner.h"
     
    5253    CreateFactory(Pawn);
    5354
    54     registerMemberNetworkFunction( Pawn, doFire );
    55 
    5655    Pawn::Pawn(BaseObject* creator) : ControllableEntity(creator)
    5756    {
     
    6968
    7069        this->spawnparticleduration_ = 3.0f;
     70
     71        this->aimPosition_ = Vector3::ZERO;
    7172
    7273        this->getPickups().setOwner(this);
     
    110111        XMLPortObject(Pawn, WeaponSlot, "weaponslots", addWeaponSlot, getWeaponSlot, xmlelement, mode);
    111112        XMLPortObject(Pawn, WeaponSet, "weaponsets", addWeaponSet, getWeaponSet, xmlelement, mode);
    112         XMLPortObject(Pawn, WeaponPack, "weapons", addWeaponPack, getWeaponPack, xmlelement, mode);
     113        XMLPortObject(Pawn, WeaponPack, "weapons", addWeaponPackXML, getWeaponPack, xmlelement, mode);
    113114    }
    114115
     
    119120        registerVariable(this->initialHealth_, VariableDirection::ToClient);
    120121        registerVariable(this->bReload_,       VariableDirection::ToServer);
     122        registerVariable(this->aimPosition_,   Bidirectionality::ServerMaster, 0, true);
    121123    }
    122124
     
    166168    void Pawn::hit(Pawn* originator, const Vector3& force, float damage)
    167169    {
    168         if (this->getGametype() && this->getGametype()->allowPawnHit(this, originator))
     170        if (this->getGametype() && this->getGametype()->allowPawnHit(this, originator) && (!this->getController() || !this->getController()->getGodMode()) )
    169171        {
    170172            this->damage(damage, originator);
     
    175177    }
    176178
     179    void Pawn::hit(Pawn* originator, btManifoldPoint& contactpoint, float damage)
     180    {
     181        if (this->getGametype() && this->getGametype()->allowPawnHit(this, originator) && (!this->getController() || !this->getController()->getGodMode()) )
     182        {
     183            this->damage(damage, originator);
     184
     185            if ( this->getController() )
     186                this->getController()->hit(originator, contactpoint, damage);
     187
     188            // play hit effect
     189        }
     190    }
     191
    177192    void Pawn::kill()
    178193    {
     
    184199    {
    185200        // play spawn effect
    186         if (this->spawnparticlesource_ != "")
     201        if (!this->spawnparticlesource_.empty())
    187202        {
    188203            ParticleSpawner* effect = new ParticleSpawner(this->getCreator());
     
    263278    }
    264279
    265     void Pawn::fire(unsigned int firemode)
    266     {
    267         this->doFire(firemode);
    268     }
    269 
    270     void Pawn::doFire(uint8_t firemode)
    271     {
    272         if(GameMode::isMaster())
    273         {
    274             if (this->weaponSystem_)
    275                 this->weaponSystem_->fire(firemode);
    276         }
    277         else
    278         {
    279             callMemberNetworkFunction(Pawn, doFire, this->getObjectID(), 0, firemode);
    280             if (this->weaponSystem_)
    281                 this->weaponSystem_->fire(firemode);
    282         }
     280    void Pawn::fired(unsigned int firemode)
     281    {
     282        if (this->weaponSystem_)
     283            this->weaponSystem_->fire(firemode);
    283284    }
    284285
     
    341342    }
    342343
     344    void Pawn::addWeaponPackXML(WeaponPack * wPack)
     345    {
     346        if (this->weaponSystem_)
     347            if (!this->weaponSystem_->addWeaponPack(wPack))
     348                wPack->destroy();
     349    }
     350
    343351    WeaponPack * Pawn::getWeaponPack(unsigned int index) const
    344352    {
  • code/trunk/src/orxonox/worldentities/pawns/Pawn.h

    r5781 r6417  
    7575                { return this->lastHitOriginator_; }
    7676
    77             virtual void damage(float damage, Pawn* originator = 0);
    7877            virtual void hit(Pawn* originator, const Vector3& force, float damage);
     78            virtual void hit(Pawn* originator, btManifoldPoint& contactpoint, float damage);
    7979            virtual void kill();
    8080
    81             virtual void fire(unsigned int firemode);
     81            virtual void fired(unsigned int firemode);
    8282            virtual void reload();
    83             virtual void doFire(uint8_t firemode);
    8483            virtual void postSpawn();
    8584
     
    8988            WeaponSet * getWeaponSet(unsigned int index) const;
    9089            void addWeaponPack(WeaponPack * wPack);
     90            void addWeaponPackXML(WeaponPack * wPack);
    9191            WeaponPack * getWeaponPack(unsigned int index) const;
    9292
     
    117117            virtual void startLocalHumanControl();
    118118
     119            void setAimPosition( Vector3 position )
     120                { this->aimPosition_ = position; }
     121            Vector3 getAimPosition()
     122                { return this->aimPosition_; }
     123
    119124        protected:
    120125            virtual void setPlayer(PlayerInfo* player);
     
    125130            virtual void deatheffect();
    126131            virtual void spawneffect();
     132
     133            virtual void damage(float damage, Pawn* originator = 0);
    127134
    128135            bool bAlive_;
     
    146153            inline void setWeaponSystem(WeaponSystem* weaponsystem)
    147154                { this->weaponSystem_ = weaponsystem; }
     155
     156            Vector3 aimPosition_;
    148157    };
    149158}
  • code/trunk/src/orxonox/worldentities/pawns/SpaceShip.cc

    r5929 r6417  
    187187    void SpaceShip::loadEngineTemplate()
    188188    {
    189         if (this->enginetemplate_ != "")
     189        if (!this->enginetemplate_.empty())
    190190        {
    191191            Template* temp = Template::getTemplate(this->enginetemplate_);
  • code/trunk/src/orxonox/worldentities/pawns/Spectator.cc

    r5929 r6417  
    189189    }
    190190
    191     void Spectator::fire(unsigned int firemode)
     191    void Spectator::fired(unsigned int firemode)
    192192    {
    193193        if (this->getPlayer())
  • code/trunk/src/orxonox/worldentities/pawns/Spectator.h

    r5781 r6417  
    5555            virtual void rotateRoll(const Vector2& value);
    5656
    57             virtual void fire(unsigned int firemode);
     57            virtual void fired(unsigned int firemode);
    5858            virtual void greet();
    5959
Note: See TracChangeset for help on using the changeset viewer.