Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions docs/usage/parameters/TileTasks.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,14 +183,19 @@ place: default:stone

### `renderSurfaces`

Renders 2-D shapes surfaces with [placeables](Placeables.md) on a given [heightmap](Heightmaps.md).
Renders 2-D shapes surfaces with [placeables](Placeables.md) on a given [heightmap](Heightmaps.md) and/or at an altitude given by model.

#### Extra parameters

- `models`: [Selection of models](ModelSelection.md) to render (required, models must be convertible to 2d shapes)
- `heightmap`: [Heightmap](Heightmaps.md) to use (required)
- `heightmap`: [Heightmap](Heightmaps.md) to use (optional, default 0)
- `altitudeOffset`: A [value](ModelValues.md) added to altitude (optional, default 0)
- `place`: [Placeable](Placeables.md) to place on each voxel of shapes (required)

If both `heightmap` and `altitudeOffset` are specified, the resulting placement altitude will be the addition of both.

If both `heightmap` and `altitudeOffset` are omitted, due to default values, flat shape will be rendered at altitude 0.

#### Examples

Draw "building" shapes with cobble on ground:
Expand Down Expand Up @@ -289,8 +294,8 @@ Layouts are tried in order, the first one that can fit the requested space is us
#### Extra parameters

- `models`: [Selection of models](ModelSelection.md) to render (required, models must be convertible to 2d shapes)
- `height` (string): Name of the metadata containing the desired height. (required)
- `altitude` (string): Name of the metadata containing the altitude. (required)
- `height`: [Value](ModelValues.md) of walls height. (required)
- `altitude`: [Value](ModelValues.md) of walls base altitude. (required)
- `build`: List of [layouts](Layouts.md) to try. Default axis policies are `ADJUST` on `X` and `Z`, `KEEP` on `Y`.

