MinieExamples/src/main/java/jme3utilities/minie/test/TestSoftBody.java
/**
     * Add a square tablecloth to the scene.
     */
Add a square tablecloth to the scene.
Add a square tablecloth to the scene .
private void addTablecloth(float startY) {
        int numLines = 40;
        float spacing = 0.08f;
        Mesh mesh = new ClothGrid(numLines, numLines, spacing);
        PhysicsSoftBody softBody = new PhysicsSoftBody();
        NativeSoftBodyUtil.appendFromTriMesh(mesh, softBody);
        softBody.setMass(mass);
        SoftBodyConfig config = softBody.getSoftConfig();
        config.set(Sbcp.Damping, 0.02f);
        config.setPositionIterations(3);
        SoftBodyMaterial material = softBody.getSoftMaterial();
        material.setAngularStiffness(0f);
        Material plaidMaterial = findMaterial("plaid");
        softBody.setDebugMaterial(plaidMaterial);
        softBody.setDebugMeshInitListener(tableclothDmiListener);
        softBody.setDebugMeshNormals(DebugMeshNormals.Smooth);
        Vector3f translation = new Vector3f(0f, startY, 0f);
        softBody.applyTranslation(translation);
        physicsSpace.addCollisionObject(softBody);
    }
private void addTablecloth ( float startY ) { int numLines = 40 ; float spacing = 0.08f ; Mesh mesh = new ClothGrid ( numLines , numLines , spacing ) ; PhysicsSoftBody softBody = new PhysicsSoftBody ( ) ; NativeSoftBodyUtil . appendFromTriMesh ( mesh , softBody ) ; softBody . setMass ( mass ) ; SoftBodyConfig config = softBody . getSoftConfig ( ) ; config . set ( Sbcp . Damping , 0.02f ) ; config . setPositionIterations ( 3 ) ; SoftBodyMaterial material = softBody . getSoftMaterial ( ) ; material . setAngularStiffness ( 0f ) ; Material plaidMaterial = findMaterial ( "plaid" ) ; softBody . setDebugMaterial ( plaidMaterial ) ; softBody . setDebugMeshInitListener ( tableclothDmiListener ) ; softBody . setDebugMeshNormals ( DebugMeshNormals . Smooth ) ; Vector3f translation = new Vector3f ( 0f , startY , 0f ) ; softBody . applyTranslation ( translation ) ; physicsSpace . addCollisionObject ( softBody ) ; }
Add a square tablecloth to the scene.
Add a square tablecloth to the scene .