MinieLibrary/src/main/java/com/jme3/bullet/util/DebugShapeFactory.java
/**
     * Create a Mesh for visualizing the specified PlaneCollisionShape.
     *
     * @param shape (not null, unaffected)
     * @param normals which normals to generate (not null)
     * @return a new, indexed, Triangles-mode Mesh
     */
Create a Mesh for visualizing the specified PlaneCollisionShape.
@param shape (not null, unaffected)
@param normals which normals to generate (not null)
@return a new, indexed, Triangles-mode Mesh
Create a Mesh for visualizing the specified PlaneCollisionShape . @param shape ( not null unaffected ) @param normals which normals to generate ( not null ) @return a new indexed Triangles - mode Mesh
private static Mesh createPlaneMesh(PlaneCollisionShape shape,
            DebugMeshNormals normals) {
        /*
         * Generate mesh positions for a large 2-sided square.
         */
        int numVertices = 8; 
        int numFloats = numVertices * numAxes;
        FloatBuffer posBuffer = BufferUtils.createFloatBuffer(numFloats);
        for (int sideIndex = 0; sideIndex < 2; ++sideIndex) {
            posBuffer.put(new float[]{
                0f, 0f, 1f,
                0f, 1f, 0f,
                0f, 0f, -1f,
                0f, -1f, 0f
            });
        }
        assert posBuffer.position() == numFloats;
        posBuffer.flip();
        /*
         * Transform mesh positions to the surface of the CollisionShape.
         */
        Transform transform = planeTransform(shape);
        float scale = meshSideLength() / root2;
        transform.setScale(scale);
        MyBuffer.transform(posBuffer, 0, numFloats, transform);
        /*
         * Generate an index buffer for a 2-sided square.
         */
        ByteBuffer indexBuffer = BufferUtils.createByteBuffer(new byte[]{
            2, 1, 0,
            3, 2, 0,
            5, 6, 7,
            4, 5, 7});
        indexBuffer.clear();
        Mesh result = new Mesh();
        result.setBuffer(VertexBuffer.Type.Position, numAxes, posBuffer);
        result.setBuffer(VertexBuffer.Type.Index, MyMesh.vpt, indexBuffer);
        /*
         * Add a normal buffer, if requested.
         */
        if (normals != DebugMeshNormals.None) {
            Plane plane = shape.getPlane();
            Vector3f v1 = plane.getNormal();
            FloatBuffer normBuffer = BufferUtils.createFloatBuffer(numFloats);
            for (int i = 0; i < 4; ++i) {
                normBuffer.put(v1.x).put(v1.y).put(v1.z);
            }
            for (int i = 0; i < 4; ++i) {
                normBuffer.put(-v1.x).put(-v1.y).put(-v1.z);
            }
            normBuffer.flip();
            result.setBuffer(VertexBuffer.Type.Normal, numAxes, normBuffer);
        }
        result.updateBound();
        result.setStatic();
        return result;
    }
private static Mesh createPlaneMesh ( PlaneCollisionShape shape , DebugMeshNormals normals ) { /*
         * Generate mesh positions for a large 2-sided square.
         */ int numVertices = 8 ; int numFloats = numVertices * numAxes ; FloatBuffer posBuffer = BufferUtils . createFloatBuffer ( numFloats ) ; for ( int sideIndex = 0 ; sideIndex < 2 ; ++ sideIndex ) { posBuffer . put ( new float [ ] { 0f , 0f , 1f , 0f , 1f , 0f , 0f , 0f , - 1f , 0f , - 1f , 0f } ) ; } assert posBuffer . position ( ) == numFloats ; posBuffer . flip ( ) ; /*
         * Transform mesh positions to the surface of the CollisionShape.
         */ Transform transform = planeTransform ( shape ) ; float scale = meshSideLength ( ) / root2 ; transform . setScale ( scale ) ; MyBuffer . transform ( posBuffer , 0 , numFloats , transform ) ; /*
         * Generate an index buffer for a 2-sided square.
         */ ByteBuffer indexBuffer = BufferUtils . createByteBuffer ( new byte [ ] { 2 , 1 , 0 , 3 , 2 , 0 , 5 , 6 , 7 , 4 , 5 , 7 } ) ; indexBuffer . clear ( ) ; Mesh result = new Mesh ( ) ; result . setBuffer ( VertexBuffer . Type . Position , numAxes , posBuffer ) ; result . setBuffer ( VertexBuffer . Type . Index , MyMesh . vpt , indexBuffer ) ; /*
         * Add a normal buffer, if requested.
         */ if ( normals != DebugMeshNormals . None ) { Plane plane = shape . getPlane ( ) ; Vector3f v1 = plane . getNormal ( ) ; FloatBuffer normBuffer = BufferUtils . createFloatBuffer ( numFloats ) ; for ( int i = 0 ; i < 4 ; ++ i ) { normBuffer . put ( v1 . x ) . put ( v1 . y ) . put ( v1 . z ) ; } for ( int i = 0 ; i < 4 ; ++ i ) { normBuffer . put ( - v1 . x ) . put ( - v1 . y ) . put ( - v1 . z ) ; } normBuffer . flip ( ) ; result . setBuffer ( VertexBuffer . Type . Normal , numAxes , normBuffer ) ; } result . updateBound ( ) ; result . setStatic ( ) ; return result ; }
Create a Mesh for visualizing the specified PlaneCollisionShape.
Create a Mesh for visualizing the specified PlaneCollisionShape .
// 4 vertices for each size