Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/modules/hover/HoverShip.cc @ 11843

Last change on this file since 11843 was 11495, checked in by patricwi, 7 years ago

reverted commit from merge with tgidronFS16 because failed to compile

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