OgreTerrainLodManager.h
Go to the documentation of this file.
1/*
2-----------------------------------------------------------------------------
3This source file is part of OGRE
4(Object-oriented Graphics Rendering Engine)
5For the latest info, see http://www.ogre3d.org/
6
7Copyright (c) 2000-2013 Torus Knot Software Ltd
8
9Permission is hereby granted, free of charge, to any person obtaining a copy
10of this software and associated documentation files (the "Software"), to deal
11in the Software without restriction, including without limitation the rights
12to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13copies of the Software, and to permit persons to whom the Software is
14furnished to do so, subject to the following conditions:
15
16The above copyright notice and this permission notice shall be included in
17all copies or substantial portions of the Software.
18
19THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25THE SOFTWARE.
26-----------------------------------------------------------------------------
27*/
28
29#ifndef __Ogre_TerrainLodManager_H__
30#define __Ogre_TerrainLodManager_H__
31
33#include "OgreWorkQueue.h"
34
35
36namespace Ogre
37{
38 class Terrain;
53 {
54 public:
59
61 {
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 = "");
89
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 );
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...
Reference-counted shared pointer, used for objects where implicit destruction is required.
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.
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)
virtual WorkQueue::Response * handleRequest(const WorkQueue::Request *req, const WorkQueue *srcQ)
The handler method every subclass must implement.
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.
Interface definition for a handler of requests.
General purpose request structure.
Interface definition for a handler of responses.
Interface to a general purpose request / response style background work queue.
unsigned short uint16
unsigned int uint32
_StringBase String
_OgreTerrainExport friend std::ostream & operator<<(std::ostream &o, const LoadLodRequest &r)
LoadLodRequest(TerrainLodManager *r, uint16 preparedLod, uint16 loadedLod, uint16 target)
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.