/* * 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 OrxoKartTile.cc @brief Represents one Wall piece in the OrxoKart Game */ #include "OrxoKartTile.h" #include "core/CoreIncludes.h" #include "graphics/Model.h" #include "objects/collisionshapes/BoxCollisionShape.h" namespace orxonox { RegisterClass(OrxoKartTile); OrxoKartTile::OrxoKartTile(Context* context) : StaticEntity(context) { RegisterObject(OrxoKartTile); this->model_ = nullptr; this->cs_ = nullptr; this->enableCollisionCallback(); this->setCollisionResponse(true); this->setCollisionType(CollisionType::Static); } /** @brief Destructor. */ OrxoKartTile::~OrxoKartTile() { if (this->isInitialized()) { if (this->model_) this->model_->destroy(); if (this->cs_) this->cs_->destroy(); } } /** @brief Initializes a OrxoKartTile @param x x-Coordinate of the center of the Tile @param y z-Coordinate of the center of the Tile @param s scaling factor of the map @param type type of tile. 1 for normal tile, 2 for Start/End tile */ void OrxoKartTile::init(int x, int z, int s, int type) { // floor design according to its type model_ = new Model(this->getContext()); if (type == 1) { model_->setMeshSource("OrxoKartStreckenabschnitt.mesh"); } else if (type == 2 ) { model_->setMeshSource("OrxoKartStreckenabschnittZiel.mesh"); } model_->setScale3D(Vector3(s*1.0f, 8.0f, s*1.0f)); model_->setPosition(Vector3(x*1.0f, 0.0f, z*1.0f)); this->attach(model_); //floor physics cs_ = new BoxCollisionShape(this->getContext()); cs_->setHalfExtents(Vector3(s/2.0f, 1.0f, s/2.0f)); cs_->setPosition(Vector3(x*1.0f, -1.0f, z*1.0f)); this->attachCollisionShape(cs_); } }