vrecko
virtual reality framework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Preloader.h
Go to the documentation of this file.
1 #ifndef _PRELOADER
2 #define _PRELOADER 1
3 
4 #include "PreloaderHeuristic.h"
5 #include <windows.h>
6 #include <process.h>
7 #include <osg/Timer>
8 #include <vrecko/MTLock.h>
9 #include "ModelManager.h"
10 
11 using namespace vrecko;
12 using namespace ArtificialWorld;
13 
15 class Preloader {
16 private:
18  PreloaderHeuristic *heuristic;
20  HANDLE loadingThreadHandle;
22  DWORD loadingThreadId;
23 
25  double heuristicUpdateInterval;
27  double heuristicRunInterval;
28 
30  bool running;
32  osg::Timer timer;
34  osg::Timer_t lastHeuristicRun;
36  osg::Timer_t lastHeuristicUpdate;
38  bool exitLoadingFunction;
40  MTLock *lock;
42  bool loadingFunctionFinnished;
44  BlockUpdater *rootBlockUpdater;
46  bool objectLoaded;
47 
48 public:
49  Preloader(BlockUpdater* _rootBlockUpdater){
50  heuristic = new BasicPreloaderHeuristic();
51  rootBlockUpdater = _rootBlockUpdater;
52 
53  heuristic->SetWorldRoot(rootBlockUpdater);
54 
55  lastHeuristicRun = timer.tick();
56  lastHeuristicUpdate = timer.tick();
57  //provadej update heuristiky kazdou vterinu
58  heuristicUpdateInterval = 1000;
59  //spust dalsi heuristiku ihned po skonceni predchozi
60  heuristicRunInterval = 0;
61  exitLoadingFunction = false;
62  running = false;
63  lock = new MTLock();
64  };
65 
66  ~Preloader(void){
67  if(lock != NULL){
68  delete lock;
69  lock = NULL;
70  }
71  };
72 
74  list<PreloaderToLoadInfo*> loadingQueue;
76  list<PreloaderLoadedInfo*> loadedObjects;
77 
79  bool ExitLoadingFunction(void){ return exitLoadingFunction; };
80 
82  void LoadingFunctionFinnished(void)
83  {
84  loadingFunctionFinnished = true;
85  };
86 
87 
89  MTLock* GetLock(void){ return lock; };
91  bool Running(void){ return running; };
92 
94  void Update(void);
96  void Start(void);
98  void Stop(void);
99 };
100 
101 
102 #endif
103