DacWizard/src/main/java/jme3utilities/minie/wizard/TestMode.java
/**
     * Write the control configuration to a stream, as Java source code.
     *
     * @param dac a configured control to use as a model (not null, unaffected)
     * @param stream the output stream (not null)
     */
Write the control configuration to a stream, as Java source code.

@param dac a configured control to use as a model (not null, unaffected)
@param stream the output stream (not null)
Write the control configuration to a stream as Java source code . @param dac a configured control to use as a model ( not null unaffected ) @param stream the output stream ( not null )
private void write(DynamicAnimControl dac, PrintStream stream) {
        stream.printf("import com.jme3.bullet.animation.CenterHeuristic;%n"
                + "import com.jme3.bullet.animation.DynamicAnimControl;%n"
                + "import com.jme3.bullet.animation.LinkConfig;%n"
                + "import com.jme3.bullet.animation.MassHeuristic;%n"
                + "import com.jme3.bullet.animation.RangeOfMotion;%n"
                + "import com.jme3.bullet.animation.ShapeHeuristic;%n"
                + "import com.jme3.math.Vector3f;%n%n");
        stream.printf("public class WControl extends DynamicAnimControl {%n%n"
                + "    public WControl() {%n"
                + "        super();%n");
        String[] lbNames = dac.listLinkedBoneNames();
        String torsoName = DacConfiguration.torsoName;
        /*
         * Write each unique LinkConfig.
         */
        int nextConfigIndex = 1;
        Map<LinkConfig, Integer> configs = new TreeMap<>();
        LinkConfig config = dac.config(torsoName);
        if (!configs.containsKey(config)) {
            configs.put(config, nextConfigIndex);
            writeConfig(config, nextConfigIndex, stream);
            ++nextConfigIndex;
        }
        for (String lbName : lbNames) {
            config = dac.config(lbName);
            if (!configs.containsKey(config)) {
                configs.put(config, nextConfigIndex);
                writeConfig(config, nextConfigIndex, stream);
                ++nextConfigIndex;
            }
        }
        /*
         * Configure the torso of the ragdoll.
         */
        config = dac.config(torsoName);
        int configIndex = configs.get(config);
        String code = String.format("        super.setConfig(%s, config%d);%n",
                MyString.quote(torsoName), configIndex);
        stream.print(code);
        /*
         * Configure each linked bone in the ragdoll.
         */
        for (String lbName : lbNames) {
            config = dac.config(lbName);
            configIndex = configs.get(config);
            RangeOfMotion range = dac.getJointLimits(lbName);
            float maxX = range.getMaxRotation(PhysicsSpace.AXIS_X);
            String maxXString = describeAngle(maxX);
            float minX = range.getMinRotation(PhysicsSpace.AXIS_X);
            String minXString = describeAngle(minX);
            float maxY = range.getMaxRotation(PhysicsSpace.AXIS_Y);
            String maxYString = describeAngle(maxY);
            float minY = range.getMinRotation(PhysicsSpace.AXIS_Y);
            String minYString = describeAngle(minY);
            float maxZ = range.getMaxRotation(PhysicsSpace.AXIS_Z);
            String maxZString = describeAngle(maxZ);
            float minZ = range.getMinRotation(PhysicsSpace.AXIS_Z);
            String minZString = describeAngle(minZ);
            String newRange = String.format("new RangeOfMotion("
                    + "%sf, %sf, %sf, %sf, %sf, %sf)",
                    maxXString, minXString,
                    maxYString, minYString,
                    maxZString, minZString);
            code = String.format("        super.link(%s, config%d,%n"
                    + "                %s);%n",
                    MyString.quote(lbName), configIndex, newRange);
            stream.print(code);
        }
        stream.printf("    }%n}%n");
    }
private void write ( DynamicAnimControl dac , PrintStream stream ) { stream . printf ( "import com.jme3.bullet.animation.CenterHeuristic;%n" + "import com.jme3.bullet.animation.DynamicAnimControl;%n" + "import com.jme3.bullet.animation.LinkConfig;%n" + "import com.jme3.bullet.animation.MassHeuristic;%n" + "import com.jme3.bullet.animation.RangeOfMotion;%n" + "import com.jme3.bullet.animation.ShapeHeuristic;%n" + "import com.jme3.math.Vector3f;%n%n" ) ; stream . printf ( "public class WControl extends DynamicAnimControl {%n%n" + "    public WControl() {%n" + "        super();%n" ) ; String [ ] lbNames = dac . listLinkedBoneNames ( ) ; String torsoName = DacConfiguration . torsoName ; /*
         * Write each unique LinkConfig.
         */ int nextConfigIndex = 1 ; Map < LinkConfig , Integer > configs = new TreeMap < > ( ) ; LinkConfig config = dac . config ( torsoName ) ; if ( ! configs . containsKey ( config ) ) { configs . put ( config , nextConfigIndex ) ; writeConfig ( config , nextConfigIndex , stream ) ; ++ nextConfigIndex ; } for ( String lbName : lbNames ) { config = dac . config ( lbName ) ; if ( ! configs . containsKey ( config ) ) { configs . put ( config , nextConfigIndex ) ; writeConfig ( config , nextConfigIndex , stream ) ; ++ nextConfigIndex ; } } /*
         * Configure the torso of the ragdoll.
         */ config = dac . config ( torsoName ) ; int configIndex = configs . get ( config ) ; String code = String . format ( "        super.setConfig(%s, config%d);%n" , MyString . quote ( torsoName ) , configIndex ) ; stream . print ( code ) ; /*
         * Configure each linked bone in the ragdoll.
         */ for ( String lbName : lbNames ) { config = dac . config ( lbName ) ; configIndex = configs . get ( config ) ; RangeOfMotion range = dac . getJointLimits ( lbName ) ; float maxX = range . getMaxRotation ( PhysicsSpace . AXIS_X ) ; String maxXString = describeAngle ( maxX ) ; float minX = range . getMinRotation ( PhysicsSpace . AXIS_X ) ; String minXString = describeAngle ( minX ) ; float maxY = range . getMaxRotation ( PhysicsSpace . AXIS_Y ) ; String maxYString = describeAngle ( maxY ) ; float minY = range . getMinRotation ( PhysicsSpace . AXIS_Y ) ; String minYString = describeAngle ( minY ) ; float maxZ = range . getMaxRotation ( PhysicsSpace . AXIS_Z ) ; String maxZString = describeAngle ( maxZ ) ; float minZ = range . getMinRotation ( PhysicsSpace . AXIS_Z ) ; String minZString = describeAngle ( minZ ) ; String newRange = String . format ( "new RangeOfMotion(" + "%sf, %sf, %sf, %sf, %sf, %sf)" , maxXString , minXString , maxYString , minYString , maxZString , minZString ) ; code = String . format ( "        super.link(%s, config%d,%n" + "                %s);%n" , MyString . quote ( lbName ) , configIndex , newRange ) ; stream . print ( code ) ; } stream . printf ( "    }%n}%n" ) ; }
Write the control configuration to a stream, as Java source code.
Write the control configuration to a stream as Java source code .