Page 1 of 1

Patch to get terrain size from terrain scene node

Posted: Sat Feb 02, 2008 5:12 pm
by Oberstille
I noticed, while attempting to use the terrain scene node with ODE, that there isn't actually any way of telling how large the terrain is (as far as I can tell). I've only added one new member, since apparently the terrain scene node only supports square terrains, which I suppose is an artifact of the LOD system.

You can add getTerrainSize() to the terrain scene nodes with the following additions:

In CTerrainSceneNode.h:

Code: Select all

		//! Returns the number of points in the heightmap (in the X/width and Z/depth directions).
		virtual s32 getTerrainSize( ) const;
In CTerrainSceneNode.cpp:

Code: Select all

	s32 CTerrainSceneNode::getTerrainSize( ) const
	{
		return TerrainData.Size;
	}
In ITerrainSceneNode.h:

Code: Select all

		//! Returns the number of points in the heightmap (in the X/width and Z/depth directions).
		/** PATCH - NOT PART OF IRRLICHT 1.4 RELEASE.
		Returns the length of one side of the square terrain.
		*/
		virtual s32 getTerrainSize( ) const = 0;
Rebuild & enjoy.

Posted: Sat Feb 02, 2008 6:47 pm
by vitek
If you are trying to get the physical dimension of the terrain that is rendered, you can use getBoundingBox() to get a bounding box that encloses the terrain. You can then get the extents of that box to find the size of the terrain in the X and Z directions.

If you use the method that you show here, you need to calculate the dimension given a few different scale factors.

Travis

Posted: Sat Feb 02, 2008 11:49 pm
by Oberstille
I was trying to get the number of vertices in each direction. I think that this is what this returns. Am I incorrect?

Posted: Sun Feb 03, 2008 3:36 am
by vitek
Yes, that is what your code does. I don't see why that would ever be necessary, but that is what you are getting.

Travis