OgreTerrainLodManager.h
Go to the documentation of this file.
1 /*
2 -----------------------------------------------------------------------------
3 This source file is part of OGRE
4 (Object-oriented Graphics Rendering Engine)
5 For the latest info, see http://www.ogre3d.org/
6 
7 Copyright (c) 2000-2013 Torus Knot Software Ltd
8 
9 Permission is hereby granted, free of charge, to any person obtaining a copy
10 of this software and associated documentation files (the "Software"), to deal
11 in the Software without restriction, including without limitation the rights
12 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 copies of the Software, and to permit persons to whom the Software is
14 furnished to do so, subject to the following conditions:
15 
16 The above copyright notice and this permission notice shall be included in
17 all copies or substantial portions of the Software.
18 
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 THE SOFTWARE.
26 -----------------------------------------------------------------------------
27 */
28 
29 #ifndef __Ogre_TerrainLodManager_H__
30 #define __Ogre_TerrainLodManager_H__
31 
33 #include "OgreWorkQueue.h"
34 
35 
36 namespace Ogre
37 {
38  class Terrain;
53  {
54  public:
59 
61  {
62  LoadLodRequest( TerrainLodManager* r, uint16 preparedLod, uint16 loadedLod, uint16 target )
63  : requestee(r)
64  , currentPreparedLod(preparedLod)
65  , currentLoadedLod(loadedLod)
66  , requestedLod(target)
67  {
68  }
73  _OgreTerrainExport friend std::ostream& operator<<(std::ostream& o, const LoadLodRequest& r)
74  { return o; }
75  };
76 
77  struct LodInfo
78  {
81  bool isLast;
84  };
85  public:
87  TerrainLodManager(Terrain* t, const String& filename = "");
88  virtual ~TerrainLodManager();
89 
91  virtual bool canHandleRequest(const WorkQueue::Request* req, const WorkQueue* srcQ);
92  virtual bool canHandleResponse(const WorkQueue::Response* res, const WorkQueue* srcQ);
93  virtual WorkQueue::Response* handleRequest(const WorkQueue::Request* req, const WorkQueue* srcQ);
94  virtual void handleResponse(const WorkQueue::Response* res, const WorkQueue* srcQ);
95 
96  void updateToLodLevel(int lodLevel, bool synchronous = false);
98  static void saveLodData(StreamSerialiser& stream, Terrain* terrain);
99 
106  void fillBufferAtLod(uint lodLevel, const float* data, uint dataSize );
113  void readLodData(uint16 lowerLodBound, uint16 higherLodBound);
114  void waitForDerivedProcesses();
115 
116  int getHighestLodPrepared(){ return mHighestLodPrepared; }
117  int getHighestLodLoaded(){ return mHighestLodLoaded; }
118  int getTargetLodLevel(){ return mTargetLodLevel; }
119 
121  {
122  if(!mLodInfoTable)
123  buildLodInfoTable();
124  return mLodInfoTable[lodLevel];
125  }
126  private:
127  void init();
128  void buildLodInfoTable();
129 
147  static void separateData(float* data, uint16 size, uint16 numLodLevels, LodsData& lods );
148  private:
153 
158 
161  };
164 }
165 
166 #endif
static const uint32 TERRAINLODDATA_CHUNK_ID
static const uint16 WORKQUEUE_LOAD_LOD_DATA_REQUEST
_OgreTerrainExport friend std::ostream & operator<<(std::ostream &o, const LoadLodRequest &r)
unsigned int uint
LodInfo & getLodInfo(uint lodLevel)
std::vector< T, A > type
Interface to a general purpose request / response style background work queue.
Definition: OgreWorkQueue.h:70
bool mLastRequestSynchronous
Is increaseLodLevel() running?
vector< LodData >::type LodsData
The main containing class for a chunk of terrain.
Definition: OgreTerrain.h:262
int mHighestLodPrepared
Which LOD level is demanded.
General purpose request structure.
Definition: OgreWorkQueue.h:83
General purpose response structure.
int mHighestLodLoaded
Highest LOD level stored in memory i.e. mHeightData/mDeltaData.
#define _OgreTerrainExport
Terrain LOD data manager.
_StringBase String
vector< float >::type LodData
Utility class providing helper methods for reading / writing structured data held in a DataStream...
static const uint16 TERRAINLODDATA_CHUNK_VERSION
unsigned int uint32
Definition: OgrePlatform.h:359
Interface definition for a handler of responses.
bool mIncreaseLodLevelInProgress
Highest LOD level loaded in GPU.
LoadLodRequest(TerrainLodManager *r, uint16 preparedLod, uint16 loadedLod, uint16 target)
Interface definition for a handler of requests.
unsigned short uint16
Definition: OgrePlatform.h:360
Superclass for all objects that wish to use custom memory allocators when their new / delete operator...

Copyright © 2012 Torus Knot Software Ltd
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Last modified Mon Jun 30 2014 22:23:12