00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00023
00024 #ifndef H_SPK_IRRSYSTEM
00025 #define H_SPK_IRRSYSTEM
00026
00027 #include "RenderingAPIs/Irrlicht/SPK_IRR_DEF.h"
00028 #include "Core/SPK_System.h"
00029
00030 namespace SPK
00031 {
00032 namespace IRR
00033 {
00050 class SPK_IRR_PREFIX IRRSystem : public System, public irr::scene::ISceneNode
00051 {
00052 SPK_IMPLEMENT_REGISTERABLE(IRRSystem)
00053
00054 public:
00055
00057
00059
00067 IRRSystem(irr::scene::ISceneNode* parent,irr::scene::ISceneManager* mgr,bool worldTransformed = true,irr::s32 id=-1);
00068
00069 IRRSystem(const IRRSystem& system);
00070
00079 static IRRSystem* create(irr::scene::ISceneNode* parent,irr::scene::ISceneManager* mgr,bool worldTransformed = true,irr::s32 id=-1);
00080
00082
00084
00090 void setAutoUpdateEnabled(bool enableState, bool onlyWhenVisible);
00091
00093
00095
00103 bool isAutoUpdateEnabled() const;
00104
00109 bool isUpdateOnlyWhenVisible() const;
00110
00121 bool isWorldTransformed() const;
00122
00130 virtual const irr::core::aabbox3d<irr::f32>& getBoundingBox() const;
00131
00145 bool hasFinished() const;
00146
00148
00150
00151 virtual bool update(float deltaTime);
00152
00158 virtual void render();
00159
00165 virtual void render() const;
00166
00168 virtual void OnRegisterSceneNode();
00169
00177 virtual void OnAnimate(irr::u32 timeMs);
00178
00180 virtual void updateAbsolutePosition();
00181
00182 private:
00183
00184 bool AutoUpdate;
00185 bool AlwaysUpdate;
00186
00187 const bool worldTransformed;
00188
00189 bool finished;
00190
00191 mutable irr::core::aabbox3d<irr::f32> BBox;
00192 mutable irr::u32 lastUpdatedTime;
00193
00194 virtual void onRegister();
00195 virtual void onUnregister();
00196
00197
00198 void updateCameraPosition() const;
00199 };
00200
00201
00202 inline IRRSystem* IRRSystem::create(irr::scene::ISceneNode* parent,irr::scene::ISceneManager* mgr,bool worldTransformed,irr::s32 id)
00203 {
00204 IRRSystem* obj = new IRRSystem(parent,mgr,worldTransformed,id);
00205 registerObject(obj);
00206 return obj;
00207 }
00208
00209 inline bool IRRSystem::isAutoUpdateEnabled() const
00210 {
00211 return AutoUpdate;
00212 }
00213
00214 inline bool IRRSystem::isUpdateOnlyWhenVisible() const
00215 {
00216 return !AlwaysUpdate;
00217 }
00218
00219 inline bool IRRSystem::isWorldTransformed() const
00220 {
00221 return worldTransformed;
00222 }
00223
00224 inline bool IRRSystem::hasFinished() const
00225 {
00226 return finished;
00227 }
00228
00229 inline void IRRSystem::setAutoUpdateEnabled(bool enableState, bool onlyWhenVisible)
00230 {
00231 AutoUpdate = enableState;
00232 AlwaysUpdate = !onlyWhenVisible;
00233 }
00234
00235 inline bool IRRSystem::update(float deltaTime)
00236 {
00237 updateCameraPosition();
00238 finished = !System::update(deltaTime);
00239 return !finished;
00240 }
00241
00242 inline void IRRSystem::render()
00243 {
00244 const_cast<const IRRSystem*>(this)->render();
00245 }
00246
00247 inline void IRRSystem::onRegister()
00248 {
00249 grab();
00250 }
00251
00252 inline void IRRSystem::onUnregister()
00253 {
00254 remove();
00255 }
00256 }}
00257
00258 #endif
00259