All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
CityThemesAnimatedObjectsLoader.h
1 // Copyright eeGeo Ltd (2012-2014), All Rights Reserved
2 
3 #pragma once
4 
5 #include <string>
6 #include <vector>
7 #include <set>
8 #include "Types.h"
9 #include "Web.h"
10 #include "Rendering.h"
11 #include "AnimatedObjects.h"
12 #include "Helpers.h"
13 #include "VectorMath.h"
14 #include "HttpAsyncTextureLoader.h"
15 #include "POD.h"
16 #include "CityThemes.h"
17 #include "Models.h"
18 #include "ModelInfoRef.h"
19 #include "PendingWebRequestsContainer.h"
20 
21 namespace Eegeo
22 {
23  namespace Resources
24  {
25  namespace CityThemes
26  {
28  {
29  public:
31  Web::IWebLoadRequestFactory& webRequestFactory,
32  Eegeo::Helpers::IHttpCache& httpCache,
34  );
35 
37 
38  void LoadAnimatedObjectsForTheme(const CityThemeData& theme);
39  bool IsLoading() const { return m_modelsStillToDownload > 0; }
40  bool LoadsFailed() const { return m_modelLoadingFailed; }
41  void CleanupRedundantLoads();
42  void RegisterAnimatedObjectsObserver(ICityThemeAnimatedObjectsObserver& observer);
43  void UnregisterAnimatedObjectsObserver(ICityThemeAnimatedObjectsObserver& observer);
44  void ApplyTheme();
45 
46  private:
47  Web::IWebLoadRequestFactory& m_webRequestFactory;
49  Eegeo::Helpers::IHttpCache& m_httpCache;
51 
52  CityThemeId m_targetThemeId;
53  int m_modelsStillToDownload;
54  bool m_modelLoadingFailed;
55 
56  std::map<std::string, ModelInfoRef> m_loadedModels;
57  std::vector<ICityThemeAnimatedObjectsObserver*> m_observers;
58  Web::PendingWebRequestsContainer m_pendingWebRequestsContainer;
59  std::set<ModelInfoRef*> m_pendingRequestInfoRefs;
60 
61  void ModelDownloadedHandler(Eegeo::Web::IWebResponse& webResponse);
62  void BeginAnimatedObjectDownload(const CityThemeAnimationData &animationData);
63  void LoadModelFromBuffer(const std::string& url, const std::vector<Byte>& buffer, ModelInfoRef modelInfoRef);
64  std::string CreateTextureUrl(const std::string modelUrl, const std::string textureNameWithoutExtension) const;
65  Eegeo::Rendering::AsyncTexturing::TIAsyncTextures LoadTexturesFromPODFile(const std::string& modelUrl, const IO::POD::PODFile& podFile);
66  };
67  }
68  }
69 }