I created a white cube in my project as shown below. now I want to add texture to it. How can I do that?
MaterialFactory.makeOpaqueWithColor(this, new Color(android.graphics.Color.WHITE))
.thenAccept(
material -> {
modelRenderable =
ShapeFactory.makeCube(new Vector3(0.8f, 0.15f, 0.8f),
new Vector3(0.0f, 0.0f, 0.0f),
material);
});
You must create a texture material and set it to you created shape like this:
//sampler for the texture
val sampler = Texture.Sampler.builder()
.setWrapMode(Texture.Sampler.WrapMode.REPEAT)
.build()
Texture.builder()
.setSampler(sampler)
.setSource(this, R.drawable.your_drawable_texture)
.build()
.thenCompose { texture ->
MaterialFactory.makeOpaqueWithTexture(this, texture)
}
.thenAccept { material ->
ShapeFactory.makeCube(vector, vector, material)
}