How does wesnoth tiling system work?

Discussion of all aspects of the game engine, including development of new and existing features.

Moderator: Forum Moderators

Post Reply
dagnelies
Posts: 9
Joined: June 2nd, 2018, 7:47 am

How does wesnoth tiling system work?

Post by dagnelies »

As an experiment, I attempted to display wesnoth maps in the browser. As I was doing this, I was surprised by the involved complexity. This WML graphics with all its macros look crazy! ;P

What I don't understand though is why some tile transitions are "border based", like most terrain. While others are "corner based" like castle. ...I mean, is it even possible that a castle has two different towers on the same side?! Same goes for chasms apparently.
Is there a reason these are handled differently that I'm missing? ...or is it just some kind of historical artifact/accident?

Also, some things are a bit muddy to me, for example the water. When I look in the images folder, there are three types of water: gray, default and tropical. However, only the "tropical" one has wave animations and border transitions in the image folder. What about the two others? Are the different waters the result of applying some program-side coloring over the same images? Also, when I draw water next to grass in the editor, I see different kind of borders ...but where do these images come from? They are not in the same directory.
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Re: How does wesnoth tiling system work?

Post by zookeeper »

dagnelies wrote: June 2nd, 2018, 8:01 am As an experiment, I attempted to display wesnoth maps in the browser. As I was doing this, I was surprised by the involved complexity. This WML graphics with all its macros look crazy! ;P
Yes, it's pretty unfeasible to try to implement a browser-based renderer that could draw terrains exactly the same way, without actually re-implementing the whole terrain builder engine and WML parser/preprocessor.
dagnelies wrote: June 2nd, 2018, 8:01 amWhat I don't understand though is why some tile transitions are "border based", like most terrain. While others are "corner based" like castle. ...I mean, is it even possible that a castle has two different towers on the same side?! Same goes for chasms apparently.
Is there a reason these are handled differently that I'm missing? ...or is it just some kind of historical artifact/accident?
It's difficult to give a short explanation, but it's basically because something like castle or chasm simply cannot be drawn using the transition style that terrains like grass/snow/hills/etc use. Castle walls get drawn both on the castle hex as well as the adjacent non-castle hex, whereas grass transitions get drawn only on the adjacent non-grass hex; this means grass transitions can be drawn in a much simpler way using images, whereas castle walls need corner-based images to allow convex and concave corners to connect seamlessly.
dagnelies wrote: June 2nd, 2018, 8:01 amAlso, some things are a bit muddy to me, for example the water. When I look in the images folder, there are three types of water: gray, default and tropical. However, only the "tropical" one has wave animations and border transitions in the image folder. What about the two others? Are the different waters the result of applying some program-side coloring over the same images? Also, when I draw water next to grass in the editor, I see different kind of borders ...but where do these images come from? They are not in the same directory.
The relevant images for the current (1.14) water are ocean01-21.png for deep water, water01-17.png for shallow water and waves*.png for the beach waves. And yes, the tropical and gray coloring is then applied by overlaying the overlay-gray.png and overlay-tropical.png images on top of gray/tropical water.
dagnelies
Posts: 9
Joined: June 2nd, 2018, 7:47 am

Re: How does wesnoth tiling system work?

Post by dagnelies »

Thanks for the prompt responses! This tiling system is indeed a challenge!
Post Reply