MinieExamples/src/main/java/jme3utilities/minie/test/RopeDemo.java
/**
     * Generate an Armature composed of straight-line branches originating from
     * the root joint.
     *
     * @param branchToNumSteps the number of joints in each branch (each &ge;1)
     * @param branchToStepOffsets the parent-to-child offset in each branch
     * @return a new Armature in bind pose (not null)
     */
Generate an Armature composed of straight-line branches originating from
the root joint.

@param branchToNumSteps the number of joints in each branch (each ≥1)
@param branchToStepOffsets the parent-to-child offset in each branch
@return a new Armature in bind pose (not null)
Generate an Armature composed of straight - line branches originating from the root joint . @param branchToNumSteps the number of joints in each branch ( each ≥1 ) @param branchToStepOffsets the parent - to - child offset in each branch @return a new Armature in bind pose ( not null )
private Armature makeArmature(int[] branchToNumSteps,
            Vector3f[] branchToStepOffsets) {
        assert branchToNumSteps.length > 0;
        assert branchToNumSteps.length == branchToStepOffsets.length;
        int numJoints = 1;
        for (int numSteps : branchToNumSteps) {
            assert numSteps >= 1 : numSteps;
            numJoints += numSteps;
        }
        Joint[] joints = new Joint[numJoints];
        Joint root = new Joint("root joint");
        joints[0] = root;
        int nextJointIndex = 1;
        int numBranches = branchToNumSteps.length;
        for (int branchIndex = 0; branchIndex < numBranches; ++branchIndex) {
            Joint parent = root;
            Vector3f stepOffset = branchToStepOffsets[branchIndex];
            int numSteps = branchToNumSteps[branchIndex];
            for (int stepIndex = 0; stepIndex < numSteps; ++stepIndex) {
                String jointName = jointName(branchIndex, stepIndex);
                Joint joint = new Joint(jointName);
                joint.setLocalTranslation(stepOffset);
                joints[nextJointIndex] = joint;
                parent.addChild(joint);
                parent = joint;
                ++nextJointIndex;
            }
        }
        assert nextJointIndex == numJoints;
        Armature armature = new Armature(joints);
        armature.saveBindPose();
        return armature;
    }
private Armature makeArmature ( int [ ] branchToNumSteps , Vector3f [ ] branchToStepOffsets ) { assert branchToNumSteps . length > 0 ; assert branchToNumSteps . length == branchToStepOffsets . length ; int numJoints = 1 ; for ( int numSteps : branchToNumSteps ) { assert numSteps >= 1 : numSteps ; numJoints += numSteps ; } Joint [ ] joints = new Joint [ numJoints ] ; Joint root = new Joint ( "root joint" ) ; joints [ 0 ] = root ; int nextJointIndex = 1 ; int numBranches = branchToNumSteps . length ; for ( int branchIndex = 0 ; branchIndex < numBranches ; ++ branchIndex ) { Joint parent = root ; Vector3f stepOffset = branchToStepOffsets [ branchIndex ] ; int numSteps = branchToNumSteps [ branchIndex ] ; for ( int stepIndex = 0 ; stepIndex < numSteps ; ++ stepIndex ) { String jointName = jointName ( branchIndex , stepIndex ) ; Joint joint = new Joint ( jointName ) ; joint . setLocalTranslation ( stepOffset ) ; joints [ nextJointIndex ] = joint ; parent . addChild ( joint ) ; parent = joint ; ++ nextJointIndex ; } } assert nextJointIndex == numJoints ; Armature armature = new Armature ( joints ) ; armature . saveBindPose ( ) ; return armature ; }
Generate an Armature composed of straight-line branches originating from
 the root joint.
Generate an Armature composed of straight - line branches originating from the root joint .