OGRE  2.0
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
OgreGrid2DPageStrategy.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_Grid2DPageStrategy_H__
30 #define __Ogre_Grid2DPageStrategy_H__
31 
33 #include "OgrePageStrategy.h"
34 #include "OgreVector2.h"
35 #include "OgreVector3.h"
36 
37 namespace Ogre
38 {
48  enum Grid2DMode
50  {
52  G2D_X_Z = 0,
54  G2D_X_Y = 1,
56  G2D_Y_Z = 2
57  };
120  {
121  protected:
140 
141  void updateDerivedMetrics();
142 
143  public:
144  static const uint32 CHUNK_ID;
145  static const uint16 CHUNK_VERSION;
146 
149 
151  virtual void setMode(Grid2DMode mode);
152 
154  virtual Grid2DMode getMode() const { return mMode; }
155 
157  virtual void setOrigin(const Vector3& worldOrigin);
159  virtual const Vector3& getOrigin(const Vector3& worldOrigin) { return mWorldOrigin; }
161  virtual void setCellSize(Real sz);
163  virtual Real getCellSize() const { return mCellSize; }
165  virtual void setLoadRadius(Real sz);
167  virtual Real getLoadRadius() const { return mLoadRadius; }
169  virtual void setHoldRadius(Real sz);
171  virtual Real getHoldRadius() const { return mHoldRadius; }
173  virtual Real getLoadRadiusInCells() { return mLoadRadiusInCells; }
175  virtual Real getHoldRadiusInCells(){ return mHoldRadiusInCells; }
176 
178  virtual void setCellRange(int32 minX, int32 minY, int32 maxX, int32 maxY);
180  virtual void setCellRangeMinX(int32 minX);
182  virtual void setCellRangeMinY(int32 minY);
184  virtual void setCellRangeMaxX(int32 maxX);
186  virtual void setCellRangeMaxY(int32 maxY);
188  virtual int32 getCellRangeMinX() const { return mMinCellX; }
190  virtual int32 getCellRangeMinY() const { return mMinCellY; }
192  virtual int32 getCellRangeMaxX() const { return mMaxCellX; }
194  virtual int32 getCellRangeMaxY() const { return mMaxCellY; }
195 
197  bool load(StreamSerialiser& stream);
199  void save(StreamSerialiser& stream);
200 
202  virtual void convertWorldToGridSpace(const Vector3& world, Vector2& grid);
204  virtual void convertGridToWorldSpace(const Vector2& grid, Vector3& world);
206  virtual void getMidPointGridSpace(int32 x, int32 y, Vector2& mid);
208  virtual void getBottomLeftGridSpace(int32 x, int32 y, Vector2& bl);
213  virtual void getCornersGridSpace(int32 x, int32 y, Vector2* pFourPoints);
214 
216  void determineGridLocation(const Vector2& gridpos, int32* x, int32* y);
217 
218  PageID calculatePageID(int32 x, int32 y);
219  void calculateCell(PageID inPageID, int32* x, int32* y);
220 
221  };
222 
223 
231  {
232  public:
234 
236 
237  // Overridden members
238  void notifyCamera(Camera* cam, PagedWorldSection* section);
239  PageStrategyData* createData();
240  void destroyData(PageStrategyData* d);
241  void updateDebugDisplay(Page* p, SceneNode* sn);
242  PageID getPageID(const Vector3& worldPos, PagedWorldSection* section);
243  };
244 
247 }
248 
249 #endif
Grid is in the X/Y plane.
A viewpoint from which the scene will be rendered.
Definition: OgreCamera.h:82
Grid2DMode mMode
Orientation of the grid.
virtual Real getHoldRadius() const
Get the Holding radius.
Specialisation of PageStrategyData for Grid2DPageStrategy.
float Real
Software floating point type.
virtual const Vector3 & getOrigin(const Vector3 &worldOrigin)
Get the origin of the grid in world space.
unsigned int uint32
Definition: OgrePlatform.h:420
The PageManager is the entry point through which you load all PagedWorld instances, and the place where PageStrategy instances and factory classes are registered to customise the paging behaviour.
virtual Grid2DMode getMode() const
Set the grid alignment mode.
Vector2 mOrigin
Origin (grid-aligned world space)
virtual int32 getCellRangeMaxX() const
get the index range of all cells (values outside this will be ignored)
Page strategy which loads new pages based on a regular 2D grid.
Class representing a node in the scene graph.
Definition: OgreSceneNode.h:53
virtual Real getHoldRadiusInCells()
Get the Hold radius as a multiple of cells.
virtual Real getLoadRadius() const
Get the loading radius.
virtual Real getCellSize() const
Get the size of the cells in the grid.
Vector3 mWorldOrigin
Origin (world space)
Standard 2-dimensional vector.
Definition: OgreVector2.h:51
#define _OgrePagingExport
Grid2DMode
The 2D grid mode.
Utility class providing helper methods for reading / writing structured data held in a DataStream...
Grid is in the Y/Z plane.
Standard 3-dimensional vector.
Definition: OgreVector3.h:50
Page class.
Definition: OgrePage.h:49
Abstract marker class representing the data held against the PagedWorldSection which is specifically ...
virtual int32 getCellRangeMaxY() const
get the index range of all cells (values outside this will be ignored)
virtual int32 getCellRangeMinX() const
get the index range of all cells (values outside this will be ignored)
int int32
Definition: OgrePlatform.h:423
Real mCellSize
Grid cell (page) size.
virtual int32 getCellRangeMinY() const
get the index range of all cells (values outside this will be ignored)
unsigned short uint16
Definition: OgrePlatform.h:421
Grid is in the X/Z plane.
Represents a section of the PagedWorld which uses a given PageStrategy, and which is made up of a gen...
Defines the interface to a strategy class which is responsible for deciding when Page instances are r...
virtual Real getLoadRadiusInCells()
Get the load radius as a multiple of cells.
uint32 PageID
Identifier for a page.