我正在尝试移动使用libGDX加载的模型的某些节点。 这是代码:
public void render() {
...
if (loading && assets.update()) //done when app starts
doneLoading();
if(!loading)
moveModel();
modelBatch.begin(cam);
modelBatch.render(instances, environment);
modelBatch.end();
}
private void doneLoading() {
I_model = assets.get("data/model.g3db", Model.class);
I_instance = new ModelInstance(I_model);
instances.add(I_instance);
loading = false;
}
private void moveModel(){
for(int i=0;i<MAX_VALUE;i++){
Node bone = I_instance.getNode(names[i]);
if(bone != null){
bone.rotation.set(new Vector3(1, 1, 0), values[i]);
}
}
I_instance.calculateTransforms();
instances.add(I_instance);
}
模型已正确显示,但根本无法移动。 有什么建议吗?
答案 0 :(得分:1)
您应该只修改ModelInstance的transform
在您的情况下,这将是I_instance.transform.translate(...)