加载模型的基础上修改贴图
方式一:直接设置
ObjActor objActor = new ObjActor("mofan.obj");
addActor3d(objActor);
Array<Material> materials = objActor.getModelInstance().materials;
for (Material material : materials) {
material.set(TextureAttribute.createDiffuse(
new Texture(Gdx.files.internal("mofan.jpg"))));
}

方式二:先获取,然后设置
TextureAttribute attribute = objActor.getModelInstance().materials.get(0).get(TextureAttribute.class, TextureAttribute.Diffuse);
attribute.set(new TextureRegion(new Texture(
Gdx.files.internal("cubelet.png")
)));

网友评论