【问题标题】:Android ArCore Sceneform API. How to change textures in runtime?Android ArCore Sceneform API。如何在运行时更改纹理?
【发布时间】:2018-05-23 10:51:20
【问题描述】:

服务器有3000多个模型,每个模型都有几种颜色的材料。我需要分别加载模型和纹理,并根据用户的选择设置纹理。如何在运行时改变baseColorMap、normalMap、metallicMap、roughnessMap?

之后 modelRenderable.getMaterial().setTexture("normalMap", normalMap.get()); 没发生什么事 我做错了什么。文档中没有这方面的信息。

【问题讨论】:

    标签: android arcore sceneform


    【解决方案1】:

    感谢您发布这个问题。

    • setTexture() 似乎不起作用:不幸的是,我们 API 的这一部分仍然有些粗糙;它有效,但很容易出错。我们正在制作一个示例来说明如何在运行时修改材质参数(包括纹理),并将在下一个版本中改进我们的错误报告。
    • 上千个模型有多个排列怎么办?:这里的计划有两个部分:
      • Android Studio 插件使用的二进制文件将可用于服务器平台上的构建脚本。这将允许您将资产在服务器端转换为.sfb。我们将很快发布一篇关于如何做到这一点的博文。
      • .sfa 将能够包含与几何体没有明确关联的松散纹理和材质,并且.sfa 将能够声明与其他.sfa 的数据依赖关系。这意味着您可以创作(和交付)包含纹理/材质(但没有几何体)的.sfb 和包含几何体(但没有纹理/材质)的.sfb,如果它们都可用在实例化时它会正常工作。

    【讨论】:

      【解决方案2】:

      使用此代码`

      CompletableFuture<Texture> futureTexture = Texture.builder()
                .setSource(this, R.drawable.shoes)
                .build();
      

      替换为

      /*.thenAccept(renderable -> andyRenderable = renderable)*/
              .thenAcceptBoth(futureTexture, (renderable, texture) -> {
                  andyRenderable = renderable;
                  andyRenderable.getMaterial().setTexture("baseColor", texture);
              })
      

      会起作用的。

      【讨论】:

      • 它只适用于baseColor,但是normaMap呢?"
      猜你喜欢
      • 1970-01-01
      • 2019-09-27
      • 1970-01-01
      • 2021-09-18
      • 2023-03-11
      • 2022-12-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多