0

I want to create an app same like magicplan and want to draw continuous green vertical pipe same like magicplan which goes near and far as camera moves.

I have tried below code but it keeps node at center of screen. Please help me how I can achieve this.

                Ray ray = arFragment.getArSceneView().getScene().getCamera().screenPointToRay(arFragment.getArSceneView().getWidth() / 2, arFragment.getArSceneView().getHeight() / 2);
                Vector3 localpos = ray.getPoint(1f);
                Quaternion localRotation = arFragment.getArSceneView().getScene().getCamera().getLocalRotation();
                Vector3 localScale = new Vector3(0.3f,0.3f,0.3f);
                Frame frame = arFragment.getArSceneView().getArFrame();
                Vector3 pos;
                pos = Vector3.add(ray.getOrigin(), ray.getDirection());

                Pose pose = Pose.makeTranslation(pos.x, pos.y, pos.z);

                anchor = arFragment.getArSceneView().getSession().createAnchor(pose);
                anchorNode = new AnchorNode(anchor);
                anchorNode.setParent(arFragment.getArSceneView().getScene());
                TransformationSystem transformationSystem = arFragment.getTransformationSystem();
                node = new TransformableNode(transformationSystem);
                node.setRenderable(cylinderRenderable2);
                node.setParent(anchorNode);
                node.setLocalPosition(localpos);
                node.setLocalRotation(localRotation);
                node.setLocalScale(localScale);
                node.select();
KishuDroid
  • 5,411
  • 4
  • 30
  • 47
  • You should state which libraries you are using (I'm guessing the now deprecated Sceneform SDK) – Morrison Chang Apr 27 '21 at 08:23
  • @MorrisonChang I am using implementation 'com.google.ar.sceneform.ux:sceneform-ux:1.17.1' implementation 'com.google.ar.sceneform:core:1.17.1' implementation 'com.google.ar:core:1.23.0' – KishuDroid Apr 27 '21 at 09:17
  • To my understanding, the Sceneform SDK is for placing packaged 3D models in space with some animation (i.e. see Solar System demo in SDK). Knowing where edges are in physical space and custom dynamic changes to the scene (i.e. drawing the correct 3D cylinders) would required accessing ARCore directly and make use of using the Depth API (and quite possibly other image processing techniques). All of which is too much to be explained in a SO answer. Reminder [How much research effort is expected of Stack Overflow users?](https://meta.stackoverflow.com/q/261592/295004) – Morrison Chang Apr 27 '21 at 21:09

0 Answers0