|
45 | 45 | import com.jme3.scene.Node; |
46 | 46 | import com.jme3.scene.Spatial; |
47 | 47 | import com.jme3.scene.VertexBuffer.Type; |
| 48 | +import java.nio.FloatBuffer; |
48 | 49 | import java.util.HashMap; |
49 | 50 | import java.util.Map; |
50 | 51 | import java.util.logging.Logger; |
@@ -121,6 +122,24 @@ public static Vector3f[] footprint(CollisionShape shape, |
121 | 122 | return cornerLocations; |
122 | 123 | } |
123 | 124 |
|
| 125 | + /** |
| 126 | + * For compatibility with the jme3-bullet library. |
| 127 | + * |
| 128 | + * @param shape (not null, unaffected) |
| 129 | + * @return a new Mesh (not null) |
| 130 | + */ |
| 131 | + public static Mesh getDebugMesh(CollisionShape shape) { |
| 132 | + long shapeId = shape.getObjectId(); |
| 133 | + DebugMeshCallback callback = new DebugMeshCallback(); |
| 134 | + getVertices2(shapeId, lowResolution, callback); |
| 135 | + FloatBuffer floatBuffer = callback.getVertices(); |
| 136 | + |
| 137 | + Mesh result = new Mesh(); |
| 138 | + result.setBuffer(Type.Position, 3, floatBuffer); |
| 139 | + |
| 140 | + return result; |
| 141 | + } |
| 142 | + |
124 | 143 | /** |
125 | 144 | * For compatibility with the jme3-bullet library. |
126 | 145 | * |
@@ -220,7 +239,7 @@ public static float volumeConvex(CollisionShape shape, int meshResolution) { |
220 | 239 | * @param shape (not null, unaffected) |
221 | 240 | * @param normals which normals to generate (not null) |
222 | 241 | * @param resolution how much detail for convex shapes (0=low, 1=high) |
223 | | - * @return a new geometry (not null) |
| 242 | + * @return a new Geometry (not null) |
224 | 243 | */ |
225 | 244 | private static Geometry createGeometry(CollisionShape shape, |
226 | 245 | DebugMeshInitListener listener, DebugMeshNormals normals, |
@@ -254,13 +273,13 @@ private static Geometry createGeometry(CollisionShape shape, |
254 | 273 | * @param shape (not null, unaffected) |
255 | 274 | * @param normals which normals to generate (not null) |
256 | 275 | * @param resolution how much detail for convex shapes (0=low, 1=high) |
257 | | - * @return a new mesh (not null) |
| 276 | + * @return a new Mesh (not null) |
258 | 277 | */ |
259 | 278 | private static Mesh createMesh(CollisionShape shape, |
260 | 279 | DebugMeshNormals normals, int resolution) { |
261 | | - long id = shape.getObjectId(); |
| 280 | + long shapeId = shape.getObjectId(); |
262 | 281 | DebugMeshCallback callback = new DebugMeshCallback(); |
263 | | - getVertices2(id, resolution, callback); |
| 282 | + getVertices2(shapeId, resolution, callback); |
264 | 283 |
|
265 | 284 | Mesh mesh = new Mesh(); |
266 | 285 | mesh.setBuffer(Type.Position, 3, callback.getVertices()); |
|
0 commit comments