[terrain-graphics] Towers & Cliffs

The place to post your WML questions and answers.

Moderators: Forum Moderators, Developers

Forum rules
  • Please use [code] BBCode tags in your posts for embedding WML snippets.
  • To keep your code readable so that others can easily help you, make sure to indent it following our conventions.
User avatar
doofus-01
Art Director
Posts: 3907
Joined: January 6th, 2008, 9:27 pm
Location: USA

[terrain-graphics] Towers & Cliffs

Post by doofus-01 »

I'm trying to make a "tower" or "wall" type terrain, that can have towers of arbitrary size, but I can't get it to go more than two hexes up. In the image below, the diagonal brick hexes should not be visible. I'd be shocked if I got all the transitions worked out correctly, but that "Btym" strip along the right side should be straightforward. Unfortunately, only the bottom two hexes get the wall graphics.

My thinking was to set a flag for the bottom hex (call it "hex1"), then when drawing the hex above it ("hex2"), check the flag for hex1, so that you know which diagonal walls to draw, then set the same flag for hex2. Then when you draw the hex north of hex2 ("hex3"), check for the flag of hex2 - should be the same as hex1 - and set it for hex3, rinse, repeat. The flag set at the bottom (or south-most) hex of the tower should be repeated up the tower (or to the north-adjacent hexes). But hex3 and up don't get the graphics that I think they should, and I don't really know how to test where the failure is.

The reason I think this is necessary, is that if you have a big mass of this terrain "Btym", what gets drawn should depend upon the shape of the bottom edge. So it is not like mountain graphics.

I hope that makes sense. I've attached my WML.

EDIT:Removed attachments, better ones are in next post.
EDIT2: Changed the title
Last edited by doofus-01 on December 19th, 2011, 3:56 am, edited 2 times in total.
BfW 1.12 supported, but active development only for BfW 1.13/1.14: Bad Moon Rising | Trinity | Archaic Era |
| Abandoned: Tales of the Setting Sun
GitHub link for these projects

User avatar
doofus-01
Art Director
Posts: 3907
Joined: January 6th, 2008, 9:27 pm
Location: USA

Re: terrain-graphics and flags

Post by doofus-01 »

I've cleaned it up a bit, and can get a three-hex-tall tower, using bottom+middle+top sections. But larger towers still don't work.
Part of the problem may be that I did not account for all layouts, but some of the ones that I'm pretty sure I did account for are not working. For example, what is wrong with the sections starting on lines 14 and 185, the case of a lone tower getting stuck at two stories (not counting the top)?
Spoiler:
Attachments
terrain_tower_graphics.cfg
(8.68 KiB) Downloaded 84 times
towershot1.png
BfW 1.12 supported, but active development only for BfW 1.13/1.14: Bad Moon Rising | Trinity | Archaic Era |
| Abandoned: Tales of the Setting Sun
GitHub link for these projects

User avatar
doofus-01
Art Director
Posts: 3907
Joined: January 6th, 2008, 9:27 pm
Location: USA

Re: terrain-graphics and flags

Post by doofus-01 »

I've left everyone awestruck and speechless.

Or it was just too difficult to bother looking at. I've uploaded a new version of Archaic_Era (1.3.13) that has this in it, which should make it easier to see what I am talking about. The towers are available in the map editor (called Marble Pallisade).
BfW 1.12 supported, but active development only for BfW 1.13/1.14: Bad Moon Rising | Trinity | Archaic Era |
| Abandoned: Tales of the Setting Sun
GitHub link for these projects

User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Re: terrain-graphics and flags

Post by zookeeper »

I did take a look at it earlier but couldn't see anything wrong with the WML, so I didn't say anything. In cases like this I can't really suggest anything but taking a very systematical approach to it; start with something very simple like just setting the flags on the bottom hexes, and work your way up from there step by step, trying to keep each step as simple and straightforward as possible.

