0

Adding StructureOverlay an overlay to color the map according to structures.

A usecase to demonstrate a possible application of the extended functionality:

**"Rails Overlay that draws only the rails that are on Cobblestone for a subway map."**

With this patch it is very easy to achive that:

```python
MineralOverlay(minerals=[(((0, 0, 0, 66), (0, -1, 0, 4)), (255, 0, 0, 255)),
                         (((0, 0, 0, 27), (0, -1, 0, 4)), (0, 255, 0, 255))])
```

In this case the overlay will be red for rails on cobblestone and green for powerrails on cobblestone.
The syntax is `(<tuple of conditions>, <target color>)`
 * where `<target color>` is a 4 tuple with a `(r, g, b, a)` color
 * and `<tuple of conditions>` is a tuple with an arbitrary number of conditions with the following syntax:
`((relx, rely, relz, blkid), ...)` where the `rel<>` parameters specify the relative coordinates to the block that is checked if it matches bklid.

In the example the fist tuple `(0,0,0,66)` checks if at the current position is a
rail while `(0,-1,0,4)` checks if at one below the current position is a cobblestone.
If both are true then the color `(255, 0, 0, 255)` is used.

A Sample Config file exploiting the capabilities:

``` python
worlds['My World'] = "~/.minecraft/saves/test/"
outputdir = "/tmp/test_render"
rendermode = "lighting"

renders["render1"] = {
    'world': 'My World',
    'title': 'A regular render',
}
renders["render_overlay_dafault_rails"] = {
    'world': 'My World',
    'title': 'Default Rails',
    'rendermode': [ClearBase(), StructureOverlay()],
    'overlay': ['render1'],
}
renders["render_overlay_cust_rails"] = {
    'world': 'My World',
    'title': 'Custom Rails',
    #relative coordinates [[(relx, rely, relz, mineral)], (red, green, blue, alpha)]
    'rendermode': [ClearBase(), StructureOverlay(structures=[(((0, 0, 0, 66), (0, -1, 0, 4)), (255, 0, 0, 255)),
                                                            (((0, 0, 0, 27), (0, -1, 0, 4)), (0, 255, 0, 255))])],
    'overlay': ['render1'],
}
```

The "Default Rails" overlay uses default coloring of the structures overlay. "Custom Rails" uses some custom coloring.

fixes overviewer/Minecraft-Overviewer#556 and fixes overviewer/Minecraft-Overviewer#787
This commit is contained in:
Franz Dietrich
2014-09-03 11:28:47 +02:00
parent af47000079
commit 086820ac72
3 changed files with 281 additions and 0 deletions

View File

@@ -1099,6 +1099,32 @@ MineralOverlay
MineralOverlay(minerals=[(64,(255,255,0)), (13,(127,0,127))])
StructureOverlay
Color the map according to patterns of blocks. With this rail overlays
or overlays for other small structures can be realized. It can also be
a MineralOverlay with alpha support.
This Overlay colors according to a patterns that are specified as
multiple tuples of the form ``(relx, rely, relz, blockid)``. So
by specifying ``(0, -1, 0, 4)`` the block below the current one has to
be a cobblestone.
One color is then specified as
``((relblockid1, relblockid2, ...), (r, g, b, a))`` where the
``relblockid*`` are relative coordinates and the blockid as specified
above. The ``relblockid*`` must match all at the same time for the
color to apply.
Example::
MineralOverlay(minerals=[(((0, 0, 0, 66), (0, -1, 0, 4)), (255, 0, 0, 255)),
(((0, 0, 0, 27), (0, -1, 0, 4)), (0, 255, 0, 255))])
In this example all rails(66) on top of cobblestone are rendered in
pure red. And all powerrails(27) are rendered in green.
If ``minerals`` is not provided, a default rail coloring is used.
BiomeOverlay
Color the map according to the biome at that point. Either use on
top of other modes or on top of ClearBase to create a pure overlay.