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-2013 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_TerrainPagedWorldSection_H__ 00030 #define __Ogre_TerrainPagedWorldSection_H__ 00031 00032 #include "OgreTerrainPrerequisites.h" 00033 #include "OgrePagedWorldSection.h" 00034 #include "OgrePageManager.h" 00035 #include "OgreWorkQueue.h" 00036 #include "OgreTerrainGroup.h" 00037 00038 00039 namespace Ogre 00040 { 00041 class Grid2DPageStrategy; 00042 class Grid2DPageStrategyData; 00043 class TerrainGroup; 00044 00081 class _OgreTerrainExport TerrainPagedWorldSection : public PagedWorldSection, 00082 public WorkQueue::RequestHandler, public WorkQueue::ResponseHandler 00083 { 00084 public: 00090 TerrainPagedWorldSection(const String& name, PagedWorld* parent, SceneManager* sm); 00091 virtual ~TerrainPagedWorldSection(); 00092 00102 virtual void init(TerrainGroup* grp); 00103 00109 virtual TerrainGroup* getTerrainGroup() { return mTerrainGroup; } 00110 00112 virtual void setLoadRadius(Real sz); 00114 virtual Real getLoadRadius() const; 00116 virtual void setHoldRadius(Real sz); 00118 virtual Real getHoldRadius(); 00120 virtual void setPageRange(int32 minX, int32 minY, int32 maxX, int32 maxY); 00122 virtual void setPageRangeMinX(int32 minX); 00124 virtual void setPageRangeMinY(int32 minY); 00126 virtual void setPageRangeMaxX(int32 maxX); 00128 virtual void setPageRangeMaxY(int32 maxY); 00130 virtual int32 getPageRangeMinX() const; 00132 virtual int32 getPageRangeMinY() const; 00134 virtual int32 getPageRangeMaxX() const; 00136 virtual int32 getPageRangeMaxY() const; 00137 00139 virtual Grid2DPageStrategy* getGridStrategy() const; 00141 virtual Grid2DPageStrategyData* getGridStrategyData() const; 00142 00144 virtual void setLoadingIntervalMs(uint32 loadingIntervalMs); 00146 virtual uint32 getLoadingIntervalMs() const; 00147 00149 void loadPage(PageID pageID, bool forceSynchronous = false); 00151 void unloadPage(PageID pageID, bool forceSynchronous = false); 00152 00154 WorkQueue::Response* handleRequest(const WorkQueue::Request* req, const WorkQueue* srcQ); 00156 void handleResponse(const WorkQueue::Response* res, const WorkQueue* srcQ); 00157 00158 static const uint16 WORKQUEUE_LOAD_TERRAIN_PAGE_REQUEST; 00159 00160 class TerrainDefiner : public TerrainAlloc 00161 { 00162 public: 00163 virtual void define(TerrainGroup* terrainGroup, long x, long y) 00164 { 00165 terrainGroup->defineTerrain(x,y); 00166 } 00167 virtual ~TerrainDefiner() {} 00168 }; 00169 00170 void setDefiner(TerrainDefiner* terrainDefiner) 00171 { 00172 if(mTerrainDefiner) 00173 OGRE_DELETE mTerrainDefiner; 00174 mTerrainDefiner = terrainDefiner; 00175 } 00176 00177 protected: 00178 TerrainGroup* mTerrainGroup; 00179 TerrainDefiner* mTerrainDefiner; 00180 std::list<PageID> mPagesInLoading; 00181 bool mHasRunningTasks; 00182 uint16 mWorkQueueChannel; 00183 unsigned long mNextLoadingTime; 00184 uint32 mLoadingIntervalMs; 00185 00187 void loadSubtypeData(StreamSerialiser& ser); 00188 void saveSubtypeData(StreamSerialiser& ser); 00189 00190 virtual void syncSettings(); 00191 00192 }; 00193 00194 00195 00196 00197 00200 } 00201 00202 #endif
Copyright © 2012 Torus Knot Software Ltd

This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Last modified Mon Jul 27 2020 13:40:48