User avatar
doofus-01
Art Director
Posts: 3907
Joined: January 6th, 2008, 9:27 pm
Location: USA

Re: terrain-graphics and flags

Post by doofus-01 »

Thanks, zookeeper. I'd tried some things, like using 72px images, but didn't do every simplifying thing I could. Now I copied and past (pasted several times) the terrain graphics tag:
Spoiler:
And I can make a "forward" or lone tower that is as tall as the number of times that tag was pasted. Not something I expected, makes me think I really don't understand terrain-graphics WML on a basic level. Also makes me think that what I'm trying to do will never work very well.
BfW 1.12 supported, but active development only for BfW 1.13/1.14: Bad Moon Rising | Trinity | Archaic Era |
| Abandoned: Tales of the Setting Sun
GitHub link for these projects

User avatar
Alarantalara
Art Contributor
Posts: 784
Joined: April 23rd, 2010, 8:17 pm
Location: Canada

Re: terrain-graphics and flags

Post by Alarantalara »

The problem is that every terrain rule is evaluated at most once for each tile on the map. There is no control over the order and it is not bottom up (nor is it like reading a page, which I discovered to my annoyance once).
So you have to have one rule for each layer since each one can advance it only a predetermined amount.

But...
you don't have to make each one increase the spacing by the same amount

You could make a rule that extends it 4, one for 3, one for 2, and one for 1 in that order, and that would let you get up to 10 levels high with only 4 rules.
Even better, use powers of 2 (8, 4, 2, 1) and you get to 15 with 4 rules and 127 (which is bigger than most maps) with 7 rules, though a rule to handle a 64 space high tower would be pretty crazy to write.

I'd suggest that if you do do this, that you set flags and place images separately to keep the rules small (unless you want 64 image tags with slightly different offsets).
That would make 7 rules for left edge, 7 rules for right, 1 for the top, and three to place the images to generate any tower height up to 127.


I should probably have answered you earlier, but I hadn't checked the terrain code recently and wanted to make sure that my description of behaviour was correct.

Edit:
It's certainly possible to change the engine so your original code will work for any height, but since it would involve some kind of "repeat until no change" effect, it would have to go in as a new key to avoid doubling the time it takes to create the map for all the terrains that don't need such an effect.

User avatar
doofus-01
Art Director
Posts: 3907
Joined: January 6th, 2008, 9:27 pm
Location: USA

Re: terrain-graphics and flags

Post by doofus-01 »

