Orxonox  0.0.5 Codename: Arcturus
Scene.h
Go to the documentation of this file.
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  * Fabian 'x3n' Landau
24  * Reto Grieder (physics)
25  * Co-authors:
26  * ...
27  *
28  */
29 
35 #ifndef _Scene_H__
36 #define _Scene_H__
37 
38 #include "OrxonoxPrereqs.h"
39 
40 #include <list>
41 #include <set>
42 #include <string>
43 
44 #include "util/Math.h"
45 #include "util/OgreForwardRefs.h"
46 #include "core/BaseObject.h"
47 #include "core/object/Context.h"
51 
52 namespace orxonox
53 {
54  class _OrxonoxExport Scene : public BaseObject, public Synchronisable, public Tickable, public Context
55  {
56  public:
63  Scene(Context* context);
64  virtual ~Scene();
65 
66  virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override;
67  void registerVariables();
68 
69  inline Ogre::SceneManager* getSceneManager() const
70  { return this->sceneManager_; }
71  inline Ogre::SceneNode* getRootSceneNode() const
72  { return this->rootSceneNode_; }
74  { return this->renderQueueListener_; }
75 
76  void setSkybox(const std::string& skybox);
77  inline const std::string& getSkybox() const
78  { return this->skybox_; }
79 
80  void setAmbientLight(const ColourValue& colour);
81  inline const ColourValue& getAmbientLight() const
82  { return this->ambientLight_; }
83 
84  void setShadow(bool bShadow);
85  inline bool getShadow() const
86  { return this->bShadows_; }
87 
88  inline void setSoundReferenceDistance(float distance)
89  { this->soundReferenceDistance_ = distance; }
90  inline float getSoundReferenceDistance() const
91  { return this->soundReferenceDistance_; }
92 
93  inline Radar* getRadar()
94  { return this->radar_; }
95 
96  virtual inline uint32_t getSceneID() const override { return this->getObjectID(); }
97 
98  virtual void tick(float dt) override;
99 
100  private:
101  void addObject(BaseObject* object);
102  BaseObject* getObject(unsigned int index) const;
103 
105  { this->setSkybox(this->skybox_); }
107  { this->setAmbientLight(this->ambientLight_); }
109  { this->setShadow(this->bShadows_); }
110 
111  Ogre::SceneManager* sceneManager_;
112  Ogre::SceneNode* rootSceneNode_;
114 
116  ColourValue ambientLight_;
117  std::list<BaseObject*> objects_;
118  bool bShadows_;
122 
123 
125  // Physics //
127 
128  public:
129  inline bool hasPhysics() const
130  { return this->physicalWorld_ != nullptr; }
131  void setPhysicalWorld(bool wantsPhysics);
132 
133  void setNegativeWorldRange(const Vector3& range);
134  inline const Vector3& getNegativeWorldRange() const
135  { return this->negativeWorldRange_; }
136 
137  void setPositiveWorldRange(const Vector3& range);
138  inline const Vector3& getPositiveWorldRange() const
139  { return this->positiveWorldRange_; }
140 
141  void setGravity(const Vector3& gravity);
142  inline const Vector3& getGravity() const
143  { return this->gravity_; }
144 
145  void addPhysicalObject(WorldEntity* object);
146  void removePhysicalObject(WorldEntity* object);
147 
148  inline bool isUpdatingPhysics() const
149  { return this->bIsUpdatingPhysics_; }
150 
151  void setDebugDrawPhysics(bool bDraw, bool bFill, float fillAlpha);
152 
153  static void consoleCommand_debugDrawPhysics(bool bDraw, bool bFill, float fillAlpha);
154 
155  private:
157  { this->setPhysicalWorld(this->bHasPhysics_); }
159  { this->setNegativeWorldRange(this->negativeWorldRange_); }
161  { this->setPositiveWorldRange(this->positiveWorldRange_); }
163  { this->setGravity(this->gravity_); }
164 
165  // collision callback from bullet
166  static bool collisionCallback(btManifoldPoint& cp, const btCollisionObject* colObj0, int partId0,
167  int index0, const btCollisionObject* colObj1, int partId1, int index1);
168 
169  // Bullet objects
170  btDiscreteDynamicsWorld* physicalWorld_;
171  bt32BitAxisSweep3* broadphase_;
172  btDefaultCollisionConfiguration* collisionConfig_;
173  btCollisionDispatcher* dispatcher_;
174  btSequentialImpulseConstraintSolver* solver_;
175 
176  std::set<WorldEntity*> physicalObjectQueue_;
177  std::set<WorldEntity*> physicalObjects_;
181  Vector3 gravity_;
182 
186  };
187 }
188 
189 #endif /* _Scene_H__ */
The BaseObject is the parent of all classes representing an instance in the game. ...
Definition: BaseObject.h:63
Radar * radar_
This is a pointer to a Radar object assigned with this scene.
Definition: Scene.h:120
std::string skybox_
This string holds information about the skybox we&#39;re using.
Definition: Scene.h:115
WeakPtr< GlobalShader > glowShader_
Definition: Scene.h:121
std::list< BaseObject * > objects_
This list holds all the objects created in our scene.
Definition: Scene.h:117
Ogre::SceneManager * getSceneManager() const
Definition: Scene.h:69
bool bIsUpdatingPhysics_
Definition: Scene.h:185
bool getShadow() const
Definition: Scene.h:85
This class is the base class of all the Objects in the universe that need to be synchronised over the...
Definition: Synchronisable.h:142
Declaration of the Tickable interface.
bool bHasPhysics_
Definition: Scene.h:178
float getSoundReferenceDistance() const
Definition: Scene.h:90
::std::string string
Definition: gtest-port.h:756
btCollisionDispatcher * dispatcher_
Definition: Scene.h:173
bool bShadows_
Do we want shadows in our scene?
Definition: Scene.h:118
float soundReferenceDistance_
This holds a reference distance, which represents the distance between our scene and the listener...
Definition: Scene.h:119
Radar * getRadar()
Definition: Scene.h:93
const Vector3 & getNegativeWorldRange() const
Definition: Scene.h:134
btSequentialImpulseConstraintSolver * solver_
Definition: Scene.h:174
void networkcallback_negativeWorldRange()
Definition: Scene.h:158
RenderQueueListener * getRenderQueueListener() const
Definition: Scene.h:73
void networkcallback_applySkybox()
Definition: Scene.h:104
WeakPtr wraps a pointer to an object, which becomes nullptr if the object is deleted.
Definition: CorePrereqs.h:236
std::set< WorldEntity * > physicalObjects_
Definition: Scene.h:177
Ogre::ColourValue colour(const btVector3 &color, btScalar alpha)
Definition: OgreBulletUtils.h:41
Declaration the SetConsoleCommand() macro.
btDefaultCollisionConfiguration * collisionConfig_
Definition: Scene.h:172
The WorldEntity represents everything that can be put in a Scene at a certain location.
Definition: WorldEntity.h:72
const Vector3 & getPositiveWorldRange() const
Definition: Scene.h:138
void setSoundReferenceDistance(float distance)
Definition: Scene.h:88
Definition: Radar.h:49
xmlelement
Definition: Super.h:519
void networkcallback_applyShadows()
Definition: Scene.h:108
Vector3 positiveWorldRange_
Definition: Scene.h:180
bool hasPhysics() const
Definition: Scene.h:129
Declaration and implementation of several math-functions, typedefs of some Ogre::Math classes to the ...
bool bDebugDrawPhysics_
Definition: Scene.h:184
Vector3 negativeWorldRange_
Definition: Scene.h:179
Originally from http://www.ogre3d.org/tikiwiki/BulletDebugDrawer&structure=Cookbook This source code ...
Definition: BulletDebugDrawer.h:19
Ogre::SceneNode * getRootSceneNode() const
Definition: Scene.h:71
Die Wagnis Klasse hat die folgenden Aufgaben:
Definition: ApplicationPaths.cc:66
Mode
Definition: CorePrereqs.h:102
Shared library macros, enums, constants and forward declarations for the orxonox library ...
void networkcallback_gravity()
Definition: Scene.h:162
Declaration of BaseObject, the base class of all objects in Orxonox.
Vector3 gravity_
Definition: Scene.h:181
btDiscreteDynamicsWorld * physicalWorld_
Definition: Scene.h:170
Definition: Context.h:45
#define _OrxonoxExport
Definition: OrxonoxPrereqs.h:60
bool isUpdatingPhysics() const
Definition: Scene.h:148
const ColourValue & getAmbientLight() const
Definition: Scene.h:81
This class derives from the Ogre-Class RenderQueueListener and provides a way to define new rendering...
Definition: RenderQueueListener.h:65
Definition: Scene.h:54
const Vector3 & getGravity() const
Definition: Scene.h:142
Ogre::SceneNode * rootSceneNode_
This is a pointer to the root node of the Scene tree.
Definition: Scene.h:112
BulletDebugDrawer * debugDrawer_
Definition: Scene.h:183
void networkcallback_hasPhysics()
Definition: Scene.h:156
virtual uint32_t getSceneID() const override
Definition: Scene.h:96
const std::string & getSkybox() const
Definition: Scene.h:77
void networkcallback_applyAmbientLight()
Definition: Scene.h:106
The Tickable interface provides a tick(dt) function, that gets called every frame.
Definition: Tickable.h:52
std::set< WorldEntity * > physicalObjectQueue_
Definition: Scene.h:176
ColourValue ambientLight_
This variable holds the color value for the ambient light in our scene, usually black in space...
Definition: Scene.h:116
void networkcallback_positiveWorldRange()
Definition: Scene.h:160
RenderQueueListener * renderQueueListener_
this is a pointer to the RenderQueueListener we&#39;re using for this Scene
Definition: Scene.h:113
bt32BitAxisSweep3 * broadphase_
Definition: Scene.h:171
Ogre::SceneManager * sceneManager_
This is a pointer to the Ogre SceneManager we&#39;re using to render the Scene.
Definition: Scene.h:111