Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/OrxoKart_HS18/src/modules/orxokart/OrxoKartTile.cc @ 12128

Last change on this file since 12128 was 12128, checked in by ottka, 5 years ago

Make two levels and more

File size: 3.3 KB
RevLine 
[12057]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:
23 *      Manuel Meier
24 *   Co-authors:
25 *      ...
26 *
27 */
28
29/**
[12062]30    @file OrxoKartTile.cc
31    @brief Represents one Wall piece in the OrxoKart Game
[12057]32*/
33
[12062]34#include "OrxoKartTile.h"
[12057]35
36#include "core/CoreIncludes.h"
37#include "graphics/Model.h"
38#include "objects/collisionshapes/BoxCollisionShape.h"
39
40namespace orxonox
41{
[12062]42    RegisterClass(OrxoKartTile);
[12057]43
[12062]44    OrxoKartTile::OrxoKartTile(Context* context) : StaticEntity(context)
[12057]45    {
[12062]46        RegisterObject(OrxoKartTile);
[12057]47
48        this->model_ = nullptr;
49        this->cs_ = nullptr;
50
51        this->enableCollisionCallback();
52        this->setCollisionResponse(true);
53        this->setCollisionType(CollisionType::Static);
54    }
55
56    /**
57    @brief
58        Destructor.
59    */
[12062]60    OrxoKartTile::~OrxoKartTile()
[12057]61    {
62        if (this->isInitialized())
63        {
64            if (this->model_)
65                this->model_->destroy();
66            if (this->cs_)
67                this->cs_->destroy();
68        }
69    }
70
71    /**
72    @brief
[12062]73        Initializes a OrxoKartTile
[12057]74    @param x
[12090]75        x-Coordinate of the center of the Tile
[12057]76    @param y
[12090]77        z-Coordinate of the center of the Tile
78    @param s
79        scaling factor of the map
80    @param type
81        type of tile. 1 for normal tile, 2 for Start/End tile     
[12057]82    */
[12128]83    void OrxoKartTile::init(int x, int z, int s, float r, int type)
[12057]84    {
[12090]85        // floor design according to its type
[12089]86        model_ = new Model(this->getContext());
87        if (type == 1) {
88           model_->setMeshSource("OrxoKartStreckenabschnitt.mesh"); 
89        }
90        else if (type == 2 ) {
91            model_->setMeshSource("OrxoKartStreckenabschnittZiel.mesh");
92        }
93        model_->setScale3D(Vector3(s*1.0f, 8.0f, s*1.0f));
94        model_->setPosition(Vector3(x*1.0f, 0.0f, z*1.0f));
[12128]95        model_->pitch(Degree(r));
[12089]96
97        this->attach(model_);
98
[12090]99
100        //floor physics
[12089]101        cs_ = new BoxCollisionShape(this->getContext());
102        cs_->setHalfExtents(Vector3(s/2.0f, 1.0f, s/2.0f));
103        cs_->setPosition(Vector3(x*1.0f, -1.0f, z*1.0f));
[12128]104        cs_->pitch(Degree(r));
[12089]105
106        this->attachCollisionShape(cs_);
[12057]107    }
[12111]108
109    /**
110    @brief
111        Checks if the OrxoKartship collided with the flag
112    */
113    bool OrxoKartTile::collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint)
114    {
115        if(otherObject->isA(Class(OrxoKartKart))) {
116            collided_ = true;
117            kartCollider = (OrxoKartKart*) otherObject;
118        }
119
120        return false;
121    }
122
123
[12057]124}
Note: See TracBrowser for help on using the repository browser.