Sirikata
libogre/include/sirikata/ogre/Skybox.hpp
Go to the documentation of this file.
00001 // Copyright (c) 2012 Sirikata Authors. All rights reserved.
00002 // Use of this source code is governed by a BSD-style license that can
00003 // be found in the LICENSE file.
00004 
00005 #ifndef _SIRIKATA_OGRE_SKYBOX_HPP_
00006 #define _SIRIKATA_OGRE_SKYBOX_HPP_
00007 
00008 #include <sirikata/ogre/Platform.hpp>
00009 #include <sirikata/ogre/OgreHeaders.hpp>
00010 #include <sirikata/core/transfer/TransferMediator.hpp>
00011 #include <sirikata/core/transfer/ResourceDownloadTask.hpp>
00012 #include <sirikata/core/util/Liveness.hpp>
00013 
00014 namespace Sirikata {
00015 namespace Graphics {
00016 
00017 class ResourceLoader;
00018 
00023 struct SIRIKATA_OGRE_EXPORT Skybox : public Liveness {
00024   public:
00025     enum SkyboxShape {
00026         SKYBOX_CUBE,
00027         SKYBOX_DOME,
00028         SKYBOX_PLANE
00029     };
00030 
00031     Skybox();
00032     Skybox(SkyboxShape shap, const String& img);
00033     virtual ~Skybox();
00034 
00035     operator bool() const { return shape != (SkyboxShape)-1 && !image.empty(); }
00036 
00037     void load(Ogre::SceneManager* scene_mgr, ResourceLoader* loader, Transfer::TransferPoolPtr tpool);
00038     void unload();
00039 
00040     // Properties
00041     SkyboxShape shape;
00042     String image;
00043 
00044     float32 distance;
00045     // Properties - skydome
00046     float32 tiling;
00047     float32 curvature;
00048     Quaternion orientation;
00049 
00050   private:
00051     void imageDownloadFinished(Liveness::Token alive, Transfer::ResourceDownloadTaskPtr taskptr,
00052         Transfer::TransferRequestPtr request, Transfer::DenseDataPtr response);
00053     void materialLoadFinished(Liveness::Token alive, String matid);
00054 
00055 
00056     // Data used to track
00057     unsigned int mCDNArchive;
00058     bool mActiveCDNArchive;
00059 
00060     // These get set when we load the skybox, are needed to perform unloading
00061     Ogre::SceneManager* mSceneManager;
00062     ResourceLoader* mResourceLoader;
00063 
00064     // Intermediate data
00065     Transfer::ResourceDownloadTaskPtr mImageDownload;
00066 
00067     // Data stored to track loaded assets and unload them.
00068     String mTextureID;
00069     String materialID() const;
00070     bool mLoaded;
00071 };
00072 
00073 typedef std::tr1::shared_ptr<Skybox> SkyboxPtr;
00074 typedef std::tr1::weak_ptr<Skybox> SkyboxWPtr;
00075 
00076 
00077 } // namespace Graphics
00078 } // namespace Sirikata
00079 
00080 #endif //_SIRIKATA_OGRE_SKYBOX_HPP_