如何在AR场景中将图像作为纹理放置在Cube上?

时间:2019-07-26 12:56:16

标签: android arcore sceneform

我正在构建一个AR应用程序,希望该应用程序启动时将图像作为横幅放置在距相机特定距离(例如3米)处。

我正在使用Sceneform SDKs材质工厂的makeCube函数获得一个多维数据集。如何将图像作为纹理放在该立方体上以替换颜色?

MaterialFactory.makeOpaqueWithColor(getApplicationContext(), new Color(0, 255, 244))
                .thenAccept(
                        material -> {
                            /* Then, create a rectangular prism, using ShapeFactory.makeCube() and use the difference vector
                                   to extend to the necessary length.  */
                            Log.d("Draw","drawLine insie .thenAccept");
                            ModelRenderable model = ShapeFactory.makeCube(
                                    new Vector3(1.0f,1.0f,1.0f),
                                    Vector3.zero(), material);
                            /* Last, set the world rotation of the node to the rotation calculated earlier and set the world position to
                                   the midpoint between the given points . */
                            Node nodeForLine = new Node();
                            nodeForLine.setParent(node1);
                            nodeForLine.setRenderable(model);
//                            nodeForLine.setLocalPosition(new Vector3(0.0f,-1.0f,0.0f));
                            nodeForLine.setWorldPosition(Vector3.add(point1, point2).scaled(.5f));
                            nodeForLine.setWorldRotation(rotationFromAToB);

                        }
                );

0 个答案:

没有答案