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-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_TerrainPagedWorldSection_H__
30 #define __Ogre_TerrainPagedWorldSection_H__
31 
33 #include "OgrePagedWorldSection.h"
34 #include "OgrePageManager.h"
35 #include "OgreWorkQueue.h"
36 #include "OgreTerrainGroup.h"
37 
38 
39 namespace Ogre
40 {
41  class Grid2DPageStrategy;
42  class Grid2DPageStrategyData;
43  class TerrainGroup;
44 
83  {
84  public:
92 
102  virtual void init(TerrainGroup* grp);
103 
109  virtual TerrainGroup* getTerrainGroup() { return mTerrainGroup; }
110 
112  virtual void setLoadRadius(Real sz);
114  virtual Real getLoadRadius() const;
116  virtual void setHoldRadius(Real sz);
118  virtual Real getHoldRadius();
120  virtual void setPageRange(int32 minX, int32 minY, int32 maxX, int32 maxY);
122  virtual void setPageRangeMinX(int32 minX);
124  virtual void setPageRangeMinY(int32 minY);
126  virtual void setPageRangeMaxX(int32 maxX);
128  virtual void setPageRangeMaxY(int32 maxY);
130  virtual int32 getPageRangeMinX() const;
132  virtual int32 getPageRangeMinY() const;
134  virtual int32 getPageRangeMaxX() const;
136  virtual int32 getPageRangeMaxY() const;
137 
142 
144  virtual void setLoadingIntervalMs(uint32 loadingIntervalMs);
146  virtual uint32 getLoadingIntervalMs() const;
147 
149  void loadPage(PageID pageID, bool forceSynchronous = false);
151  void unloadPage(PageID pageID, bool forceSynchronous = false);
152 
156  void handleResponse(const WorkQueue::Response* res, const WorkQueue* srcQ);
157 
159 
161  {
162  public:
163  virtual void define(TerrainGroup* terrainGroup, long x, long y)
164  {
165  terrainGroup->defineTerrain(x,y);
166  }
167  virtual ~TerrainDefiner() {}
168  };
169 
170  void setDefiner(TerrainDefiner* terrainDefiner)
171  {
172  if(mTerrainDefiner)
173  OGRE_DELETE mTerrainDefiner;
174  mTerrainDefiner = terrainDefiner;
175  }
176 
177  protected:
180  std::list<PageID> mPagesInLoading;
183  unsigned long mNextLoadingTime;
185 
189 
190  virtual void syncSettings();
191 
192  };
193 
194 
195 
196 
197 
200 }
201 
202 #endif
#define _OgreTerrainExport
Superclass for all objects that wish to use custom memory allocators when their new / delete operator...
Specialisation of PageStrategyData for Grid2DPageStrategy.
Page strategy which loads new pages based on a regular 2D grid.
Represents a section of the PagedWorld which uses a given PageStrategy, and which is made up of a gen...
This class represents a collection of pages which make up a world.
Manages the organisation and rendering of a 'scene' i.e.
Utility class providing helper methods for reading / writing structured data held in a DataStream.
Helper class to assist you in managing multiple terrain instances that are connected to each other.
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.
virtual void define(TerrainGroup *terrainGroup, long x, long y)
A world section which includes paged terrain.
virtual Real getHoldRadius()
Get the Holding radius.
virtual TerrainGroup * getTerrainGroup()
Get the TerrainGroup which this world section is using.
void handleResponse(const WorkQueue::Response *res, const WorkQueue *srcQ)
WorkQueue::ResponseHandler override.
void unloadPage(PageID pageID, bool forceSynchronous=false)
Overridden from PagedWorldSection.
void loadPage(PageID pageID, bool forceSynchronous=false)
Overridden from PagedWorldSection.
virtual void setPageRange(int32 minX, int32 minY, int32 maxX, int32 maxY)
Set the index range of all Pages (values outside this will be ignored)
virtual void init(TerrainGroup *grp)
Initialise this section from an existing TerrainGroup instance.
virtual void setPageRangeMinX(int32 minX)
Set the index range of all Pages (values outside this will be ignored)
virtual int32 getPageRangeMinX() const
get the index range of all Pages (values outside this will be ignored)
virtual void setLoadRadius(Real sz)
Set the loading radius.
virtual void setPageRangeMinY(int32 minY)
Set the index range of all Pages (values outside this will be ignored)
virtual Real getLoadRadius() const
Get the loading radius.
WorkQueue::Response * handleRequest(const WorkQueue::Request *req, const WorkQueue *srcQ)
WorkQueue::RequestHandler override.
virtual uint32 getLoadingIntervalMs() const
Get the interval between the loading of single pages in milliseconds (ms)
virtual int32 getPageRangeMaxX() const
get the index range of all Pages (values outside this will be ignored)
virtual int32 getPageRangeMaxY() const
get the index range of all Pages (values outside this will be ignored)
void loadSubtypeData(StreamSerialiser &ser)
Overridden from PagedWorldSection.
virtual void setLoadingIntervalMs(uint32 loadingIntervalMs)
Set the interval between the loading of single pages in milliseconds (ms)
virtual void setHoldRadius(Real sz)
Set the Holding radius.
virtual Grid2DPageStrategyData * getGridStrategyData() const
Convenience method - this section always uses a grid strategy.
TerrainPagedWorldSection(const String &name, PagedWorld *parent, SceneManager *sm)
Constructor.
virtual void setPageRangeMaxY(int32 maxY)
Set the index range of all Pages (values outside this will be ignored)
void setDefiner(TerrainDefiner *terrainDefiner)
virtual int32 getPageRangeMinY() const
get the index range of all Pages (values outside this will be ignored)
virtual Grid2DPageStrategy * getGridStrategy() const
Convenience method - this section always uses a grid strategy.
void saveSubtypeData(StreamSerialiser &ser)
virtual void setPageRangeMaxX(int32 maxX)
Set the index range of all Pages (values outside this will be ignored)
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
#define OGRE_DELETE
int int32
Definition: OgrePlatform.h:362
uint32 PageID
Identifier for a page.
float Real
Software floating point type.
unsigned short uint16
Definition: OgrePlatform.h:360
unsigned int uint32
Definition: OgrePlatform.h:359
_StringBase String
General purpose response structure.

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