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);
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);
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();
129 
147  static void separateData(float* data, uint16 size, uint16 numLodLevels, LodsData& lods );
148  private:
153 
158 
161  };
164 }
165 
166 #endif
#define _OgreTerrainExport
Superclass for all objects that wish to use custom memory allocators when their new / delete operator...
Utility class providing helper methods for reading / writing structured data held in a DataStream.
Terrain LOD data manager.
bool mIncreaseLodLevelInProgress
Highest LOD level loaded in GPU.
LodInfo & getLodInfo(uint lodLevel)
virtual bool canHandleResponse(const WorkQueue::Response *res, const WorkQueue *srcQ)
Return whether this handler can process a given response.
virtual WorkQueue::Response * handleRequest(const WorkQueue::Request *req, const WorkQueue *srcQ)
The handler method every subclass must implement.
static void separateData(float *data, uint16 size, uint16 numLodLevels, LodsData &lods)
Separate geometry data by LOD level.
virtual void handleResponse(const WorkQueue::Response *res, const WorkQueue *srcQ)
The handler method every subclass must implement.
void fillBufferAtLod(uint lodLevel, const float *data, uint dataSize)
Copy geometry data from buffer to mHeightData/mDeltaData.
static const uint16 WORKQUEUE_LOAD_LOD_DATA_REQUEST
static void saveLodData(StreamSerialiser &stream, Terrain *terrain)
Save each LOD level separately compressed so seek is possible.
int mHighestLodLoaded
Highest LOD level stored in memory i.e. mHeightData/mDeltaData.
int mHighestLodPrepared
Which LOD level is demanded.
static const uint16 TERRAINLODDATA_CHUNK_VERSION
vector< LodData >::type LodsData
static const uint32 TERRAINLODDATA_CHUNK_ID
void updateToLodLevel(int lodLevel, bool synchronous=false)
TerrainLodManager(Terrain *t, const String &filename="")
bool mLastRequestSynchronous
Is increaseLodLevel() running?
TerrainLodManager(Terrain *t, DataStreamPtr &stream)
void readLodData(uint16 lowerLodBound, uint16 higherLodBound)
Read separated geometry data from file into allocated memory.
vector< float >::type LodData
virtual bool canHandleRequest(const WorkQueue::Request *req, const WorkQueue *srcQ)
Return whether this handler can process a given request.
The main containing class for a chunk of terrain.
Definition: OgreTerrain.h:264
Interface definition for a handler of requests.
General purpose request structure.
Definition: OgreWorkQueue.h:84
Interface definition for a handler of responses.
Interface to a general purpose request / response style background work queue.
Definition: OgreWorkQueue.h:71
unsigned short uint16
Definition: OgrePlatform.h:360
unsigned int uint
unsigned int uint32
Definition: OgrePlatform.h:359
_StringBase String
LoadLodRequest(TerrainLodManager *r, uint16 preparedLod, uint16 loadedLod, uint16 target)
_OgreTerrainExport friend std::ostream & operator<<(std::ostream &o, const LoadLodRequest &r)
General purpose response structure.
std::vector< T, A > type

Copyright © 2012 Torus Knot Software Ltd
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.