LUS are Lua Unit Scripts, they basically gave me easier access to Spring.LevelHeightMap() functions when units where created.
This is the LUS that controls the heightmap under the circular platforms in the corner, the metal patch in the center aswell as the beam weapon that was used.
As the terrain is actually a unit rendered under an invisible ground, that allows me to give it animations. I could even take it further and make it destroyable, and apply another height change in Script.Killed() aswell as an animation in order to make the ground destroyable-like.
Code: Select all
local base, center, zaxis = piece("base", "center", "zaxis")
cx, cy, cz = Spring.GetUnitPiecePosDir(unitID, 2)
zx, zy, zz = Spring.GetUnitPiecePosDir(unitID, 3)
x, y, z = zx - cx, 0, zz - cz
radius = 768 -- Should be = math.sqrt(x^2 + z^2) for compatibility with similar circular platforms of different sizes.
Spring.SetUnitBlocking(unitID, false, false, false, false, false, false, false)
Spring.MoveCtrl.SetPosition(unitID, cx, 780,cz)
for px = -radius/16, radius/16 do
for pz = -radius/16, radius/16 do
if math.sqrt(px^2 + pz^2) <= 768/16 then
Spring.LevelHeightMap(cx + px*16, cz + pz*16, cx + px*16 + 15, cz + pz*16 + 15, 782)
for i = -1,2 do
for j = -1,2 do
Spring.SetMetalAmount((cx/16)+i, (cz/16)+j, 255 * 0.076 * 20)
Move(center, 2, 3)
Move(zaxis, 2, -768)
Move(zaxis, 3, -768)
Spring.SetUnitTarget(unitID, cx,cy+5000,cz, false, false, 1)
if num == 1 then
if num == 1 then
Basically, i tried to use maths as much as possible to generate a height map that would bring the highest fidelity to the models used.
I've set up pieces in the model corresponding to key points (ie, a rectangle's corners, or a circle's radius) in order to have minimal input needed and have compatibility with different models. I still have to work out the different shapes that can be interesting.
Once this is done, I'll be able to fully generate the hightmap ingame rather than have to generate it before hand and adapt models to it.
In the end, it takes a huge amount of time to load, so the next step, after setting up the height map ingame, would be to extract the heightmap after gamestart (i understand some widgets can do it) and recompile the map using this extracted heightmap (hoping there isn't too much quality loss in the process). Doing that will then significantly reduce load times as the only things that will remain will be the model animations themselves.
This is still very BETA, i try to go as far as I can with experiments and get a hang of it. :)