Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/shaders/src/orxonox/Scene.h @ 9420

Last change on this file since 9420 was 9420, checked in by davidsa, 12 years ago

Added some documentation to orxonox::Scene

  • Property svn:eol-style set to native
File size: 6.9 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/**
31@file Scene.h
32@brief Definition of Scene Class
33*/
34
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 "network/synchronisable/Synchronisable.h"
48#include "tools/interfaces/Tickable.h"
49
50namespace orxonox
51{
52    class _OrxonoxExport Scene : public BaseObject, public Synchronisable, public Tickable
53    {
54        public:
55            /**
56            @brief
57                This class holds a Scene which is a collection of all kinds of objects to be rendered in the same space,
58                with the same physics and the same light properties. Objects can be anything from a light source, over non physical objects
59                like Billboards to just plain Models with an attached Mesh
60            */
61            Scene(BaseObject* creator);
62            virtual ~Scene();
63
64            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
65            void registerVariables();
66
67            inline Ogre::SceneManager* getSceneManager() const
68                { return this->sceneManager_; }
69            inline Ogre::SceneNode* getRootSceneNode() const
70                { return this->rootSceneNode_; }
71
72            void setSkybox(const std::string& skybox);
73            inline const std::string& getSkybox() const
74                { return this->skybox_; }
75
76            void setAmbientLight(const ColourValue& colour);
77            inline const ColourValue& getAmbientLight() const
78                { return this->ambientLight_; }
79
80            void setShadow(bool bShadow);
81            inline bool getShadow() const
82                { return this->bShadows_; }
83
84            inline void setSoundReferenceDistance(float distance)
85                { this->soundReferenceDistance_ = distance; }
86            inline float getSoundReferenceDistance() const
87                { return this->soundReferenceDistance_; }
88
89            inline Radar* getRadar()
90                { return this->radar_; }
91
92            inline virtual uint32_t getSceneID() const { return this->getObjectID(); }
93
94            virtual void tick(float dt);
95
96        private:
97            void addObject(BaseObject* object);
98            BaseObject* getObject(unsigned int index) const;
99
100            void networkcallback_applySkybox()
101                { this->setSkybox(this->skybox_); }
102            void networkcallback_applyAmbientLight()
103                { this->setAmbientLight(this->ambientLight_); }
104            void networkcallback_applyShadows()
105                { this->setShadow(this->bShadows_); }
106
107            Ogre::SceneManager*      sceneManager_; //!< This is a pointer to the Ogre SceneManager we're using to render the Scene
108            Ogre::SceneNode*         rootSceneNode_; //!< This is a pointer to the root node of the Scene tree
109
110            std::string              skybox_; //!< This string holds information about the skybox we're using
111            ColourValue              ambientLight_; //!< This variable holds the color value for the ambient light in our scene, usually black in space
112            std::list<BaseObject*>   objects_; //!< This list holds all the objects created in our scene
113            bool                     bShadows_; //!< Do we want shadows in our scene?
114            float                    soundReferenceDistance_; //!< This holds a reference distance, which represents the distance between our scene and the listener
115            Radar*                   radar_; //!< This is a pointer to a Radar object assigned with this scene
116
117
118        /////////////
119        // Physics //
120        /////////////
121
122        public:
123            inline bool hasPhysics()
124                { return this->physicalWorld_ != 0; }
125            void setPhysicalWorld(bool wantsPhysics);
126
127            void setNegativeWorldRange(const Vector3& range);
128            inline const Vector3& getNegativeWorldRange() const
129                { return this->negativeWorldRange_; }
130
131            void setPositiveWorldRange(const Vector3& range);
132            inline const Vector3& getPositiveWorldRange() const
133                { return this->positiveWorldRange_; }
134
135            void setGravity(const Vector3& gravity);
136            inline const Vector3& getGravity() const
137                { return this->gravity_; }
138
139            void addPhysicalObject(WorldEntity* object);
140            void removePhysicalObject(WorldEntity* object);
141
142        private:
143            inline void networkcallback_hasPhysics()
144                { this->setPhysicalWorld(this->bHasPhysics_); }
145            inline void networkcallback_negativeWorldRange()
146                { this->setNegativeWorldRange(this->negativeWorldRange_); }
147            inline void networkcallback_positiveWorldRange()
148                { this->setPositiveWorldRange(this->positiveWorldRange_); }
149            inline void networkcallback_gravity()
150                { this->setGravity(this->gravity_); }
151
152            // collision callback from bullet
153            static bool collisionCallback(btManifoldPoint& cp, const btCollisionObject* colObj0, int partId0,
154                                          int index0, const btCollisionObject* colObj1, int partId1, int index1);
155
156            // Bullet objects
157            btDiscreteDynamicsWorld*             physicalWorld_;
158            bt32BitAxisSweep3*                   broadphase_;
159            btDefaultCollisionConfiguration*     collisionConfig_;
160            btCollisionDispatcher*               dispatcher_;
161            btSequentialImpulseConstraintSolver* solver_;
162
163            std::set<WorldEntity*>               physicalObjectQueue_;
164            std::set<WorldEntity*>               physicalObjects_;
165            bool                                 bHasPhysics_;
166            Vector3                              negativeWorldRange_;
167            Vector3                              positiveWorldRange_;
168            Vector3                              gravity_;
169    };
170}
171
172#endif /* _Scene_H__ */
Note: See TracBrowser for help on using the repository browser.