Scaling my terrain

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
Crushinator
Posts: 11
Joined: Sun Mar 24, 2013 10:27 pm

Scaling my terrain

Post 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?
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Scaling my terrain

Post 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.
Crushinator
Posts: 11
Joined: Sun Mar 24, 2013 10:27 pm

Re: Scaling my terrain

Post by Crushinator »

Thanks, that worked perfectly.
Post Reply