Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/orxonox/Scene.h @ 11071

Last change on this file since 11071 was 11071, checked in by landauf, 8 years ago

merged branch cpp11_v3 back to trunk

  • Property svn:eol-style set to native
File size: 6.4 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 *      Fabian 'x3n' Landau
24 *      Reto Grieder (physics)
25 *   Co-authors:
26 *      ...
27 *
28 */
29
30#ifndef _Scene_H__
31#define _Scene_H__
32
33#include "OrxonoxPrereqs.h"
34
35#include <list>
36#include <set>
37#include <string>
38
39#include "util/Math.h"
40#include "util/OgreForwardRefs.h"
41#include "core/BaseObject.h"
42#include "core/object/Context.h"
43#include "network/synchronisable/Synchronisable.h"
44#include "tools/interfaces/Tickable.h"
45
46namespace orxonox
47{
48    class _OrxonoxExport Scene : public BaseObject, public Synchronisable, public Tickable, public Context
49    {
50        public:
51            Scene(Context* context);
52            virtual ~Scene();
53
54            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override;
55            void registerVariables();
56
57            inline Ogre::SceneManager* getSceneManager() const
58                { return this->sceneManager_; }
59            inline Ogre::SceneNode* getRootSceneNode() const
60                { return this->rootSceneNode_; }
61
62            void setSkybox(const std::string& skybox);
63            inline const std::string& getSkybox() const
64                { return this->skybox_; }
65
66            void setAmbientLight(const ColourValue& colour);
67            inline const ColourValue& getAmbientLight() const
68                { return this->ambientLight_; }
69
70            void setShadow(bool bShadow);
71            inline bool getShadow() const
72                { return this->bShadows_; }
73
74            inline void setSoundReferenceDistance(float distance)
75                { this->soundReferenceDistance_ = distance; }
76            inline float getSoundReferenceDistance() const
77                { return this->soundReferenceDistance_; }
78
79            inline Radar* getRadar()
80                { return this->radar_; }
81
82            virtual inline uint32_t getSceneID() const override { return this->getObjectID(); }
83
84            virtual void tick(float dt) override;
85
86        private:
87            void addObject(BaseObject* object);
88            BaseObject* getObject(unsigned int index) const;
89
90            void networkcallback_applySkybox()
91                { this->setSkybox(this->skybox_); }
92            void networkcallback_applyAmbientLight()
93                { this->setAmbientLight(this->ambientLight_); }
94            void networkcallback_applyShadows()
95                { this->setShadow(this->bShadows_); }
96
97            Ogre::SceneManager*      sceneManager_;
98            Ogre::SceneNode*         rootSceneNode_;
99
100            std::string              skybox_;
101            ColourValue              ambientLight_;
102            std::list<BaseObject*>   objects_;
103            bool                     bShadows_;
104            float                    soundReferenceDistance_;
105            Radar*                   radar_;
106
107
108        /////////////
109        // Physics //
110        /////////////
111
112        public:
113            inline bool hasPhysics() const
114                { return this->physicalWorld_ != nullptr; }
115            void setPhysicalWorld(bool wantsPhysics);
116
117            void setNegativeWorldRange(const Vector3& range);
118            inline const Vector3& getNegativeWorldRange() const
119                { return this->negativeWorldRange_; }
120
121            void setPositiveWorldRange(const Vector3& range);
122            inline const Vector3& getPositiveWorldRange() const
123                { return this->positiveWorldRange_; }
124
125            void setGravity(const Vector3& gravity);
126            inline const Vector3& getGravity() const
127                { return this->gravity_; }
128
129            void addPhysicalObject(WorldEntity* object);
130            void removePhysicalObject(WorldEntity* object);
131
132            inline bool isUpdatingPhysics() const
133                { return this->bIsUpdatingPhysics_; }
134
135            void setDebugDrawPhysics(bool bDraw, bool bFill, float fillAlpha);
136
137            static void consoleCommand_debugDrawPhysics(bool bDraw, bool bFill, float fillAlpha);
138
139        private:
140            inline void networkcallback_hasPhysics()
141                { this->setPhysicalWorld(this->bHasPhysics_); }
142            inline void networkcallback_negativeWorldRange()
143                { this->setNegativeWorldRange(this->negativeWorldRange_); }
144            inline void networkcallback_positiveWorldRange()
145                { this->setPositiveWorldRange(this->positiveWorldRange_); }
146            inline void networkcallback_gravity()
147                { this->setGravity(this->gravity_); }
148
149            // collision callback from bullet
150            static bool collisionCallback(btManifoldPoint& cp, const btCollisionObject* colObj0, int partId0,
151                                          int index0, const btCollisionObject* colObj1, int partId1, int index1);
152
153            // Bullet objects
154            btDiscreteDynamicsWorld*             physicalWorld_;
155            bt32BitAxisSweep3*                   broadphase_;
156            btDefaultCollisionConfiguration*     collisionConfig_;
157            btCollisionDispatcher*               dispatcher_;
158            btSequentialImpulseConstraintSolver* solver_;
159
160            std::set<WorldEntity*>               physicalObjectQueue_;
161            std::set<WorldEntity*>               physicalObjects_;
162            bool                                 bHasPhysics_;
163            Vector3                              negativeWorldRange_;
164            Vector3                              positiveWorldRange_;
165            Vector3                              gravity_;
166
167            BulletDebugDrawer*                   debugDrawer_;
168            bool                                 bDebugDrawPhysics_;
169            bool                                 bIsUpdatingPhysics_;
170    };
171}
172
173#endif /* _Scene_H__ */
Note: See TracBrowser for help on using the repository browser.