Changing heightmap ingame, possible?
Moderator: Moderators
Changing heightmap ingame, possible?
Been brainstorming some ideas for a new map, is it possible to use LUA to script terrain height changing ingame, like with terraform but defined with an entire heightmap?
Re: Changing heightmap ingame, possible?
Yes. Might be slow though.
Re: Changing heightmap ingame, possible?
Slow as in slow on performance or slow to modify the terrain? Because I'm totally okay with the latter, are there any maps that have done this in the past?
Re: Changing heightmap ingame, possible?
Can be slow in performance, especially if you modify large blocks. Check out zwzsg's hexfarm and other maps.
Re: Changing heightmap ingame, possible?
look at zk's terraforming for clues (or zwzgs hexfarm map)
it would be slow ingame to make a realistic change because gradual changes would need recalculated pathing very often, so you are more or less stuck with small area of effect or very sudden changes (small aoe -> zk terraforming, sudden change -> hexfarm)
it would be slow ingame to make a realistic change because gradual changes would need recalculated pathing very often, so you are more or less stuck with small area of effect or very sudden changes (small aoe -> zk terraforming, sudden change -> hexfarm)
Re: Changing heightmap ingame, possible?
On HexFarm I change the complete heightmap of the whole map at the beginning of the game. Then, during the course of the game, I change smaller area whenever a bridge or pillar gets destroyed. If you pick chose position before game start and have exploration set to a strictly positive number, after starts pos are picked and just as game start, it will make nearly all bridge and pillar update. Then you feel a little lag. However, it's not clear which part of the lag comes from the terraforming, which part comes from Lua OpenGL (I'm only caching into drawlists what's immobile), and which part comes from my unoptimised calculations.
The code of gadget of HexFarm may be a bit too complicated if you just want to see how to change heighmap, so instead simply look there: http://springrts.com/wiki/Lua_SyncedCtrl#Heightmap
I use Spring.SetHeightMapFunc, to which I pass a function that uses Spring.SetHeightMap. (With a step of 8).
If you make noticeable change to heightmap, don't forget to also use Spring.SetSmoothMesh (with a step of 16), or else planes might fly below ground.
There is also Spring.SetMapSquareTerrainType (with a step of 16) and Spring.SetMetalAmount (with coordinates divided by 16), to change more than just the height.
Only Spring.SetHeightMap use the Spring.SetHeightMapFunc thing, if it confuse you to pass a function to a function, you can just use the slower Spring.LevelHeightMap.
The code of gadget of HexFarm may be a bit too complicated if you just want to see how to change heighmap, so instead simply look there: http://springrts.com/wiki/Lua_SyncedCtrl#Heightmap
I use Spring.SetHeightMapFunc, to which I pass a function that uses Spring.SetHeightMap. (With a step of 8).
If you make noticeable change to heightmap, don't forget to also use Spring.SetSmoothMesh (with a step of 16), or else planes might fly below ground.
There is also Spring.SetMapSquareTerrainType (with a step of 16) and Spring.SetMetalAmount (with coordinates divided by 16), to change more than just the height.
Only Spring.SetHeightMap use the Spring.SetHeightMapFunc thing, if it confuse you to pass a function to a function, you can just use the slower Spring.LevelHeightMap.
Re: Changing heightmap ingame, possible?
With a step of Game.squareSizezwzsg wrote:I use Spring.SetHeightMapFunc, to which I pass a function that uses Spring.SetHeightMap. (With a step of.
Re: Changing heightmap ingame, possible?
I've seen complaints on ZK forums that units aren't aware of the terraformed ramps, and I've run into problems myself in ZK with all-terrain units being confused by overridden typemaps.
In general, the pathfinder responds poorly to these things and is getting completely revamped with QTFPS.
In general, the pathfinder responds poorly to these things and is getting completely revamped with QTFPS.
Re: Changing heightmap ingame, possible?
If you terraform all the map, spring takes a 30 sec brake on 16x16.. but yes, you can go all the way.
Re: Changing heightmap ingame, possible?
30 secs?!?? That's alot! 
But fear not, for I can help you reduce those lenghty thirty seconds into a mere half a second!!
I condensed the ancestral Spring knownledge formerly required for such incredible feat into a very easy trick, so that you too can now enjoy the benefit of a x64 speed boost from the luxury of your own home!
Just follow those simple steps:




But fear not, for I can help you reduce those lenghty thirty seconds into a mere half a second!!
I condensed the ancestral Spring knownledge formerly required for such incredible feat into a very easy trick, so that you too can now enjoy the benefit of a x64 speed boost from the luxury of your own home!
Just follow those simple steps:



Re: Changing heightmap ingame, possible?
oh, this is in steps of 8.. but then.. i must presume a lot of special cases :)
if i > endvaluez-8 then do it the old fashioned way..
if i > endvaluez-8 then do it the old fashioned way..
Re: Changing heightmap ingame, possible?
i can't tell if it's trolling or not with you, but as jk said:PicassoCT wrote:oh, this is in steps of 8.. but then.. i must presume a lot of special cases :)
if i > endvaluez-8 then do it the old fashioned way..
is what you should useGame.squareSize
Re: Changing heightmap ingame, possible?
No!PicassoCT wrote:if i > endvaluez-8 then do it the old fashioned way..
Re: Changing heightmap ingame, possible?
but this only does every eight heightmapvalue, basically jumping over the whole process..
i need another loop on the inside to handle those missed seven iterrations..
i need another loop on the inside to handle those missed seven iterrations..
Re: Changing heightmap ingame, possible?
No! There is just every 8 worldcoords a heightmap value, the one between are just SMF texture values.PicassoCT wrote:but this only does every eight heightmapvalue
Re: Changing heightmap ingame, possible?
No!PicassoCT wrote:but this only does every eight heightmapvalue
No!PicassoCT wrote:basically jumping over the whole process..
No!PicassoCT wrote:i need another loop on the inside to handle those missed seven iterrations..
There are only heightmap values every 8x8.
There are no values inbetween.
The heightmap has a lower resolution than the texture.
Don't you remember from when you made maps?
Re: Changing heightmap ingame, possible?
I do..now.. no... noo.... i have to rework the whole thing.. 

Re: Changing heightmap ingame, possible?
Neither!PicassoCT wrote:no... noo.... i have to rework the whole thing..
Re: Changing heightmap ingame, possible?
i have a terrain map that is GameMapSize.. and i computate the 3 heightmap with that..
still the gain by using only 1/8 is very perciveable :D

- KingRaptor
- Zero-K Developer
- Posts: 838
- Joined: 14 Mar 2007, 03:44
Re: Changing heightmap ingame, possible?
I approve of zwzsg's use of alot.