Skip to content

Commit 161fc1c

Browse files
committed
Add depthTest option to ShapeMarkers and add a helper-funktion
1 parent 4a84f62 commit 161fc1c

File tree

3 files changed

+37
-3
lines changed

3 files changed

+37
-3
lines changed

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
org.gradle.jvmargs=-Xmx3G
22
org.gradle.daemon=false
33

4-
apiVersion=1.0.1
4+
apiVersion=1.1.0

src/main/java/de/bluecolored/bluemap/api/marker/MarkerSet.java

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import java.util.Collection;
2828
import java.util.Optional;
2929

30+
import com.flowpowered.math.vector.Vector2d;
3031
import com.flowpowered.math.vector.Vector3d;
3132

3233
import de.bluecolored.bluemap.api.BlueMapMap;
@@ -136,11 +137,13 @@ default POIMarker createPOIMarker(String id, BlueMapMap map, double posX, double
136137
* Creates a {@link ShapeMarker} with the given id and adds it to this {@link MarkerSet}.<br>
137138
* If a {@link Marker} with that id already exists, it will be replaced by the new {@link ShapeMarker}!
138139
*
140+
* <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>
141+
*
139142
* @param id the id of the new marker
140143
* @param map the {@link BlueMapMap} of the new marker
141144
* @param position the position of the new marker
142145
* @param shape the Shape of the marker (See: {@link ShapeMarker#setShape(Shape, float)})
143-
* @param height the height of shape of the marker (See: {@link ShapeMarker#setShape(Shape, float)})
146+
* @param height the height (y-position on the map) of shape of the marker (See: {@link ShapeMarker#setShape(Shape, float)})
144147
* @return the created {@link ShapeMarker}
145148
*/
146149
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
149152
* Creates a {@link ShapeMarker} with the given id and adds it to this {@link MarkerSet}.<br>
150153
* If a Marker with that id already exists, it will be replaced by the new {@link ShapeMarker}!
151154
*
155+
* <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>
156+
*
152157
* @param id the id of the new marker
153158
* @param map the {@link BlueMapMap} of the new marker
154159
* @param posX the x-position of the new marker
155160
* @param posY the y-position of the new marker
156161
* @param posZ the z-position of the new marker
157162
* @param shape the Shape of the marker (See: {@link ShapeMarker#setShape(Shape, float)})
158-
* @param height the height of shape of the marker (See: {@link ShapeMarker#setShape(Shape, float)})
163+
* @param height the height (y-position on the map) of shape of the marker (See: {@link ShapeMarker#setShape(Shape, float)})
159164
* @return the created {@link ShapeMarker}
160165
*/
161166
default ShapeMarker createShapeMarker(String id, BlueMapMap map, double posX, double posY, double posZ, Shape shape, float height) {
162167
return createShapeMarker(id, map, new Vector3d(posX, posY, posZ), shape, height);
163168
}
164169

170+
/**
171+
* Creates a {@link ShapeMarker} with the given id and adds it to this {@link MarkerSet}.<br>
172+
* If a Marker with that id already exists, it will be replaced by the new {@link ShapeMarker}!
173+
*
174+
* <p><i>(The position of the marker will be the center of the shape (it's bounding box))</i></p>
175+
*
176+
* @param id the id of the new marker
177+
* @param map the {@link BlueMapMap} of the new marker
178+
* @param shape the Shape of the marker (See: {@link ShapeMarker#setShape(Shape, float)})
179+
* @param height the height of shape of the marker (See: {@link ShapeMarker#setShape(Shape, float)})
180+
* @return the created {@link ShapeMarker}
181+
*/
182+
default ShapeMarker createShapeMarker(String id, BlueMapMap map, Shape shape, float height) {
183+
Vector2d center = shape.getMin().add(shape.getMax()).div(2);
184+
return createShapeMarker(id, map, new Vector3d(center.getX(), height, center.getY()), shape, height);
185+
}
186+
165187
/**
166188
* Removes the given Marker from this {@link MarkerSet}.<br>
167189
* This is equivalent to calling <code>removeMarker(marker.getId())</code>.

src/main/java/de/bluecolored/bluemap/api/marker/ShapeMarker.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,18 @@ public interface ShapeMarker extends Marker {
4848
* @param height the new height of the shape on the map
4949
*/
5050
void setShape(Shape shape, float height);
51+
52+
/**
53+
* 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.
54+
* @return <code>true</code> if the depthTest is enabled
55+
*/
56+
boolean isDepthTestEnabled();
57+
58+
/**
59+
* 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.
60+
* @param enabled if the depth-test should be enabled for this {@link ShapeMarker}
61+
*/
62+
void setDepthTestEnabled(boolean enabled);
5163

5264
/**
5365
* Getter for the {@link Color} of the border of the shape.

0 commit comments

Comments
 (0)