Giter VIP home page Giter VIP logo

Comments (11)

KamikX avatar KamikX commented on July 26, 2024 3

@mistrydarshan99 Hi, try this code:

         // Build texture sampler
        Texture.Sampler sampler = Texture.Sampler.builder()
                .setMinFilter(Texture.Sampler.MinFilter.LINEAR)
                .setMagFilter(Texture.Sampler.MagFilter.LINEAR)
                .setWrapMode(Texture.Sampler.WrapMode.REPEAT).build();

        // Build texture with sampler
        CompletableFuture<Texture> trigrid = Texture.builder()
                .setSource(this, R.drawable.trigrid_0)
                .setSampler(sampler).build();

        // Set plane texture
        this.sceneformFragment.getArSceneView()
                .getPlaneRenderer()
                .getMaterial()
                .thenAcceptBoth(trigrid, (material, texture) -> {
                    material.setTexture(PlaneRenderer.MATERIAL_TEXTURE, texture);
                });

Result :
screenshot_20180605-144612

from sceneform-android-sdk.

dsternfeld7 avatar dsternfeld7 commented on July 26, 2024

You can change the color of the plane by setting the color parameter of the plane's material like this:

arSceneView.getPlaneRenderer().getMaterial().thenAccept(material -> material.setFloat3(PlaneRenderer.MATERIAL_COLOR, new Color(0.0f, 0.0f, 1.0f, 1.0f)) );

For information about all of the material parameters available for the plane, see the PlaneRenderer documentation here.

from sceneform-android-sdk.

mistrydarshan99 avatar mistrydarshan99 commented on July 26, 2024

@dsternfeld7 plane color changes successfully. But now I have to try to render texture image instead of color while plane detected but it will not work as expected. Here is my texture image.

CompletableFuture<Texture> build = Texture.builder().setSource(this, R.drawable.images).build();
arFragment.getArSceneView()
        .getPlaneRenderer()
        .getMaterial()
        .thenAcceptBoth(build, (material, texture) -> {
          material.setTexture(PlaneRenderer.MATERIAL_TEXTURE, texture);
          //material.setFloat3(PlaneRenderer.MATERIAL_COLOR, new Color(0.0f, 0.0f, 1.0f, 1.0f));
        });

images
Output:
screenshot_20180531-185240_augment 3d

Another issue is that horizontal and vertical surface detected successfully when I detect a ceiling plane is not visible on ceiling detection, but I put android anchor on it see screenshot:
screenshot_20180531-185936_augment 3d

from sceneform-android-sdk.

dsternfeld7 avatar dsternfeld7 commented on July 26, 2024

I believe you can get the behavior you expect by changing the MATERIAL_UV_SCALE parameter. This parameter is used to control the size at which the texture is tiled in world-space, the default values are setup for the default texture. Try this and see what happens:

CompletableFuture<Texture> build = Texture.builder().setSource(this, R.drawable.images).build();
arFragment.getArSceneView()
        .getPlaneRenderer()
        .getMaterial()
        .thenAcceptBoth(build, (material, texture) -> {
          material.setTexture(PlaneRenderer.MATERIAL_TEXTURE, texture);
          material.setFloat2(PlaneRenderer.MATERIAL_UV_SCALE, 50.0f, 50.0f);
        });

The plane not rendering on ceiling planes sounds like a bug. Can you open a new issue specifically to track that bug?

from sceneform-android-sdk.

mistrydarshan99 avatar mistrydarshan99 commented on July 26, 2024

Hi,

I have used your code still issue is not fixed. Below is a screenshot.
screenshot_20180601-112457_augment 3d

from sceneform-android-sdk.

mistrydarshan99 avatar mistrydarshan99 commented on July 26, 2024

@KamikX Thanks, bro. it works very well.

from sceneform-android-sdk.

dementia2029 avatar dementia2029 commented on July 26, 2024

Hi. I think that this issue is not fixed properly. Custom texture have wrong proportions.

from sceneform-android-sdk.

dementia2029 avatar dementia2029 commented on July 26, 2024

We also need to set uvScale for Image like this:
material.setFloat2("uvScale", 1f, 1.19245f);

from sceneform-android-sdk.

kenyee avatar kenyee commented on July 26, 2024

FYI, this doesn't work w/ vector drawables...you can stick the PNG into the drawables-nodpi folder though.

from sceneform-android-sdk.

narendra02031997 avatar narendra02031997 commented on July 26, 2024

How can i apply texture on an object

from sceneform-android-sdk.

ChanduMnS avatar ChanduMnS commented on July 26, 2024

Hi, try this code:

         // Build texture sampler
        Texture.Sampler sampler = Texture.Sampler.builder()
                .setMinFilter(Texture.Sampler.MinFilter.LINEAR)
                .setMagFilter(Texture.Sampler.MagFilter.LINEAR)
                .setWrapMode(Texture.Sampler.WrapMode.REPEAT).build();

        // Build texture with sampler
        CompletableFuture<Texture> trigrid = Texture.builder()
                .setSource(this, R.drawable.trigrid_0)
                .setSampler(sampler).build();

        // Set plane texture
        this.sceneformFragment.getArSceneView()
                .getPlaneRenderer()
                .getMaterial()
                .thenAcceptBoth(trigrid, (material, texture) -> {
                    material.setTexture(PlaneRenderer.MATERIAL_TEXTURE, texture);
                });

Result :
screenshot_20180605-144612

Hey @KamikX. Thanks for the code. I want to replicate the same for the model. I'm trying to apply a picture to the model. I tried the above code for the plane and it worked. I was applying the texture using modelrenderable.setMaterial(), but I didn't find success the texture is extended. Kindly help me with this.
Thanks in Advance
Chandu.

from sceneform-android-sdk.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.