Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

Added Hardware Occlusion Query Capabilities for use in dynamic flare effects, this is still a pretty static implemenation, meaning it will fail with mutltiple HOQ objects on screen, also needs some tidying up and documentation at a later point

  • Property svn:eol-style set to native
File size: 7.1 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            inline RenderQueueListener* getRenderQueueListener() const
72                { return this->renderQueueListener_; }
73
74            void setSkybox(const std::string& skybox);
75            inline const std::string& getSkybox() const
76                { return this->skybox_; }
77
78            void setAmbientLight(const ColourValue& colour);
79            inline const ColourValue& getAmbientLight() const
80                { return this->ambientLight_; }
81
82            void setShadow(bool bShadow);
83            inline bool getShadow() const
84                { return this->bShadows_; }
85
86            inline void setSoundReferenceDistance(float distance)
87                { this->soundReferenceDistance_ = distance; }
88            inline float getSoundReferenceDistance() const
89                { return this->soundReferenceDistance_; }
90
91            inline Radar* getRadar()
92                { return this->radar_; }
93
94            inline virtual uint32_t getSceneID() const { return this->getObjectID(); }
95
96            virtual void tick(float dt);
97
98        private:
99            void addObject(BaseObject* object);
100            BaseObject* getObject(unsigned int index) const;
101
102            void networkcallback_applySkybox()
103                { this->setSkybox(this->skybox_); }
104            void networkcallback_applyAmbientLight()
105                { this->setAmbientLight(this->ambientLight_); }
106            void networkcallback_applyShadows()
107                { this->setShadow(this->bShadows_); }
108
109            Ogre::SceneManager*      sceneManager_; //!< This is a pointer to the Ogre SceneManager we're using to render the Scene
110            Ogre::SceneNode*         rootSceneNode_; //!< This is a pointer to the root node of the Scene tree
111            RenderQueueListener*     renderQueueListener_; //!< this is a pointer to the RenderQueueListener we're using for this Scene
112
113            std::string              skybox_; //!< This string holds information about the skybox we're using
114            ColourValue              ambientLight_; //!< This variable holds the color value for the ambient light in our scene, usually black in space
115            std::list<BaseObject*>   objects_; //!< This list holds all the objects created in our scene
116            bool                     bShadows_; //!< Do we want shadows in our scene?
117            float                    soundReferenceDistance_; //!< This holds a reference distance, which represents the distance between our scene and the listener
118            Radar*                   radar_; //!< This is a pointer to a Radar object assigned with this scene
119
120
121        /////////////
122        // Physics //
123        /////////////
124
125        public:
126            inline bool hasPhysics()
127                { return this->physicalWorld_ != 0; }
128            void setPhysicalWorld(bool wantsPhysics);
129
130            void setNegativeWorldRange(const Vector3& range);
131            inline const Vector3& getNegativeWorldRange() const
132                { return this->negativeWorldRange_; }
133
134            void setPositiveWorldRange(const Vector3& range);
135            inline const Vector3& getPositiveWorldRange() const
136                { return this->positiveWorldRange_; }
137
138            void setGravity(const Vector3& gravity);
139            inline const Vector3& getGravity() const
140                { return this->gravity_; }
141
142            void addPhysicalObject(WorldEntity* object);
143            void removePhysicalObject(WorldEntity* object);
144
145        private:
146            inline void networkcallback_hasPhysics()
147                { this->setPhysicalWorld(this->bHasPhysics_); }
148            inline void networkcallback_negativeWorldRange()
149                { this->setNegativeWorldRange(this->negativeWorldRange_); }
150            inline void networkcallback_positiveWorldRange()
151                { this->setPositiveWorldRange(this->positiveWorldRange_); }
152            inline void networkcallback_gravity()
153                { this->setGravity(this->gravity_); }
154
155            // collision callback from bullet
156            static bool collisionCallback(btManifoldPoint& cp, const btCollisionObject* colObj0, int partId0,
157                                          int index0, const btCollisionObject* colObj1, int partId1, int index1);
158
159            // Bullet objects
160            btDiscreteDynamicsWorld*             physicalWorld_;
161            bt32BitAxisSweep3*                   broadphase_;
162            btDefaultCollisionConfiguration*     collisionConfig_;
163            btCollisionDispatcher*               dispatcher_;
164            btSequentialImpulseConstraintSolver* solver_;
165
166            std::set<WorldEntity*>               physicalObjectQueue_;
167            std::set<WorldEntity*>               physicalObjects_;
168            bool                                 bHasPhysics_;
169            Vector3                              negativeWorldRange_;
170            Vector3                              positiveWorldRange_;
171            Vector3                              gravity_;
172    };
173}
174
175#endif /* _Scene_H__ */
Note: See TracBrowser for help on using the repository browser.