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-2006 Torus Knot Software Ltd |
---|
8 | Also see acknowledgements in Readme.html |
---|
9 | |
---|
10 | This program is free software; you can redistribute it and/or modify it under |
---|
11 | the terms of the GNU Lesser General Public License as published by the Free Software |
---|
12 | Foundation; either version 2 of the License, or (at your option) any later |
---|
13 | version. |
---|
14 | |
---|
15 | This program is distributed in the hope that it will be useful, but WITHOUT |
---|
16 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
---|
17 | FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. |
---|
18 | |
---|
19 | You should have received a copy of the GNU Lesser General Public License along with |
---|
20 | this program; if not, write to the Free Software Foundation, Inc., 59 Temple |
---|
21 | Place - Suite 330, Boston, MA 02111-1307, USA, or go to |
---|
22 | http://www.gnu.org/copyleft/lesser.txt. |
---|
23 | |
---|
24 | You may alternatively use this source under the terms of a specific version of |
---|
25 | the OGRE Unrestricted License provided you have obtained such a license from |
---|
26 | Torus Knot Software Ltd. |
---|
27 | ----------------------------------------------------------------------------- |
---|
28 | */ |
---|
29 | /*************************************************************************** |
---|
30 | terrainscenemanager.cpp - description |
---|
31 | ------------------- |
---|
32 | begin : Mon Sep 23 2002 |
---|
33 | copyright : (C) 2002 by Jon Anderson |
---|
34 | email : janders@users.sf.net |
---|
35 | |
---|
36 | Enhancements 2003 - 2004 (C) The OGRE Team |
---|
37 | |
---|
38 | ***************************************************************************/ |
---|
39 | #include <OgreTerrainSceneManager.h> |
---|
40 | #include <OgreImage.h> |
---|
41 | #include <OgreConfigFile.h> |
---|
42 | #include <OgreMaterial.h> |
---|
43 | #include <OgreTechnique.h> |
---|
44 | #include <OgrePass.h> |
---|
45 | #include <OgreCamera.h> |
---|
46 | #include "OgreException.h" |
---|
47 | #include "OgreStringConverter.h" |
---|
48 | #include "OgreRenderSystem.h" |
---|
49 | #include "OgreRenderSystemCapabilities.h" |
---|
50 | #include "OgreGpuProgram.h" |
---|
51 | #include "OgreGpuProgramManager.h" |
---|
52 | #include "OgreTerrainVertexProgram.h" |
---|
53 | #include "OgreTerrainPage.h" |
---|
54 | #include "OgreLogManager.h" |
---|
55 | #include "OgreResourceGroupManager.h" |
---|
56 | #include "OgreMaterialManager.h" |
---|
57 | #include "OgreHeightmapTerrainPageSource.h" |
---|
58 | #include <fstream> |
---|
59 | |
---|
60 | #define TERRAIN_MATERIAL_NAME "TerrainSceneManager/Terrain" |
---|
61 | |
---|
62 | namespace Ogre |
---|
63 | { |
---|
64 | //------------------------------------------------------------------------- |
---|
65 | //------------------------------------------------------------------------- |
---|
66 | TerrainSceneManager::TerrainSceneManager(const String& name) |
---|
67 | : OctreeSceneManager(name) |
---|
68 | { |
---|
69 | //setDisplaySceneNodes( true ); |
---|
70 | //setShowBoxes( true ); |
---|
71 | |
---|
72 | mUseCustomMaterial = false; |
---|
73 | mUseNamedParameterLodMorph = false; |
---|
74 | mLodMorphParamIndex = 3; |
---|
75 | mTerrainRoot = 0; |
---|
76 | mActivePageSource = 0; |
---|
77 | mPagingEnabled = false; |
---|
78 | mLivePageMargin = 0; |
---|
79 | mBufferedPageMargin = 0; |
---|
80 | |
---|
81 | |
---|
82 | } |
---|
83 | //------------------------------------------------------------------------- |
---|
84 | const String& TerrainSceneManager::getTypeName(void) const |
---|
85 | { |
---|
86 | return TerrainSceneManagerFactory::FACTORY_TYPE_NAME; |
---|
87 | } |
---|
88 | //------------------------------------------------------------------------- |
---|
89 | void TerrainSceneManager::shutdown(void) |
---|
90 | { |
---|
91 | // Make sure the indexes are destroyed during orderly shutdown |
---|
92 | // and not when statics are destroyed (may be too late) |
---|
93 | mIndexCache.shutdown(); |
---|
94 | destroyLevelIndexes(); |
---|
95 | |
---|
96 | // Make sure we free up material (static) |
---|
97 | mOptions.terrainMaterial.setNull(); |
---|
98 | |
---|
99 | // Shut down page source to free terrain pages |
---|
100 | if (mActivePageSource) |
---|
101 | { |
---|
102 | mActivePageSource->shutdown(); |
---|
103 | } |
---|
104 | |
---|
105 | } |
---|
106 | //------------------------------------------------------------------------- |
---|
107 | TerrainSceneManager::~TerrainSceneManager() |
---|
108 | { |
---|
109 | shutdown(); |
---|
110 | } |
---|
111 | //------------------------------------------------------------------------- |
---|
112 | void TerrainSceneManager::loadConfig(DataStreamPtr& stream) |
---|
113 | { |
---|
114 | /* Set up the options */ |
---|
115 | ConfigFile config; |
---|
116 | String val; |
---|
117 | |
---|
118 | config.load( stream ); |
---|
119 | |
---|
120 | val = config.getSetting( "DetailTile" ); |
---|
121 | if ( !val.empty() ) |
---|
122 | setDetailTextureRepeat(atoi(val.c_str())); |
---|
123 | |
---|
124 | val = config.getSetting( "MaxMipMapLevel" ); |
---|
125 | if ( !val.empty() ) |
---|
126 | setMaxGeoMipMapLevel(atoi( val.c_str() )); |
---|
127 | |
---|
128 | |
---|
129 | val = config.getSetting( "PageSize" ); |
---|
130 | if ( !val.empty() ) |
---|
131 | setPageSize(atoi( val.c_str() )); |
---|
132 | else |
---|
133 | OGRE_EXCEPT(Exception::ERR_ITEM_NOT_FOUND, "Missing option 'PageSize'", |
---|
134 | "TerrainSceneManager::loadConfig"); |
---|
135 | |
---|
136 | |
---|
137 | val = config.getSetting( "TileSize" ); |
---|
138 | if ( !val.empty() ) |
---|
139 | setTileSize(atoi( val.c_str() )); |
---|
140 | else |
---|
141 | OGRE_EXCEPT(Exception::ERR_ITEM_NOT_FOUND, "Missing option 'TileSize'", |
---|
142 | "TerrainSceneManager::loadConfig"); |
---|
143 | |
---|
144 | Vector3 v = Vector3::UNIT_SCALE; |
---|
145 | |
---|
146 | val = config.getSetting( "PageWorldX" ); |
---|
147 | if ( !val.empty() ) |
---|
148 | v.x = atof( val.c_str() ); |
---|
149 | |
---|
150 | val = config.getSetting( "MaxHeight" ); |
---|
151 | if ( !val.empty() ) |
---|
152 | v.y = atof( val.c_str() ); |
---|
153 | |
---|
154 | val = config.getSetting( "PageWorldZ" ); |
---|
155 | if ( !val.empty() ) |
---|
156 | v.z = atof( val.c_str() ); |
---|
157 | |
---|
158 | // Scale x/z relative to pagesize |
---|
159 | v.x /= mOptions.pageSize - 1; |
---|
160 | v.z /= mOptions.pageSize - 1; |
---|
161 | setScale(v); |
---|
162 | |
---|
163 | val = config.getSetting( "MaxPixelError" ); |
---|
164 | if ( !val.empty() ) |
---|
165 | setMaxPixelError(atoi( val.c_str() )); |
---|
166 | |
---|
167 | mDetailTextureName = config.getSetting( "DetailTexture" ); |
---|
168 | |
---|
169 | mWorldTextureName = config.getSetting( "WorldTexture" ); |
---|
170 | |
---|
171 | if ( config.getSetting( "VertexColours" ) == "yes" ) |
---|
172 | mOptions.coloured = true; |
---|
173 | |
---|
174 | if ( config.getSetting( "VertexNormals" ) == "yes" ) |
---|
175 | mOptions.lit = true; |
---|
176 | |
---|
177 | if ( config.getSetting( "UseTriStrips" ) == "yes" ) |
---|
178 | setUseTriStrips(true); |
---|
179 | |
---|
180 | if ( config.getSetting( "VertexProgramMorph" ) == "yes" ) |
---|
181 | setUseLODMorph(true); |
---|
182 | |
---|
183 | val = config.getSetting( "LODMorphStart"); |
---|
184 | if ( !val.empty() ) |
---|
185 | setLODMorphStart(atof(val.c_str())); |
---|
186 | |
---|
187 | val = config.getSetting( "CustomMaterialName" ); |
---|
188 | if ( !val.empty() ) |
---|
189 | setCustomMaterial(val); |
---|
190 | |
---|
191 | val = config.getSetting( "MorphLODFactorParamName" ); |
---|
192 | if ( !val.empty() ) |
---|
193 | setCustomMaterialMorphFactorParam(val); |
---|
194 | |
---|
195 | val = config.getSetting( "MorphLODFactorParamIndex" ); |
---|
196 | if ( !val.empty() ) |
---|
197 | setCustomMaterialMorphFactorParam(atoi(val.c_str())); |
---|
198 | |
---|
199 | // Now scan through the remaining settings, looking for any PageSource |
---|
200 | // prefixed items |
---|
201 | String pageSourceName = config.getSetting("PageSource"); |
---|
202 | if (pageSourceName == "") |
---|
203 | { |
---|
204 | OGRE_EXCEPT(Exception::ERR_ITEM_NOT_FOUND, "Missing option 'PageSource'", |
---|
205 | "TerrainSceneManager::loadConfig"); |
---|
206 | } |
---|
207 | TerrainPageSourceOptionList optlist; |
---|
208 | ConfigFile::SettingsIterator setIt = config.getSettingsIterator(); |
---|
209 | while (setIt.hasMoreElements()) |
---|
210 | { |
---|
211 | String name = setIt.peekNextKey(); |
---|
212 | String value = setIt.getNext(); |
---|
213 | if (StringUtil::startsWith(name, pageSourceName, false)) |
---|
214 | { |
---|
215 | optlist.push_back(TerrainPageSourceOption(name, value)); |
---|
216 | } |
---|
217 | } |
---|
218 | // set the page source |
---|
219 | selectPageSource(pageSourceName, optlist); |
---|
220 | |
---|
221 | |
---|
222 | } |
---|
223 | //------------------------------------------------------------------------- |
---|
224 | /* |
---|
225 | void TerrainSceneManager::loadHeightmap(void) |
---|
226 | { |
---|
227 | Image image; |
---|
228 | |
---|
229 | image.load( mHeightmapName ); |
---|
230 | |
---|
231 | //check to make sure it's 2^n + 1 size. |
---|
232 | if ( image.getWidth() != image.getHeight() || |
---|
233 | ! _checkSize( image.getWidth() ) ) |
---|
234 | { |
---|
235 | String err = "Error: Invalid heightmap size : " + |
---|
236 | StringConverter::toString( image.getWidth() ) + |
---|
237 | "," + StringConverter::toString( image.getHeight() ) + |
---|
238 | ". Should be 2^n+1, 2^n+1"; |
---|
239 | OGRE_EXCEPT( Exception::ERR_INVALIDPARAMS, err, "TerrainSceneManager::loadHeightmap" ); |
---|
240 | } |
---|
241 | |
---|
242 | int upperRange = 0; |
---|
243 | int size = image.getWidth(); |
---|
244 | |
---|
245 | if ( image.getFormat() == PF_L8 ) |
---|
246 | { |
---|
247 | upperRange = 255; |
---|
248 | |
---|
249 | // Parse the char data into floats |
---|
250 | mOptions.heightData = new Real[size*size]; |
---|
251 | const uchar* pSrc = image. getData(); |
---|
252 | Real* pDest = mOptions.heightData; |
---|
253 | for (int i = 0; i < size*size; ++i) |
---|
254 | { |
---|
255 | *pDest++ = *pSrc++ * mOptions.scale.y; |
---|
256 | } |
---|
257 | } |
---|
258 | else |
---|
259 | { |
---|
260 | OGRE_EXCEPT( Exception::ERR_INVALIDPARAMS, "Error: Image is not a grayscale image.", |
---|
261 | "TerrainSceneManager::setWorldGeometry" ); |
---|
262 | } |
---|
263 | |
---|
264 | |
---|
265 | // set up the octree size. |
---|
266 | float max_x = mOptions.scale.x * size; |
---|
267 | |
---|
268 | float max_y = upperRange * mOptions.scale.y; |
---|
269 | |
---|
270 | float max_z = mOptions.scale.z * size; |
---|
271 | |
---|
272 | resize( AxisAlignedBox( 0, 0, 0, max_x, max_y, max_z ) ); |
---|
273 | |
---|
274 | mOptions.pageSize = size; |
---|
275 | |
---|
276 | } |
---|
277 | */ |
---|
278 | //------------------------------------------------------------------------- |
---|
279 | void TerrainSceneManager::setupTerrainMaterial(void) |
---|
280 | { |
---|
281 | if (mCustomMaterialName == "") |
---|
282 | { |
---|
283 | // define our own material |
---|
284 | mOptions.terrainMaterial = |
---|
285 | MaterialManager::getSingleton().getByName(TERRAIN_MATERIAL_NAME); |
---|
286 | // Make unique terrain material name |
---|
287 | StringUtil::StrStreamType s; |
---|
288 | s << mName << "/Terrain"; |
---|
289 | mOptions.terrainMaterial = MaterialManager::getSingleton().getByName(s.str()); |
---|
290 | if (mOptions.terrainMaterial.isNull()) |
---|
291 | { |
---|
292 | mOptions.terrainMaterial = MaterialManager::getSingleton().create( |
---|
293 | s.str(), |
---|
294 | ResourceGroupManager::getSingleton().getWorldResourceGroupName()); |
---|
295 | |
---|
296 | } |
---|
297 | else |
---|
298 | { |
---|
299 | mOptions.terrainMaterial->getTechnique(0)->getPass(0)->removeAllTextureUnitStates(); |
---|
300 | } |
---|
301 | |
---|
302 | Pass* pass = mOptions.terrainMaterial->getTechnique(0)->getPass(0); |
---|
303 | |
---|
304 | if ( mWorldTextureName != "" ) |
---|
305 | { |
---|
306 | pass->createTextureUnitState( mWorldTextureName, 0 ); |
---|
307 | } |
---|
308 | if ( mDetailTextureName != "" ) |
---|
309 | { |
---|
310 | pass->createTextureUnitState( mDetailTextureName, 1 ); |
---|
311 | } |
---|
312 | |
---|
313 | mOptions.terrainMaterial -> setLightingEnabled( mOptions.lit ); |
---|
314 | |
---|
315 | if (mOptions.lodMorph && |
---|
316 | mDestRenderSystem->getCapabilities()->hasCapability(RSC_VERTEX_PROGRAM) && |
---|
317 | GpuProgramManager::getSingleton().getByName("Terrain/VertexMorph").isNull()) |
---|
318 | { |
---|
319 | // Create & assign LOD morphing vertex program |
---|
320 | String syntax; |
---|
321 | if (GpuProgramManager::getSingleton().isSyntaxSupported("arbvp1")) |
---|
322 | { |
---|
323 | syntax = "arbvp1"; |
---|
324 | } |
---|
325 | else |
---|
326 | { |
---|
327 | syntax = "vs_1_1"; |
---|
328 | } |
---|
329 | |
---|
330 | // Get source, and take into account current fog mode |
---|
331 | FogMode fm = getFogMode(); |
---|
332 | const String& source = TerrainVertexProgram::getProgramSource( |
---|
333 | fm, syntax); |
---|
334 | |
---|
335 | GpuProgramPtr prog = GpuProgramManager::getSingleton().createProgramFromString( |
---|
336 | "Terrain/VertexMorph", ResourceGroupManager::getSingleton().getWorldResourceGroupName(), |
---|
337 | source, GPT_VERTEX_PROGRAM, syntax); |
---|
338 | |
---|
339 | // Attach |
---|
340 | pass->setVertexProgram("Terrain/VertexMorph"); |
---|
341 | |
---|
342 | // Get params |
---|
343 | GpuProgramParametersSharedPtr params = pass->getVertexProgramParameters(); |
---|
344 | |
---|
345 | // worldviewproj |
---|
346 | params->setAutoConstant(0, GpuProgramParameters::ACT_WORLDVIEWPROJ_MATRIX); |
---|
347 | // morph factor |
---|
348 | params->setAutoConstant(4, GpuProgramParameters::ACT_CUSTOM, MORPH_CUSTOM_PARAM_ID); |
---|
349 | // fog exp density(if relevant) |
---|
350 | if (fm == FOG_EXP || fm == FOG_EXP2) |
---|
351 | { |
---|
352 | params->setConstant(5, Vector3(getFogDensity(), 0, 0)); |
---|
353 | // Override scene fog since otherwise it's applied twice |
---|
354 | // Set to linear and we derive [0,1] fog value in the shader |
---|
355 | pass->setFog(true, FOG_LINEAR, getFogColour(), 0, 1, 0); |
---|
356 | } |
---|
357 | |
---|
358 | // Also set shadow receiver program |
---|
359 | const String& source2 = TerrainVertexProgram::getProgramSource( |
---|
360 | fm, syntax, true); |
---|
361 | |
---|
362 | prog = GpuProgramManager::getSingleton().createProgramFromString( |
---|
363 | "Terrain/VertexMorphShadowReceive", |
---|
364 | ResourceGroupManager::getSingleton().getWorldResourceGroupName(), |
---|
365 | source2, GPT_VERTEX_PROGRAM, syntax); |
---|
366 | pass->setShadowReceiverVertexProgram("Terrain/VertexMorphShadowReceive"); |
---|
367 | params = pass->getShadowReceiverVertexProgramParameters(); |
---|
368 | // worldviewproj |
---|
369 | params->setAutoConstant(0, GpuProgramParameters::ACT_WORLDVIEWPROJ_MATRIX); |
---|
370 | // world |
---|
371 | params->setAutoConstant(4, GpuProgramParameters::ACT_WORLD_MATRIX); |
---|
372 | // texture view / proj |
---|
373 | params->setAutoConstant(8, GpuProgramParameters::ACT_TEXTURE_VIEWPROJ_MATRIX); |
---|
374 | // morph factor |
---|
375 | params->setAutoConstant(12, GpuProgramParameters::ACT_CUSTOM, MORPH_CUSTOM_PARAM_ID); |
---|
376 | |
---|
377 | |
---|
378 | // Set param index |
---|
379 | mLodMorphParamName = ""; |
---|
380 | mLodMorphParamIndex = 4; |
---|
381 | } |
---|
382 | |
---|
383 | mOptions.terrainMaterial->load(); |
---|
384 | |
---|
385 | } |
---|
386 | else |
---|
387 | { |
---|
388 | // Custom material |
---|
389 | mOptions.terrainMaterial = |
---|
390 | MaterialManager::getSingleton().getByName(mCustomMaterialName); |
---|
391 | mOptions.terrainMaterial->load(); |
---|
392 | |
---|
393 | } |
---|
394 | |
---|
395 | // now set up the linkage between vertex program and LOD morph param |
---|
396 | if (mOptions.lodMorph) |
---|
397 | { |
---|
398 | Technique* t = mOptions.terrainMaterial->getBestTechnique(); |
---|
399 | for (ushort i = 0; i < t->getNumPasses(); ++i) |
---|
400 | { |
---|
401 | Pass* p = t->getPass(i); |
---|
402 | if (p->hasVertexProgram()) |
---|
403 | { |
---|
404 | // we have to assume vertex program includes LOD morph capability |
---|
405 | GpuProgramParametersSharedPtr params = |
---|
406 | p->getVertexProgramParameters(); |
---|
407 | // Check to see if custom param is already there |
---|
408 | GpuProgramParameters::AutoConstantIterator aci = params->getAutoConstantIterator(); |
---|
409 | bool found = false; |
---|
410 | while (aci.hasMoreElements()) |
---|
411 | { |
---|
412 | const GpuProgramParameters::AutoConstantEntry& ace = aci.getNext(); |
---|
413 | if (ace.paramType == GpuProgramParameters::ACT_CUSTOM && |
---|
414 | ace.data == MORPH_CUSTOM_PARAM_ID) |
---|
415 | { |
---|
416 | found = true; |
---|
417 | } |
---|
418 | } |
---|
419 | if (!found) |
---|
420 | { |
---|
421 | if(mLodMorphParamName != "") |
---|
422 | { |
---|
423 | params->setNamedAutoConstant(mLodMorphParamName, |
---|
424 | GpuProgramParameters::ACT_CUSTOM, MORPH_CUSTOM_PARAM_ID); |
---|
425 | } |
---|
426 | else |
---|
427 | { |
---|
428 | params->setAutoConstant(mLodMorphParamIndex, |
---|
429 | GpuProgramParameters::ACT_CUSTOM, MORPH_CUSTOM_PARAM_ID); |
---|
430 | } |
---|
431 | } |
---|
432 | |
---|
433 | } |
---|
434 | } |
---|
435 | } |
---|
436 | |
---|
437 | } |
---|
438 | //------------------------------------------------------------------------- |
---|
439 | void TerrainSceneManager::setupTerrainPages(void) |
---|
440 | { |
---|
441 | |
---|
442 | //create a root terrain node. |
---|
443 | if (!mTerrainRoot) |
---|
444 | mTerrainRoot = getRootSceneNode() -> createChildSceneNode( "Terrain" ); |
---|
445 | |
---|
446 | //setup the page array. |
---|
447 | unsigned short pageSlots = 1 + (mBufferedPageMargin * 2); |
---|
448 | unsigned short i, j; |
---|
449 | for (i = 0; i < pageSlots; ++i) |
---|
450 | { |
---|
451 | mTerrainPages.push_back(TerrainPageRow()); |
---|
452 | for (j = 0; j < pageSlots; ++j) |
---|
453 | { |
---|
454 | mTerrainPages[i].push_back(0); |
---|
455 | } |
---|
456 | } |
---|
457 | |
---|
458 | // If we're not paging, load immediate for convenience |
---|
459 | if ( mActivePageSource && !mPagingEnabled ) |
---|
460 | mActivePageSource->requestPage(0,0); |
---|
461 | |
---|
462 | |
---|
463 | } |
---|
464 | //------------------------------------------------------------------------- |
---|
465 | void TerrainSceneManager::setWorldGeometry( const String& filename ) |
---|
466 | { |
---|
467 | // try to open in the current folder first |
---|
468 | std::ifstream fs; |
---|
469 | fs.open(filename.c_str(), std::ios::in | std::ios::binary); |
---|
470 | if (fs) |
---|
471 | { |
---|
472 | // Wrap as a stream |
---|
473 | DataStreamPtr stream( |
---|
474 | new FileStreamDataStream(filename, &fs, false)); |
---|
475 | setWorldGeometry(stream); |
---|
476 | } |
---|
477 | else |
---|
478 | { |
---|
479 | // otherwise try resource system |
---|
480 | DataStreamPtr stream = |
---|
481 | ResourceGroupManager::getSingleton().openResource(filename, |
---|
482 | ResourceGroupManager::getSingleton().getWorldResourceGroupName()); |
---|
483 | |
---|
484 | setWorldGeometry(stream); |
---|
485 | } |
---|
486 | } |
---|
487 | //------------------------------------------------------------------------- |
---|
488 | void TerrainSceneManager::setWorldGeometry(DataStreamPtr& stream, const String& typeName ) |
---|
489 | { |
---|
490 | // Clear out any existing world resources (if not default) |
---|
491 | if (ResourceGroupManager::getSingleton().getWorldResourceGroupName() != |
---|
492 | ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME) |
---|
493 | { |
---|
494 | ResourceGroupManager::getSingleton().clearResourceGroup( |
---|
495 | ResourceGroupManager::getSingleton().getWorldResourceGroupName()); |
---|
496 | } |
---|
497 | destroyLevelIndexes(); |
---|
498 | mTerrainPages.clear(); |
---|
499 | // Load the configuration |
---|
500 | loadConfig(stream); |
---|
501 | initLevelIndexes(); |
---|
502 | |
---|
503 | // Resize the octree, allow for 1 page for now |
---|
504 | float max_x = mOptions.scale.x * mOptions.pageSize; |
---|
505 | float max_y = mOptions.scale.y; |
---|
506 | float max_z = mOptions.scale.z * mOptions.pageSize; |
---|
507 | resize( AxisAlignedBox( 0, 0, 0, max_x, max_y, max_z ) ); |
---|
508 | |
---|
509 | setupTerrainMaterial(); |
---|
510 | |
---|
511 | setupTerrainPages(); |
---|
512 | |
---|
513 | } |
---|
514 | //------------------------------------------------------------------------- |
---|
515 | void TerrainSceneManager::clearScene(void) |
---|
516 | { |
---|
517 | OctreeSceneManager::clearScene(); |
---|
518 | mTerrainPages.clear(); |
---|
519 | destroyLevelIndexes(); |
---|
520 | // Octree has destroyed our root |
---|
521 | mTerrainRoot = 0; |
---|
522 | } |
---|
523 | //------------------------------------------------------------------------- |
---|
524 | void TerrainSceneManager::_renderScene(Camera* cam, Viewport *vp, bool includeOverlays) |
---|
525 | { |
---|
526 | // For now, no paging and expect immediate response |
---|
527 | if (!mTerrainPages.empty() && mTerrainPages[0][0] == 0) |
---|
528 | { |
---|
529 | mActivePageSource->requestPage(0, 0); |
---|
530 | } |
---|
531 | SceneManager::_renderScene(cam, vp, includeOverlays); |
---|
532 | |
---|
533 | } |
---|
534 | //------------------------------------------------------------------------- |
---|
535 | void TerrainSceneManager::attachPage(ushort pageX, ushort pageZ, TerrainPage* page) |
---|
536 | { |
---|
537 | assert(pageX == 0 && pageZ == 0 && "Multiple pages not yet supported"); |
---|
538 | |
---|
539 | assert(mTerrainPages[pageX][pageZ] == 0 && "Page at that index not yet expired!"); |
---|
540 | // Insert page into list |
---|
541 | mTerrainPages[pageX][pageZ] = page; |
---|
542 | // Attach page to terrain root |
---|
543 | if (page->pageSceneNode->getParentSceneNode() != mTerrainRoot) |
---|
544 | mTerrainRoot->addChild(page->pageSceneNode); |
---|
545 | |
---|
546 | } |
---|
547 | //------------------------------------------------------------------------- |
---|
548 | void TerrainSceneManager::_renderVisibleObjects( void ) |
---|
549 | { |
---|
550 | |
---|
551 | OctreeSceneManager::_renderVisibleObjects(); |
---|
552 | |
---|
553 | } |
---|
554 | //------------------------------------------------------------------------- |
---|
555 | float TerrainSceneManager::getHeightAt( float x, float z ) |
---|
556 | { |
---|
557 | |
---|
558 | |
---|
559 | Vector3 pt( x, 0, z ); |
---|
560 | |
---|
561 | TerrainRenderable * t = getTerrainTile( pt ); |
---|
562 | |
---|
563 | if ( t == 0 ) |
---|
564 | { |
---|
565 | // printf( "No tile found for point\n" ); |
---|
566 | return -1; |
---|
567 | } |
---|
568 | |
---|
569 | float h = t -> getHeightAt( x, z ); |
---|
570 | |
---|
571 | // printf( "Height is %f\n", h ); |
---|
572 | return h; |
---|
573 | |
---|
574 | } |
---|
575 | //------------------------------------------------------------------------- |
---|
576 | TerrainPage* TerrainSceneManager::getTerrainPage( const Vector3 & pt ) |
---|
577 | { |
---|
578 | if (mPagingEnabled) |
---|
579 | { |
---|
580 | // TODO |
---|
581 | return 0; |
---|
582 | } |
---|
583 | else |
---|
584 | { |
---|
585 | // Single page |
---|
586 | if (mTerrainPages.empty() || mTerrainPages[0].empty()) |
---|
587 | return 0; |
---|
588 | return mTerrainPages[0][0]; |
---|
589 | } |
---|
590 | } |
---|
591 | //------------------------------------------------------------------------- |
---|
592 | TerrainRenderable * TerrainSceneManager::getTerrainTile( const Vector3 & pt ) |
---|
593 | { |
---|
594 | TerrainPage* tp = getTerrainPage(pt); |
---|
595 | if (!tp) |
---|
596 | return NULL; |
---|
597 | else |
---|
598 | return tp->getTerrainTile(pt); |
---|
599 | } |
---|
600 | //------------------------------------------------------------------------- |
---|
601 | bool TerrainSceneManager::intersectSegment( const Vector3 & start, |
---|
602 | const Vector3 & end, Vector3 * result ) |
---|
603 | { |
---|
604 | TerrainRenderable * t = getTerrainTile( start ); |
---|
605 | |
---|
606 | if ( t == 0 ) |
---|
607 | { |
---|
608 | *result = Vector3( -1, -1, -1 ); |
---|
609 | return false; |
---|
610 | } |
---|
611 | |
---|
612 | return t -> intersectSegment( start, end, result ); |
---|
613 | } |
---|
614 | //------------------------------------------------------------------------- |
---|
615 | void TerrainSceneManager::setUseTriStrips(bool useStrips) |
---|
616 | { |
---|
617 | mOptions.useTriStrips = useStrips; |
---|
618 | } |
---|
619 | //------------------------------------------------------------------------- |
---|
620 | void TerrainSceneManager::setUseLODMorph(bool morph) |
---|
621 | { |
---|
622 | // Set true only if vertex programs are supported |
---|
623 | mOptions.lodMorph = morph && |
---|
624 | mDestRenderSystem->getCapabilities()->hasCapability(RSC_VERTEX_PROGRAM); |
---|
625 | } |
---|
626 | //------------------------------------------------------------------------- |
---|
627 | void TerrainSceneManager::setUseVertexNormals(bool useNormals) |
---|
628 | { |
---|
629 | mOptions.lit = useNormals; |
---|
630 | } |
---|
631 | //------------------------------------------------------------------------- |
---|
632 | void TerrainSceneManager::setUseVertexColours(bool useColours) |
---|
633 | { |
---|
634 | mOptions.coloured = useColours; |
---|
635 | } |
---|
636 | //------------------------------------------------------------------------- |
---|
637 | void TerrainSceneManager::setWorldTexture(const String& textureName) |
---|
638 | { |
---|
639 | mWorldTextureName = textureName; |
---|
640 | } |
---|
641 | //------------------------------------------------------------------------- |
---|
642 | void TerrainSceneManager::setDetailTexture(const String& textureName) |
---|
643 | { |
---|
644 | mDetailTextureName = textureName; |
---|
645 | |
---|
646 | } |
---|
647 | //------------------------------------------------------------------------- |
---|
648 | void TerrainSceneManager::setDetailTextureRepeat(int repeat) |
---|
649 | { |
---|
650 | mOptions.detailTile = repeat; |
---|
651 | } |
---|
652 | //------------------------------------------------------------------------- |
---|
653 | void TerrainSceneManager::setTileSize(int size) |
---|
654 | { |
---|
655 | mOptions.tileSize = size; |
---|
656 | } |
---|
657 | //------------------------------------------------------------------------- |
---|
658 | void TerrainSceneManager::setPageSize(int size) |
---|
659 | { |
---|
660 | mOptions.pageSize = size; |
---|
661 | } |
---|
662 | //------------------------------------------------------------------------- |
---|
663 | void TerrainSceneManager::setMaxPixelError(int pixelError) |
---|
664 | { |
---|
665 | mOptions.maxPixelError = pixelError; |
---|
666 | } |
---|
667 | //------------------------------------------------------------------------- |
---|
668 | void TerrainSceneManager::setScale(const Vector3& scale) |
---|
669 | { |
---|
670 | mOptions.scale = scale; |
---|
671 | } |
---|
672 | //------------------------------------------------------------------------- |
---|
673 | void TerrainSceneManager::setMaxGeoMipMapLevel(int maxMip) |
---|
674 | { |
---|
675 | mOptions.maxGeoMipMapLevel = maxMip; |
---|
676 | } |
---|
677 | //------------------------------------------------------------------------- |
---|
678 | void TerrainSceneManager::setCustomMaterial(const String& materialName) |
---|
679 | { |
---|
680 | mCustomMaterialName = materialName; |
---|
681 | if (materialName != "") |
---|
682 | mUseCustomMaterial = true; |
---|
683 | else |
---|
684 | mUseCustomMaterial = false; |
---|
685 | } |
---|
686 | //------------------------------------------------------------------------- |
---|
687 | void TerrainSceneManager::setCustomMaterialMorphFactorParam(const String& paramName) |
---|
688 | { |
---|
689 | mUseNamedParameterLodMorph = true; |
---|
690 | mLodMorphParamName = paramName; |
---|
691 | |
---|
692 | } |
---|
693 | //------------------------------------------------------------------------- |
---|
694 | void TerrainSceneManager::setCustomMaterialMorphFactorParam(size_t paramIndex) |
---|
695 | { |
---|
696 | mUseNamedParameterLodMorph = false; |
---|
697 | mLodMorphParamIndex = paramIndex; |
---|
698 | } |
---|
699 | //------------------------------------------------------------------------- |
---|
700 | void TerrainSceneManager::setLODMorphStart(Real morphStart) |
---|
701 | { |
---|
702 | mOptions.lodMorphStart = morphStart; |
---|
703 | } |
---|
704 | //------------------------------------------------------------------------- |
---|
705 | Camera* TerrainSceneManager::createCamera( const String &name ) |
---|
706 | { |
---|
707 | Camera* c = OctreeSceneManager::createCamera(name); |
---|
708 | |
---|
709 | // Set primary camera, if none |
---|
710 | if (!mOptions.primaryCamera) |
---|
711 | setPrimaryCamera(c); |
---|
712 | |
---|
713 | return c; |
---|
714 | |
---|
715 | } |
---|
716 | //------------------------------------------------------------------------- |
---|
717 | void TerrainSceneManager::setPrimaryCamera(const Camera* cam) |
---|
718 | { |
---|
719 | mOptions.primaryCamera = cam; |
---|
720 | } |
---|
721 | //------------------------------------------------------------------------- |
---|
722 | bool TerrainSceneManager::setOption( const String & name, const void *value ) |
---|
723 | { |
---|
724 | if (name == "PageSize") |
---|
725 | { |
---|
726 | setPageSize(*static_cast<const int*>(value)); |
---|
727 | return true; |
---|
728 | } |
---|
729 | else if (name == "TileSize") |
---|
730 | { |
---|
731 | setTileSize(*static_cast<const int*>(value)); |
---|
732 | return true; |
---|
733 | } |
---|
734 | else if (name == "PrimaryCamera") |
---|
735 | { |
---|
736 | setPrimaryCamera(static_cast<const Camera*>(value)); |
---|
737 | return true; |
---|
738 | } |
---|
739 | else if (name == "MaxMipMapLevel") |
---|
740 | { |
---|
741 | setMaxGeoMipMapLevel(*static_cast<const int*>(value)); |
---|
742 | return true; |
---|
743 | } |
---|
744 | else if (name == "Scale") |
---|
745 | { |
---|
746 | setScale(*static_cast<const Vector3*>(value)); |
---|
747 | return true; |
---|
748 | } |
---|
749 | else if (name == "MaxPixelError") |
---|
750 | { |
---|
751 | setMaxPixelError(*static_cast<const int*>(value)); |
---|
752 | return true; |
---|
753 | } |
---|
754 | else if (name == "UseTriStrips") |
---|
755 | { |
---|
756 | setUseTriStrips(*static_cast<const bool*>(value)); |
---|
757 | return true; |
---|
758 | } |
---|
759 | else if (name == "VertexProgramMorph") |
---|
760 | { |
---|
761 | setUseLODMorph(*static_cast<const bool*>(value)); |
---|
762 | return true; |
---|
763 | } |
---|
764 | else if (name == "DetailTile") |
---|
765 | { |
---|
766 | setDetailTextureRepeat(*static_cast<const int*>(value)); |
---|
767 | return true; |
---|
768 | } |
---|
769 | else if (name == "LodMorphStart") |
---|
770 | { |
---|
771 | setLODMorphStart(*static_cast<const Real*>(value)); |
---|
772 | return true; |
---|
773 | } |
---|
774 | else if (name == "VertexNormals") |
---|
775 | { |
---|
776 | setUseVertexNormals(*static_cast<const bool*>(value)); |
---|
777 | return true; |
---|
778 | } |
---|
779 | else if (name == "VertexColours") |
---|
780 | { |
---|
781 | setUseVertexColours(*static_cast<const bool*>(value)); |
---|
782 | return true; |
---|
783 | } |
---|
784 | else if (name == "MorphLODFactorParamName") |
---|
785 | { |
---|
786 | setCustomMaterialMorphFactorParam(*static_cast<const String*>(value)); |
---|
787 | return true; |
---|
788 | } |
---|
789 | else if (name == "MorphLODFactorParamIndex") |
---|
790 | { |
---|
791 | setCustomMaterialMorphFactorParam(*static_cast<const size_t*>(value)); |
---|
792 | return true; |
---|
793 | } |
---|
794 | else if (name == "CustomMaterialName") |
---|
795 | { |
---|
796 | setCustomMaterial(*static_cast<const String*>(value)); |
---|
797 | return true; |
---|
798 | } |
---|
799 | else if (name == "WorldTexture") |
---|
800 | { |
---|
801 | setWorldTexture(*static_cast<const String*>(value)); |
---|
802 | return true; |
---|
803 | } |
---|
804 | else if (name == "DetailTexture") |
---|
805 | { |
---|
806 | setDetailTexture(*static_cast<const String*>(value)); |
---|
807 | return true; |
---|
808 | } |
---|
809 | else |
---|
810 | { |
---|
811 | return OctreeSceneManager::setOption(name, value); |
---|
812 | } |
---|
813 | |
---|
814 | return false; |
---|
815 | } |
---|
816 | //------------------------------------------------------------------------- |
---|
817 | void TerrainSceneManager::registerPageSource(const String& typeName, |
---|
818 | TerrainPageSource* source) |
---|
819 | { |
---|
820 | std::pair<PageSourceMap::iterator, bool> retPair = |
---|
821 | mPageSources.insert( |
---|
822 | PageSourceMap::value_type(typeName, source)); |
---|
823 | if (!retPair.second) |
---|
824 | { |
---|
825 | OGRE_EXCEPT(Exception::ERR_DUPLICATE_ITEM, |
---|
826 | "The page source " + typeName + " is already registered", |
---|
827 | "TerrainSceneManager::registerPageSource"); |
---|
828 | } |
---|
829 | LogManager::getSingleton().logMessage( |
---|
830 | "TerrainSceneManager: Registered a new PageSource for " |
---|
831 | "type " + typeName); |
---|
832 | } |
---|
833 | //------------------------------------------------------------------------- |
---|
834 | void TerrainSceneManager::selectPageSource(const String& typeName, |
---|
835 | TerrainPageSourceOptionList& optionList) |
---|
836 | { |
---|
837 | PageSourceMap::iterator i = mPageSources.find(typeName); |
---|
838 | if (i == mPageSources.end()) |
---|
839 | { |
---|
840 | OGRE_EXCEPT(Exception::ERR_ITEM_NOT_FOUND, |
---|
841 | "Cannot locate a TerrainPageSource for type " + typeName, |
---|
842 | "TerrainSceneManager::selectPageSource"); |
---|
843 | } |
---|
844 | |
---|
845 | if (mActivePageSource) |
---|
846 | { |
---|
847 | mActivePageSource->shutdown(); |
---|
848 | } |
---|
849 | mActivePageSource = i->second; |
---|
850 | mActivePageSource->initialise(this, mOptions.tileSize, mOptions.pageSize, |
---|
851 | mPagingEnabled, optionList); |
---|
852 | |
---|
853 | LogManager::getSingleton().logMessage( |
---|
854 | "TerrainSceneManager: Activated PageSource " + typeName); |
---|
855 | |
---|
856 | } |
---|
857 | //------------------------------------------------------------------------- |
---|
858 | int TerrainSceneManager::getDetailTextureRepeat(void) |
---|
859 | { |
---|
860 | return mOptions.detailTile; |
---|
861 | } |
---|
862 | //------------------------------------------------------------------------- |
---|
863 | int TerrainSceneManager::getTileSize(void) |
---|
864 | { |
---|
865 | return mOptions.tileSize; |
---|
866 | } |
---|
867 | //------------------------------------------------------------------------- |
---|
868 | int TerrainSceneManager::getPageSize(void) |
---|
869 | { |
---|
870 | return mOptions.pageSize; |
---|
871 | } |
---|
872 | //------------------------------------------------------------------------- |
---|
873 | int TerrainSceneManager::getMaxPixelError(void) |
---|
874 | { |
---|
875 | return mOptions.maxPixelError; |
---|
876 | } |
---|
877 | //------------------------------------------------------------------------- |
---|
878 | const Vector3& TerrainSceneManager::getScale(void) |
---|
879 | { |
---|
880 | return mOptions.scale; |
---|
881 | } |
---|
882 | //------------------------------------------------------------------------- |
---|
883 | int TerrainSceneManager::getMaxGeoMipMapLevel(void) |
---|
884 | { |
---|
885 | return mOptions.maxGeoMipMapLevel; |
---|
886 | } |
---|
887 | //----------------------------------------------------------------------- |
---|
888 | void TerrainSceneManager::initLevelIndexes() |
---|
889 | { |
---|
890 | if ( mLevelIndex.size() == 0 ) |
---|
891 | { |
---|
892 | for ( int i = 0; i < 16; i++ ) |
---|
893 | { |
---|
894 | |
---|
895 | mLevelIndex.push_back( new IndexMap() ); |
---|
896 | |
---|
897 | } |
---|
898 | |
---|
899 | } |
---|
900 | } |
---|
901 | //----------------------------------------------------------------------- |
---|
902 | void TerrainSceneManager::destroyLevelIndexes() |
---|
903 | { |
---|
904 | for ( int i = 0; i < mLevelIndex.size(); i++ ) |
---|
905 | { |
---|
906 | delete mLevelIndex[i]; |
---|
907 | } |
---|
908 | mLevelIndex.clear(); |
---|
909 | } |
---|
910 | //------------------------------------------------------------------------- |
---|
911 | //------------------------------------------------------------------------- |
---|
912 | RaySceneQuery* |
---|
913 | TerrainSceneManager::createRayQuery(const Ray& ray, unsigned long mask) |
---|
914 | { |
---|
915 | TerrainRaySceneQuery *trsq = new TerrainRaySceneQuery(this); |
---|
916 | trsq->setRay(ray); |
---|
917 | trsq->setQueryMask(mask); |
---|
918 | return trsq; |
---|
919 | } |
---|
920 | //------------------------------------------------------------------------- |
---|
921 | TerrainRaySceneQuery::TerrainRaySceneQuery(SceneManager* creator) |
---|
922 | :OctreeRaySceneQuery(creator) |
---|
923 | { |
---|
924 | mSupportedWorldFragments.insert(SceneQuery::WFT_SINGLE_INTERSECTION); |
---|
925 | } |
---|
926 | //------------------------------------------------------------------------- |
---|
927 | TerrainRaySceneQuery::~TerrainRaySceneQuery() |
---|
928 | { |
---|
929 | } |
---|
930 | //------------------------------------------------------------------------- |
---|
931 | void TerrainRaySceneQuery::execute(RaySceneQueryListener* listener) |
---|
932 | { |
---|
933 | mWorldFrag.fragmentType = SceneQuery::WFT_SINGLE_INTERSECTION; |
---|
934 | |
---|
935 | const Vector3& dir = mRay.getDirection(); |
---|
936 | const Vector3& origin = mRay.getOrigin(); |
---|
937 | // Straight up / down? |
---|
938 | if (dir == Vector3::UNIT_Y || dir == Vector3::NEGATIVE_UNIT_Y) |
---|
939 | { |
---|
940 | Real height = static_cast<TerrainSceneManager*>(mParentSceneMgr)->getHeightAt( |
---|
941 | origin.x, origin.z); |
---|
942 | if (height != -1 && (height <= origin.y && dir.y < 0) || (height >= origin.y && dir.y > 0)) |
---|
943 | { |
---|
944 | mWorldFrag.singleIntersection.x = origin.x; |
---|
945 | mWorldFrag.singleIntersection.z = origin.z; |
---|
946 | mWorldFrag.singleIntersection.y = height; |
---|
947 | if (!listener->queryResult(&mWorldFrag, |
---|
948 | (mWorldFrag.singleIntersection - origin).length())) |
---|
949 | return; |
---|
950 | } |
---|
951 | } |
---|
952 | else |
---|
953 | { |
---|
954 | // Perform arbitrary query |
---|
955 | if (static_cast<TerrainSceneManager*>(mParentSceneMgr)->intersectSegment( |
---|
956 | origin, origin + (dir * 100000), &mWorldFrag.singleIntersection)) |
---|
957 | { |
---|
958 | if (!listener->queryResult(&mWorldFrag, |
---|
959 | (mWorldFrag.singleIntersection - origin).length())) |
---|
960 | return; |
---|
961 | } |
---|
962 | |
---|
963 | |
---|
964 | } |
---|
965 | OctreeRaySceneQuery::execute(listener); |
---|
966 | |
---|
967 | } |
---|
968 | //------------------------------------------------------------------------- |
---|
969 | MaterialPtr& TerrainSceneManager::getTerrainMaterial(void) |
---|
970 | { |
---|
971 | return mOptions.terrainMaterial; |
---|
972 | } |
---|
973 | //------------------------------------------------------------------------- |
---|
974 | TerrainSceneManager::PageSourceIterator TerrainSceneManager::getPageSourceIterator(void) |
---|
975 | { |
---|
976 | return PageSourceIterator(mPageSources.begin(), mPageSources.end()); |
---|
977 | } |
---|
978 | //------------------------------------------------------------------------- |
---|
979 | void TerrainSceneManager::setWorldGeometryRenderQueue(uint8 qid) |
---|
980 | { |
---|
981 | OctreeSceneManager::setWorldGeometryRenderQueue(qid); |
---|
982 | |
---|
983 | for (TerrainPage2D::iterator pi = mTerrainPages.begin(); |
---|
984 | pi != mTerrainPages.end(); ++pi) |
---|
985 | { |
---|
986 | TerrainPageRow& row = *pi; |
---|
987 | for (TerrainPageRow::iterator ri = row.begin(); ri != row.end(); ++ri) |
---|
988 | { |
---|
989 | TerrainPage* page = *ri; |
---|
990 | if (page) |
---|
991 | { |
---|
992 | page->setRenderQueue(qid); |
---|
993 | } |
---|
994 | } |
---|
995 | } |
---|
996 | |
---|
997 | } |
---|
998 | |
---|
999 | //----------------------------------------------------------------------- |
---|
1000 | const String TerrainSceneManagerFactory::FACTORY_TYPE_NAME = "TerrainSceneManager"; |
---|
1001 | //----------------------------------------------------------------------- |
---|
1002 | TerrainSceneManagerFactory::TerrainSceneManagerFactory() |
---|
1003 | { |
---|
1004 | } |
---|
1005 | //----------------------------------------------------------------------- |
---|
1006 | TerrainSceneManagerFactory::~TerrainSceneManagerFactory() |
---|
1007 | { |
---|
1008 | for (TerrainPageSources::iterator i = mTerrainPageSources.begin(); |
---|
1009 | i != mTerrainPageSources.end(); ++i) |
---|
1010 | { |
---|
1011 | delete *i; |
---|
1012 | } |
---|
1013 | mTerrainPageSources.clear(); |
---|
1014 | } |
---|
1015 | //----------------------------------------------------------------------- |
---|
1016 | void TerrainSceneManagerFactory::initMetaData(void) const |
---|
1017 | { |
---|
1018 | mMetaData.typeName = FACTORY_TYPE_NAME; |
---|
1019 | mMetaData.description = "Scene manager which generally organises the scene on " |
---|
1020 | "the basis of an octree, but also supports terrain world geometry. "; |
---|
1021 | mMetaData.sceneTypeMask = ST_EXTERIOR_CLOSE; // previous compatiblity |
---|
1022 | mMetaData.worldGeometrySupported = true; |
---|
1023 | } |
---|
1024 | //----------------------------------------------------------------------- |
---|
1025 | SceneManager* TerrainSceneManagerFactory::createInstance( |
---|
1026 | const String& instanceName) |
---|
1027 | { |
---|
1028 | TerrainSceneManager* tsm = new TerrainSceneManager(instanceName); |
---|
1029 | // Create & register default sources (one per manager) |
---|
1030 | HeightmapTerrainPageSource* ps = new HeightmapTerrainPageSource(); |
---|
1031 | mTerrainPageSources.push_back(ps); |
---|
1032 | tsm->registerPageSource("Heightmap", ps); |
---|
1033 | |
---|
1034 | return tsm; |
---|
1035 | |
---|
1036 | } |
---|
1037 | //----------------------------------------------------------------------- |
---|
1038 | void TerrainSceneManagerFactory::destroyInstance(SceneManager* instance) |
---|
1039 | { |
---|
1040 | delete instance; |
---|
1041 | } |
---|
1042 | |
---|
1043 | |
---|
1044 | } //namespace |
---|