Skip to content

Commit

Permalink
Add depthTest option to ShapeMarkers and add a helper-funktion
Browse files Browse the repository at this point in the history
  • Loading branch information
TBlueF committed Apr 23, 2020
1 parent 4a84f62 commit 161fc1c
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 3 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
org.gradle.jvmargs=-Xmx3G
org.gradle.daemon=false

apiVersion=1.0.1
apiVersion=1.1.0
26 changes: 24 additions & 2 deletions src/main/java/de/bluecolored/bluemap/api/marker/MarkerSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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}.<br>
* If a {@link Marker} with that id already exists, it will be replaced by the new {@link ShapeMarker}!
*
* <p><i>(Since the shape has its own positions, the position is only used to determine e.g. the distance to the camera)</i></p>
*
* @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);
Expand All @@ -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}.<br>
* If a Marker with that id already exists, it will be replaced by the new {@link ShapeMarker}!
*
* <p><i>(Since the shape has its own positions, the position is only used to determine e.g. the distance to the camera)</i></p>
*
* @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}.<br>
* If a Marker with that id already exists, it will be replaced by the new {@link ShapeMarker}!
*
* <p><i>(The position of the marker will be the center of the shape (it's bounding box))</i></p>
*
* @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}.<br>
* This is equivalent to calling <code>removeMarker(marker.getId())</code>.
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/de/bluecolored/bluemap/api/marker/ShapeMarker.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 <code>true</code> 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.
Expand Down

0 comments on commit 161fc1c

Please sign in to comment.