Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/modules/hover/HoverFlag.cc @ 11677

Last change on this file since 11677 was 11495, checked in by patricwi, 7 years ago

reverted commit from merge with tgidronFS16 because failed to compile

  • Property svn:eol-style set to native
File size: 3.1 KB
RevLine 
[10894]1/*
2 *   ORXONOX - the hottest 3D action shooter ever to exist
3 *                    > www.orxonox.net <
4 *
5 *
6 *   License notice:
7 *
8 *   This program is free software; you can redistribute it and/or
9 *   modify it under the terms of the GNU General Public License
10 *   as published by the Free Software Foundation; either version 2
11 *   of the License, or (at your option) any later version.
12 *
13 *   This program is distributed in the hope that it will be useful,
14 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 *   GNU General Public License for more details.
17 *
18 *   You should have received a copy of the GNU General Public License
19 *   along with this program; if not, write to the Free Software
20 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21 *
22 *   Author:
[10930]23 *      Manuel Meier
[10894]24 *   Co-authors:
25 *      ...
26 *
27 */
28
29/**
30    @file HoverFlag.cc
[10930]31    @brief The Flags that are being set in the Hover Minigame They support two coordinates from 0-9 each
[10894]32*/
33
34#include "HoverFlag.h"
35#include "HoverShip.h"
36
37#include "core/CoreIncludes.h"
[11041]38
[10894]39#include "graphics/Model.h"
[11041]40#include "objects/collisionshapes/BoxCollisionShape.h"
[10894]41#include "core/XMLPort.h"
42
43namespace orxonox
44{
45    RegisterClass(HoverFlag);
46
47    HoverFlag::HoverFlag(Context* context) : StaticEntity(context)
48    {
49        RegisterObject(HoverFlag);
[11042]50
[11071]51        this->model_ = nullptr;
52        this->cs_ = nullptr;
[11042]53        this->collided_ = false;
54
55        this->enableCollisionCallback();
56        this->setCollisionResponse(true);
[11071]57        this->setCollisionType(CollisionType::Static);
[10894]58    }
59
[10930]60    /**
61    @brief
[11043]62        Destructor.
63    */
64    HoverFlag::~HoverFlag()
65    {
66        if (this->isInitialized())
67        {
68            if (this->model_)
69                this->model_->destroy();
70            if (this->cs_)
71                this->cs_->destroy();
72        }
73    }
74
75    /**
76    @brief
[11042]77        Initializes the flag.
[10930]78    @param xCoordinate
79        X-Coordinate of the flage, 0-9, origin is bottom left
80    @param yCoordinate
81        Y-Coordinate of the flage, 0-9, origin is bottom left
[11099]82    @param cellSize
83        The size of the cells
[10930]84    */
[11042]85    void HoverFlag::init(int xCoordinate, int yCoordinate, int cellSize)
[10894]86    {
[11042]87        model_ = new Model(this->getContext());
[10894]88        model_->setMeshSource("ss_flag_eu.mesh");
[11495]89        model_->setScale3D(Vector3(5, 5, 5));
90        model_->setPosition(Vector3(xCoordinate*cellSize*1.0f + cellSize/2,10.0f,yCoordinate*cellSize*1.0f + cellSize/2));
[10894]91
92        this->attach(model_);
93
[11042]94        cs_ = new BoxCollisionShape(this->getContext());
[11495]95        cs_->setHalfExtents(Vector3(5, 5, 5));
[11040]96        cs_->setPosition(Vector3(xCoordinate*cellSize*1.0f + cellSize/2,0.0f,yCoordinate*cellSize*1.0f + cellSize/2));
[10894]97
98        this->attachCollisionShape(cs_);
99    }
100
101    /**
102    @brief
[10930]103        Checks if the Hovership collided with the flag
104    */
[10894]105    bool HoverFlag::collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint)
106    {
[10928]107        if(otherObject->isA(Class(HoverShip)))
[10894]108            collided_ = true;
109        return false;
110    }
111}
Note: See TracBrowser for help on using the repository browser.