Java 在动画期间获取网格/对象的变换

Java 在动画期间获取网格/对象的变换,java,libgdx,Java,Libgdx,我有3个立方体连接到电枢上。设置动画时,是否可以获得特定立方体的变换 上面的两个立方体上下摆动。我要做的是在设置动画时将红色立方体放在左侧白色立方体上,使其看起来像红色立方体已设置动画 private void doneLoading() { Model model = assets.get("data/cubes.g3db", Model.class); Model model2 = assets.get("data/colored.g3db&qu

我有3个立方体连接到电枢上。设置动画时,是否可以获得特定立方体的变换

上面的两个立方体上下摆动。我要做的是在设置动画时将红色立方体放在左侧白色立方体上,使其看起来像红色立方体已设置动画

private void doneLoading() {
    Model model = assets.get("data/cubes.g3db", Model.class);
    Model model2 = assets.get("data/colored.g3db", Model.class);

    cubes = new ModelInstance(model);
    con = new AnimationController(cubes);
    con.setAnimation(cubes.animations.get(0).id, -1);

    red = new ModelInstance(model2, "Red");

    instances.add(cubes);
    instances.add(red);
}

//in render function
if(!loading){
    //Tried, but it's not changing during animation
    //Node left = cubes.getNode("Cubel");
    //Matrix4 mat = left.globalTransform; 
    //System.out.println(mat.toString()); 
            
    //This worked but the red cube is on the bone's position, not on the white cube's.
    Matrix4 mat = con.current.animation.nodeAnimations.get(0).node.globalTransform;     
    red.transform.set(mat);

    con.update(delta);
    loading = false;
}
黄色-表示电枢或骨骼

绿色-动画中的运动