|
1 | 1 | /* |
2 | | - * Copyright (c) 2009-2020 jMonkeyEngine |
| 2 | + * Copyright (c) 2009-2025 jMonkeyEngine |
3 | 3 | * All rights reserved. |
4 | 4 | * |
5 | 5 | * Redistribution and use in source and binary forms, with or without |
|
33 | 33 |
|
34 | 34 | import com.jme3.bounding.BoundingSphere; |
35 | 35 | import com.jme3.math.FastMath; |
| 36 | +import com.jme3.math.Vector3f; |
| 37 | +import com.jme3.scene.Geometry; |
36 | 38 | import com.jme3.scene.Mesh; |
37 | | -import com.jme3.scene.Mesh.Mode; |
38 | 39 | import com.jme3.scene.VertexBuffer; |
39 | 40 | import com.jme3.scene.VertexBuffer.Format; |
40 | 41 | import com.jme3.scene.VertexBuffer.Type; |
41 | 42 | import com.jme3.scene.VertexBuffer.Usage; |
42 | 43 | import com.jme3.util.BufferUtils; |
| 44 | + |
43 | 45 | import java.nio.FloatBuffer; |
44 | 46 | import java.nio.ShortBuffer; |
45 | 47 |
|
@@ -151,11 +153,25 @@ public void updatePositions(float radius) { |
151 | 153 | /** |
152 | 154 | * Create a WireSphere from a BoundingSphere |
153 | 155 | * |
154 | | - * @param bsph |
155 | | - * BoundingSphere used to create the WireSphere |
156 | | - * |
| 156 | + * @param bsph BoundingSphere used to create the WireSphere |
157 | 157 | */ |
158 | 158 | public void fromBoundingSphere(BoundingSphere bsph) { |
159 | 159 | updatePositions(bsph.getRadius()); |
160 | 160 | } |
| 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 | + } |
161 | 177 | } |
0 commit comments