OGRE  2.0
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
OgreTerrainPagedWorldSection.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-2014 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_TerrainPagedWorldSection_H__
30 #define __Ogre_TerrainPagedWorldSection_H__
31 
33 #include "OgrePagedWorldSection.h"
34 #include "OgreWorkQueue.h"
35 #include "OgreTerrainGroup.h"
36 
37 
38 namespace Ogre
39 {
40  class Grid2DPageStrategy;
41  class Grid2DPageStrategyData;
42 
81  {
82  public:
88  TerrainPagedWorldSection(const String& name, PagedWorld* parent, SceneManager* sm);
89  virtual ~TerrainPagedWorldSection();
90 
100  virtual void init(TerrainGroup* grp);
101 
107  virtual TerrainGroup* getTerrainGroup() { return mTerrainGroup; }
108 
110  virtual void setLoadRadius(Real sz);
112  virtual Real getLoadRadius() const;
114  virtual void setHoldRadius(Real sz);
116  virtual Real getHoldRadius();
118  virtual void setPageRange(int32 minX, int32 minY, int32 maxX, int32 maxY);
120  virtual void setPageRangeMinX(int32 minX);
122  virtual void setPageRangeMinY(int32 minY);
124  virtual void setPageRangeMaxX(int32 maxX);
126  virtual void setPageRangeMaxY(int32 maxY);
128  virtual int32 getPageRangeMinX() const;
130  virtual int32 getPageRangeMinY() const;
132  virtual int32 getPageRangeMaxX() const;
134  virtual int32 getPageRangeMaxY() const;
135 
137  virtual Grid2DPageStrategy* getGridStrategy() const;
139  virtual Grid2DPageStrategyData* getGridStrategyData() const;
140 
142  virtual void setLoadingIntervalMs(uint32 loadingIntervalMs);
144  virtual uint32 getLoadingIntervalMs() const;
145 
147  void loadPage(PageID pageID, bool forceSynchronous = false);
149  void unloadPage(PageID pageID, bool forceSynchronous = false);
150 
152  WorkQueue::Response* handleRequest(const WorkQueue::Request* req, const WorkQueue* srcQ);
154  void handleResponse(const WorkQueue::Response* res, const WorkQueue* srcQ);
155 
157 
159  {
160  public:
161  virtual void define(TerrainGroup* terrainGroup, long x, long y)
162  {
163  terrainGroup->defineTerrain(x,y);
164  }
165  virtual ~TerrainDefiner() {}
166  };
167 
168  void setDefiner(TerrainDefiner* terrainDefiner)
169  {
170  if(mTerrainDefiner)
171  OGRE_DELETE mTerrainDefiner;
172  mTerrainDefiner = terrainDefiner;
173  }
174 
175  protected:
178  std::list<PageID> mPagesInLoading;
181  unsigned long mNextLoadingTime;
183 
185  void loadSubtypeData(StreamSerialiser& ser);
186  void saveSubtypeData(StreamSerialiser& ser);
187 
188  virtual void syncSettings();
189 
190  };
191 
192 
193 
194 
195 
198 }
199 
200 #endif
Specialisation of PageStrategyData for Grid2DPageStrategy.
float Real
Software floating point type.
unsigned int uint32
Definition: OgrePlatform.h:420
General purpose request structure.
Definition: OgreWorkQueue.h:84
General purpose response structure.
Manages the organisation and rendering of a 'scene' i.e.
This class represents a collection of pages which make up a world.
Page strategy which loads new pages based on a regular 2D grid.
virtual void defineTerrain(long x, long y)
Define a 'slot' in the terrain grid - in this case to be loaded from a generated file name...
Interface definition for a handler of requests.
A world section which includes paged terrain.
Superclass for all objects that wish to use custom memory allocators when their new / delete operator...
#define _OgreTerrainExport
Utility class providing helper methods for reading / writing structured data held in a DataStream...
#define OGRE_DELETE
Interface definition for a handler of responses.
virtual void define(TerrainGroup *terrainGroup, long x, long y)
int int32
Definition: OgrePlatform.h:423
_StringBase String
Definition: OgreCommon.h:53
unsigned short uint16
Definition: OgrePlatform.h:421
void setDefiner(TerrainDefiner *terrainDefiner)
Interface to a general purpose request / response style background work queue.
Definition: OgreWorkQueue.h:71
Represents a section of the PagedWorld which uses a given PageStrategy, and which is made up of a gen...
Helper class to assist you in managing multiple terrain instances that are connected to each other...
uint32 PageID
Identifier for a page.
virtual TerrainGroup * getTerrainGroup()
Get the TerrainGroup which this world section is using.