OgreGrid2DPageStrategy.h

Go to the documentation of this file.
00001 /*
00002 -----------------------------------------------------------------------------
00003 This source file is part of OGRE
00004 (Object-oriented Graphics Rendering Engine)
00005 For the latest info, see http://www.ogre3d.org/
00006 
00007 Copyright (c) 2000-2012 Torus Knot Software Ltd
00008 
00009 Permission is hereby granted, free of charge, to any person obtaining a copy
00010 of this software and associated documentation files (the "Software"), to deal
00011 in the Software without restriction, including without limitation the rights
00012 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
00013 copies of the Software, and to permit persons to whom the Software is
00014 furnished to do so, subject to the following conditions:
00015 
00016 The above copyright notice and this permission notice shall be included in
00017 all copies or substantial portions of the Software.
00018 
00019 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00020 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00021 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
00022 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00023 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
00024 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
00025 THE SOFTWARE.
00026 -----------------------------------------------------------------------------
00027 */
00028 
00029 #ifndef __Ogre_Grid2DPageStrategy_H__
00030 #define __Ogre_Grid2DPageStrategy_H__
00031 
00032 #include "OgrePagingPrerequisites.h"
00033 #include "OgrePageStrategy.h"
00034 #include "OgreVector2.h"
00035 #include "OgreVector3.h"
00036 #include "OgreQuaternion.h"
00037 
00038 namespace Ogre
00039 {
00047 
00048 
00050     enum Grid2DMode
00051     {
00053         G2D_X_Z = 0, 
00055         G2D_X_Y = 1, 
00057         G2D_Y_Z = 2
00058     };
00120     class _OgrePagingExport Grid2DPageStrategyData : public PageStrategyData
00121     {
00122     protected:
00124         Grid2DMode mMode;
00126         Vector3 mWorldOrigin;
00128         Vector2 mOrigin;
00130         Real mCellSize;
00132         Real mLoadRadius;
00134         Real mHoldRadius;
00135         Real mLoadRadiusInCells;
00136         Real mHoldRadiusInCells;
00137         int32 mMinCellX;
00138         int32 mMinCellY;
00139         int32 mMaxCellX;
00140         int32 mMaxCellY;
00141 
00142         void updateDerivedMetrics();
00143 
00144     public:
00145         static const uint32 CHUNK_ID;
00146         static const uint16 CHUNK_VERSION;
00147 
00148         Grid2DPageStrategyData();
00149         ~Grid2DPageStrategyData();
00150 
00152         virtual void setMode(Grid2DMode mode);
00153 
00155         virtual Grid2DMode getMode() const { return mMode; }
00156 
00158         virtual void setOrigin(const Vector3& worldOrigin);
00160         virtual const Vector3& getOrigin(const Vector3& worldOrigin) { return mWorldOrigin; }
00162         virtual void setCellSize(Real sz);
00164         virtual Real getCellSize() const { return mCellSize; }
00166         virtual void setLoadRadius(Real sz);
00168         virtual Real getLoadRadius() const { return mLoadRadius; }
00170         virtual void setHoldRadius(Real sz);
00172         virtual Real getHoldRadius() const { return mHoldRadius; }
00174         virtual Real getLoadRadiusInCells() { return mLoadRadiusInCells; }
00176         virtual Real getHoldRadiusInCells(){ return mHoldRadiusInCells; }
00177 
00179         virtual void setCellRange(int32 minX, int32 minY, int32 maxX, int32 maxY);
00181         virtual void setCellRangeMinX(int32 minX);
00183         virtual void setCellRangeMinY(int32 minY);
00185         virtual void setCellRangeMaxX(int32 maxX);
00187         virtual void setCellRangeMaxY(int32 maxY);
00189         virtual int32 getCellRangeMinX() const { return mMinCellX; }
00191         virtual int32 getCellRangeMinY() const { return mMinCellY; }
00193         virtual int32 getCellRangeMaxX() const { return mMaxCellX; }
00195         virtual int32 getCellRangeMaxY() const { return mMaxCellY; }
00196 
00198         bool load(StreamSerialiser& stream);
00200         void save(StreamSerialiser& stream);
00201 
00203         virtual void convertWorldToGridSpace(const Vector3& world, Vector2& grid);
00205         virtual void convertGridToWorldSpace(const Vector2& grid, Vector3& world);
00207         virtual void getMidPointGridSpace(int32 x, int32 y, Vector2& mid);
00209         virtual void getBottomLeftGridSpace(int32 x, int32 y, Vector2& bl);
00214         virtual void getCornersGridSpace(int32 x, int32 y, Vector2* pFourPoints);
00215         
00217         void determineGridLocation(const Vector2& gridpos, int32* x, int32* y);
00218 
00219         PageID calculatePageID(int32 x, int32 y);
00220         void calculateCell(PageID inPageID, int32* x, int32* y);
00221 
00222     };
00223 
00224 
00231     class _OgrePagingExport Grid2DPageStrategy : public PageStrategy
00232     {
00233     public:
00234         Grid2DPageStrategy(PageManager* manager);
00235 
00236         ~Grid2DPageStrategy();
00237 
00238         // Overridden members
00239         void notifyCamera(Camera* cam, PagedWorldSection* section);
00240         PageStrategyData* createData();
00241         void destroyData(PageStrategyData* d);
00242         void updateDebugDisplay(Page* p, SceneNode* sn);
00243         PageID getPageID(const Vector3& worldPos, PagedWorldSection* section);
00244     };
00245 
00248 }
00249 
00250 #endif

Copyright © 2012 Torus Knot Software Ltd
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Last modified Fri May 25 23:36:24 2012