Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 25, 2009, 1:18:03 PM (15 years ago)
Author:
dafrick
Message:

Merged presentation2 branch into pickup2 branch.

Location:
code/branches/pickup2
Files:
14 edited
2 copied

Legend:

Unmodified
Added
Removed
  • code/branches/pickup2

  • code/branches/pickup2/src/orxonox/worldentities/CMakeLists.txt

    r5781 r6412  
    77
    88  BigExplosion.cc
     9  EffectContainer.cc
    910  ExplosionChunk.cc
    1011  CameraPosition.cc
  • code/branches/pickup2/src/orxonox/worldentities/ControllableEntity.cc

    r5929 r6412  
    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/branches/pickup2/src/orxonox/worldentities/ControllableEntity.h

    r5929 r6412  
    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/branches/pickup2/src/orxonox/worldentities/MovableEntity.cc

    r5929 r6412  
    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/branches/pickup2/src/orxonox/worldentities/MovableEntity.h

    r5929 r6412  
    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/branches/pickup2/src/orxonox/worldentities/StaticEntity.cc

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

    r5929 r6412  
    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/branches/pickup2/src/orxonox/worldentities/WorldEntity.h

    r5781 r6412  
    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/branches/pickup2/src/orxonox/worldentities/pawns/Pawn.cc

    r6405 r6412  
    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        //TODO: Remove.
     
    111112        XMLPortObject(Pawn, WeaponSlot, "weaponslots", addWeaponSlot, getWeaponSlot, xmlelement, mode);
    112113        XMLPortObject(Pawn, WeaponSet, "weaponsets", addWeaponSet, getWeaponSet, xmlelement, mode);
    113         XMLPortObject(Pawn, WeaponPack, "weapons", addWeaponPack, getWeaponPack, xmlelement, mode);
     114        XMLPortObject(Pawn, WeaponPack, "weapons", addWeaponPackXML, getWeaponPack, xmlelement, mode);
    114115    }
    115116
     
    120121        registerVariable(this->initialHealth_, VariableDirection::ToClient);
    121122        registerVariable(this->bReload_,       VariableDirection::ToServer);
     123        registerVariable(this->aimPosition_,   Bidirectionality::ServerMaster, 0, true);
    122124    }
    123125
     
    167169    void Pawn::hit(Pawn* originator, const Vector3& force, float damage)
    168170    {
    169         if (this->getGametype() && this->getGametype()->allowPawnHit(this, originator))
     171        if (this->getGametype() && this->getGametype()->allowPawnHit(this, originator) && (!this->getController() || !this->getController()->getGodMode()) )
    170172        {
    171173            this->damage(damage, originator);
     
    176178    }
    177179
     180    void Pawn::hit(Pawn* originator, btManifoldPoint& contactpoint, float damage)
     181    {
     182        if (this->getGametype() && this->getGametype()->allowPawnHit(this, originator) && (!this->getController() || !this->getController()->getGodMode()) )
     183        {
     184            this->damage(damage, originator);
     185
     186            if ( this->getController() )
     187                this->getController()->hit(originator, contactpoint, damage);
     188
     189            // play hit effect
     190        }
     191    }
     192
    178193    void Pawn::kill()
    179194    {
     
    185200    {
    186201        // play spawn effect
    187         if (this->spawnparticlesource_ != "")
     202        if (!this->spawnparticlesource_.empty())
    188203        {
    189204            ParticleSpawner* effect = new ParticleSpawner(this->getCreator());
     
    264279    }
    265280
    266     void Pawn::fire(unsigned int firemode)
    267     {
    268         this->doFire(firemode);
    269     }
    270 
    271     void Pawn::doFire(uint8_t firemode)
    272     {
    273         if(GameMode::isMaster())
    274         {
    275             if (this->weaponSystem_)
    276                 this->weaponSystem_->fire(firemode);
    277         }
    278         else
    279         {
    280             callMemberNetworkFunction(Pawn, doFire, this->getObjectID(), 0, firemode);
    281             if (this->weaponSystem_)
    282                 this->weaponSystem_->fire(firemode);
    283         }
     281    void Pawn::fired(unsigned int firemode)
     282    {
     283        if (this->weaponSystem_)
     284            this->weaponSystem_->fire(firemode);
    284285    }
    285286
     
    343344    }
    344345
     346    void Pawn::addWeaponPackXML(WeaponPack * wPack)
     347    {
     348        if (this->weaponSystem_)
     349            if (!this->weaponSystem_->addWeaponPack(wPack))
     350                wPack->destroy();
     351    }
     352
    345353    WeaponPack * Pawn::getWeaponPack(unsigned int index) const
    346354    {
  • code/branches/pickup2/src/orxonox/worldentities/pawns/Pawn.h

    r6405 r6412  
    7676                { return this->lastHitOriginator_; }
    7777
    78             virtual void damage(float damage, Pawn* originator = 0);
    7978            virtual void hit(Pawn* originator, const Vector3& force, float damage);
     79            virtual void hit(Pawn* originator, btManifoldPoint& contactpoint, float damage);
    8080            virtual void kill();
    8181
    82             virtual void fire(unsigned int firemode);
     82            virtual void fired(unsigned int firemode);
    8383            virtual void reload();
    84             virtual void doFire(uint8_t firemode);
    8584            virtual void postSpawn();
    8685
     
    9089            WeaponSet * getWeaponSet(unsigned int index) const;
    9190            void addWeaponPack(WeaponPack * wPack);
     91            void addWeaponPackXML(WeaponPack * wPack);
    9292            WeaponPack * getWeaponPack(unsigned int index) const;
    9393
     
    119119            virtual void startLocalHumanControl();
    120120
     121            void setAimPosition( Vector3 position )
     122                { this->aimPosition_ = position; }
     123            Vector3 getAimPosition()
     124                { return this->aimPosition_; }
     125
    121126        protected:
    122127            virtual void setPlayer(PlayerInfo* player);
     
    127132            virtual void deatheffect();
    128133            virtual void spawneffect();
     134
     135            virtual void damage(float damage, Pawn* originator = 0);
    129136
    130137            bool bAlive_;
     
    149156            inline void setWeaponSystem(WeaponSystem* weaponsystem)
    150157                { this->weaponSystem_ = weaponsystem; }
     158
     159            Vector3 aimPosition_;
    151160    };
    152161}
  • code/branches/pickup2/src/orxonox/worldentities/pawns/SpaceShip.cc

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

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

    r5781 r6412  
    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.