[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 | |
---|
| 43 | namespace orxonox |
---|
| 44 | { |
---|
| 45 | RegisterClass(HoverFlag); |
---|
| 46 | |
---|
| 47 | HoverFlag::HoverFlag(Context* context) : StaticEntity(context) |
---|
| 48 | { |
---|
| 49 | RegisterObject(HoverFlag); |
---|
| 50 | model_ = NULL; |
---|
| 51 | cs_ = NULL; |
---|
| 52 | } |
---|
| 53 | |
---|
[10930] | 54 | /** |
---|
| 55 | @brief |
---|
| 56 | Constructor that expects two coordinate-values in the range 0-9 |
---|
| 57 | @param xCoordinate |
---|
| 58 | X-Coordinate of the flage, 0-9, origin is bottom left |
---|
| 59 | @param yCoordinate |
---|
| 60 | Y-Coordinate of the flage, 0-9, origin is bottom left |
---|
| 61 | */ |
---|
[11040] | 62 | HoverFlag::HoverFlag(Context* context, int xCoordinate, int yCoordinate, int cellSize) : StaticEntity(context) |
---|
[10894] | 63 | { |
---|
| 64 | RegisterObject(HoverFlag); |
---|
| 65 | enableCollisionCallback(); |
---|
| 66 | model_ = NULL; |
---|
| 67 | cs_ = NULL; |
---|
| 68 | |
---|
| 69 | model_ = new Model(context); |
---|
| 70 | model_->setMeshSource("ss_flag_eu.mesh"); |
---|
| 71 | model_->setScale3D(Vector3(5, 5, 5)); |
---|
[11040] | 72 | model_->setPosition(Vector3(xCoordinate*cellSize*1.0f + cellSize/2,10.0f,yCoordinate*cellSize*1.0f + cellSize/2)); |
---|
[10894] | 73 | |
---|
| 74 | this->attach(model_); |
---|
| 75 | |
---|
| 76 | this->enableCollisionCallback(); |
---|
| 77 | this->setCollisionResponse(true); |
---|
| 78 | this->setCollisionType(Static); |
---|
| 79 | |
---|
| 80 | cs_ = new BoxCollisionShape(context); |
---|
| 81 | cs_->setHalfExtents(Vector3(5, 5, 5)); |
---|
[11040] | 82 | cs_->setPosition(Vector3(xCoordinate*cellSize*1.0f + cellSize/2,0.0f,yCoordinate*cellSize*1.0f + cellSize/2)); |
---|
[10894] | 83 | |
---|
| 84 | this->attachCollisionShape(cs_); |
---|
| 85 | this->collided_ = false; |
---|
| 86 | |
---|
| 87 | } |
---|
| 88 | |
---|
| 89 | /** |
---|
| 90 | @brief |
---|
| 91 | Destructor. |
---|
| 92 | */ |
---|
| 93 | HoverFlag::~HoverFlag() |
---|
| 94 | { |
---|
| 95 | |
---|
| 96 | } |
---|
| 97 | |
---|
| 98 | /** |
---|
| 99 | @brief |
---|
[10930] | 100 | Checks if the Hovership collided with the flag |
---|
| 101 | */ |
---|
[10894] | 102 | bool HoverFlag::collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint) |
---|
| 103 | { |
---|
[10928] | 104 | if(otherObject->isA(Class(HoverShip))) |
---|
[10894] | 105 | collided_ = true; |
---|
| 106 | return false; |
---|
| 107 | } |
---|
| 108 | } |
---|