加載模型的基礎上修改貼圖
方式一:直接設置
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"))));
}
image.png
方式二:先獲取,然后設置
TextureAttribute attribute = objActor.getModelInstance().materials.get(0).get(TextureAttribute.class, TextureAttribute.Diffuse);
attribute.set(new TextureRegion(new Texture(
Gdx.files.internal("cubelet.png")
)));
image.png