[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 |
---|
[2662] | 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 | |
---|
[3196] | 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" |
---|
[2662] | 42 | #include "network/synchronisable/Synchronisable.h" |
---|
[5693] | 43 | #include "tools/interfaces/Tickable.h" |
---|
[2072] | 44 | |
---|
| 45 | namespace orxonox |
---|
| 46 | { |
---|
[9667] | 47 | class _OrxonoxExport Scene : public BaseObject, public Synchronisable, public Tickable, public Context |
---|
[2072] | 48 | { |
---|
| 49 | public: |
---|
[9667] | 50 | Scene(Context* context); |
---|
[2072] | 51 | virtual ~Scene(); |
---|
| 52 | |
---|
| 53 | virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); |
---|
| 54 | void registerVariables(); |
---|
| 55 | |
---|
| 56 | inline Ogre::SceneManager* getSceneManager() const |
---|
| 57 | { return this->sceneManager_; } |
---|
| 58 | inline Ogre::SceneNode* getRootSceneNode() const |
---|
| 59 | { return this->rootSceneNode_; } |
---|
| 60 | |
---|
| 61 | void setSkybox(const std::string& skybox); |
---|
| 62 | inline const std::string& getSkybox() const |
---|
| 63 | { return this->skybox_; } |
---|
| 64 | |
---|
| 65 | void setAmbientLight(const ColourValue& colour); |
---|
| 66 | inline const ColourValue& getAmbientLight() const |
---|
| 67 | { return this->ambientLight_; } |
---|
| 68 | |
---|
| 69 | void setShadow(bool bShadow); |
---|
| 70 | inline bool getShadow() const |
---|
| 71 | { return this->bShadows_; } |
---|
| 72 | |
---|
[6417] | 73 | inline void setSoundReferenceDistance(float distance) |
---|
| 74 | { this->soundReferenceDistance_ = distance; } |
---|
| 75 | inline float getSoundReferenceDistance() const |
---|
| 76 | { return this->soundReferenceDistance_; } |
---|
| 77 | |
---|
[5929] | 78 | inline Radar* getRadar() |
---|
| 79 | { return this->radar_; } |
---|
[6417] | 80 | |
---|
[5929] | 81 | inline virtual uint32_t getSceneID() const { return this->getObjectID(); } |
---|
| 82 | |
---|
[2171] | 83 | virtual void tick(float dt); |
---|
| 84 | |
---|
[2072] | 85 | private: |
---|
| 86 | void addObject(BaseObject* object); |
---|
| 87 | BaseObject* getObject(unsigned int index) const; |
---|
| 88 | |
---|
| 89 | void networkcallback_applySkybox() |
---|
| 90 | { this->setSkybox(this->skybox_); } |
---|
| 91 | void networkcallback_applyAmbientLight() |
---|
| 92 | { this->setAmbientLight(this->ambientLight_); } |
---|
[2662] | 93 | void networkcallback_applyShadows() |
---|
| 94 | { this->setShadow(this->bShadows_); } |
---|
[2072] | 95 | |
---|
[2662] | 96 | Ogre::SceneManager* sceneManager_; |
---|
| 97 | Ogre::SceneNode* rootSceneNode_; |
---|
| 98 | |
---|
| 99 | std::string skybox_; |
---|
| 100 | ColourValue ambientLight_; |
---|
| 101 | std::list<BaseObject*> objects_; |
---|
| 102 | bool bShadows_; |
---|
[6417] | 103 | float soundReferenceDistance_; |
---|
[5929] | 104 | Radar* radar_; |
---|
[2662] | 105 | |
---|
| 106 | |
---|
| 107 | ///////////// |
---|
| 108 | // Physics // |
---|
| 109 | ///////////// |
---|
| 110 | |
---|
| 111 | public: |
---|
| 112 | inline bool hasPhysics() |
---|
| 113 | { return this->physicalWorld_ != 0; } |
---|
| 114 | void setPhysicalWorld(bool wantsPhysics); |
---|
| 115 | |
---|
| 116 | void setNegativeWorldRange(const Vector3& range); |
---|
| 117 | inline const Vector3& getNegativeWorldRange() const |
---|
| 118 | { return this->negativeWorldRange_; } |
---|
| 119 | |
---|
| 120 | void setPositiveWorldRange(const Vector3& range); |
---|
| 121 | inline const Vector3& getPositiveWorldRange() const |
---|
| 122 | { return this->positiveWorldRange_; } |
---|
| 123 | |
---|
| 124 | void setGravity(const Vector3& gravity); |
---|
| 125 | inline const Vector3& getGravity() const |
---|
| 126 | { return this->gravity_; } |
---|
| 127 | |
---|
| 128 | void addPhysicalObject(WorldEntity* object); |
---|
| 129 | void removePhysicalObject(WorldEntity* object); |
---|
| 130 | |
---|
| 131 | private: |
---|
| 132 | inline void networkcallback_hasPhysics() |
---|
| 133 | { this->setPhysicalWorld(this->bHasPhysics_); } |
---|
| 134 | inline void networkcallback_negativeWorldRange() |
---|
| 135 | { this->setNegativeWorldRange(this->negativeWorldRange_); } |
---|
| 136 | inline void networkcallback_positiveWorldRange() |
---|
| 137 | { this->setPositiveWorldRange(this->positiveWorldRange_); } |
---|
| 138 | inline void networkcallback_gravity() |
---|
| 139 | { this->setGravity(this->gravity_); } |
---|
| 140 | |
---|
| 141 | // collision callback from bullet |
---|
| 142 | static bool collisionCallback(btManifoldPoint& cp, const btCollisionObject* colObj0, int partId0, |
---|
| 143 | int index0, const btCollisionObject* colObj1, int partId1, int index1); |
---|
| 144 | |
---|
[10073] | 145 | static bool customCollisionCallback(btManifoldPoint& cp, const btCollisionObject* colObj0, int partId0, |
---|
| 146 | int index0, const btCollisionObject* colObj1, int partId1, int index1); |
---|
| 147 | |
---|
[2662] | 148 | // Bullet objects |
---|
| 149 | btDiscreteDynamicsWorld* physicalWorld_; |
---|
| 150 | bt32BitAxisSweep3* broadphase_; |
---|
| 151 | btDefaultCollisionConfiguration* collisionConfig_; |
---|
| 152 | btCollisionDispatcher* dispatcher_; |
---|
| 153 | btSequentialImpulseConstraintSolver* solver_; |
---|
| 154 | |
---|
| 155 | std::set<WorldEntity*> physicalObjectQueue_; |
---|
| 156 | std::set<WorldEntity*> physicalObjects_; |
---|
| 157 | bool bHasPhysics_; |
---|
| 158 | Vector3 negativeWorldRange_; |
---|
| 159 | Vector3 positiveWorldRange_; |
---|
| 160 | Vector3 gravity_; |
---|
[2072] | 161 | }; |
---|
| 162 | } |
---|
| 163 | |
---|
| 164 | #endif /* _Scene_H__ */ |
---|