Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/presentationHS15/src/modules/hover/HoverWall.cc @ 11041

Last change on this file since 11041 was 11041, checked in by landauf, 9 years ago

cleanup in hover module

  • Property svn:eol-style set to native
File size: 3.0 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 HoverWall.cc
31    @brief Represents one Wall piece in the Hover Game
32*/
33
34#include "HoverWall.h"
35
36#include "core/CoreIncludes.h"
37#include "graphics/Model.h"
38#include "objects/collisionshapes/BoxCollisionShape.h"
39
40namespace orxonox
41{
42    RegisterClass(HoverWall);
43
44    HoverWall::HoverWall(Context* context) : StaticEntity(context)
45    {
46        RegisterObject(HoverWall);
47        model_ = NULL;
48        cs_ = NULL;
49    }
50
51
52    /**
53    @brief
54        Constructor of a HoverWall
55    @param x
56        x-Coordinate of the Square that the Wall is attached to, 0-9, Origin is Bottom left
57    @param y
58        y-Coordinate of the Square that the Wall is attached to, 0-9, Origin is Bottom left
59    @param orientation
60            Wall on the right side (1) or on top (2) of this square, 0-1       
61    */
62    HoverWall::HoverWall(Context* context, int x, int y, int cellSize, int cellHeight, int orientation) : StaticEntity(context)
63    {
64        RegisterObject(HoverWall);
65
66        int xSize_, zSize_, xPos_, zPos_;
67
68        if(orientation == 1){
69            xSize_ = cellSize/2;
70            zSize_ = 2;
71            zPos_ = x*cellSize;
72            xPos_ = y*cellSize-cellSize/2;
73        }
74        else{
75            xSize_ = 2;
76            zSize_ = cellSize/2;
77            zPos_ = x*cellSize-cellSize/2;
78            xPos_ = y*cellSize;
79        }
80
81
82        model_ = new Model(context);
83        model_->setMeshSource("CuboidBody.mesh");
84        model_->setScale3D(Vector3(xSize_*1.0f, cellHeight*1.0f, zSize_*1.0f));
85        model_->setPosition(Vector3(xPos_*1.0f, 0.0f, zPos_*1.0f));
86
87        this->attach(model_);
88
89        this->enableCollisionCallback();
90        this->setCollisionResponse(true);
91        this->setCollisionType(Static);
92
93        cs_ = new BoxCollisionShape(context);
94        cs_->setHalfExtents(Vector3(xSize_*1.0f, cellHeight*1.0f, zSize_*1.0f));
95        cs_->setPosition(Vector3(xPos_*1.0f, 0.0f, zPos_*1.0f));
96
97        this->attachCollisionShape(cs_);
98    }
99
100    /**
101    @brief
102        Destructor.
103    */
104    HoverWall::~HoverWall()
105    {
106
107    }
108}
Note: See TracBrowser for help on using the repository browser.