Terrain type related problems in RTS game

Started by
1 comment, last by Shockwave 10 years, 1 month ago

Hi,

I've started a small RTS project and had encountered some interesting problems for which I can't find solutions in the Internet and thus I've made my own algos for solving 'em but I'm not sure that I'm not inventing a wheel (and even that it's not a square wheel smile.png ).

Lets say we have a terrain built from a heightmap and with textures applied to it using splatting. There are 4 textures: sand, stone (red), grass, snow.

1. I want to allow construction of buildings only on terrain covered by stone. One of the approaches I can think of is to have a quadtree structure where sectors have boolean value saying if sector is constructible or not. The smallest size of quadtree's region is a size of smallest building's aabb. This boolean value in quadtree tree node is set according to color of region of pixels in splatting texture (if all pixels are red, mark this node as one in which building construction is allowed).

2. I have a vehicle and I want to change its speed according to terrain type (for example, on sand vehicle's speed should be reduced by 0.4, etc.). So I need to know on what terrain type vehicle is on. I thought of checking splatting map's pixel color in the current position of vehicle but I'm not sure this is a correct approach.

So guys I need your opinion, if described solutions are good or I'm inventing square wheel. Any help will be much appreciated.

Thanks in advance

Advertisement
You can store the data inside your heightmap, use R and G channels for the height level, B for the construction data and the alpha channel for the speed factor.
Using this approach you will only need a short lookup function. Just remember to store the texture info inside the heightmap when you "paint" your terrain.

- Flick

Ok I think I've found solution to all my problems described in the first post. I should generate another grid not for geometry but for logic and store any info I want there (in tiles). I've read about this solution here: http://www.richardssoftware.net/2013/12/pathfinding-1-map-representation-and.html and I think it completely satisfies my needs.

You can store the data inside your heightmap, use R and G channels for the height level, B for the construction data and the alpha channel for the speed factor.
Using this approach you will only need a short lookup function. Just remember to store the texture info inside the heightmap when you "paint" your terrain.

Thank you for your answer but I think I'll stick to having additional grid for storing all required data. As far as I understand this is a common way to handle things in RTS games.

This topic is closed to new replies.

Advertisement