有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java更新ModelInstance中连接节点的转换

我正在尝试将子节点附加到我在libgdx中创建的模型。我使用modeBuilder创建了如下框:

       Model model = modelBuilder.createBox(20, 20, 20, new Material(ColorAttribute.createDiffuse(Color.BLUE)),
                VertexAttributes.Usage.Position | VertexAttributes.Usage.Normal);
box = new ModelInstance(model);
box.transform.translate(0, 15, -10); 

我有一个我从搅拌机中加载的另一个模型:

    Model model;
    model = modelLoader.loadModel(Gdx.files.getFileHandle("crane.g3db", Files.FileType.Internal));
    modelInstance = new ModelInstance(model);
    modelInstance.transform.scale(0.05f, 0.05f, 0.05f);
    modelInstance.transform.translate(0, 0, 500);
    modelInstance.calculateTransforms();

现在,我尝试将长方体作为上述混合器模型的一个节点的子节点连接,如下所示:

public void attachBox(int i){
    this.attachedBox = box;
    Node hook = this.modelInstance.getNode("gancho");
    this.attachedBoxNode = this.attachedBox.getNode("node1");
    gancho.addChild(this.attachedBoxNode);
    attachedBoxNode.inheritTransform=true;
    modelInstance.calculateTransforms();
    this.attachedBoxNode.isAnimated = true;


}

我的问题如下:

更新节点变换的正确方法是什么?当我附加子对象并设置inheritTransforms=true;时,我将使框缩放并在世界各地移动。如果我设置inheritTransforms=false;。该框保持原始大小,但我无法通过移动父节点来移动它。我希望能够保持长方体的大小,并通过移动父节点和长方体节点本身来移动它


共 (0) 个答案