OGRE  1.9.0
OgreGrid2DPageStrategy.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-2014 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_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
38namespace Ogre
39{
51 {
53 G2D_X_Z = 0,
55 G2D_X_Y = 1,
57 G2D_Y_Z = 2
58 };
121 {
122 protected:
141
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
220 void calculateCell(PageID inPageID, int32* x, int32* y);
221
222 };
223
224
232 {
233 public:
235
237
238 // Overridden members
243 PageID getPageID(const Vector3& worldPos, PagedWorldSection* section);
244 };
245
248}
249
250#endif
#define _OgrePagingExport
A viewpoint from which the scene will be rendered.
Definition OgreCamera.h:87
Specialisation of PageStrategyData for Grid2DPageStrategy.
virtual Real getHoldRadiusInCells()
Get the Hold radius as a multiple of cells.
void determineGridLocation(const Vector2 &gridpos, int32 *x, int32 *y)
Convert a grid position into a row and column index.
virtual void setCellRangeMinX(int32 minX)
Set the index range of all cells (values outside this will be ignored)
Grid2DMode mMode
Orientation of the grid.
void save(StreamSerialiser &stream)
Save this data to a stream.
Vector3 mWorldOrigin
Origin (world space)
virtual void getBottomLeftGridSpace(int32 x, int32 y, Vector2 &bl)
Get the (grid space) bottom-left of a cell.
void calculateCell(PageID inPageID, int32 *x, int32 *y)
virtual void getMidPointGridSpace(int32 x, int32 y, Vector2 &mid)
Get the (grid space) mid point of a cell.
Vector2 mOrigin
Origin (grid-aligned world space)
virtual Real getCellSize() const
Get the size of the cells in the grid.
virtual void getCornersGridSpace(int32 x, int32 y, Vector2 *pFourPoints)
Get the (grid space) corners of a cell.
virtual void setHoldRadius(Real sz)
Set the Holding radius.
PageID calculatePageID(int32 x, int32 y)
virtual int32 getCellRangeMinY() const
get the index range of all cells (values outside this will be ignored)
virtual Real getHoldRadius() const
Get the Holding radius.
virtual Real getLoadRadiusInCells()
Get the load radius as a multiple of cells.
virtual void setMode(Grid2DMode mode)
Set the grid alignment mode.
bool load(StreamSerialiser &stream)
Load this data from a stream (returns true if successful)
virtual int32 getCellRangeMinX() const
get the index range of all cells (values outside this will be ignored)
virtual void setLoadRadius(Real sz)
Set the loading radius.
virtual Grid2DMode getMode() const
Set the grid alignment mode.
virtual void setCellRangeMinY(int32 minY)
Set the index range of all cells (values outside this will be ignored)
virtual void setCellSize(Real sz)
Set the size of the cells in the grid.
virtual void setCellRangeMaxX(int32 maxX)
Set the index range of all cells (values outside this will be ignored)
virtual int32 getCellRangeMaxY() const
get the index range of all cells (values outside this will be ignored)
virtual void convertWorldToGridSpace(const Vector3 &world, Vector2 &grid)
Convert a world point to grid space (not relative to origin)
virtual void convertGridToWorldSpace(const Vector2 &grid, Vector3 &world)
Convert a grid point to world space - note only 2 axes populated.
virtual const Vector3 & getOrigin(const Vector3 &worldOrigin)
Get the origin of the grid in world space.
virtual Real getLoadRadius() const
Get the loading radius.
virtual void setOrigin(const Vector3 &worldOrigin)
Set the origin of the grid in world space.
virtual void setCellRange(int32 minX, int32 minY, int32 maxX, int32 maxY)
Set the index range of all cells (values outside this will be ignored)
virtual int32 getCellRangeMaxX() const
get the index range of all cells (values outside this will be ignored)
virtual void setCellRangeMaxY(int32 maxY)
Set the index range of all cells (values outside this will be ignored)
Real mCellSize
Grid cell (page) size.
Page strategy which loads new pages based on a regular 2D grid.
PageID getPageID(const Vector3 &worldPos, PagedWorldSection *section)
Get the page ID for a given world position.
PageStrategyData * createData()
Create a PageStrategyData instance containing the data specific to this PageStrategy.
void notifyCamera(Camera *cam, PagedWorldSection *section)
Called when a camera is used for any kind of rendering.
void updateDebugDisplay(Page *p, SceneNode *sn)
Update the contents of the passed in SceneNode to reflect the debug display of a given page.
Grid2DPageStrategy(PageManager *manager)
void destroyData(PageStrategyData *d)
Destroy a PageStrategyData instance containing the data specific to this PageStrategy.
The PageManager is the entry point through which you load all PagedWorld instances,...
Abstract marker class representing the data held against the PagedWorldSection which is specifically ...
Defines the interface to a strategy class which is responsible for deciding when Page instances are r...
Page class.
Definition OgrePage.h:51
Represents a section of the PagedWorld which uses a given PageStrategy, and which is made up of a gen...
Class representing a node in the scene graph.
Utility class providing helper methods for reading / writing structured data held in a DataStream.
Standard 2-dimensional vector.
Definition OgreVector2.h:52
Standard 3-dimensional vector.
Definition OgreVector3.h:52
Grid2DMode
The 2D grid mode.
@ G2D_Y_Z
Grid is in the Y/Z plane.
@ G2D_X_Y
Grid is in the X/Y plane.
@ G2D_X_Z
Grid is in the X/Z plane.
int int32
uint32 PageID
Identifier for a page.
float Real
Software floating point type.
unsigned short uint16
unsigned int uint32