Skip to content

Commit 37ea339

Browse files
authored
Merge pull request #2458 from capdevon/capdevon-WireSphere
Add makeGeometry() method to WireSphere for consistency with WireBox
2 parents b7f1118 + 730c688 commit 37ea339

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

jme3-core/src/main/java/com/jme3/scene/debug/WireSphere.java

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2009-2020 jMonkeyEngine
2+
* Copyright (c) 2009-2025 jMonkeyEngine
33
* All rights reserved.
44
*
55
* Redistribution and use in source and binary forms, with or without
@@ -33,13 +33,15 @@
3333

3434
import com.jme3.bounding.BoundingSphere;
3535
import com.jme3.math.FastMath;
36+
import com.jme3.math.Vector3f;
37+
import com.jme3.scene.Geometry;
3638
import com.jme3.scene.Mesh;
37-
import com.jme3.scene.Mesh.Mode;
3839
import com.jme3.scene.VertexBuffer;
3940
import com.jme3.scene.VertexBuffer.Format;
4041
import com.jme3.scene.VertexBuffer.Type;
4142
import com.jme3.scene.VertexBuffer.Usage;
4243
import com.jme3.util.BufferUtils;
44+
4345
import java.nio.FloatBuffer;
4446
import java.nio.ShortBuffer;
4547

@@ -151,11 +153,25 @@ public void updatePositions(float radius) {
151153
/**
152154
* Create a WireSphere from a BoundingSphere
153155
*
154-
* @param bsph
155-
* BoundingSphere used to create the WireSphere
156-
*
156+
* @param bsph BoundingSphere used to create the WireSphere
157157
*/
158158
public void fromBoundingSphere(BoundingSphere bsph) {
159159
updatePositions(bsph.getRadius());
160160
}
161+
162+
/**
163+
* Create a geometry suitable for visualizing the specified bounding sphere.
164+
*
165+
* @param bsph the bounding sphere (not null)
166+
* @return a new Geometry instance in world space
167+
*/
168+
public static Geometry makeGeometry(BoundingSphere bsph) {
169+
WireSphere mesh = new WireSphere(bsph.getRadius());
170+
Geometry result = new Geometry("bounding sphere", mesh);
171+
172+
Vector3f center = bsph.getCenter();
173+
result.setLocalTranslation(center);
174+
175+
return result;
176+
}
161177
}

0 commit comments

Comments
 (0)