# [solved]New Terrain Paged Geometry Question

mamairaja

27-01-2011 05:42:33

Hello

Actually this is not exactly a paged geometry problem.
Just tried out paged geometry with ogre new terrain, For me hightfunction(took from example) seems to be a problem.
same code worked fine with ogre1.6

Problem : I could see that trees are placed at y=0 position.

So did I missed any? Here is my code(took from example)

```PagedGeometry* trees = new PagedGeometry(); trees->setCamera(mCamera ); trees->setPageSize(50); trees->setInfinite(); trees->addDetailLevel<BatchPage>(150, 30); trees->addDetailLevel<ImpostorPage>(600, 50); TreeLoader2D *treeLoader = new TreeLoader2D(trees, TBounds(100, 100, 1400, 1400)); trees->setPageLoader(treeLoader); HeightFunction::initialize(mSceneMgr); treeLoader->setHeightFunction(&HeightFunction::getTerrainHeight); Ogre::Radian yaw; Ogre::Vector3 position = Ogre::Vector3::ZERO; for (int i = 0; i < 2500; i++) { yaw = Degree(Ogre::Math::RangeRandom(0, 360)); scale = Ogre::Math::RangeRandom(0.07f, 0.4f); position.x = Ogre::Math::RangeRandom(0, 1500); position.z = Ogre::Math::RangeRandom(0, 1500); treeLoader->addTree(treeEntitiy, position, yaw, 1); }```

Thanks

Fish

27-01-2011 17:58:21

You need to provide PagedGeometry with a height function that works with the new terrain system introduced with Ogre 1.7. The height function provided in the samples is designed to work with the TerrainSceneManager.

Your next question will probably be, "How do I get the heights from the new terrain?" I believe there is a function called Ogre::Terrain::getHeightAtTerrainPosition()

- Fish

mamairaja

27-01-2011 18:48:15

Thanks fish

This worked me fine
```float getTerrainHeight(const float x, const float z, void *userData) { //updateRay.setOrigin(Vector3(x, 0.0f, z)); //updateRay.setDirection(Vector3::UNIT_Y); //raySceneQuery->setRay(updateRay); //raySceneQuery->execute(raySceneQueryListener); //return raySceneQueryListener->resultDistance; return terrain->getHeightAtWorldPosition(x, 0, z); }```