Spring.LevelHeightMap confuses me

Spring.LevelHeightMap confuses me

Discuss Lua based Spring scripts (LuaUI widgets, mission scripts, gaia scripts, mod-rules scripts, scripted keybindings, etc...)

Moderator: Moderators

Post Reply
yanom
Posts: 323
Joined: 10 Jul 2009, 23:34

Spring.LevelHeightMap confuses me

Post 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)

?
gajop
Moderator
Posts: 3051
Joined: 05 Aug 2009, 20:42

Re: Spring.LevelHeightMap confuses me

Post 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..
User avatar
Beherith
Posts: 5145
Joined: 26 Oct 2007, 16:21

Re: Spring.LevelHeightMap confuses me

Post 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.
Google_Frog
Moderator
Posts: 2464
Joined: 12 Oct 2007, 09:24

Re: Spring.LevelHeightMap confuses me

Post 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.
yanom
Posts: 323
Joined: 10 Jul 2009, 23:34

Re: Spring.LevelHeightMap confuses me

Post 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?
gajop
Moderator
Posts: 3051
Joined: 05 Aug 2009, 20:42

Re: Spring.LevelHeightMap confuses me

Post by gajop »

by setting the height map: something like this except you'll want to do it linearly instead as a gradient
Post Reply

Return to “Lua Scripts”