Thanks for the explanation, Alarantalara. I'm not sure I understand all of it, none of this is intuitive to me...
Alarantalara wrote:The problem is that every terrain rule is evaluated at most once for each tile on the map. There is no control over the order and it is not bottom up (nor is it like reading a page, which I discovered to my annoyance once).
So you have to have one rule for each layer since each one can advance it only a predetermined amount.
(bold mine) How is this?
- Each rule is only good for a single tile on the map-file map? That can't be what you mean.
- Each rule is only good for a single tile on the little rule map? But it works once per [terrain_graphics] tag (<-that's a rule, right?) so there is some influence of having little rule maps overlap on the map-file maps? So that the "rule has been evaluated" process can propagate, but the rules themselves can't?
Alarantalara wrote:You could make a rule that extends it 4, one for 3, one for 2, and one for 1 in that order, and that would let you get up to 10 levels high with only 4 rules.
That makes sense. That's probably good for lone towers, I can't imagine anyone really wanting more than 10 hexes.
Alarantalara wrote:I'd suggest that if you do do this, that you set flags and place images separately to keep the rules small (unless you want 64 image tags with slightly different offsets).
That would make 7 rules for left edge, 7 rules for right, 1 for the top, and three to place the images to generate any tower height up to 127.
This, unfortunately, I don't quite follow. Is there anything you'd suggest I look at that illustrates this?

Just to let you know where I'm going with this, I'm trying to see if it is possible to have "cliffs" that give an illusion of depth to maps. These are stone walls, but if I can understand the WML, I think it can be extended to natural cliffs and shadows could hopefully be handled too. There would be more transitions than just left-flank/right-flank, but we have to start somewhere.
BfW 1.12 supported, but active development only for BfW 1.13/1.14: Bad Moon Rising | Trinity | Archaic Era |
| Abandoned: Tales of the Setting Sun
GitHub link for these projects

User avatar
Alarantalara
Art Contributor
Posts: 784
Joined: April 23rd, 2010, 8:17 pm
Location: Canada

Re: terrain-graphics and flags

Post by Alarantalara »

doofus-01 wrote:Thanks for the explanation, Alarantalara. I'm not sure I understand all of it, none of this is intuitive to me...
Alarantalara wrote:The problem is that every terrain rule is evaluated at most once for each tile on the map. There is no control over the order and it is not bottom up (nor is it like reading a page, which I discovered to my annoyance once).
So you have to have one rule for each layer since each one can advance it only a predetermined amount.
(bold mine) How is this?
- Each rule is only good for a single tile on the map-file map? That can't be what you mean.
- Each rule is only good for a single tile on the little rule map? But it works once per [terrain_graphics] tag (<-that's a rule, right?) so there is some influence of having little rule maps overlap on the map-file maps? So that the "rule has been evaluated" process can propagate, but the rules themselves can't?
You can think of it like this:
For each terrain_graphics tag, put them into a big list of rules in the order they appear.
Then go through the list in order and try each rule on every map hex that it is likely to match in a random order.

This covers the once part. To make things faster, there is some extra logic that skips some hexes, so some hexes are not checked at all, which is why it is at most once.
doofus-01 wrote:
Alarantalara wrote:I'd suggest that if you do do this, that you set flags and place images separately to keep the rules small (unless you want 64 image tags with slightly different offsets).
That would make 7 rules for left edge, 7 rules for right, 1 for the top, and three to place the images to generate any tower height up to 127.
This, unfortunately, I don't quite follow. Is there anything you'd suggest I look at that illustrates this?
The track layout code does something similar. It first finds all the connections and sets flags to say which ones, then goes back and places images according to the flags. This lets you have a simple rule for image placement instead of copying the image tag over and over with different offsets (since it appears to be too big to fit in a single hex). Also, once it's only flags, it's possible to do some backtracking and choose images that cover some of the more unusual arrangements.

I mention the top since you seem to have a separate image for that now, the rules for left and right are because a left and a right is the same as both of them, so you can skip the ones that find both at once.

I don't have time at the moment, but I'll try to put together an example for you later.

User avatar
Alarantalara
Art Contributor
Posts: 784
Joined: April 23rd, 2010, 8:17 pm
Location: Canada

Re: terrain-graphics and flags

Post by Alarantalara »

Here is working code for towers up to 8 16 steps tall. To get to 16 32 requires only two additional rules in the propagation section. There is no limit to the height of a tower that has no adjacent tower pieces.

There are a few issues with image drawing (everything is on the same layer), but that wasn't the point of this demonstration.

Code: Select all

# set base flags
[terrain_graphics]
    map="
1
, 2"
    [tile]
        pos=1
        type=Btym
        set_no_flag=tower_right
    [/tile]
    [tile]
        pos=2
        type=!,Btym
    [/tile]
[/terrain_graphics]

[terrain_graphics]
    map="
, 1
2"
    [tile]
        pos=1
        type=Btym
        set_no_flag=tower_left
    [/tile]
    [tile]
        pos=2
        type=!,Btym
    [/tile]
[/terrain_graphics]

# propogate flags
[terrain_graphics]
    map="
1
, .
1
, .
1
, .
1
, .
1
, .
1
, .
1
, .
1
, .
2
"
    [tile]
        pos=1
        type=Btym
        set_no_flag=tower_left
    [/tile]
    [tile]
        pos=2
        has_flag=tower_left
    [/tile]
[/terrain_graphics]

[terrain_graphics]
    map="
1
, .
1
, .
1
, .
1
, .
1
, .
1
, .
1
, .
1
, .
2
"
    [tile]
        pos=1
        type=Btym
        set_no_flag=tower_right
    [/tile]
    [tile]
        pos=2
        has_flag=tower_right
    [/tile]
[/terrain_graphics]

[terrain_graphics]
    map="
1
, .
1
, .
1
, .
1
, .
2
"
    [tile]
        pos=1
        type=Btym
        set_no_flag=tower_left
    [/tile]
    [tile]
        pos=2
        has_flag=tower_left
    [/tile]
[/terrain_graphics]

[terrain_graphics]
    map="
1
, .
1
, .
1
, .
1
, .
2
"
    [tile]
        pos=1
        type=Btym
        set_no_flag=tower_right
    [/tile]
    [tile]
        pos=2
        has_flag=tower_right
    [/tile]
[/terrain_graphics]

[terrain_graphics]
    map="
1
, .
1
, .
2
"
    [tile]
        pos=1
        type=Btym
        set_no_flag=tower_left
    [/tile]

    [tile]
        pos=2
        has_flag=tower_left
    [/tile]
[/terrain_graphics]

[terrain_graphics]
    map="
1
, .
1
, .
2
"
    [tile]
        pos=1
        type=Btym
        set_no_flag=tower_right
    [/tile]
    [tile]
        pos=2
        has_flag=tower_right
    [/tile]
[/terrain_graphics]

[terrain_graphics]
    map="
1
, .
2
"
    [tile]
        pos=1
        type=Btym
        set_no_flag=tower_left
    [/tile]

    [tile]
        pos=2
        has_flag=tower_left
    [/tile]
[/terrain_graphics]

[terrain_graphics]
    map="
1
, .
2
"
    [tile]
        pos=1
        type=Btym
        set_no_flag=tower_right
    [/tile]
    [tile]
        pos=2
        has_flag=tower_right
    [/tile]
[/terrain_graphics]

#place images
[terrain_graphics]
    map="
,*,*
*,2
,*,*
*,1
,*,*
*,*"
    [tile]
        pos=1
        type=Btym
        set_no_flag=tower_n_drawn
    [/tile]
    [tile]
        pos=2
        type=!,Btym
    [/tile]
    [image]
        name=brick1/tower-wall-top-n.png
        base=90,216
        center=144,200
        layer=-86
    [/image]
[/terrain_graphics]

[terrain_graphics]
    map="
*,*
,*,*
*,1
,*,*
*,2"
    [tile]
        pos=1
        type=Btym
        set_no_flag=tower_n_drawn
    [/tile]
    [tile]
        pos=2
        type=!,Btym
    [/tile]
    [image]
        name=brick1/tower-wall-bottom-n.png
        base=90,144
        center=144,128
        layer=-86
    [/image]
[/terrain_graphics]

[terrain_graphics]
    map="
*,*
,*,*
*,1
,*,*
*,*"
    [tile]
        pos=1
        type=Btym
        set_no_flag=tower_n_drawn
    [/tile]
    [image]
        name=brick1/tower-wall-n.png
        base=90,144
        center=144,128
        layer=-86
    [/image]
[/terrain_graphics]

[terrain_graphics]
    map="
,*,*
*,2
,*,*
*,1
,*,*
*,*"
    [tile]
        pos=1
        type=Btym
        has_flag=tower_right
        set_no_flag=tower_nw_drawn
    [/tile]
    [tile]
        pos=2
        type=!,Btym
    [/tile]
    [image]
        name=brick1/tower-wall-top-nw.png
        base=90,144
        center=144,200
        layer=-85
    [/image]
[/terrain_graphics]

[terrain_graphics]
    map="
*,*
,*,*
*,1
,*,*
*,2"
    [tile]
        pos=1
        type=Btym
        has_flag=tower_right
        set_no_flag=tower_nw_drawn
    [/tile]
    [tile]
        pos=2
        type=!,Btym
    [/tile]
    [image]
        name=brick1/tower-wall-bottom-nw.png
        base=90,144
        center=144,128
        layer=-85
    [/image]
[/terrain_graphics]

[terrain_graphics]
    map="
*,*
,*,*
*,1
,*,*
*,*"
    [tile]
        pos=1
        type=Btym
        has_flag=tower_right
        set_no_flag=tower_nw_drawn
    [/tile]
    [image]
        name=brick1/tower-wall-nw.png
        base=90,144
        center=144,128
        layer=-85
    [/image]
[/terrain_graphics]

[terrain_graphics]
    map="
,*,*
*,2
,*,*
*,1
,*,*
*,*"
    [tile]
        pos=1
        type=Btym
        has_flag=tower_left
        set_no_flag=tower_ne_drawn
    [/tile]
    [tile]
        pos=2
        type=!,Btym
    [/tile]
    [image]
        name=brick1/tower-wall-top-ne.png
        base=90,144
        center=144,200
        layer=-85
    [/image]
[/terrain_graphics]

[terrain_graphics]
    map="
*,*
,*,*
*,1
,*,*
*,2"
    [tile]
        pos=1
        type=Btym
        has_flag=tower_left
        set_no_flag=tower_ne_drawn
    [/tile]
    [tile]
        pos=2
        type=!,Btym
    [/tile]
    [image]
        name=brick1/tower-wall-bottom-ne.png
        base=90,144
        center=144,128
        layer=-85
    [/image]
[/terrain_graphics]

[terrain_graphics]
    map="
*,*
,*,*
*,1
,*,*
*,*
,*"
    [tile]
        pos=1
        type=Btym
        has_flag=tower_left
        set_no_flag=tower_ne_drawn
    [/tile]
    [image]
        name=brick1/tower-wall-ne.png
        base=90,144
        center=144,128
        layer=-85
    [/image]
[/terrain_graphics]
towers.jpg
towers.jpg (94.85 KiB) Viewed 1637 times
Edit: I wasn't sure as to where you would want tops in such an image, so I've left them out entirely. Should they appear at the top of every tower? Or do you also want walkways in some situations.

Edit 2: I've fixed the layers and experimented with adding the tops to everything.
Some things of note from an art perspective:
It would be easier to work with if the top cap wasn't glued to a front piece.
There is a need for side pieces that are simultaneously top and bottom.

User avatar
doofus-01
Art Director
Posts: 3907
Joined: January 6th, 2008, 9:27 pm
Location: USA

Re: terrain-graphics and flags

Post by doofus-01 »

Thanks! It'll take me a bit of time (next weekend maybe) to digest this, but I can answer some things now:
Alarantalara wrote:Edit: I wasn't sure as to where you would want tops in such an image, so I've left them out entirely. Should they appear at the top of every tower? Or do you also want walkways in some situations.
What I have been using is that if the north-adjacent hex of the topmost tower hex is the marble tile, there is no top, and the marble floor transition images are overlaid on the tower. If the north-adjacent is something else, there is a tower top. It is possible to make sensible maps with that, but it could probably be better. To me at least, it looks like an elevated section.
elevated-demo.png
Alarantalara wrote:Edit 2: I've fixed the layers and experimented with adding the tops to everything.
Some things of note from an art perspective:
It would be easier to work with if the top cap wasn't glued to a front piece.
There is a need for side pieces that are simultaneously top and bottom.
I can split up the images better. The tops are pretty sloppy, but I was having trouble with the WML and couldn't get past that. The bottom moulding can be split from the wall, no problem.

Thanks again.

And speaking of split off images, how would you deal with shadows? With my broken method, it wasn't clear how to vertically scale the shadows, so only the bottoms got them and it looks like crap. The rules you posted might make it possible to change the shadow size with the tower size, I'm not sure right now.
BfW 1.12 supported, but active development only for BfW 1.13/1.14: Bad Moon Rising | Trinity | Archaic Era |
| Abandoned: Tales of the Setting Sun
GitHub link for these projects

User avatar
Alarantalara
Art Contributor
Posts: 784
Joined: April 23rd, 2010, 8:17 pm
Location: Canada

Re: terrain-graphics and flags

Post by Alarantalara »

Ah, so you mean something like this:
Screen shot 2011-12-04 at 11.10.10 PM.jpg
Screen shot 2011-12-04 at 11.10.10 PM.jpg (65.95 KiB) Viewed 1630 times
Edit:
As for shadows, as long as they're cast on something close like another tower, there's no problem. If they have to extend an unknown distance out, then you run into another counting problem, except that this one needs a rule per hex of height.

User avatar
doofus-01
Art Director
Posts: 3907
Joined: January 6th, 2008, 9:27 pm
Location: USA

Re: terrain-graphics and flags

Post by doofus-01 »

Alarantalara wrote:Ah, so you mean something like this:
Yes, like that.
Alarantalara wrote:As for shadows, as long as they're cast on something close like another tower, there's no problem. If they have to extend an unknown distance out, then you run into another counting problem, except that this one needs a rule per hex of height.
Nearby surfaces, such as the south-facing, rear walls in the image you posted, are one issue. The unknown distance out onto something like a grass field can have a limit, I think. If the far shadows are more blurry the farther away the tower top is from the ground, maybe it can max out at 3 or 4 hexes tall and, while not totally realistic, at least not look really bad.
BfW 1.12 supported, but active development only for BfW 1.13/1.14: Bad Moon Rising | Trinity | Archaic Era |
| Abandoned: Tales of the Setting Sun
GitHub link for these projects

User avatar
Alarantalara
Art Contributor
Posts: 784
Joined: April 23rd, 2010, 8:17 pm
Location: Canada

Re: terrain-graphics and flags

Post by Alarantalara »

I've drawn in shadows and numbered them for discussion.
file.jpg
file.jpg (58.63 KiB) Viewed 1626 times
1 is the easy case. It's just a bottom, middle and top shadow piece.
2 is what you mentioned, and fading it out works nicely here, assuming some reasonable limit.
3 is the worst. It hits another tower, which looks fine here, but if it went further (into the next back section), there could be overlapping shadows which would make things too dark. Also, if we're fading, then suddenly there is the problem of combining multiple shadows without making any of them extra dark. This is the part I am least sure about.

User avatar
doofus-01
Art Director
Posts: 3907
Joined: January 6th, 2008, 9:27 pm
Location: USA

Re: terrain-graphics and flags

Post by doofus-01 »

I'm inclined to think that not every configuration needs to be automated(? - from the user's perspective) by the map editor. If conditions 1 & 2 can be taken care of, we can write off #3, this is never going to look perfect no matter what we do so we need to set a reasonable limit. I believe reasonable maps could be made with just #1 & #2.

For maps where such a thing as #3 is important, there is always the option of doing it manually with a giant ~70+ hex monstrosity. That is a pain, but if the map is finalized and such details are important enough, it can be made better than anything done with the editor.
BfW 1.12 supported, but active development only for BfW 1.13/1.14: Bad Moon Rising | Trinity | Archaic Era |
| Abandoned: Tales of the Setting Sun
GitHub link for these projects

User avatar
Alarantalara
Art Contributor
Posts: 784
Joined: April 23rd, 2010, 8:17 pm
Location: Canada

Re: terrain-graphics and flags

Post by Alarantalara »

Thinking about it, I'd personally suggest the pictured version of 3 since it doesn't have any of the overlapping issues so stays simple to do, plus cover the case where a shadow goes behind another tower (and not worry about it being visible on the other side of the concealing tower regardless of height).

Edit: While nothing else does this, if you keep the shadows separate from the walls in all cases (including the existing ne tiles), you could have the shadows change direction based on time of day. I don't know if this is something you would want.

Post Reply