OgreGrid2DPageStrategy.h
Go to the documentation of this file.
/*
-----------------------------------------------------------------------------
This source file is part of OGRE
(Object-oriented Graphics Rendering Engine)
For the latest info, see http://www.ogre3d.org/
Copyright (c) 2000-2013 Torus Knot Software Ltd
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-----------------------------------------------------------------------------
*/
#ifndef __Ogre_Grid2DPageStrategy_H__
#define __Ogre_Grid2DPageStrategy_H__
#include "OgrePagingPrerequisites.h"
#include "OgrePageStrategy.h"
#include "OgreVector2.h"
#include "OgreVector3.h"
#include "OgreQuaternion.h"
namespace Ogre
{
enum Grid2DMode
{
G2D_X_Z = 0,
G2D_X_Y = 1,
G2D_Y_Z = 2
};
class _OgrePagingExport Grid2DPageStrategyData : public PageStrategyData
{
protected:
Grid2DMode mMode;
Vector3 mWorldOrigin;
Vector2 mOrigin;
Real mCellSize;
Real mLoadRadius;
Real mHoldRadius;
Real mLoadRadiusInCells;
Real mHoldRadiusInCells;
int32 mMinCellX;
int32 mMinCellY;
int32 mMaxCellX;
int32 mMaxCellY;
void updateDerivedMetrics();
public:
static const uint32 CHUNK_ID;
static const uint16 CHUNK_VERSION;
Grid2DPageStrategyData();
~Grid2DPageStrategyData();
virtual void setMode(Grid2DMode mode);
virtual Grid2DMode getMode() const { return mMode; }
virtual void setOrigin(const Vector3& worldOrigin);
virtual const Vector3& getOrigin(const Vector3& worldOrigin) { return mWorldOrigin; }
virtual void setCellSize(Real sz);
virtual Real getCellSize() const { return mCellSize; }
virtual void setLoadRadius(Real sz);
virtual Real getLoadRadius() const { return mLoadRadius; }
virtual void setHoldRadius(Real sz);
virtual Real getHoldRadius() const { return mHoldRadius; }
virtual Real getLoadRadiusInCells() { return mLoadRadiusInCells; }
virtual Real getHoldRadiusInCells(){ return mHoldRadiusInCells; }
virtual void setCellRange(int32 minX, int32 minY, int32 maxX, int32 maxY);
virtual void setCellRangeMinX(int32 minX);
virtual void setCellRangeMinY(int32 minY);
virtual void setCellRangeMaxX(int32 maxX);
virtual void setCellRangeMaxY(int32 maxY);
virtual int32 getCellRangeMinX() const { return mMinCellX; }
virtual int32 getCellRangeMinY() const { return mMinCellY; }
virtual int32 getCellRangeMaxX() const { return mMaxCellX; }
virtual int32 getCellRangeMaxY() const { return mMaxCellY; }
bool load(StreamSerialiser& stream);
void save(StreamSerialiser& stream);
virtual void convertWorldToGridSpace(const Vector3& world, Vector2& grid);
virtual void convertGridToWorldSpace(const Vector2& grid, Vector3& world);
virtual void getMidPointGridSpace(int32 x, int32 y, Vector2& mid);
virtual void getBottomLeftGridSpace(int32 x, int32 y, Vector2& bl);
virtual void getCornersGridSpace(int32 x, int32 y, Vector2* pFourPoints);
void determineGridLocation(const Vector2& gridpos, int32* x, int32* y);
PageID calculatePageID(int32 x, int32 y);
void calculateCell(PageID inPageID, int32* x, int32* y);
};
class _OgrePagingExport Grid2DPageStrategy : public PageStrategy
{
public:
Grid2DPageStrategy(PageManager* manager);
~Grid2DPageStrategy();
// Overridden members
void notifyCamera(Camera* cam, PagedWorldSection* section);
PageStrategyData* createData();
void destroyData(PageStrategyData* d);
void updateDebugDisplay(Page* p, SceneNode* sn);
PageID getPageID(const Vector3& worldPos, PagedWorldSection* section);
};
}
#endif
_OgrePagingExport
#define _OgrePagingExport
Definition: OgrePagingPrerequisites.h:72
Ogre::Grid2DPageStrategyData
Specialisation of PageStrategyData for Grid2DPageStrategy.
Definition: OgreGrid2DPageStrategy.h:120
Ogre::Grid2DMode
Grid2DMode
The 2D grid mode.
Definition: OgreGrid2DPageStrategy.h:50
OgreQuaternion.h
OgreVector3.h
Ogre::Page
Page class.
Definition: OgrePage.h:49
Ogre::Grid2DPageStrategyData::getMode
virtual Grid2DMode getMode() const
Set the grid alignment mode.
Definition: OgreGrid2DPageStrategy.h:155
Ogre::Grid2DPageStrategyData::CHUNK_ID
static const uint32 CHUNK_ID
Definition: OgreGrid2DPageStrategy.h:145
Ogre::Vector2
Standard 2-dimensional vector.
Definition: OgreVector2.h:51
Ogre::Real
float Real
Software floating point type.
Definition: OgrePrerequisites.h:70
Ogre::Grid2DPageStrategyData::mMaxCellY
int32 mMaxCellY
Definition: OgreGrid2DPageStrategy.h:140
Ogre::Grid2DPageStrategyData::getHoldRadius
virtual Real getHoldRadius() const
Get the Holding radius.
Definition: OgreGrid2DPageStrategy.h:172
OgrePagingPrerequisites.h
Ogre::Grid2DPageStrategyData::mMode
Grid2DMode mMode
Orientation of the grid.
Definition: OgreGrid2DPageStrategy.h:124
Ogre::Grid2DPageStrategyData::getCellRangeMinX
virtual int32 getCellRangeMinX() const
get the index range of all cells (values outside this will be ignored)
Definition: OgreGrid2DPageStrategy.h:189
Ogre::PagedWorldSection
Represents a section of the PagedWorld which uses a given PageStrategy, and which is made up of a gen...
Definition: OgrePagedWorldSection.h:69
Ogre::SceneNode
Class representing a node in the scene graph.
Definition: OgreSceneNode.h:58
Ogre::Grid2DPageStrategyData::mLoadRadiusInCells
Real mLoadRadiusInCells
Definition: OgreGrid2DPageStrategy.h:135
OgrePageStrategy.h
Ogre::Grid2DPageStrategyData::CHUNK_VERSION
static const uint16 CHUNK_VERSION
Definition: OgreGrid2DPageStrategy.h:146
Ogre::Grid2DPageStrategyData::getLoadRadius
virtual Real getLoadRadius() const
Get the loading radius.
Definition: OgreGrid2DPageStrategy.h:168
Ogre::Grid2DPageStrategyData::getCellRangeMinY
virtual int32 getCellRangeMinY() const
get the index range of all cells (values outside this will be ignored)
Definition: OgreGrid2DPageStrategy.h:191
Ogre::G2D_X_Y
Grid is in the X/Y plane.
Definition: OgreGrid2DPageStrategy.h:55
Ogre::Vector3
Standard 3-dimensional vector.
Definition: OgreVector3.h:51
Ogre::Grid2DPageStrategyData::getCellRangeMaxX
virtual int32 getCellRangeMaxX() const
get the index range of all cells (values outside this will be ignored)
Definition: OgreGrid2DPageStrategy.h:193
Ogre::PageStrategyData
Abstract marker class representing the data held against the PagedWorldSection which is specifically ...
Definition: OgrePageStrategy.h:49
Ogre::Grid2DPageStrategyData::getLoadRadiusInCells
virtual Real getLoadRadiusInCells()
Get the load radius as a multiple of cells.
Definition: OgreGrid2DPageStrategy.h:174
Ogre::Grid2DPageStrategyData::mHoldRadius
Real mHoldRadius
Hold radius.
Definition: OgreGrid2DPageStrategy.h:134
Ogre::PageManager
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.
Definition: OgrePageManager.h:136
Ogre::Grid2DPageStrategyData::mHoldRadiusInCells
Real mHoldRadiusInCells
Definition: OgreGrid2DPageStrategy.h:136
Ogre::StreamSerialiser
Utility class providing helper methods for reading / writing structured data held in a DataStream...
Definition: OgreStreamSerialiser.h:66
Ogre::int32
int int32
Definition: OgrePlatform.h:362
Ogre::Camera
A viewpoint from which the scene will be rendered.
Definition: OgreCamera.h:86
Ogre::Grid2DPageStrategy
Page strategy which loads new pages based on a regular 2D grid.
Definition: OgreGrid2DPageStrategy.h:231
Ogre::Grid2DPageStrategyData::mOrigin
Vector2 mOrigin
Origin (grid-aligned world space)
Definition: OgreGrid2DPageStrategy.h:128
Ogre::Grid2DPageStrategyData::getOrigin
virtual const Vector3 & getOrigin(const Vector3 &worldOrigin)
Get the origin of the grid in world space.
Definition: OgreGrid2DPageStrategy.h:160
Ogre::PageID
uint32 PageID
Identifier for a page.
Definition: OgrePagingPrerequisites.h:58
Ogre::uint32
unsigned int uint32
Definition: OgrePlatform.h:359
Ogre::Grid2DPageStrategyData::mCellSize
Real mCellSize
Grid cell (page) size.
Definition: OgreGrid2DPageStrategy.h:130
Ogre
Definition: OgreAndroidLogListener.h:34
Ogre::Grid2DPageStrategyData::getCellRangeMaxY
virtual int32 getCellRangeMaxY() const
get the index range of all cells (values outside this will be ignored)
Definition: OgreGrid2DPageStrategy.h:195
Ogre::Grid2DPageStrategyData::getCellSize
virtual Real getCellSize() const
Get the size of the cells in the grid.
Definition: OgreGrid2DPageStrategy.h:164
Ogre::Grid2DPageStrategyData::mWorldOrigin
Vector3 mWorldOrigin
Origin (world space)
Definition: OgreGrid2DPageStrategy.h:126
Ogre::Grid2DPageStrategyData::mMinCellX
int32 mMinCellX
Definition: OgreGrid2DPageStrategy.h:137
Ogre::G2D_Y_Z
Grid is in the Y/Z plane.
Definition: OgreGrid2DPageStrategy.h:57
OgreVector2.h
Ogre::Grid2DPageStrategyData::mMinCellY
int32 mMinCellY
Definition: OgreGrid2DPageStrategy.h:138
Ogre::Grid2DPageStrategyData::getHoldRadiusInCells
virtual Real getHoldRadiusInCells()
Get the Hold radius as a multiple of cells.
Definition: OgreGrid2DPageStrategy.h:176
Ogre::G2D_X_Z
Grid is in the X/Z plane.
Definition: OgreGrid2DPageStrategy.h:53
Ogre::Grid2DPageStrategyData::mMaxCellX
int32 mMaxCellX
Definition: OgreGrid2DPageStrategy.h:139
Ogre::uint16
unsigned short uint16
Definition: OgrePlatform.h:360
Ogre::Grid2DPageStrategyData::mLoadRadius
Real mLoadRadius
Load radius.
Definition: OgreGrid2DPageStrategy.h:132
Ogre::PageStrategy
Defines the interface to a strategy class which is responsible for deciding when Page instances are r...
Definition: OgrePageStrategy.h:73

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