Jules Robichaud Gagnon
02-07-2008 19:48:38
Trees will not appear anymore when setBounds is used instead of "isInfinite()"
I recreated the problem in Example2 with the current SVN version.
With 0 to 1500 it works but -1500 to 1500 the trees have odd positions.
I added MAX_BOUND and MIN_BOUND to be able to change the bounds easily.
I recreated the problem in Example2 with the current SVN version.
With 0 to 1500 it works but -1500 to 1500 the trees have odd positions.
I added MAX_BOUND and MIN_BOUND to be able to change the bounds easily.
Index: examples/source/Example2.cpp
===================================================================
--- examples/source/Example2.cpp (revision 2459)
+++ examples/source/Example2.cpp (working copy)
@@ -180,6 +180,8 @@
unload();
}
+#define MAX_BOUND 1500
+#define MIN_BOUND -1500
//[NOTE] In addition to some Ogre setup, this function configures PagedGeometry in the scene.
void World::load()
@@ -192,19 +194,25 @@
sceneMgr->setWorldGeometry("terrain.cfg");
//Start off with the camera at the center of the terrain
- camera->setPosition(700, 100, 700);
+ camera->setPosition(0, 100, 0);
//-------------------------------------- LOAD TREES --------------------------------------
//Create and configure a new PagedGeometry instance
trees = new PagedGeometry();
trees->setCamera(camera); //Set the camera so PagedGeometry knows how to calculate LODs
trees->setPageSize(80); //Set the size of each page of geometry
- trees->setInfinite(); //Use infinite paging mode
+//trees->setInfinite(); //Use infinite paging mode
+ Ogre::TRect<Ogre::Real> bound;
+ bound.bottom = MAX_BOUND;
+ bound.top = MIN_BOUND;
+ bound.right = MAX_BOUND;
+ bound.left = MIN_BOUND;
+ trees->setBounds( bound );
trees->addDetailLevel<BatchPage>(150, 50); //Use batches up to 150 units away, and fade for 30 more units
trees->addDetailLevel<ImpostorPage>(500, 50); //Use impostors up to 400 units, and for for 50 more units
//Create a new TreeLoader2D object
- TreeLoader2D *treeLoader = new TreeLoader2D(trees, TBounds(0, 0, 1500, 1500));
+ TreeLoader2D *treeLoader = new TreeLoader2D(trees, bound);
trees->setPageLoader(treeLoader); //Assign the "treeLoader" to be used to load geometry for the PagedGeometry instance
//Supply a height function to TreeLoader2D so it can calculate tree Y values
@@ -221,8 +229,8 @@
for (int i = 0; i < 20000; i++){
yaw = Degree(Math::RangeRandom(0, 360));
- position.x = Math::RangeRandom(0, 1500);
- position.z = Math::RangeRandom(0, 1500);
+ position.x = Math::RangeRandom(MIN_BOUND, MAX_BOUND);
+ position.z = Math::RangeRandom(MIN_BOUND, MAX_BOUND);
scale = Math::RangeRandom(0.5f, 0.6f);