Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/hoverHS15/src/modules/hover/HoverOrigin.h @ 10795

Last change on this file since 10795 was 10751, checked in by meierman, 9 years ago

working cpp object generation

File size: 5.8 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 *      Fabien Vultier
24 *   Co-authors:
25 *      ...
26 *
27 */
28
29#ifndef _HoverOrigin_H__
30#define _HoverOrigin_H__
31
32#include "HoverPrereqs.h"
33
34#include <string>
35
36#include <util/Math.h>
37
38#include "worldentities/StaticEntity.h"
39
40namespace orxonox
41{
42   
43    /**
44    @brief
45        The HoverOrigin implements the playing field @ref orxonox::Hover "Hover" takes place in and allows for many parameters of the minigame to be set.
46        The playing field resides in the x,z-plane, with the x-axis being the horizontal axis and the z-axis being the vertical axis.
47       
48        Various parameters can be set:
49        - The <b>dimension</b> is a vector, that defines the width and height of the playing field. The default is <em>(200, 120)</em>.
50        - The <b>balltemplate</b> is a template that is applied to the @ref orxonox::HoverPlatform "HoverPlatform", it can be used to attach different things to it, e.g. its @ref orxonox::Model "Model". See below for a usage example.
51        - The <b>battemplate</b> is a template that is applied to the @ref orxonox::HoverPlatform "HoverFigure", it can be used to attach different things to it, e.g. its @ref orxonox::Model "Model". See below for a usage example.
52        - The <b>ballspeed</b> is the speed with which the @ref orxonox::HoverPlatform "HoverPlatform" moves. The default is <em>100</em>.
53        - The <b>ballaccfactor</b> is the acceleration factor for the @ref orxonox::HoverPlatform "HoverPlatform". The default is <em>1.0</em>.
54        - The <b>batspeed</b> is the speed with which the @ref orxonox::HoverFigure "HoverFigures" move. The default is <em>60</em>.
55        - The <b>batlength</b> is the length of the @ref orxonox::HoverFigure "HoverFigures" as the percentage of the height of the playing field. The default is <em>0.25</em>.
56       
57        An example in XML of the HoverOrigin would be:
58       
59        First the needed templates:
60        The template for the @ref orxonox::HoverPlatform "HoverPlatform".
61        @code
62        <Template name="Hoverball">
63          <HoverPlatform>
64            <attached>
65              <Model mesh="sphere.mesh" scale="2" />
66              <ParticleSpawner name="hiteffect" position="0,0,0" source="Orxonox/sparks2" lifetime="0.01" autostart="0" mainstate="spawn" />
67            </attached>
68            <eventlisteners>
69              <EventTarget target="hiteffect" />
70            </eventlisteners>
71          </HoverPlatform>
72        </Template>
73        @endcode
74        As can be seen, a sphere is attached as the @ref orxonox::Model "Model" for the @ref orxonox::HoverPlatform "HoverPlatform", and also an @ref orxonox::EventListener "EventListener" that triggers a @ref orxonox::ParticleSpawner "ParticleSpawner", whenever the ball hits the boundaries is attached.
75       
76        Additionally the template for the @ref orxonox::HoverFigure "HoverFigure".
77        @code
78        <Template name="Hoverbatcameras" defaults="0">
79          <HoverFigure>
80            <camerapositions>
81              <CameraPosition position="0,200,0" pitch="-90" absolute="true" />
82            </camerapositions>
83          </HoverFigure>
84        </Template>
85
86        <Template name="Hoverbat">
87          <HoverFigure camerapositiontemplate=Hoverbatcameras>
88            <attached>
89              <Model position="0,0,3" mesh="cube.mesh" scale3D="14,2,2" />
90            </attached>
91          </HoverFigure>
92        </Template>
93        @endcode
94        As can be seen, there are actually two templates. The first template is needed to set the camera for the @ref orxonox::HoverFigure "HoverFigure". The second template ist the actual template for the @ref orxonox::HoverFigure "HoverFigure", the template for the camera position is added and a @ref orxonox::Model "Model" for the @ref orxonox::HoverFigure "HoverFigure" is attached.
95        propellerTemplate_
96        Finally the HoverOrigin is created.
97        @code
98        <HoverOrigin name="Hovercenter" dimension="200,120" balltemplate="Hoverball" battemplate="Hoverbat" ballspeed="200" ballaccfactor="1.0" batspeed="130" batlength="0.25">
99          <attached>
100            <Model position="0,0,60" mesh="cube.mesh" scale3D="105,1,1" />
101            <Model position="0,0,-60" mesh="cube.mesh" scale3D="105,1,1" />
102          </attached>
103        </HoverOrigin>
104        @endcode
105        All parameters are specified. And also two @ref orxonox::Model "Models" (for the upper and lower boundary) are attached.
106       
107        For a more elaborate example, have a look at the <code>Hover.oxw</code> level file.
108
109    */
110    class _HoverExport HoverOrigin : public StaticEntity
111    {
112        public:
113            HoverOrigin(Context* context); //!< Constructor. Registers and initializes the object and checks whether the gametype is actually Hover.
114            virtual ~HoverOrigin() {}
115            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method to create a HoverOrigin through XML.
116           
117        private:
118            void checkGametype();
119       
120    };
121}
122
123#endif /* _HoverOrigin_H__ */
Note: See TracBrowser for help on using the repository browser.