| [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 | *      Cyrill Burgener | 
|---|
|  | 24 | * | 
|---|
|  | 25 | */ | 
|---|
|  | 26 |  | 
|---|
|  | 27 | /** | 
|---|
| [12066] | 28 | @file OrxoKartKart.cc | 
|---|
|  | 29 | @brief Implementation of the OrxoKartKart control | 
|---|
| [12057] | 30 | */ | 
|---|
|  | 31 |  | 
|---|
| [12066] | 32 | #include "OrxoKartKart.h" | 
|---|
| [12057] | 33 | #include "core/CoreIncludes.h" | 
|---|
|  | 34 | #include "core/XMLPort.h" | 
|---|
|  | 35 |  | 
|---|
|  | 36 | #include <BulletCollision/NarrowPhaseCollision/btManifoldPoint.h> | 
|---|
|  | 37 |  | 
|---|
|  | 38 | namespace orxonox | 
|---|
|  | 39 | { | 
|---|
| [12066] | 40 | RegisterClass(OrxoKartKart); | 
|---|
| [12057] | 41 |  | 
|---|
| [12066] | 42 | OrxoKartKart::OrxoKartKart(Context* context) : SpaceShip(context) | 
|---|
| [12057] | 43 | { | 
|---|
| [12066] | 44 | RegisterObject(OrxoKartKart); | 
|---|
| [12057] | 45 | enableCollisionCallback(); | 
|---|
|  | 46 | isFloor_ = false; | 
|---|
|  | 47 | jumpBoost_ = 0; | 
|---|
|  | 48 | } | 
|---|
|  | 49 |  | 
|---|
| [12066] | 50 | void OrxoKartKart::moveFrontBack(const Vector2& value) | 
|---|
|  | 51 | { | 
|---|
|  | 52 | this->steering_.z -= value.x; | 
|---|
|  | 53 | orxout() << "mFB" << endl; | 
|---|
|  | 54 | } | 
|---|
| [12057] | 55 |  | 
|---|
| [12066] | 56 | void OrxoKartKart::moveRightLeft(const Vector2& value) | 
|---|
|  | 57 | { | 
|---|
|  | 58 | this->rotateYaw(value); | 
|---|
|  | 59 | orxout() << "mRL" << endl; | 
|---|
|  | 60 | } | 
|---|
| [12057] | 61 |  | 
|---|
| [12066] | 62 | void OrxoKartKart::moveUpDown(const Vector2& value) | 
|---|
|  | 63 | { | 
|---|
|  | 64 | this->steering_.y += value.x; | 
|---|
|  | 65 | orxout() << "mUD" << endl; | 
|---|
|  | 66 | } | 
|---|
| [12057] | 67 |  | 
|---|
| [12066] | 68 | void OrxoKartKart::rotateYaw(const Vector2& value) | 
|---|
|  | 69 | { | 
|---|
|  | 70 | this->localAngularAcceleration_.setY(this->localAngularAcceleration_.y() - value.x); | 
|---|
|  | 71 | //orxout() << value; | 
|---|
|  | 72 | Pawn::rotateYaw(value); | 
|---|
|  | 73 | } | 
|---|
| [12057] | 74 |  | 
|---|
| [12066] | 75 | void OrxoKartKart::XMLPort(Element& xmlelement, XMLPort::Mode mode) | 
|---|
| [12057] | 76 | { | 
|---|
| [12066] | 77 | SUPER(OrxoKartKart, XMLPort, xmlelement, mode); | 
|---|
| [12057] | 78 |  | 
|---|
| [12066] | 79 | XMLPortParam(OrxoKartKart, "jumpBoost", setJumpBoost, getJumpBoost, xmlelement, mode); | 
|---|
| [12057] | 80 | } | 
|---|
|  | 81 |  | 
|---|
|  | 82 | /** | 
|---|
|  | 83 | @brief | 
|---|
|  | 84 | Removed, does nothing. | 
|---|
|  | 85 | @param value | 
|---|
|  | 86 | */ | 
|---|
| [12066] | 87 | void OrxoKartKart::rotatePitch(const Vector2& value) { } | 
|---|
| [12057] | 88 |  | 
|---|
|  | 89 | /** | 
|---|
|  | 90 | @brief | 
|---|
|  | 91 | Removed, does nothing. | 
|---|
|  | 92 | @param value | 
|---|
|  | 93 | */ | 
|---|
| [12066] | 94 | void OrxoKartKart::rotateRoll(const Vector2& value) { } | 
|---|
| [12057] | 95 |  | 
|---|
|  | 96 | /** | 
|---|
|  | 97 | @brief | 
|---|
|  | 98 | Checks if the ship is touching the floor. The ship can only jump if there is contact with someting beneath it. | 
|---|
|  | 99 | */ | 
|---|
| [12066] | 100 | bool OrxoKartKart::collidesAgainst(WorldEntity* otherObject, const btCollisionShape* cs, btManifoldPoint& contactPoint) | 
|---|
| [12057] | 101 | { | 
|---|
|  | 102 | SpaceShip::collidesAgainst(otherObject, cs, contactPoint); | 
|---|
| [12066] | 103 | //SUPER(OrxoKartKart, collidesAgainst, otherObject, cs, contactPoint); | 
|---|
| [12057] | 104 |  | 
|---|
|  | 105 | if (contactPoint.m_normalWorldOnB.y() > 0.6 | 
|---|
|  | 106 | && this->getVelocity().y < 1) { | 
|---|
|  | 107 | this->isFloor_ = true; | 
|---|
|  | 108 | } else { | 
|---|
|  | 109 | this->isFloor_ = false; | 
|---|
|  | 110 | } | 
|---|
|  | 111 |  | 
|---|
|  | 112 | return false; | 
|---|
|  | 113 | } | 
|---|
|  | 114 |  | 
|---|
|  | 115 | /** | 
|---|
|  | 116 | @brief | 
|---|
|  | 117 | Makes the ship jump | 
|---|
|  | 118 | @param bBoost | 
|---|
|  | 119 | */ | 
|---|
| [12066] | 120 | void OrxoKartKart::boost(bool bBoost) { | 
|---|
| [12057] | 121 | if (bBoost && this->isFloor_) | 
|---|
|  | 122 | { | 
|---|
|  | 123 | this->setVelocity( | 
|---|
|  | 124 | this->getVelocity().x, | 
|---|
|  | 125 | jumpBoost_, | 
|---|
|  | 126 | this->getVelocity().z | 
|---|
|  | 127 | ); | 
|---|
|  | 128 | this->isFloor_ = false; | 
|---|
|  | 129 | } | 
|---|
|  | 130 | } | 
|---|
|  | 131 | } | 
|---|