Page 1 of 1

Spring.LevelHeightMap confuses me

Posted: 22 Jan 2013, 16:58
by yanom
So I'm trying to write some custom terraform lua that will set the height map whenever a certain "terra pylon" building gets built.

the documentation says

Code: Select all

Spring.LevelHeightMap
 ( number x1, number z1 [, number x2, number z2], number height )
but what exactly are the x1,z1 and x2,z2 parameters referencing?
Does it terraform the area between the rectangle defined by these points:
[x1,z1] [x2,z1]
[x1,z2] [x2,z2]
or the rectangle defined by these points?
[x1,z1] [x1+x2,z1]
[x1,z1+z2] [x1+x2,z1+z2]


That is, are the four parameters defining 2 points on a rectangle or are they in the form (cornerX,cornerY,rectangleWidth,rectangleLength)

?

Re: Spring.LevelHeightMap confuses me

Posted: 22 Jan 2013, 17:20
by gajop
1) probably absolute coordinates
2) would've been xSize/zSize, sizeX/sizeZ, or rectX/rectZ or something if they were to denote rectangle size
3) try it out..

Re: Spring.LevelHeightMap confuses me

Posted: 22 Jan 2013, 19:45
by Beherith
It terraforms
[x1,z1] [x2,z1]
[x1,z2] [x2,z2]

If only 3 params given, (x,z,height) then it wil terraform a single heightmap pixel.
Remember that the x and z params given here are worldpos/8 in scale.

Re: Spring.LevelHeightMap confuses me

Posted: 23 Jan 2013, 04:36
by Google_Frog
I would suggest something like this:
http://code.google.com/p/zero-k/source/ ... m.lua#3213 to line 3277

Unless you want a rectangle there is not much point using your function because the heightmap is really a set of points. Apparently Spring.SetHeightMapFunction is faster than multiple rectangles.

Re: Spring.LevelHeightMap confuses me

Posted: 24 Jan 2013, 17:05
by yanom
ok, got it. I can now make big flat plateus with this code:

Code: Select all

Spring.LevelHeightMap(unitx-1000,unitz-1000,unitx+1000,unitz+1000,unity)
this makes nice flat areas, but once you get to the edge of that, there is a sheer clif dropoff to the original terrain height. What code can I apply along the edges of the clif to make it a vehicle-passable smooth slooe?

Re: Spring.LevelHeightMap confuses me

Posted: 24 Jan 2013, 17:11
by gajop
by setting the height map: something like this except you'll want to do it linearly instead as a gradient