Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/Boxhead_FS19/src/modules/orxokart/OrxoKartTile.cc @ 12398

Last change on this file since 12398 was 12144, checked in by ottka, 6 years ago

New HUDs and Start

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