| [10657] | 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: |
|---|
| [10659] | 23 | * Cyrill Burgener |
|---|
| [10657] | 24 | * Co-authors: |
|---|
| 25 | * ... |
|---|
| 26 | * |
|---|
| 27 | */ |
|---|
| 28 | |
|---|
| 29 | /** |
|---|
| [10659] | 30 | @file HoverShip.cc |
|---|
| 31 | @brief Implementation of the HoverShip class. |
|---|
| [10657] | 32 | */ |
|---|
| 33 | |
|---|
| [10659] | 34 | #include "HoverShip.h" |
|---|
| [10657] | 35 | #include "core/CoreIncludes.h" |
|---|
| 36 | |
|---|
| 37 | namespace orxonox |
|---|
| 38 | { |
|---|
| [10659] | 39 | RegisterClass(HoverShip); |
|---|
| [10657] | 40 | |
|---|
| [10659] | 41 | HoverShip::HoverShip(Context* context) : SpaceShip(context) |
|---|
| [10657] | 42 | { |
|---|
| [10659] | 43 | RegisterObject(HoverShip); |
|---|
| [10784] | 44 | enableCollisionCallback(); |
|---|
| 45 | isFloor_ = false; |
|---|
| [10657] | 46 | } |
|---|
| 47 | |
|---|
| [10659] | 48 | void HoverShip::tick(float dt) |
|---|
| [10657] | 49 | { |
|---|
| [10659] | 50 | SUPER(HoverShip, tick, dt); |
|---|
| [10657] | 51 | } |
|---|
| 52 | |
|---|
| [10784] | 53 | void HoverShip::moveFrontBack(const Vector2& value) |
|---|
| 54 | { this->steering_.z -= value.x; } |
|---|
| [10694] | 55 | |
|---|
| 56 | void HoverShip::moveRightLeft(const Vector2& value) |
|---|
| 57 | { this->steering_.x += value.x; } |
|---|
| 58 | |
|---|
| 59 | void HoverShip::moveUpDown(const Vector2& value) |
|---|
| 60 | { this->steering_.y += value.x; } |
|---|
| 61 | |
|---|
| [10784] | 62 | void HoverShip::rotateYaw(const Vector2& value) |
|---|
| 63 | { |
|---|
| 64 | this->localAngularAcceleration_.setY(this->localAngularAcceleration_.y() + value.x); |
|---|
| [10694] | 65 | |
|---|
| [10784] | 66 | Pawn::rotateYaw(value); |
|---|
| 67 | } |
|---|
| 68 | |
|---|
| 69 | void HoverShip::XMLPort(Element& xmlelement, XMLPort::Mode mode) |
|---|
| 70 | { |
|---|
| 71 | SUPER(HoverShip, XMLPort, xmlelement, mode); |
|---|
| 72 | |
|---|
| 73 | XMLPortParam(HoverShip, "jumpBoost", setJumpBoost, getJumpBoost, xmlelement, mode); |
|---|
| 74 | } |
|---|
| 75 | |
|---|
| 76 | |
|---|
| 77 | void HoverShip::setJumpBoost(float jumpBoost) |
|---|
| 78 | { |
|---|
| 79 | this->jumpBoost_ = jumpBoost; |
|---|
| 80 | } |
|---|
| 81 | |
|---|
| 82 | |
|---|
| 83 | float HoverShip::getJumpBoost() |
|---|
| 84 | { |
|---|
| 85 | return jumpBoost_; |
|---|
| 86 | } |
|---|
| 87 | |
|---|
| 88 | /** |
|---|
| 89 | @brief |
|---|
| 90 | Rotate in pitch direction. |
|---|
| 91 | Due to added left, can also lead to an additional up-down motion. |
|---|
| 92 | @param value |
|---|
| 93 | A vector whose first component specifies the magnitude of the rotation. Positive means pitch up, negative means pitch down. |
|---|
| 94 | */ |
|---|
| 95 | void HoverShip::rotatePitch(const Vector2& value) { } |
|---|
| 96 | |
|---|
| 97 | /** |
|---|
| 98 | @brief |
|---|
| 99 | Rotate in roll direction. |
|---|
| 100 | @param value |
|---|
| 101 | A vector whose first component specifies the magnitude of the rotation. Positive means roll left, negative means roll right. |
|---|
| 102 | */ |
|---|
| 103 | void HoverShip::rotateRoll(const Vector2& value) { } |
|---|
| 104 | |
|---|
| [10760] | 105 | bool HoverShip::collidesAgainst(WorldEntity* otherObject, const btCollisionShape* cs, btManifoldPoint& contactPoint) |
|---|
| [10694] | 106 | { |
|---|
| [10784] | 107 | SpaceShip::collidesAgainst(otherObject, cs, contactPoint); |
|---|
| 108 | //SUPER(HoverShip, collidesAgainst, otherObject, cs, contactPoint); |
|---|
| [10760] | 109 | |
|---|
| [10784] | 110 | if (contactPoint.m_normalWorldOnB.y() > 0.6 |
|---|
| 111 | && this->getVelocity().y < 1) { |
|---|
| [10694] | 112 | this->isFloor_ = true; |
|---|
| [10784] | 113 | } else { |
|---|
| [10694] | 114 | this->isFloor_ = false; |
|---|
| [10784] | 115 | } |
|---|
| [10694] | 116 | |
|---|
| 117 | return false; |
|---|
| 118 | } |
|---|
| 119 | |
|---|
| 120 | void HoverShip::boost(bool bBoost) { |
|---|
| [10784] | 121 | if (bBoost && this->isFloor_) |
|---|
| [10694] | 122 | { |
|---|
| [10784] | 123 | this->setVelocity( |
|---|
| 124 | this->getVelocity().x, |
|---|
| 125 | jumpBoost_, |
|---|
| 126 | this->getVelocity().z |
|---|
| 127 | ); |
|---|
| [10694] | 128 | this->isFloor_ = false; |
|---|
| [10784] | 129 | } |
|---|
| [10694] | 130 | } |
|---|
| 131 | |
|---|
| [10784] | 132 | /*Hover* HoverShip::getGame() |
|---|
| [10657] | 133 | { |
|---|
| [10664] | 134 | if (game == NULL) |
|---|
| [10657] | 135 | { |
|---|
| [10659] | 136 | for (ObjectList<Hover>::iterator it = ObjectList<Hover>::begin(); it != ObjectList<Hover>::end(); ++it) |
|---|
| [10657] | 137 | { |
|---|
| 138 | game = *it; |
|---|
| 139 | } |
|---|
| 140 | } |
|---|
| [10664] | 141 | return game; |
|---|
| 142 | }*/ |
|---|
| [10657] | 143 | } |
|---|