[2072] | 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 |
---|
[2446] | 24 | * Reto Grieder (physics) |
---|
[2072] | 25 | * Co-authors: |
---|
| 26 | * ... |
---|
| 27 | * |
---|
| 28 | */ |
---|
| 29 | |
---|
| 30 | #ifndef _Scene_H__ |
---|
| 31 | #define _Scene_H__ |
---|
| 32 | |
---|
| 33 | #include "OrxonoxPrereqs.h" |
---|
| 34 | |
---|
[2371] | 35 | #include "network/synchronisable/Synchronisable.h" |
---|
[2072] | 36 | #include "core/BaseObject.h" |
---|
| 37 | #include "util/Math.h" |
---|
[2171] | 38 | #include "objects/Tickable.h" |
---|
[2072] | 39 | |
---|
| 40 | namespace orxonox |
---|
| 41 | { |
---|
[2171] | 42 | class _OrxonoxExport Scene : public BaseObject, public Synchronisable, public Tickable |
---|
[2072] | 43 | { |
---|
| 44 | public: |
---|
| 45 | Scene(BaseObject* creator); |
---|
| 46 | virtual ~Scene(); |
---|
| 47 | |
---|
| 48 | virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); |
---|
| 49 | void registerVariables(); |
---|
| 50 | |
---|
| 51 | inline Ogre::SceneManager* getSceneManager() const |
---|
| 52 | { return this->sceneManager_; } |
---|
| 53 | inline Ogre::SceneNode* getRootSceneNode() const |
---|
| 54 | { return this->rootSceneNode_; } |
---|
| 55 | |
---|
| 56 | void setSkybox(const std::string& skybox); |
---|
| 57 | inline const std::string& getSkybox() const |
---|
| 58 | { return this->skybox_; } |
---|
| 59 | |
---|
| 60 | void setAmbientLight(const ColourValue& colour); |
---|
| 61 | inline const ColourValue& getAmbientLight() const |
---|
| 62 | { return this->ambientLight_; } |
---|
| 63 | |
---|
| 64 | void setShadow(bool bShadow); |
---|
| 65 | inline bool getShadow() const |
---|
| 66 | { return this->bShadows_; } |
---|
| 67 | |
---|
[2171] | 68 | virtual void tick(float dt); |
---|
| 69 | |
---|
[2072] | 70 | private: |
---|
| 71 | void addObject(BaseObject* object); |
---|
| 72 | BaseObject* getObject(unsigned int index) const; |
---|
| 73 | |
---|
| 74 | void networkcallback_applySkybox() |
---|
| 75 | { this->setSkybox(this->skybox_); } |
---|
| 76 | void networkcallback_applyAmbientLight() |
---|
| 77 | { this->setAmbientLight(this->ambientLight_); } |
---|
| 78 | |
---|
[2442] | 79 | Ogre::SceneManager* sceneManager_; |
---|
| 80 | Ogre::SceneNode* rootSceneNode_; |
---|
| 81 | |
---|
| 82 | std::string skybox_; |
---|
| 83 | ColourValue ambientLight_; |
---|
| 84 | std::list<BaseObject*> objects_; |
---|
| 85 | bool bShadows_; |
---|
[2446] | 86 | |
---|
| 87 | |
---|
| 88 | ///////////// |
---|
| 89 | // Physics // |
---|
| 90 | ///////////// |
---|
| 91 | |
---|
| 92 | public: |
---|
| 93 | inline bool hasPhysics() |
---|
| 94 | { return this->physicalWorld_ != 0; } |
---|
| 95 | void setPhysicalWorld(bool wantsPhysics); |
---|
| 96 | |
---|
| 97 | void setNegativeWorldRange(const Vector3& range); |
---|
| 98 | inline const Vector3& getNegativeWorldRange() const |
---|
| 99 | { return this->negativeWorldRange_; } |
---|
| 100 | |
---|
| 101 | void setPositiveWorldRange(const Vector3& range); |
---|
| 102 | inline const Vector3& getPositiveWorldRange() const |
---|
| 103 | { return this->positiveWorldRange_; } |
---|
| 104 | |
---|
| 105 | void setGravity(const Vector3& gravity); |
---|
| 106 | inline const Vector3& getGravity() const |
---|
| 107 | { return this->gravity_; } |
---|
| 108 | |
---|
| 109 | void addPhysicalObject(WorldEntity* object); |
---|
| 110 | void removePhysicalObject(WorldEntity* object); |
---|
| 111 | |
---|
| 112 | private: |
---|
| 113 | inline void networkcallback_hasPhysics() |
---|
| 114 | { this->setPhysicalWorld(this->bHasPhysics_); } |
---|
| 115 | inline void networkcallback_negativeWorldRange() |
---|
| 116 | { this->setNegativeWorldRange(this->negativeWorldRange_); } |
---|
| 117 | inline void networkcallback_positiveWorldRange() |
---|
| 118 | { this->setPositiveWorldRange(this->positiveWorldRange_); } |
---|
| 119 | inline void networkcallback_gravity() |
---|
| 120 | { this->setGravity(this->gravity_); } |
---|
| 121 | |
---|
| 122 | // Bullet objects |
---|
| 123 | btDiscreteDynamicsWorld* physicalWorld_; |
---|
| 124 | bt32BitAxisSweep3* broadphase_; |
---|
| 125 | btDefaultCollisionConfiguration* collisionConfig_; |
---|
| 126 | btCollisionDispatcher* dispatcher_; |
---|
| 127 | btSequentialImpulseConstraintSolver* solver_; |
---|
| 128 | |
---|
| 129 | std::set<WorldEntity*> physicalObjectQueue_; |
---|
| 130 | std::set<WorldEntity*> physicalObjects_; |
---|
| 131 | bool bHasPhysics_; |
---|
| 132 | Vector3 negativeWorldRange_; |
---|
| 133 | Vector3 positiveWorldRange_; |
---|
| 134 | Vector3 gravity_; |
---|
[2072] | 135 | }; |
---|
| 136 | } |
---|
| 137 | |
---|
| 138 | #endif /* _Scene_H__ */ |
---|