Changing heightmap ingame, possible?

Changing heightmap ingame, possible?

Discuss maps & map creation - from concept to execution to the ever elusive release.

Moderator: Moderators

Post Reply
User avatar
The Yak
Posts: 351
Joined: 20 May 2012, 05:36

Changing heightmap ingame, possible?

Post by The Yak »

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

Re: Changing heightmap ingame, possible?

Post by Beherith »

Yes. Might be slow though.
User avatar
The Yak
Posts: 351
Joined: 20 May 2012, 05:36

Re: Changing heightmap ingame, possible?

Post by The Yak »

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

Re: Changing heightmap ingame, possible?

Post by Beherith »

Can be slow in performance, especially if you modify large blocks. Check out zwzsg's hexfarm and other maps.
BaNa
Posts: 1562
Joined: 09 Sep 2007, 21:05

Re: Changing heightmap ingame, possible?

Post by BaNa »

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)
User avatar
zwzsg
Kernel Panic Co-Developer
Posts: 7052
Joined: 16 Nov 2004, 13:08

Re: Changing heightmap ingame, possible?

Post by zwzsg »

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.
User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

Re: Changing heightmap ingame, possible?

Post by jK »

zwzsg wrote:I use Spring.SetHeightMapFunc, to which I pass a function that uses Spring.SetHeightMap. (With a step of 8).
With a step of Game.squareSize
User avatar
Pxtl
Posts: 6112
Joined: 23 Oct 2004, 01:43

Re: Changing heightmap ingame, possible?

Post by Pxtl »

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.
User avatar
PicassoCT
Journeywar Developer & Mapper
Posts: 10454
Joined: 24 Jan 2006, 21:12

Re: Changing heightmap ingame, possible?

Post by PicassoCT »

If you terraform all the map, spring takes a 30 sec brake on 16x16.. but yes, you can go all the way.
User avatar
zwzsg
Kernel Panic Co-Developer
Posts: 7052
Joined: 16 Nov 2004, 13:08

Re: Changing heightmap ingame, possible?

Post by zwzsg »

30 secs?!?? That's alot! Image

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:

Image

Image

Image
User avatar
PicassoCT
Journeywar Developer & Mapper
Posts: 10454
Joined: 24 Jan 2006, 21:12

Re: Changing heightmap ingame, possible?

Post by PicassoCT »

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

Re: Changing heightmap ingame, possible?

Post by gajop »

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..
i can't tell if it's trolling or not with you, but as jk said:
Game.squareSize
is what you should use
User avatar
zwzsg
Kernel Panic Co-Developer
Posts: 7052
Joined: 16 Nov 2004, 13:08

Re: Changing heightmap ingame, possible?

Post by zwzsg »

PicassoCT wrote:if i > endvaluez-8 then do it the old fashioned way..
No!
User avatar
PicassoCT
Journeywar Developer & Mapper
Posts: 10454
Joined: 24 Jan 2006, 21:12

Re: Changing heightmap ingame, possible?

Post by PicassoCT »

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..
User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

Re: Changing heightmap ingame, possible?

Post by jK »

PicassoCT wrote:but this only does every eight heightmapvalue
No! There is just every 8 worldcoords a heightmap value, the one between are just SMF texture values.
User avatar
zwzsg
Kernel Panic Co-Developer
Posts: 7052
Joined: 16 Nov 2004, 13:08

Re: Changing heightmap ingame, possible?

Post by zwzsg »

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..
No!


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?
User avatar
PicassoCT
Journeywar Developer & Mapper
Posts: 10454
Joined: 24 Jan 2006, 21:12

Re: Changing heightmap ingame, possible?

Post by PicassoCT »

I do..now.. no... noo.... i have to rework the whole thing.. :(
User avatar
zwzsg
Kernel Panic Co-Developer
Posts: 7052
Joined: 16 Nov 2004, 13:08

Re: Changing heightmap ingame, possible?

Post by zwzsg »

PicassoCT wrote:no... noo.... i have to rework the whole thing.. :(
Neither!
User avatar
PicassoCT
Journeywar Developer & Mapper
Posts: 10454
Joined: 24 Jan 2006, 21:12

Re: Changing heightmap ingame, possible?

Post by PicassoCT »

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
User avatar
KingRaptor
Zero-K Developer
Posts: 838
Joined: 14 Mar 2007, 03:44

Re: Changing heightmap ingame, possible?

Post by KingRaptor »

I approve of zwzsg's use of alot.
Post Reply

Return to “Map Creation”