MinieExamples/src/main/java/jme3utilities/minie/test/TrackDemo.java
/**
     * Initialization that takes place once all links are ready for dynamic
     * mode.
     */
Initialization that takes place once all links are ready for dynamic
mode.
Initialization that takes place once all links are ready for dynamic mode .
private void initWhenReady() {
        /*
         * Touch the tip vertex to the target.
         */
        Vector3f pivot = new Vector3f();
        tipLink = dac.findManagerForVertex(tipSpec, null, pivot);
        dac.setMass(tipLink, 100f);
        dac.setDynamicChain(tipLink, chainLength, Vector3f.ZERO, false);
        IKJoint ikJoint
                = dac.moveToBody(tipLink, pivot, targetBody, Vector3f.ZERO);
        tipJoint = ikJoint.getPhysicsJoint();
        tipJoint.setEnabled(false);
        /*
         * The face and neck track the target.
         */
        Face face = (Face) dac;
        Vector3f faceDirection = face.faceDirection(null);
        String noseSpec = face.faceCenterSpec();
        PhysicsLink noseLink = dac.findManagerForVertex(noseSpec, null, pivot);
        noseLink.setDynamic(Vector3f.ZERO);
        watch = new TrackController(noseLink, pivot, faceDirection, targetBody);
        noseLink.addIKController(watch);
        watch.setDeltaGainFactor(1.2f);
        watch.setEnabled(false);
        watch.setErrorGainFactor(0.3f);
        /*
         * If the model's eyes are animated, each eye also tracks the target.
         */
        if (dac instanceof Binocular) {
            Binocular binocular = (Binocular) dac;
            /*
             * left eye
             */
            String spec = binocular.leftPupilSpec();
            PhysicsLink link = dac.findManagerForVertex(spec, null, pivot);
            link.setDynamic(Vector3f.ZERO);
            Vector3f lookDirection = binocular.leftEyeLookDirection(null);
            leftWatch = new TrackController(link, pivot, lookDirection,
                    targetBody);
            link.addIKController(leftWatch);
            leftWatch.setDeltaGainFactor(4f);
            leftWatch.setEnabled(false);
            leftWatch.setErrorGainFactor(1f);
            /*
             * right eye
             */
            spec = binocular.rightPupilSpec();
            link = dac.findManagerForVertex(spec, null, pivot);
            link.setDynamic(Vector3f.ZERO);
            binocular.leftEyeLookDirection(lookDirection);
            rightWatch = new TrackController(link, pivot, lookDirection,
                    targetBody);
            link.addIKController(rightWatch);
            rightWatch.setDeltaGainFactor(4f);
            rightWatch.setEnabled(false);
            rightWatch.setErrorGainFactor(1f);
        }
    }
private void initWhenReady ( ) { /*
         * Touch the tip vertex to the target.
         */ Vector3f pivot = new Vector3f ( ) ; tipLink = dac . findManagerForVertex ( tipSpec , null , pivot ) ; dac . setMass ( tipLink , 100f ) ; dac . setDynamicChain ( tipLink , chainLength , Vector3f . ZERO , false ) ; IKJoint ikJoint = dac . moveToBody ( tipLink , pivot , targetBody , Vector3f . ZERO ) ; tipJoint = ikJoint . getPhysicsJoint ( ) ; tipJoint . setEnabled ( false ) ; /*
         * The face and neck track the target.
         */ Face face = ( Face ) dac ; Vector3f faceDirection = face . faceDirection ( null ) ; String noseSpec = face . faceCenterSpec ( ) ; PhysicsLink noseLink = dac . findManagerForVertex ( noseSpec , null , pivot ) ; noseLink . setDynamic ( Vector3f . ZERO ) ; watch = new TrackController ( noseLink , pivot , faceDirection , targetBody ) ; noseLink . addIKController ( watch ) ; watch . setDeltaGainFactor ( 1.2f ) ; watch . setEnabled ( false ) ; watch . setErrorGainFactor ( 0.3f ) ; /*
         * If the model's eyes are animated, each eye also tracks the target.
         */ if ( dac instanceof Binocular ) { Binocular binocular = ( Binocular ) dac ; /*
             * left eye
             */ String spec = binocular . leftPupilSpec ( ) ; PhysicsLink link = dac . findManagerForVertex ( spec , null , pivot ) ; link . setDynamic ( Vector3f . ZERO ) ; Vector3f lookDirection = binocular . leftEyeLookDirection ( null ) ; leftWatch = new TrackController ( link , pivot , lookDirection , targetBody ) ; link . addIKController ( leftWatch ) ; leftWatch . setDeltaGainFactor ( 4f ) ; leftWatch . setEnabled ( false ) ; leftWatch . setErrorGainFactor ( 1f ) ; /*
             * right eye
             */ spec = binocular . rightPupilSpec ( ) ; link = dac . findManagerForVertex ( spec , null , pivot ) ; link . setDynamic ( Vector3f . ZERO ) ; binocular . leftEyeLookDirection ( lookDirection ) ; rightWatch = new TrackController ( link , pivot , lookDirection , targetBody ) ; link . addIKController ( rightWatch ) ; rightWatch . setDeltaGainFactor ( 4f ) ; rightWatch . setEnabled ( false ) ; rightWatch . setErrorGainFactor ( 1f ) ; } }
Initialization that takes place once all links are ready for dynamic
 mode.
Initialization that takes place once all links are ready for dynamic mode .