Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9232 for code/branches


Ignore:
Timestamp:
May 23, 2012, 5:56:57 PM (12 years ago)
Author:
decapitb
Message:

safety checkin

Location:
code/branches/captureTheFlag
Files:
6 edited
2 copied

Legend:

Unmodified
Added
Removed
  • code/branches/captureTheFlag

  • code/branches/captureTheFlag/src/modules/overlays/hud/HUDNavigation.cc

    r9016 r9232  
    3636#include <OgreTextAreaOverlayElement.h>
    3737#include <OgrePanelOverlayElement.h>
     38#include <OgreEntity.h>
    3839
    3940#include "util/Math.h"
     
    4546#include "Radar.h"
    4647#include "graphics/Camera.h"
     48#include "graphics/Model.h"
     49#include "worldentities/MovableEntity.h"
    4750#include "controllers/HumanController.h"
    4851#include "worldentities/pawns/Pawn.h"
     
    8083    this->setNavMarkerSize ( 0.05f );
    8184    this->setDetectionLimit( 10000.0f );
     85
     86    //Ogre::Entity* ent = this->getScene()->getSceneManager()->createEntity("Arrow3D", "Arrow3D.mesh");
     87
     88    Model* arrow = new Model(this);
     89    this->arrowEntity = new MovableEntity(this);
     90    arrow->setMeshSource("Arrow3D.mesh");
     91    arrow->setSyncMode(0);
     92    this->arrowEntity->attach(arrow);
     93    this->arrowEntity->scale(1);
     94    this->arrowEntity->setVisible(true);
     95    this->arrowEntity->setPosition(0, +30, -100);
     96    this->arrowEntity->setSyncMode(0);
     97    this->arrowEntity->attachToNode(this->overlay3d_);
     98    //this->add3DMesh(arrowEntity);
     99
     100    //this->overlay3d_->setPosition(0, 0, 0);
     101    //this->overlay3d_->setVisible(false, true);
     102    this->overlay_->setZOrder(0);
     103    this->overlay_->show();
     104    hideArrow3D();
    82105}
    83106
     
    178201    unsigned int markerCount_ = 0;
    179202    bool closeEnough_ = false; //only display objects that are close enough to be relevant for the player
     203
     204    //for the first element of sortedObjectList_ / the closest waypoint show the Arrow3D
     205    //set the direction of the arrow to the closest waypoint
     206    if(!sortedObjectList_.empty())
     207    {
     208        showArrow3D();
     209                sortedList::iterator firstIt = sortedObjectList_.begin();
     210
     211                Ogre::Vector3 pos1 = camTransform * firstIt->first->getRVWorldPosition();
     212                orxout(user_info, context::events()) << pos1 << endl;
     213                this->arrowEntity->setDirection(1-pos1.x, 1 - pos1.y, 1 - pos1.z);
     214
     215                //this->arrowEntity->rotate(quat);
     216                //this->overlay3d_->setDirection(pos1);
     217    }
     218    else{hideArrow3D();}
     219
    180220
    181221//         for (ObjectMap::iterator it = activeObjectList_.begin(); it != activeObjectList_.end(); ++it)
     
    382422    this->background_->addChild ( text );
    383423
    384     sortedObjectList_.push_front ( std::make_pair ( object, ( unsigned int ) 0 ) );
     424    Ogre::Vector3 temp = object->getWorldEntity()->getPosition();
     425    unsigned int distance = sqrt(temp.x*temp.x+temp.y*temp.y+temp.z*temp.z);
     426
     427
     428
     429    sortedObjectList_.push_front ( std::make_pair ( object, distance ) );
    385430
    386431
     
    445490    }
    446491}
    447 
    448 }
     492void HUDNavigation::showArrow3D()
     493                { this->overlay3d_->setVisible(true, true);}
     494void HUDNavigation::hideArrow3D()
     495                { this->overlay3d_->setVisible(false, true);}
     496
     497
     498}
  • code/branches/captureTheFlag/src/modules/overlays/hud/HUDNavigation.h

    r9016 r9232  
    4242#include "overlays/OrxonoxOverlay.h"
    4343
     44
    4445namespace orxonox
    4546{
     
    5152
    5253    void setConfigValues();
     54
     55
    5356
    5457    virtual void XMLPort ( Element& xmlelement, XMLPort::Mode mode );
     
    8083
    8184    };
     85
     86    void showArrow3D();
     87    void hideArrow3D();
     88
     89    orxonox::MovableEntity* arrowEntity;
    8290
    8391    bool showObject( RadarViewable* rv );
  • code/branches/captureTheFlag/src/modules/pickup/items/FlagPickup.cc

    r9220 r9232  
    3939
    4040#include "pickup/PickupIdentifier.h"
    41 #include "worldentities/pawns/Pawn.h"
    4241
    4342namespace orxonox
    4443{
    45 
    46     /*static*/ const std::string FlagPickup::flagTypeBlue_s = "blue";
    47     /*static*/ const std::string FlagPickup::flagTypeRed_s = "red";
    48     /*static*/ const std::string FlagPickup::flagTypeNeutral_s = "neutral";
    4944
    5045    CreateFactory(FlagPickup);
     
    7671    void FlagPickup::initialize(void)
    7772    {
    78         this->flagType_ = pickupFlagType::0;
     73        this->flagType_ = 0;
    7974
    8075        this->addTarget(ClassIdentifier<Pawn>::getIdentifier());
     
    8782    void FlagPickup::initializeIdentifier(void)
    8883    {
    89         std::string val1 = this->getFlagType();
     84        std::stringstream stream;
     85        int type = this->getFlagType();
     86        stream << type;
     87                std::string val = stream.str();
     88               
    9089        std::string type1 = "flagType";
    91         this->pickupIdentifier_->addParameter(type1, val1);
     90        this->pickupIdentifier_->addParameter(type1, val);
    9291    }
    9392
     
    113112        Returns the falg type as a string.
    114113    */
    115     const std::string& FlagPickup::getFlagType(void) const
     114    const int FlagPickup::getFlagType(void) const
    116115    {
    117         switch(this->getFlagTypeDirect())
    118         {
    119             case pickupFlagType::blue:
    120                 return FlagPickup::flagTypeBlue_s;
    121             case pickupFlagType::red:
    122                 return FlagPickup::flagTypeRed_s;
    123             case pickupFlagType::neutral:
    124                 return FlagPickup::flagTypeNeutral_s;
    125             default:
    126                 orxout(internal_error, context::pickups) << "Invalid flagType in FlagPickup." << endl;
    127                 return BLANKSTRING;
    128         }
    129     }
     116                return this->flagType_;
     117        }
    130118
    131119    /**
     
    135123        The type as a string.
    136124    */
    137     void FlagPickup::setFlagType(std::string type)
     125    void FlagPickup::setFlagType(int type)
    138126    {
    139         if(type == FlagPickup::flagTypeRed_s)
    140             this->setFlagTypeDirect(pickupFlagType::2);
    141         else if(type == FlagPickup::flagTypeBlue_s)
    142             this->setFlagTypeDirect(pickupFlagType::1);
    143         else if(type == FlagPickup::flagTypeNeutral_s)
    144             this->setFlagTypeDirect(pickupFlagType::0);
    145         else
     127        if(type<3){
     128                this->flagType_ = type;
     129        }
     130       
     131        else{
    146132            orxout(internal_error, context::pickups) << "Invalid flagType '" << type << "' in FlagPickup." << endl;
     133        }
    147134    }
    148135
     
    163150           if(this->isUsed())
    164151           {
    165                int team = getTeam(pawn->getPlayer);
    166 
    167                if(this->flagType_ == team){
    168                    if(pawn->hasFlag_){
    169                            teamScore_ = TeamScore_ + 1000;
    170                            pawn->hasFlag_ = false;
    171                    }
    172                this->Pickupable::destroy();
    173                }else{
    174                    pawn->hasFlag_ = true;
    175                }
     152                 this->bPickedUp_ = true;
     153                 this->pickedUpBy_ = pawn;
    176154           }
    177155       }
    178 
    179 
    180156
    181157       /**
     
    196172       }
    197173
    198     int FlagPickup::getTeam(PlayerInfo* player)
    199     {
    200         std::map<PlayerInfo*, int>::const_iterator it_player = this->teamnumbers_.find(player);
    201         if (it_player != this->teamnumbers_.end())
    202             return it_player->second;
    203         else
    204             return -1;
    205     }
    206174
    207 }
    208175
    209176        void FlagPickup::tick(float dt)
     
    213180               Pawn* pawn = this->carrierToPawnHelper();
    214181
    215                    if(pawn->isAlive() && pawn->hasFlag_){
     182                   if(pawn->isAlive() && pawn->hasFlag()){
    216183               this->Pickupable::destroy();
    217184                   }
    218185
    219186           }
     187}
  • code/branches/captureTheFlag/src/modules/pickup/items/FlagPickup.h

    r9220 r9232  
    3737
    3838#include "pickup/PickupPrereqs.h"
     39#include "worldentities/pawns/Pawn.h"
    3940
    4041#include <string>
     
    4243#include "pickup/Pickup.h"
    4344#include "tools/Timer.h"
     45#include "tools/interfaces/Tickable.h"
    4446
    4547
     
    4749/*
    4850    @ingroup PickupItems
    49     */
    50     namespace pickupFlagType
    51     {
    52         enum Value
    53         {
    54             blue, //!< Means that the @ref orxonox::FlagPickup "FlagPickup" is the flag of the blue team.
    55             red, //!< Means that the @ref orxonox::FlagPickup "FlagPickup" is the flag of the red team.
    56                 neutral //!< Means that the @ref orxonox::FlagPickup "FlagPickup" is a neutral flag.
    57         };
    58     }
    59 
    60     /**
     51   
    6152
    6253    @author
     
    7667            virtual void tick(float dt);
    7768
    78             const std::string& getFlagType(void) const; //!< Get the flag type of this pickup.
    79 
    80         int teamScore_;
    81 
     69            const int getFlagType(void) const; //!< Get the flag type of this pickup.
     70           
     71                inline bool isPickedUp() const
     72                        { return this->bPickedUp_; }
     73                inline Pawn* pickedUpBy() const
     74                        { return this->pickedUpBy_; }
     75                       
     76                inline void setPickedUp(bool pickedUp)
     77                { this->bPickedUp_ = pickedUp; }
     78               
     79                inline void ignorePickedUp()
     80                { this->Pickupable::destroy(); }
     81                       
    8282            virtual void changedUsed(void); //!< Is called when the pickup has transited from used to unused or the other way around.
    8383
     
    8989            @param type The type of this pickup as an enum.
    9090            */
    91             inline void setFlagTypeDirect(pickupFlagType::Value type)
     91            inline void setFlagTypeDirect(int type)
    9292                { this->flagType_ = type; }
    93             void setFlagType(std::string type); //!< Set the type of the FlagPickup.
     93            void setFlagType(int type); //!< Set the type of the FlagPickup.
    9494
    9595        private:
    9696            Pawn* carrierToPawnHelper(void); //!< Helper to transform the PickupCarrier to a Pawn, and throw an error message if the conversion fails.
    97             int getTeam(PlayerInfo* player);
    9897            void initialize(void); //!< Initializes the member variables.
    99 
    100             pickupFlagType::Value flagType_; //!< The type of the FlagPickup.
    101 
    102 
    103             //! Strings for the flag types.
    104             static const std::string flagTypeBlue_s;
    105             static const std::string flagTypeRed_s;
    106                 static const std::string flagTypeNeutral_s;
    107 
     98            Pawn* pickedUpBy_;
     99                        int flagType_;
     100                       
     101                        bool bPickedUp_;
     102                       
    108103    };
    109104}
  • code/branches/captureTheFlag/src/orxonox/overlays/OrxonoxOverlay.cc

    r8858 r9232  
    4242#include <OgreTechnique.h>
    4343#include <OgrePass.h>
     44#include <OgreEntity.h>
    4445
    4546#include "util/Convert.h"
     
    8384            "OrxonoxOverlay_background_" + multi_cast<std::string>(hudOverlayCounter_s++)));
    8485        this->overlay_->add2D(this->background_);
     86
     87        overlay3d_ = new Ogre::SceneNode(NULL);
     88        this->overlay_->add3D(overlay3d_);
    8589
    8690        // Get aspect ratio from the render window. Later on, we get informed automatically
     
    448452        tempTx->setColourOperationEx(Ogre::LBX_MODULATE, Ogre::LBS_MANUAL, Ogre::LBS_CURRENT, colour);
    449453    }
     454    void OrxonoxOverlay::add3DMesh(Ogre::Entity* entity)
     455    {
     456        this->overlay3d_->attachObject(entity);
     457    }
     458
    450459}
  • code/branches/captureTheFlag/src/orxonox/overlays/OrxonoxOverlay.h

    r8706 r9232  
    4444#include "core/Super.h"
    4545#include "core/WindowEventListener.h"
     46
    4647
    4748namespace orxonox
     
    186187        virtual void changedOverlayGroup()
    187188            { this->changedVisibility(); }
     189        void add3DMesh(Ogre::Entity* entity);
     190
    188191
    189192    protected:
     
    195198        Ogre::Overlay* overlay_;                   //!< The overlay the entire class is about.
    196199        Ogre::PanelOverlayElement* background_;    //!< Background image (blank per default).
     200        Ogre::SceneNode* overlay3d_;                               //!< The scene where one can add 3D objects to the overlay
    197201
    198202        float windowAspectRatio_;                  //!< Screen.width / screen.height
     
    215219        OverlayGroup* group_;
    216220        Ogre::Pass* backgroundAlphaPass_;
     221
    217222  };
    218223
  • code/branches/captureTheFlag/src/orxonox/worldentities/pawns/Pawn.h

    r9016 r9232  
    161161            inline unsigned int getExplosionChunks() const
    162162                { return this->numexplosionchunks_; }
     163            inline bool hasFlag() const
     164                { return this->hasFlag_; }
     165            inline void setHasFlag(bool hasFlag)
     166                { this->hasFlag_ = hasFlag; }
    163167
    164168            virtual void startLocalHumanControl();
     
    207211            float reloadWaitTime_;
    208212            float reloadWaitCountdown_;
     213            bool hasFlag_;
    209214
    210215            WeakPtr<Pawn> lastHitOriginator_;
Note: See TracChangeset for help on using the changeset viewer.