MinieExamples/src/main/java/jme3utilities/minie/test/TestSoftBody.java
/**
     * Add a wraparound skirt to the specified Puppet model.
     *
     * @param puppetDac the model's physics control (not null)
     */
Add a wraparound skirt to the specified Puppet model.

@param puppetDac the model's physics control (not null)
Add a wraparound skirt to the specified Puppet model . @param puppetDac the model ' s physics control ( not null )
private void addSkirt(DynamicAnimControl puppetDac) {
        int numSubdiv = 5;
        int numAnchors = 51;
        float length = 0.57f;
        Vector3f[] anchorLocs = new Vector3f[numAnchors];
        for (int zIndex = 0; zIndex < numAnchors; ++zIndex) {
            anchorLocs[zIndex] = new Vector3f();
        }
        Mesh mesh = createSkirtMesh(puppetDac, numSubdiv, length, anchorLocs);
        /*
         * Create and configure the soft body.
         */
        PhysicsSoftBody skirtPsb = new PhysicsSoftBody();
        NativeSoftBodyUtil.appendFromTriMesh(mesh, skirtPsb);
        skirtPsb.setMargin(0.1f);
        skirtPsb.setMass(0.02f);
        SoftBodyConfig config = skirtPsb.getSoftConfig();
        config.set(Sbcp.AnchorHardness, 1f);
        config.set(Sbcp.KineticHardness, 1f);
        config.setPositionIterations(6);
        SoftBodyMaterial material = skirtPsb.getSoftMaterial();
        material.setAngularStiffness(0f);
        material.setLinearStiffness(0.5f);
        Material redMaterial = findMaterial("red");
        skirtPsb.setDebugMaterial(redMaterial);
        skirtPsb.setDebugMeshNormals(DebugMeshNormals.Smooth);
        String vSpec0 = puppetVSpec(0);
        PhysicsLink link = puppetDac.findManagerForVertex(vSpec0, null, null);
        Transform localToWorld = link.physicsTransform(null);
        skirtPsb.applyTransform(localToWorld);
        physicsSpace.addCollisionObject(skirtPsb);
        skirtPsb.setGravity(new Vector3f(0f, -10f, 0f));
        /*
         * Add anchors that join Puppet to her skirt.
         */
        PhysicsRigidBody rigid = link.getRigidBody();
        boolean allowCollisions = true;
        for (int anchorIndex = 0; anchorIndex < numAnchors; ++anchorIndex) {
            Vector3f location = anchorLocs[anchorIndex];
            Anchor anchor = new Anchor(skirtPsb, anchorIndex, rigid, location,
                    allowCollisions);
            physicsSpace.addJoint(anchor);
        }
    }
private void addSkirt ( DynamicAnimControl puppetDac ) { int numSubdiv = 5 ; int numAnchors = 51 ; float length = 0.57f ; Vector3f [ ] anchorLocs = new Vector3f [ numAnchors ] ; for ( int zIndex = 0 ; zIndex < numAnchors ; ++ zIndex ) { anchorLocs [ zIndex ] = new Vector3f ( ) ; } Mesh mesh = createSkirtMesh ( puppetDac , numSubdiv , length , anchorLocs ) ; /*
         * Create and configure the soft body.
         */ PhysicsSoftBody skirtPsb = new PhysicsSoftBody ( ) ; NativeSoftBodyUtil . appendFromTriMesh ( mesh , skirtPsb ) ; skirtPsb . setMargin ( 0.1f ) ; skirtPsb . setMass ( 0.02f ) ; SoftBodyConfig config = skirtPsb . getSoftConfig ( ) ; config . set ( Sbcp . AnchorHardness , 1f ) ; config . set ( Sbcp . KineticHardness , 1f ) ; config . setPositionIterations ( 6 ) ; SoftBodyMaterial material = skirtPsb . getSoftMaterial ( ) ; material . setAngularStiffness ( 0f ) ; material . setLinearStiffness ( 0.5f ) ; Material redMaterial = findMaterial ( "red" ) ; skirtPsb . setDebugMaterial ( redMaterial ) ; skirtPsb . setDebugMeshNormals ( DebugMeshNormals . Smooth ) ; String vSpec0 = puppetVSpec ( 0 ) ; PhysicsLink link = puppetDac . findManagerForVertex ( vSpec0 , null , null ) ; Transform localToWorld = link . physicsTransform ( null ) ; skirtPsb . applyTransform ( localToWorld ) ; physicsSpace . addCollisionObject ( skirtPsb ) ; skirtPsb . setGravity ( new Vector3f ( 0f , - 10f , 0f ) ) ; /*
         * Add anchors that join Puppet to her skirt.
         */ PhysicsRigidBody rigid = link . getRigidBody ( ) ; boolean allowCollisions = true ; for ( int anchorIndex = 0 ; anchorIndex < numAnchors ; ++ anchorIndex ) { Vector3f location = anchorLocs [ anchorIndex ] ; Anchor anchor = new Anchor ( skirtPsb , anchorIndex , rigid , location , allowCollisions ) ; physicsSpace . addJoint ( anchor ) ; } }
Add a wraparound skirt to the specified Puppet model.
Add a wraparound skirt to the specified Puppet model .