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-2013 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

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 Wed Oct 16 2013 14:35:42