From 161fc1c96808594d0ad522536c36ef237f69df93 Mon Sep 17 00:00:00 2001 From: "Blue (Lukas Rieger)" Date: Thu, 23 Apr 2020 18:06:42 +0200 Subject: [PATCH] Add depthTest option to ShapeMarkers and add a helper-funktion --- gradle.properties | 2 +- .../bluemap/api/marker/MarkerSet.java | 26 +++++++++++++++++-- .../bluemap/api/marker/ShapeMarker.java | 12 +++++++++ 3 files changed, 37 insertions(+), 3 deletions(-) diff --git a/gradle.properties b/gradle.properties index 1f4afd6..d743d11 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ org.gradle.jvmargs=-Xmx3G org.gradle.daemon=false -apiVersion=1.0.1 +apiVersion=1.1.0 diff --git a/src/main/java/de/bluecolored/bluemap/api/marker/MarkerSet.java b/src/main/java/de/bluecolored/bluemap/api/marker/MarkerSet.java index 8d7ba07..148e776 100644 --- a/src/main/java/de/bluecolored/bluemap/api/marker/MarkerSet.java +++ b/src/main/java/de/bluecolored/bluemap/api/marker/MarkerSet.java @@ -27,6 +27,7 @@ import java.util.Collection; import java.util.Optional; +import com.flowpowered.math.vector.Vector2d; import com.flowpowered.math.vector.Vector3d; import de.bluecolored.bluemap.api.BlueMapMap; @@ -136,11 +137,13 @@ default POIMarker createPOIMarker(String id, BlueMapMap map, double posX, double * Creates a {@link ShapeMarker} with the given id and adds it to this {@link MarkerSet}.
* If a {@link Marker} with that id already exists, it will be replaced by the new {@link ShapeMarker}! * + *

(Since the shape has its own positions, the position is only used to determine e.g. the distance to the camera)

+ * * @param id the id of the new marker * @param map the {@link BlueMapMap} of the new marker * @param position the position of the new marker * @param shape the Shape of the marker (See: {@link ShapeMarker#setShape(Shape, float)}) - * @param height the height of shape of the marker (See: {@link ShapeMarker#setShape(Shape, float)}) + * @param height the height (y-position on the map) of shape of the marker (See: {@link ShapeMarker#setShape(Shape, float)}) * @return the created {@link ShapeMarker} */ ShapeMarker createShapeMarker(String id, BlueMapMap map, Vector3d position, Shape shape, float height); @@ -149,19 +152,38 @@ default POIMarker createPOIMarker(String id, BlueMapMap map, double posX, double * Creates a {@link ShapeMarker} with the given id and adds it to this {@link MarkerSet}.
* If a Marker with that id already exists, it will be replaced by the new {@link ShapeMarker}! * + *

(Since the shape has its own positions, the position is only used to determine e.g. the distance to the camera)

+ * * @param id the id of the new marker * @param map the {@link BlueMapMap} of the new marker * @param posX the x-position of the new marker * @param posY the y-position of the new marker * @param posZ the z-position of the new marker * @param shape the Shape of the marker (See: {@link ShapeMarker#setShape(Shape, float)}) - * @param height the height of shape of the marker (See: {@link ShapeMarker#setShape(Shape, float)}) + * @param height the height (y-position on the map) of shape of the marker (See: {@link ShapeMarker#setShape(Shape, float)}) * @return the created {@link ShapeMarker} */ default ShapeMarker createShapeMarker(String id, BlueMapMap map, double posX, double posY, double posZ, Shape shape, float height) { return createShapeMarker(id, map, new Vector3d(posX, posY, posZ), shape, height); } + /** + * Creates a {@link ShapeMarker} with the given id and adds it to this {@link MarkerSet}.
+ * If a Marker with that id already exists, it will be replaced by the new {@link ShapeMarker}! + * + *

(The position of the marker will be the center of the shape (it's bounding box))

+ * + * @param id the id of the new marker + * @param map the {@link BlueMapMap} of the new marker + * @param shape the Shape of the marker (See: {@link ShapeMarker#setShape(Shape, float)}) + * @param height the height of shape of the marker (See: {@link ShapeMarker#setShape(Shape, float)}) + * @return the created {@link ShapeMarker} + */ + default ShapeMarker createShapeMarker(String id, BlueMapMap map, Shape shape, float height) { + Vector2d center = shape.getMin().add(shape.getMax()).div(2); + return createShapeMarker(id, map, new Vector3d(center.getX(), height, center.getY()), shape, height); + } + /** * Removes the given Marker from this {@link MarkerSet}.
* This is equivalent to calling removeMarker(marker.getId()). diff --git a/src/main/java/de/bluecolored/bluemap/api/marker/ShapeMarker.java b/src/main/java/de/bluecolored/bluemap/api/marker/ShapeMarker.java index 30887e2..4629415 100644 --- a/src/main/java/de/bluecolored/bluemap/api/marker/ShapeMarker.java +++ b/src/main/java/de/bluecolored/bluemap/api/marker/ShapeMarker.java @@ -48,6 +48,18 @@ public interface ShapeMarker extends Marker { * @param height the new height of the shape on the map */ void setShape(Shape shape, float height); + + /** + * If the depth-test is disabled, you can see the marker fully through all objects on the map. If it is enabled, you'll only see the border of the marker when it is - for example - under the ground. + * @return true if the depthTest is enabled + */ + boolean isDepthTestEnabled(); + + /** + * If the depth-test is disabled, you can see the marker fully through all objects on the map. If it is enabled, you'll only see the border of the marker when it is - for example - under the ground. + * @param enabled if the depth-test should be enabled for this {@link ShapeMarker} + */ + void setDepthTestEnabled(boolean enabled); /** * Getter for the {@link Color} of the border of the shape.