[Orxonox-commit 6093] r10751 - in code/branches/hoverHS15: data/levels src/modules/hover
meierman at orxonox.net
meierman at orxonox.net
Mon Nov 2 15:19:01 CET 2015
Author: meierman
Date: 2015-11-02 15:19:00 +0100 (Mon, 02 Nov 2015)
New Revision: 10751
Added:
code/branches/hoverHS15/src/modules/hover/HoverOrigin.cc
code/branches/hoverHS15/src/modules/hover/HoverOrigin.h
code/branches/hoverHS15/src/modules/hover/HoverWall.cc
code/branches/hoverHS15/src/modules/hover/HoverWall.h
Modified:
code/branches/hoverHS15/data/levels/Hover.oxw
code/branches/hoverHS15/src/modules/hover/CMakeLists.txt
code/branches/hoverHS15/src/modules/hover/Hover.cc
code/branches/hoverHS15/src/modules/hover/Hover.h
code/branches/hoverHS15/src/modules/hover/HoverPrereqs.h
Log:
working cpp object generation
Modified: code/branches/hoverHS15/data/levels/Hover.oxw
===================================================================
--- code/branches/hoverHS15/data/levels/Hover.oxw 2015-11-02 13:56:51 UTC (rev 10750)
+++ code/branches/hoverHS15/data/levels/Hover.oxw 2015-11-02 14:19:00 UTC (rev 10751)
@@ -41,10 +41,10 @@
<Model position="1000, 0, 500" yaw="0" pitch="0" roll="0" scale3D="2, 30, 500" mesh="cube_green.mesh" />
</attached>
<collisionShapes>
- <BoxCollisionShape yaw="0" pitch="0" roll="0" position="0,0,0" halfExtents="500, 30, 2" />
- <BoxCollisionShape yaw="0" pitch="0" roll="0" position="0,0,1000" halfExtents="500, 30, 2" />
+ <BoxCollisionShape yaw="0" pitch="0" roll="0" position="500,0,0" halfExtents="500, 30, 2" />
+ <BoxCollisionShape yaw="0" pitch="0" roll="0" position="500,0,1000" halfExtents="500, 30, 2" />
<BoxCollisionShape yaw="0" pitch="0" roll="0" position="0,0,500" halfExtents="2, 30, 500" />
- <BoxCollisionShape yaw="0" pitch="0" roll="0" position="1000,500,0" halfExtents="2, 30, 500" />
+ <BoxCollisionShape yaw="0" pitch="0" roll="0" position="1000,0,500" halfExtents="2, 30, 500" />
</collisionShapes>
</StaticEntity>
@@ -59,6 +59,19 @@
</StaticEntity>
+ <MovableEntity>
+ <attached>
+ <HoverOrigin>
+
+ <attached>
+
+ </attached>
+ </HoverOrigin>
+ </attached>
+ </MovableEntity>
+
+
+
<Light type=directional position="0,0,0" direction="0.253, 0.593, -0.765" diffuse="1.0, 0.9, 0.9, 1.0" specular="1.0, 0.9, 0.9, 1.0"/>
<SpawnPoint team=0 position="0,100,0" lookat="100,100,0" spawnclass=SpaceShip pawndesign=spaceshippirate />
Modified: code/branches/hoverHS15/src/modules/hover/CMakeLists.txt
===================================================================
--- code/branches/hoverHS15/src/modules/hover/CMakeLists.txt 2015-11-02 13:56:51 UTC (rev 10750)
+++ code/branches/hoverHS15/src/modules/hover/CMakeLists.txt 2015-11-02 14:19:00 UTC (rev 10751)
@@ -2,6 +2,7 @@
Hover.cc
HoverShip.cc
HoverWall.cc
+HoverOrigin.cc
)
ORXONOX_ADD_LIBRARY(hover
Modified: code/branches/hoverHS15/src/modules/hover/Hover.cc
===================================================================
--- code/branches/hoverHS15/src/modules/hover/Hover.cc 2015-11-02 13:56:51 UTC (rev 10750)
+++ code/branches/hoverHS15/src/modules/hover/Hover.cc 2015-11-02 14:19:00 UTC (rev 10751)
@@ -39,13 +39,13 @@
namespace orxonox
{
+ bool firstTick = true;
RegisterUnloadableClass(Hover);
Hover::Hover(Context* context) : Gametype(context)
{
RegisterObject(Hover);
- new HoverWall(context);
//this->setHUDTemplate("HoverHUD");
}
@@ -54,6 +54,13 @@
void Hover::tick(float dt)
{
SUPER(Hover, tick, dt);
+
+ if(firstTick){
+ firstTick = false;
+ new HoverWall(origin_->getContext(), 1, 2);
+ }
+
+
}
Modified: code/branches/hoverHS15/src/modules/hover/Hover.h
===================================================================
--- code/branches/hoverHS15/src/modules/hover/Hover.h 2015-11-02 13:56:51 UTC (rev 10750)
+++ code/branches/hoverHS15/src/modules/hover/Hover.h 2015-11-02 14:19:00 UTC (rev 10751)
@@ -36,7 +36,7 @@
#define _Hover_H__
#include "HoverPrereqs.h"
-//#include "HoverCenterPoint.h" // Necessary for WeakPointer??
+#include "HoverOrigin.h" // Necessary for WeakPointer
//#include "HoverShip.h" DO NOT include in Header. Will cause forward declaration issues
//#include "HoverHUDinfo.h"
@@ -70,10 +70,15 @@
virtual void tick(float dt);
- // void setCenterpoint(HoverCenterPoint* center)
- // { this->center_ = center; }
+ // void setOrigin(HoverOrigin* center)
+ // { center_ = center; }
+ void setOrigin(HoverOrigin* origin)
+ { this->origin_ = origin; }
+
+ WeakPtr<HoverOrigin> origin_;
+
};
}
Added: code/branches/hoverHS15/src/modules/hover/HoverOrigin.cc
===================================================================
--- code/branches/hoverHS15/src/modules/hover/HoverOrigin.cc (rev 0)
+++ code/branches/hoverHS15/src/modules/hover/HoverOrigin.cc 2015-11-02 14:19:00 UTC (rev 10751)
@@ -0,0 +1,62 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Fabien Vultier
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @file HoverOrigin.cc
+ @brief The HoverOrigin is a StaticEntity which represents the level of the minigame. All platforms, enemies and items are attached to the HoverOrigin.
+*/
+
+#include "HoverOrigin.h"
+#include "core/CoreIncludes.h"
+#include "core/XMLPort.h"
+#include "Hover.h"
+
+namespace orxonox
+{
+ RegisterClass(HoverOrigin);
+
+ HoverOrigin::HoverOrigin(Context* context) : StaticEntity(context)
+ {
+ RegisterObject(HoverOrigin);
+ checkGametype();
+ }
+
+ void HoverOrigin::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+ {
+ SUPER(HoverOrigin, XMLPort, xmlelement, mode);
+ }
+
+ void HoverOrigin::checkGametype()
+ {
+ if (getGametype() != NULL && this->getGametype()->isA(Class(Hover)))
+ {
+ Hover* hoverGametype = orxonox_cast<Hover*>(this->getGametype());
+ hoverGametype->setOrigin(this);
+ }
+ }
+}
Added: code/branches/hoverHS15/src/modules/hover/HoverOrigin.h
===================================================================
--- code/branches/hoverHS15/src/modules/hover/HoverOrigin.h (rev 0)
+++ code/branches/hoverHS15/src/modules/hover/HoverOrigin.h 2015-11-02 14:19:00 UTC (rev 10751)
@@ -0,0 +1,123 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Fabien Vultier
+ * Co-authors:
+ * ...
+ *
+ */
+
+#ifndef _HoverOrigin_H__
+#define _HoverOrigin_H__
+
+#include "HoverPrereqs.h"
+
+#include <string>
+
+#include <util/Math.h>
+
+#include "worldentities/StaticEntity.h"
+
+namespace orxonox
+{
+
+ /**
+ @brief
+ The HoverOrigin implements the playing field @ref orxonox::Hover "Hover" takes place in and allows for many parameters of the minigame to be set.
+ 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.
+
+ Various parameters can be set:
+ - The <b>dimension</b> is a vector, that defines the width and height of the playing field. The default is <em>(200, 120)</em>.
+ - 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.
+ - 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.
+ - The <b>ballspeed</b> is the speed with which the @ref orxonox::HoverPlatform "HoverPlatform" moves. The default is <em>100</em>.
+ - The <b>ballaccfactor</b> is the acceleration factor for the @ref orxonox::HoverPlatform "HoverPlatform". The default is <em>1.0</em>.
+ - The <b>batspeed</b> is the speed with which the @ref orxonox::HoverFigure "HoverFigures" move. The default is <em>60</em>.
+ - 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>.
+
+ An example in XML of the HoverOrigin would be:
+
+ First the needed templates:
+ The template for the @ref orxonox::HoverPlatform "HoverPlatform".
+ @code
+ <Template name="Hoverball">
+ <HoverPlatform>
+ <attached>
+ <Model mesh="sphere.mesh" scale="2" />
+ <ParticleSpawner name="hiteffect" position="0,0,0" source="Orxonox/sparks2" lifetime="0.01" autostart="0" mainstate="spawn" />
+ </attached>
+ <eventlisteners>
+ <EventTarget target="hiteffect" />
+ </eventlisteners>
+ </HoverPlatform>
+ </Template>
+ @endcode
+ 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.
+
+ Additionally the template for the @ref orxonox::HoverFigure "HoverFigure".
+ @code
+ <Template name="Hoverbatcameras" defaults="0">
+ <HoverFigure>
+ <camerapositions>
+ <CameraPosition position="0,200,0" pitch="-90" absolute="true" />
+ </camerapositions>
+ </HoverFigure>
+ </Template>
+
+ <Template name="Hoverbat">
+ <HoverFigure camerapositiontemplate=Hoverbatcameras>
+ <attached>
+ <Model position="0,0,3" mesh="cube.mesh" scale3D="14,2,2" />
+ </attached>
+ </HoverFigure>
+ </Template>
+ @endcode
+ 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.
+ propellerTemplate_
+ Finally the HoverOrigin is created.
+ @code
+ <HoverOrigin name="Hovercenter" dimension="200,120" balltemplate="Hoverball" battemplate="Hoverbat" ballspeed="200" ballaccfactor="1.0" batspeed="130" batlength="0.25">
+ <attached>
+ <Model position="0,0,60" mesh="cube.mesh" scale3D="105,1,1" />
+ <Model position="0,0,-60" mesh="cube.mesh" scale3D="105,1,1" />
+ </attached>
+ </HoverOrigin>
+ @endcode
+ All parameters are specified. And also two @ref orxonox::Model "Models" (for the upper and lower boundary) are attached.
+
+ For a more elaborate example, have a look at the <code>Hover.oxw</code> level file.
+
+ */
+ class _HoverExport HoverOrigin : public StaticEntity
+ {
+ public:
+ HoverOrigin(Context* context); //!< Constructor. Registers and initializes the object and checks whether the gametype is actually Hover.
+ virtual ~HoverOrigin() {}
+ virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method to create a HoverOrigin through XML.
+
+ private:
+ void checkGametype();
+
+ };
+}
+
+#endif /* _HoverOrigin_H__ */
Modified: code/branches/hoverHS15/src/modules/hover/HoverPrereqs.h
===================================================================
--- code/branches/hoverHS15/src/modules/hover/HoverPrereqs.h 2015-11-02 13:56:51 UTC (rev 10750)
+++ code/branches/hoverHS15/src/modules/hover/HoverPrereqs.h 2015-11-02 14:19:00 UTC (rev 10751)
@@ -70,6 +70,7 @@
class Hover;
class HoverShip;
class HoverWall;
+ class HoverOrigin;
}
#endif /* _HoverPrereqs_H__*/
Added: code/branches/hoverHS15/src/modules/hover/HoverWall.cc
===================================================================
--- code/branches/hoverHS15/src/modules/hover/HoverWall.cc (rev 0)
+++ code/branches/hoverHS15/src/modules/hover/HoverWall.cc 2015-11-02 14:19:00 UTC (rev 10751)
@@ -0,0 +1,111 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Fabien Vultier
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @file HoverWall.cc
+ @brief All platforms in this minigame inherit from this class. The basic functions of a platform (interact with figure) is implemented here. Special functions are implemented in the specialized classes.
+*/
+
+#include "HoverWall.h"
+
+#include "core/CoreIncludes.h"
+#include "core/GameMode.h"
+#include "graphics/Model.h"
+#include "gametypes/Gametype.h"
+
+
+
+#include "core/XMLPort.h"
+
+namespace orxonox
+{
+ RegisterClass(HoverWall);
+
+ HoverWall::HoverWall(Context* context) : StaticEntity(context)
+ {
+ RegisterObject(HoverWall);
+ model_ = new Model(context);
+ cs_ = new BoxCollisionShape(context);
+ model_->setMeshSource("cube.mesh");
+ model_->setScale3D(Vector3(100, 30, 2));
+ model_->setPosition(Vector3(100,0,100));
+ cs_->setPosition(Vector3(100,0,100));
+ cs_->setHalfExtents(Vector3(100, 30, 2));
+
+
+
+ }
+
+ HoverWall::HoverWall(Context* context, int x, int y) : StaticEntity(context)
+ {
+ RegisterObject(HoverWall);
+ model_ = new Model(context);
+ cs_ = new BoxCollisionShape(context);
+ model_->setMeshSource("cube.mesh");
+ model_->setScale3D(Vector3(50, 30, 2));
+ model_->setPosition(Vector3(x*100-50,0,y*100-50));
+ cs_->setPosition(Vector3(x*100-50,0,y*100-50));
+ cs_->setHalfExtents(Vector3(50, 30, 2));
+
+
+
+ }
+
+ /**
+ @brief
+ Destructor.
+ */
+ HoverWall::~HoverWall()
+ {
+
+ }
+
+ //xml port for loading height and width of the platform
+ void HoverWall::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+ {
+ SUPER(HoverWall, XMLPort, xmlelement, mode);
+
+ // XMLPortParam(HoverWall, "height", setHeight, getHeight, xmlelement, mode);
+ //XMLPortParam(HoverWall, "width", setWidth, getWidth, xmlelement, mode);
+ }
+
+ /**
+ @brief
+ Is called every tick.
+ Handles the movement of the ball and its interaction with the boundaries and bats.
+ @param dt
+ The time since the last tick.
+ */
+ void HoverWall::tick(float dt)
+ {
+ SUPER(HoverWall, tick, dt);
+
+ }
+
+
+}
Added: code/branches/hoverHS15/src/modules/hover/HoverWall.h
===================================================================
--- code/branches/hoverHS15/src/modules/hover/HoverWall.h (rev 0)
+++ code/branches/hoverHS15/src/modules/hover/HoverWall.h 2015-11-02 14:19:00 UTC (rev 10751)
@@ -0,0 +1,63 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Fabien Vultier
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @file HoverWall.h
+ @brief Declaration of the HoverWall class.
+ @ingroup Jump
+*/
+
+#ifndef _HoverWall_H__
+#define _HoverWall_H__
+
+#include "HoverPrereqs.h"
+#include "util/Math.h"
+#include "worldentities/StaticEntity.h"
+#include "graphics/Model.h"
+#include "objects/collisionshapes/BoxCollisionShape.h"
+
+
+namespace orxonox
+{
+ class _HoverExport HoverWall : public StaticEntity
+ {
+ public:
+ HoverWall(Context* context);
+ HoverWall(Context* context, int x, int y);
+ virtual ~HoverWall();
+ virtual void tick(float dt);
+ virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+
+ private:
+ Model* model_;
+ BoxCollisionShape* cs_;
+
+ };
+}
+
+#endif /* _HoverWall_H__ */
More information about the Orxonox-commit
mailing list