Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/modules/hover/HoverWall.cc @ 11317

Last change on this file since 11317 was 11099, checked in by muemart, 9 years ago

Fix loads of doxygen warnings and other documentation issues

  • Property svn:eol-style set to native
File size: 3.2 KB
RevLine 
[10751]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:
[10930]23 *      Manuel Meier
[10751]24 *   Co-authors:
25 *      ...
26 *
27 */
28
29/**
30    @file HoverWall.cc
[10930]31    @brief Represents one Wall piece in the Hover Game
[10751]32*/
33
34#include "HoverWall.h"
35
36#include "core/CoreIncludes.h"
37#include "graphics/Model.h"
[11041]38#include "objects/collisionshapes/BoxCollisionShape.h"
[10751]39
40namespace orxonox
41{
42    RegisterClass(HoverWall);
43
44    HoverWall::HoverWall(Context* context) : StaticEntity(context)
45    {
46        RegisterObject(HoverWall);
[11042]47
[11071]48        this->model_ = nullptr;
49        this->cs_ = nullptr;
[11042]50
51        this->enableCollisionCallback();
52        this->setCollisionResponse(true);
[11071]53        this->setCollisionType(CollisionType::Static);
[10751]54    }
55
[11042]56    /**
57    @brief
58        Destructor.
59    */
60    HoverWall::~HoverWall()
61    {
[11043]62        if (this->isInitialized())
63        {
64            if (this->model_)
65                this->model_->destroy();
66            if (this->cs_)
67                this->cs_->destroy();
68        }
[11042]69    }
70
[10930]71    /**
72    @brief
[11042]73        Initializes a HoverWall
[10930]74    @param x
75        x-Coordinate of the Square that the Wall is attached to, 0-9, Origin is Bottom left
76    @param y
77        y-Coordinate of the Square that the Wall is attached to, 0-9, Origin is Bottom left
[11099]78    @param cellSize
79        The size of a cell
80    @param cellHeight
81        The height of a cell
[10930]82    @param orientation
83            Wall on the right side (1) or on top (2) of this square, 0-1       
84    */
[11042]85    void HoverWall::init(int x, int y, int cellSize, int cellHeight, int orientation)
[10751]86    {
[10785]87        int xSize_, zSize_, xPos_, zPos_;
88
89        if(orientation == 1){
[11040]90            xSize_ = cellSize/2;
[10785]91            zSize_ = 2;
[11040]92            zPos_ = x*cellSize;
93            xPos_ = y*cellSize-cellSize/2;
[10785]94        }
95        else{
96            xSize_ = 2;
[11040]97            zSize_ = cellSize/2;
98            zPos_ = x*cellSize-cellSize/2;
99            xPos_ = y*cellSize;
[10785]100        }
101
102
[11042]103        model_ = new Model(this->getContext());
[10926]104        model_->setMeshSource("CuboidBody.mesh");
[11040]105        model_->setScale3D(Vector3(xSize_*1.0f, cellHeight*1.0f, zSize_*1.0f));
[11030]106        model_->setPosition(Vector3(xPos_*1.0f, 0.0f, zPos_*1.0f));
[10751]107
[10760]108        this->attach(model_);
[10751]109
[11042]110        cs_ = new BoxCollisionShape(this->getContext());
[11040]111        cs_->setHalfExtents(Vector3(xSize_*1.0f, cellHeight*1.0f, zSize_*1.0f));
[11030]112        cs_->setPosition(Vector3(xPos_*1.0f, 0.0f, zPos_*1.0f));
[10760]113
114        this->attachCollisionShape(cs_);
[10751]115    }
116}
Note: See TracBrowser for help on using the repository browser.