Page 1 of 1
Scaling my terrain
Posted: Sat Apr 06, 2013 4:52 am
by Crushinator
I have a terrain generated from a 1024x1024 heightmap. I have a parameter in engine that scales the position of each vertex by a user-defined amount, so that the world can be larger without requiring larger heightmap images and more memory. I need to be able to take a 1024x1024 heightfield array and create a scaled terrain in BEPU, like one that would be 4096x4096 in size. Can this be done?
Re: Scaling my terrain
Posted: Sat Apr 06, 2013 5:12 pm
by Norbo
Yup. The Terrain has a world transform associated with it. The transform can accept any affine transform including scaling.
For example, here's a snippet from the TerrainDemo:
Code: Select all
var terrain = new Terrain(heights, new AffineTransform(
new Vector3(xSpacing, 1, zSpacing),
Quaternion.Identity,
new Vector3(-xLength * xSpacing / 2, 0, -zLength * zSpacing / 2)));
That AffineTransform constructor takes a scaling, orientation, and translation.
Re: Scaling my terrain
Posted: Sun Apr 07, 2013 2:52 pm
by Crushinator
Thanks, that worked perfectly.