/* * ORXONOX - the hottest 3D action shooter ever to exist * > www.orxonox.net < * * * License notice: * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * Author: * Manuel Meier * Co-authors: * ... * */ /** @file OrxoKartFlag.cc @brief The Flags that are being set in the OrxoKart Minigame They support two coordinates from 0-9 each */ #include "OrxoKartFlag.h" #include "OrxoKartKart.h" #include "core/CoreIncludes.h" #include "graphics/Model.h" #include "objects/collisionshapes/BoxCollisionShape.h" #include "core/XMLPort.h" namespace orxonox { RegisterClass(OrxoKartFlag); OrxoKartFlag::OrxoKartFlag(Context* context) : StaticEntity(context) { RegisterObject(OrxoKartFlag); this->model_ = nullptr; this->cs_ = nullptr; this->collided_ = false; this->kartCollider = nullptr; this->enableCollisionCallback(); this->setCollisionResponse(true); this->setCollisionType(CollisionType::Static); } /** @brief Destructor. */ OrxoKartFlag::~OrxoKartFlag() { if (this->isInitialized()) { if (this->model_) this->model_->destroy(); if (this->cs_) this->cs_->destroy(); } } /** @brief Initializes the flag. @param xCoordinate X-Coordinate of the flage, 0-9, origin is bottom left @param yCoordinate Y-Coordinate of the flage, 0-9, origin is bottom left @param cellSize The size of the cells */ void OrxoKartFlag::init(int n, int s) { cs_ = new BoxCollisionShape(this->getContext()); cs_->setHalfExtents(Vector3(s*n, 1, s*n)); cs_->setPosition(Vector3(s*n*0.5f,-60.0f, s*n*0.5f)); this->attachCollisionShape(cs_); } /** @brief Checks if the OrxoKartship collided with the flag */ bool OrxoKartFlag::collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint) { if(otherObject->isA(Class(OrxoKartKart))) { collided_ = true; kartCollider = (OrxoKartKart*) otherObject; } return false; } }