OGRE  1.9
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 #include "OgreQuaternion.h"
37 
38 namespace Ogre
39 {
49  enum Grid2DMode
51  {
53  G2D_X_Z = 0,
55  G2D_X_Y = 1,
57  G2D_Y_Z = 2
58  };
121  {
122  protected:
141 
142  void updateDerivedMetrics();
143 
144  public:
145  static const uint32 CHUNK_ID;
146  static const uint16 CHUNK_VERSION;
147 
150 
152  virtual void setMode(Grid2DMode mode);
153 
155  virtual Grid2DMode getMode() const { return mMode; }
156 
158  virtual void setOrigin(const Vector3& worldOrigin);
160  virtual const Vector3& getOrigin(const Vector3& worldOrigin) { return mWorldOrigin; }
162  virtual void setCellSize(Real sz);
164  virtual Real getCellSize() const { return mCellSize; }
166  virtual void setLoadRadius(Real sz);
168  virtual Real getLoadRadius() const { return mLoadRadius; }
170  virtual void setHoldRadius(Real sz);
172  virtual Real getHoldRadius() const { return mHoldRadius; }
174  virtual Real getLoadRadiusInCells() { return mLoadRadiusInCells; }
176  virtual Real getHoldRadiusInCells(){ return mHoldRadiusInCells; }
177 
179  virtual void setCellRange(int32 minX, int32 minY, int32 maxX, int32 maxY);
181  virtual void setCellRangeMinX(int32 minX);
183  virtual void setCellRangeMinY(int32 minY);
185  virtual void setCellRangeMaxX(int32 maxX);
187  virtual void setCellRangeMaxY(int32 maxY);
189  virtual int32 getCellRangeMinX() const { return mMinCellX; }
191  virtual int32 getCellRangeMinY() const { return mMinCellY; }
193  virtual int32 getCellRangeMaxX() const { return mMaxCellX; }
195  virtual int32 getCellRangeMaxY() const { return mMaxCellY; }
196 
198  bool load(StreamSerialiser& stream);
200  void save(StreamSerialiser& stream);
201 
203  virtual void convertWorldToGridSpace(const Vector3& world, Vector2& grid);
205  virtual void convertGridToWorldSpace(const Vector2& grid, Vector3& world);
207  virtual void getMidPointGridSpace(int32 x, int32 y, Vector2& mid);
209  virtual void getBottomLeftGridSpace(int32 x, int32 y, Vector2& bl);
214  virtual void getCornersGridSpace(int32 x, int32 y, Vector2* pFourPoints);
215 
217  void determineGridLocation(const Vector2& gridpos, int32* x, int32* y);
218 
219  PageID calculatePageID(int32 x, int32 y);
220  void calculateCell(PageID inPageID, int32* x, int32* y);
221 
222  };
223 
224 
232  {
233  public:
235 
237 
238  // Overridden members
239  void notifyCamera(Camera* cam, PagedWorldSection* section);
240  PageStrategyData* createData();
241  void destroyData(PageStrategyData* d);
242  void updateDebugDisplay(Page* p, SceneNode* sn);
243  PageID getPageID(const Vector3& worldPos, PagedWorldSection* section);
244  };
245 
248 }
249 
250 #endif
Grid is in the X/Y plane.
A viewpoint from which the scene will be rendered.
Definition: OgreCamera.h:86
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:344
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:58
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:51
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:347
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:345
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.