MinieExamples/src/main/java/jme3utilities/minie/test/TestDac.java
/**
     * Add an animated model to the scene, removing any previously added model.
     *
     * @param modelName the name of the model to add (not null, not empty)
     */
Add an animated model to the scene, removing any previously added model.

@param modelName the name of the model to add (not null, not empty)
Add an animated model to the scene removing any previously added model . @param modelName the name of the model to add ( not null not empty )
private void addModel(String modelName) {
        if (cgModel != null) {
            dac.getSpatial().removeControl(dac);
            rootNode.detachChild(cgModel);
            rootNode.removeControl(sv);
            removeAllBalls();
        }
        switch (modelName) {
            case "BaseMesh":
                loadBaseMesh();
                break;
            case "Elephant":
                loadElephant();
                break;
            case "Jaime":
                loadJaime();
                break;
            case "MhGame":
                loadMhGame();
                break;
            case "Ninja":
                loadNinja();
                break;
            case "Oto":
                loadOto();
                break;
            case "Puppet":
                loadPuppet();
                break;
            case "Sinbad":
                loadSinbad();
                break;
            case "SinbadWith1Sword":
                loadSinbadWith1Sword();
                break;
            case "SinbadWithSwords":
                loadSinbadWithSwords();
                break;
            default:
                throw new IllegalArgumentException(modelName);
        }
        testName = modelName;
        animPose = null;
        List<Spatial> list = MySpatial.listSpatials(cgModel);
        for (Spatial spatial : list) {
            spatial.setShadowMode(RenderQueue.ShadowMode.Cast);
        }
        cgModel.setCullHint(Spatial.CullHint.Never);
        rootNode.attachChild(cgModel);
        setCgmHeight(cgModel, 10f);
        centerCgm(cgModel);
        resetTransform = cgModel.getLocalTransform().clone();
        sc = (SkinningControl) RagUtils.findSControl(cgModel);
        Spatial controlledSpatial = sc.getSpatial();
        controlledSpatial.addControl(dac);
        dac.setGravity(new Vector3f(0f, -50f, 0f));
        PhysicsSpace physicsSpace = getPhysicsSpace();
        dac.setPhysicsSpace(physicsSpace);
        leftClavicle = dac.findBoneLink(leftClavicleName);
        if (dac instanceof Biped) {
            BoneLink leftFoot = ((Biped) dac).getLeftFoot();
            leftFemur = leftFoot;
            while (leftFemur.getParent() instanceof BoneLink) {
                leftFemur = (BoneLink) leftFemur.getParent();
            }
            BoneLink rightFoot = ((Biped) dac).getRightFoot();
            rightFemur = rightFoot;
            while (rightFemur.getParent() instanceof BoneLink) {
                rightFemur = (BoneLink) rightFemur.getParent();
            }
        } else if (dac instanceof ElephantControl) {
            leftFemur = dac.findBoneLink("Oberschenkel_B_L");
            rightFemur = dac.findBoneLink("Oberschenkel_B_R");
        }
        leftUlna = dac.findBoneLink(leftUlnaName);
        rightClavicle = dac.findBoneLink(rightClavicleName);
        upperBody = dac.findBoneLink(upperBodyName);
        AnimComposer composer
                = controlledSpatial.getControl(AnimComposer.class);
        composer.setCurrentAction(animationName);
        sv = new SkeletonVisualizer(assetManager, sc);
        sv.setLineColor(ColorRGBA.Yellow);
        InfluenceUtil.hideNonInfluencers(sv, sc);
        rootNode.addControl(sv);
    }
private void addModel ( String modelName ) { if ( cgModel != null ) { dac . getSpatial ( ) . removeControl ( dac ) ; rootNode . detachChild ( cgModel ) ; rootNode . removeControl ( sv ) ; removeAllBalls ( ) ; } switch ( modelName ) { case "BaseMesh" : loadBaseMesh ( ) ; break ; case "Elephant" : loadElephant ( ) ; break ; case "Jaime" : loadJaime ( ) ; break ; case "MhGame" : loadMhGame ( ) ; break ; case "Ninja" : loadNinja ( ) ; break ; case "Oto" : loadOto ( ) ; break ; case "Puppet" : loadPuppet ( ) ; break ; case "Sinbad" : loadSinbad ( ) ; break ; case "SinbadWith1Sword" : loadSinbadWith1Sword ( ) ; break ; case "SinbadWithSwords" : loadSinbadWithSwords ( ) ; break ; default : throw new IllegalArgumentException ( modelName ) ; } testName = modelName ; animPose = null ; List < Spatial > list = MySpatial . listSpatials ( cgModel ) ; for ( Spatial spatial : list ) { spatial . setShadowMode ( RenderQueue . ShadowMode . Cast ) ; } cgModel . setCullHint ( Spatial . CullHint . Never ) ; rootNode . attachChild ( cgModel ) ; setCgmHeight ( cgModel , 10f ) ; centerCgm ( cgModel ) ; resetTransform = cgModel . getLocalTransform ( ) . clone ( ) ; sc = ( SkinningControl ) RagUtils . findSControl ( cgModel ) ; Spatial controlledSpatial = sc . getSpatial ( ) ; controlledSpatial . addControl ( dac ) ; dac . setGravity ( new Vector3f ( 0f , - 50f , 0f ) ) ; PhysicsSpace physicsSpace = getPhysicsSpace ( ) ; dac . setPhysicsSpace ( physicsSpace ) ; leftClavicle = dac . findBoneLink ( leftClavicleName ) ; if ( dac instanceof Biped ) { BoneLink leftFoot = ( ( Biped ) dac ) . getLeftFoot ( ) ; leftFemur = leftFoot ; while ( leftFemur . getParent ( ) instanceof BoneLink ) { leftFemur = ( BoneLink ) leftFemur . getParent ( ) ; } BoneLink rightFoot = ( ( Biped ) dac ) . getRightFoot ( ) ; rightFemur = rightFoot ; while ( rightFemur . getParent ( ) instanceof BoneLink ) { rightFemur = ( BoneLink ) rightFemur . getParent ( ) ; } } else if ( dac instanceof ElephantControl ) { leftFemur = dac . findBoneLink ( "Oberschenkel_B_L" ) ; rightFemur = dac . findBoneLink ( "Oberschenkel_B_R" ) ; } leftUlna = dac . findBoneLink ( leftUlnaName ) ; rightClavicle = dac . findBoneLink ( rightClavicleName ) ; upperBody = dac . findBoneLink ( upperBodyName ) ; AnimComposer composer = controlledSpatial . getControl ( AnimComposer . class ) ; composer . setCurrentAction ( animationName ) ; sv = new SkeletonVisualizer ( assetManager , sc ) ; sv . setLineColor ( ColorRGBA . Yellow ) ; InfluenceUtil . hideNonInfluencers ( sv , sc ) ; rootNode . addControl ( sv ) ; }
Add an animated model to the scene, removing any previously added model.
Add an animated model to the scene removing any previously added model .