Как добавить пользовательскую текстуру с shapefactory shape (куб) в моем коде? - PullRequest
0 голосов
/ 06 апреля 2019

я создал белый куб в своем проекте.как показано ниже.Теперь я хочу добавить текстуру к нему.как я могу это сделать?

                .thenAccept(
                        material -> {
                            modelRenderable =
                                    ShapeFactory.makeCube(new Vector3(0.8f,0.15f,0.8f), new Vector3(0.0f, 0.0f, 0.0f), material);

                        });

1 Ответ

2 голосов
/ 11 апреля 2019

Вы должны создать текстурный материал и установить его для созданной вами формы следующим образом:

    //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)
            }
...