Package com.jme3.bullet.util
Class DebugShapeFactory
java.lang.Object
com.jme3.bullet.util.DebugShapeFactory
A utility class to generate debug meshes for Bullet collision shapes.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
specify high-resolution debug meshes for convex shapes (up to 256 vertices) and zero-margin debug meshes for concave shapesstatic final int
specify high-resolution debug meshes for convex shapes (up to 256 vertices) and actual-margin debug meshes for concave shapesstatic final Logger
message logger for this classstatic final int
specify low-res debug meshes for convex shapes (up to 42 vertices) and zero-margin debug meshes for concave shapes -
Method Summary
Modifier and TypeMethodDescriptionstatic void
Forget all previously generated debug meshes.static int
Count how many debug meshes are cached.static FloatBuffer
debugVertices
(CollisionShape shape, int meshResolution) Determine vertex locations for the specified collision shape.static com.jme3.math.Vector3f[]
footprint
(CollisionShape shape, com.jme3.math.Transform shapeToWorld, int meshResolution) Estimate the footprint of the specified (non-compound, non-plane) shape.static com.jme3.scene.Mesh
getDebugMesh
(CollisionShape shape) For compatibility with the jme3-jbullet library.static com.jme3.scene.Spatial
Create a Spatial for visualizing the specified collision object.static com.jme3.scene.Spatial
getDebugShape
(CollisionShape shape) For compatibility with the jme3-jbullet library.static FloatBuffer
getDebugTriangles
(CollisionShape shape, int meshResolution) Generate vertex locations for triangles to visualize the specified collision shape.static void
installMeshCustomizer
(MeshCustomizer customizer) Install the specified MeshCustomizer, replacing any customizer previously installed.static float
maxDistance
(CollisionShape shape, com.jme3.math.Transform shapeToWorld, int meshResolution) Estimate how far the specified (non-compound, non-plane) shape extends from some origin, based on its debug mesh.static void
removeShapeFromCache
(long shapeId) Forget all previously generated debug meshes for the identified shape.static void
setIndexBuffers
(boolean setting) Alter whether to index new debug meshes.static void
setIndexBuffers
(int maxVertices) Alter whether to index new debug meshes.static float
volumeConvex
(ConvexShape shape, int meshResolution) Calculate the volume of a debug mesh for the specified convex shape.
-
Field Details
-
highResolution
public static final int highResolutionspecify high-resolution debug meshes for convex shapes (up to 256 vertices) and zero-margin debug meshes for concave shapes- See Also:
-
highResolution2
public static final int highResolution2specify high-resolution debug meshes for convex shapes (up to 256 vertices) and actual-margin debug meshes for concave shapes- See Also:
-
lowResolution
public static final int lowResolutionspecify low-res debug meshes for convex shapes (up to 42 vertices) and zero-margin debug meshes for concave shapes- See Also:
-
logger
message logger for this class
-
-
Method Details
-
clearCache
public static void clearCache()Forget all previously generated debug meshes. -
countCachedMeshes
public static int countCachedMeshes()Count how many debug meshes are cached.- Returns:
- the count (≥0)
-
debugVertices
Determine vertex locations for the specified collision shape. Note: recursive!- Parameters:
shape
- the input shape (not null, unaffected)meshResolution
- 0→low, 1→high for convex shapes, 2→high for all shapes- Returns:
- a new, unflipped, direct buffer full of scaled shape coordinates (capacity a multiple of 3)
-
footprint
public static com.jme3.math.Vector3f[] footprint(CollisionShape shape, com.jme3.math.Transform shapeToWorld, int meshResolution) Estimate the footprint of the specified (non-compound, non-plane) shape. The shape's scale and margin are taken into account, but not its debug-mesh resolution.- Parameters:
shape
- (not null, not compound, not plane, unaffected)shapeToWorld
- the world transform of the collision object (not null, unaffected)meshResolution
- 0→low, 1→high for convex shapes, 2→high for all shapes- Returns:
- a new array of corner locations (in world coordinates)
-
getDebugMesh
For compatibility with the jme3-jbullet library.- Parameters:
shape
- the shape to visualize (not null, not compound, not plane, unaffected)- Returns:
- a new Triangles-mode Mesh (no indices, no normals)
-
getDebugShape
For compatibility with the jme3-jbullet library.- Parameters:
shape
- the shape to visualize (may be null, unaffected)- Returns:
- a new Spatial or null
-
getDebugShape
Create a Spatial for visualizing the specified collision object.This is mostly used internally. To enable debug visualization, use
BulletAppState.setDebugEnabled(boolean)
.- Parameters:
pco
- the object to visualize (not null, unaffected)- Returns:
- a new tree of nodes and geometries, or null
-
getDebugTriangles
Generate vertex locations for triangles to visualize the specified collision shape. Note: recursive!- Parameters:
shape
- the shape to visualize (not null, unaffected)meshResolution
- 0→low, 1→high for convex shapes, 2→high for all shapes- Returns:
- a new, unflipped, direct buffer full of scaled shape coordinates (capacity a multiple of 9)
-
installMeshCustomizer
Install the specified MeshCustomizer, replacing any customizer previously installed.- Parameters:
customizer
- the desired customizer, or null for none
-
maxDistance
public static float maxDistance(CollisionShape shape, com.jme3.math.Transform shapeToWorld, int meshResolution) Estimate how far the specified (non-compound, non-plane) shape extends from some origin, based on its debug mesh. The shape's scale and margin are taken into account, but not its debug-mesh resolution.- Parameters:
shape
- (not null, not compound, not plane, unaffected)shapeToWorld
- the transform to apply to debug-mesh coordinates (not null, unaffected)meshResolution
- 0→low, 1→high for convex shapes, 2→high for all shapes- Returns:
- the maximum length of the transformed vertex locations (≥0)
-
removeShapeFromCache
public static void removeShapeFromCache(long shapeId) Forget all previously generated debug meshes for the identified shape.- Parameters:
shapeId
- the ID of the shape to remove
-
setIndexBuffers
public static void setIndexBuffers(boolean setting) Alter whether to index new debug meshes. (Doesn't affect cached meshes or plane shapes.) Indexing might boost performance when there are many small meshes; it isn't recommended for very large meshes.- Parameters:
setting
- true→always index, false→never index
-
setIndexBuffers
public static void setIndexBuffers(int maxVertices) Alter whether to index new debug meshes. (Doesn't affect cached meshes or plane shapes.) Indexing might boost performance when there are many small meshes; it isn't recommended for very large meshes.- Parameters:
maxVertices
- the largest mesh to be indexed (vertex count, ≥-1, default=6000)
-
volumeConvex
Calculate the volume of a debug mesh for the specified convex shape. The shape's scale and margin are taken into account, but not its debug-mesh resolution.- Parameters:
shape
- the convex shape to analyze (not null, unaffected)meshResolution
- 0→low, 1→high for convex shapes, 2→high for all shapes- Returns:
- the scaled volume (in physics-space units cubed, ≥0)
-