OgreGrid3DPageStrategy.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_Grid3DPageStrategy_H__
    00030 #define __Ogre_Grid3DPageStrategy_H__
    00031
    00032 #include "OgrePagingPrerequisites.h"
    00033 #include "OgrePageStrategy.h"
    00034 #include "OgreVector3.h"
    00035
    00036 namespace Ogre
    00037 {
    00045
    00046
    00104     class _OgrePagingExport Grid3DPageStrategyData : public PageStrategyData
    00105     {
    00106     protected:
    00108         Vector3 mWorldOrigin;
    00110         Vector3 mOrigin;
    00112         Vector3 mCellSize;
    00114         Real mLoadRadius;
    00116         Real mHoldRadius;
    00117         int32 mMinCellX;
    00118         int32 mMinCellY;
    00119         int32 mMinCellZ;
    00120         int32 mMaxCellX;
    00121         int32 mMaxCellY;
    00122         int32 mMaxCellZ;
    00123
    00124     public:
    00125         static const uint32 CHUNK_ID;
    00126         static const uint16 CHUNK_VERSION;
    00127
    00128         Grid3DPageStrategyData();
    00129         ~Grid3DPageStrategyData();
    00130
    00132         virtual void setOrigin(const Vector3& worldOrigin);
    00134         virtual const Vector3& getOrigin(const Vector3& worldOrigin) { return mWorldOrigin; }
    00136         virtual void setCellSize(const Vector3& sz);
    00138         virtual Vector3 getCellSize() const { return mCellSize; }
    00140         virtual void setLoadRadius(Real sz);
    00142         virtual Real getLoadRadius() const { return mLoadRadius; }
    00144         virtual void setHoldRadius(Real sz);
    00146         virtual Real getHoldRadius() const { return mHoldRadius; }
    00147
    00149         virtual void setCellRange(int32 minX, int32 minY, int32 minZ, int32 maxX, int32 maxY, int32 maxZ);
    00151         virtual void setCellRangeMinX(int32 minX);
    00153         virtual void setCellRangeMinY(int32 minY);
    00155         virtual void setCellRangeMinZ(int32 minZ);
    00157         virtual void setCellRangeMaxX(int32 maxX);
    00159         virtual void setCellRangeMaxY(int32 maxY);
    00161         virtual void setCellRangeMaxZ(int32 maxZ);
    00163         virtual int32 getCellRangeMinX() const { return mMinCellX; }
    00165         virtual int32 getCellRangeMinY() const { return mMinCellY; }
    00167         virtual int32 getCellRangeMinZ() const { return mMinCellZ; }
    00169         virtual int32 getCellRangeMaxX() const { return mMaxCellX; }
    00171         virtual int32 getCellRangeMaxY() const { return mMaxCellY; }
    00173         virtual int32 getCellRangeMaxZ() const { return mMaxCellZ; }
    00174
    00176         bool load(StreamSerialiser& stream);
    00178         void save(StreamSerialiser& stream);
    00179
    00180         virtual void getMidPointGridSpace(int32 x, int32 y, int32 z, Vector3& mid);
    00182         virtual void getBottomLeftGridSpace(int32 x, int32 y, int z, Vector3& bl);
    00187         virtual void getCornersGridSpace(int32 x, int32 y, int32 z, Vector3* pEightPoints);
    00188
    00190         void determineGridLocation(const Vector3& gridpos, int32* x, int32* y, int32* z);
    00191
    00192         PageID calculatePageID(int32 x, int32 y, int32 z);
    00193         void calculateCell(PageID inPageID, int32* x, int32* y, int32* z);
    00194     };
    00195
    00196
    00203     class _OgrePagingExport Grid3DPageStrategy : public PageStrategy
    00204     {
    00205     public:
    00206         Grid3DPageStrategy(PageManager* manager);
    00207
    00208         ~Grid3DPageStrategy();
    00209
    00210         // Overridden members
    00211         void notifyCamera(Camera* cam, PagedWorldSection* section);
    00212         PageStrategyData* createData();
    00213         void destroyData(PageStrategyData* d);
    00214         void updateDebugDisplay(Page* p, SceneNode* sn);
    00215         PageID getPageID(const Vector3& worldPos, PagedWorldSection* section);
    00216     };
    00217
    00220 }
    00221
    00222 #endif

Copyright © 2012 Torus Knot Software Ltd
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Last modified Sun Sep 2 2012 07:27:22