See [Layouts](Layouts.md) for more information about layouts
Expand All @@ -300,8 +305,9 @@ See [Layouts](Layouts.md) for more information about layouts
```yaml
type: renderFacades
models: buildings
height: height
altitude: ground-floor-altitude
height: 20
altitude:
metadata: ground-floor-altitude
build:
- structure:
at: [ 0, -1..0, 0 ]
Expand Down
32 changes: 18 additions & 14 deletions examples/processes/full.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -118,20 +118,16 @@ forEachTile:
placeAbove: *voxel-air
placeBelow: *voxel-building-ground

# Hacky way to render roofs. Should be removed.
# Would have been nice to have a fillBetweenMetadatas
renderRoofs:
after: flattenGroundBuildings
type: renderBuildings
type: renderSurfaces
models:
type: buildings
filter:
value:
metadata: height
greaterThan: 0
roof: *voxel-cobble
wall: *voxel-air
window: *voxel-air
altitudeOffset:
sum:
- metadata: ground-floor-altitude
- metadata: height
place: *voxel-cobble

forest:
type: sequence
Expand Down Expand Up @@ -313,8 +309,12 @@ forEachTile:
filter:
metadata: usage_1
equals: Résidentiel
height: height
altitude: ground-floor-altitude
height:
metadata: height
altitude:
sum:
- metadata: ground-floor-altitude
- 1
# TODO: Layout should probably be defined on a common.yaml file in format.
build:
- along: x
Expand Down Expand Up @@ -405,8 +405,12 @@ forEachTile:
not:
metadata: usage_1
equals: Résidentiel
height: height
altitude: ground-floor-altitude
height:
metadata: height
altitude:
sum:
- metadata: ground-floor-altitude
- 1
# TODO: Layout should probably be defined on a common.yaml file in format.
build:
- along: x
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/fr/ign/voxatile/core/Voxatile.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
import fr.ign.voxatile.core.parameters.tasks.HeightmapStatsTaskParams;
import fr.ign.voxatile.core.parameters.tasks.NoOperationTaskParams;
import fr.ign.voxatile.core.parameters.tasks.PopulateHeightmapTaskParams;
import fr.ign.voxatile.core.parameters.tasks.RenderBuildingsTaskParams;
import fr.ign.voxatile.core.parameters.tasks.RenderFacadesTaskParams;
import fr.ign.voxatile.core.parameters.tasks.RenderHeightmapTaskParams;
import fr.ign.voxatile.core.parameters.tasks.RenderLines2dTaskParams;
Expand Down Expand Up @@ -128,7 +127,6 @@ public static void main(String[] args) throws FactoryException, InterruptedExcep
parser.registerParams("fetchData", FetchDataTaskParams.class);
parser.registerParams("fillBetweenHeightmapAndValue", FillBetweenHeightmapAndValueTaskParams.class);
parser.registerParams("populateHeightmap", PopulateHeightmapTaskParams.class);
parser.registerParams("renderBuildings", RenderBuildingsTaskParams.class);
parser.registerParams("renderHeightmap", RenderHeightmapTaskParams.class);
parser.registerParams("renderSurfaces", RenderSurfacesTaskParams.class);
parser.registerParams("renderLines", RenderLinesTaskParams.class);
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import com.fasterxml.jackson.annotation.Nulls;

import fr.ign.voxatile.core.generation.Generation;
import fr.ign.voxatile.core.parameters.models.values.ModelValueParams;
import fr.ign.voxatile.core.parameters.placeables.layouts.LayoutBuilderParams;
import fr.ign.voxatile.core.placeables.layouts.UnbuildableLayoutException;
import fr.ign.voxatile.core.tasks.RenderFacadesTask;
Expand All @@ -30,28 +31,28 @@ public class RenderFacadesTaskParams extends ModelTaskParams {
public List<LayoutBuilderParams> build;

/**
* Name of metadata containing building height (from wall bottom to wall top).
* Building height (from wall bottom to wall top).
*/
@JsonSetter(nulls = Nulls.FAIL)
public String height;
public ModelValueParams height;

/**
* Name of metadata containing building altitude (altitude of wall bottom).
* Building base altitude (altitude of wall bottom).
*/
@JsonSetter(nulls = Nulls.FAIL)
public String altitude;
public ModelValueParams altitude;

/**
* Creates a new {@code RenderFacadeTaskParams} out of mandatory parameters.
* Creates a new {@code RenderFacadesTaskParams} out of mandatory parameters.
* @param build builders to try, in order
* @param height name of metadata containing building height
* @param altitude name of metadata containing building altitude
* @param height building height
* @param altitude building base altitude (altitude of walls bottom)
*/
@ConstructorProperties({ "build", "height", "altitude"})
public RenderFacadesTaskParams(
List<LayoutBuilderParams> build,
String height,
String altitude
ModelValueParams height,
ModelValueParams altitude
) {
this.build = build;
this.height = height;
Expand All @@ -61,10 +62,8 @@ public RenderFacadesTaskParams(
@Override
public void validate() {
super.validate();
if (height.isBlank())
throw new IllegalArgumentException("Height metadata cannot be blank");
if (altitude.isBlank())
throw new IllegalArgumentException("Altitude metadata cannot be blank");
height.validate();
altitude.validate();
build.forEach(LayoutBuilderParams::validate);
}

Expand All @@ -83,8 +82,8 @@ public TileTask create(Generation generation) {
throw new IllegalArgumentException(e);
}
}).toList(),
height,
altitude
height.create(generation),
altitude.create(generation)
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
import com.fasterxml.jackson.annotation.Nulls;

import fr.ign.voxatile.core.generation.Generation;
import fr.ign.voxatile.core.parameters.heightmaps.ConstantHeightmapParams;
import fr.ign.voxatile.core.parameters.heightmaps.ReadableHeightmapParams;
import fr.ign.voxatile.core.parameters.models.values.AbsentValueParams;
import fr.ign.voxatile.core.parameters.models.values.ModelValueParams;
import fr.ign.voxatile.core.parameters.placeables.PlaceableParams;
import fr.ign.voxatile.core.tasks.RenderSurfacesTask;
import fr.ign.voxatile.core.tasks.TileTask;
Expand All @@ -16,10 +19,17 @@
*/
public class RenderSurfacesTaskParams extends ModelTaskParams {
/**
* Heightmap to render on (required).
* Heightmap to render on (optional default 0).
*/
@JsonSetter(nulls = Nulls.FAIL)
public ReadableHeightmapParams heightmap;
@JsonSetter(nulls = Nulls.SKIP)
public ReadableHeightmapParams heightmap = new ConstantHeightmapParams(0);

/**
* Altitude offset to add (optional default 0).
*/
@JsonSetter(nulls = Nulls.SKIP)
public ModelValueParams altitudeOffset = new AbsentValueParams();

/**
* What to place on surface (required).
*/
Expand All @@ -29,19 +39,18 @@ public class RenderSurfacesTaskParams extends ModelTaskParams {
/**
* Constructor used to ensure that the required fields are present during deserialization.
*
* @param heightmap heightmap to render on.
* @param place what to place on surface.
*/
@ConstructorProperties({ "heightmap", "place"})
public RenderSurfacesTaskParams(ReadableHeightmapParams heightmap, PlaceableParams place) {
this.heightmap = heightmap;
@ConstructorProperties({ "place" })
public RenderSurfacesTaskParams(PlaceableParams place) {
this.place = place;
}

@Override
public void validate() throws IllegalArgumentException {
super.validate();
heightmap.validate();
altitudeOffset.validate();
place.validate();
}

Expand All @@ -50,6 +59,7 @@ public TileTask create(Generation generation) {
return new RenderSurfacesTask(
models.create(generation),
heightmap.create(generation.heightmaps()),
altitudeOffset.create(generation),
place.create(generation.seed())
);
}
Expand Down
Loading
Loading