[SOLVED] AnimControl getControl Problem

Hi,

I have a Problem with the Node.getControl method it does not set the AnimControl. What am I doing wrong? This is the code (Problem in Line 70):

package mygame;

import com.jme3.animation.AnimChannel;
import com.jme3.animation.AnimControl;
import com.jme3.app.SimpleApplication;
import com.jme3.light.PointLight;
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector3f;
import com.jme3.renderer.Camera;
import com.jme3.renderer.RenderManager;
import com.jme3.scene.Geometry;
import com.jme3.scene.Node;
import com.jme3.scene.Spatial;
import com.jme3.scene.shape.Box;
import com.jme3.system.AppSettings;
import com.jme3.system.JmeCanvasContext;
import java.awt.Dimension;
import java.awt.FlowLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;

public class Main extends SimpleApplication
{
    AnimControl kontrolle;
    AnimChannel kanal;

    public static void main(String[] args)
    {
        java.awt.EventQueue.invokeLater(new Runnable()
        {
            @Override
            public void run()
            {
                AppSettings settings = new AppSettings(true);
                settings.setWidth(640);
                settings.setHeight(480);
                
                Main canvasApplication = new Main();
                canvasApplication.setSettings(settings);
                canvasApplication.createCanvas(); // create canvas!
                JmeCanvasContext ctx = (JmeCanvasContext) canvasApplication.getContext();
                ctx.setSystemListener(canvasApplication);
                Dimension dim = new Dimension(640, 480);
                ctx.getCanvas().setPreferredSize(dim);
                
                JFrame window = new JFrame("Swing Application");
                window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                JButton test = new JButton("Hallo");
                test.setBounds(0, 0, 200, 50);
                
                window.add(test);
                window.add(ctx.getCanvas());
                window.setSize(640, 480);
                window.setVisible(true);
                
                canvasApplication.startCanvas();
            }
        });
    }
                
    @Override
    public void simpleInitApp()
    {
        flyCam.setDragToRotate(true);
                
        Node testObjekt = (Node)assetManager.loadModel("Textures/testObjekt/testObjekt.j3o");
        testObjekt.setLocalScale(1f);
        kontrolle = testObjekt.getControl(AnimControl.class);
        System.out.println(kontrolle);
        kanal = kontrolle.createChannel();
        
        //System.out.println(kanal.getAnimationName());
        //kanal.setAnim("");
        PointLight licht = new PointLight(new Vector3f(0.5f, 2, 1), new ColorRGBA(1, 1, 1, 1), 10);
        

        rootNode.attachChild(testObjekt);
        rootNode.addLight(licht);
        
    }

    @Override
    public void simpleUpdate(float tpf)
    {
        //TODO: add update code
    }

    @Override
    public void simpleRender(RenderManager rm)
    {
        //TODO: add render code
    }
}

3.3+ version of JME use AnimComposer instead AnimControl class (models converted using 3.3 version)

First for the future (or if you want to edit your post): How to type code blocks

Second, what oxplay says is true but it also could be that the control is not on the node but on one of the children. We’d have to know more information about JME version, where you got the j3o file, etc… We don’t even really have enough information to know if it should have an animation control.

well I use the 3.3.2 sdk.
I tried to do it like in the Tutorial

is there a Tutorial on using AnimComposer as well?

i think that Wiki you linked is confusing, because Test Model it uses probably have old Control class in it. @mitm i thought 3.3 wiki use new Animation class in it. seems like it didnt.

@Dares see links:

and other files inside:

You can open it in SDK by New Project → JME → JME Tests project → Run → search for animation test

it works,
thank you

2 Likes

It requires someone who uses the new system to write about it. I have not used it but I am saving forum posts about it so I can gather it all together into something that makes sense once I do.

As the wiki is open to anyone, anyone can freely contribute, but that has not happened yet. So here we are.

I don’t have the time right now to do anything for a short while to come.

1 Like

thanks for info, currently having mind in networking topic, but if noone will do it, i will try myself make some pull request. (just hope we had some GLTF model in test-repo there)

There is a duck gltf on engine site in testdata believe. I think Oto and Sinbad uses new system also.

yes, old models should work too, i just thought that many new users had problems with “older formats” so it would be better them to see GLTF instead “ogre.mesh” so they use new one :slight_smile:

so it would be good to convert old models to gltf version of them.

Yes, there are open source gltf I have seen myself with cc0 that can be used.