0

I have successfully implement 3D model by detecting image but problem is I have to rotate and zoom in and zoom out that model.I have also achieved it by using transformabel method but the issue is whenever I touch that model it's getting double.

          AnchorNode anchorNode = new AnchorNode(anchor);
          arFragment.getArSceneView().getScene().addChild(anchorNode);
          TransformableNode transformableNode = new TransformableNode(arFragment.getTransformationSystem());
          transformableNode.setParent(anchorNode);
          transformableNode.setRenderable(modelRenderable);
          transformableNode.select();

enter image description here]1

halfer
  • 19,824
  • 17
  • 99
  • 186

1 Answers1

0

A common way to move a renderable, possibly the main way at the time of writing, is to actually delete it and then create it in the new position or pose - e.g.:

  1. Delete existing renderable and remove from scene
  2. Create a new anchor and place it in the pose/position you want it
  3. Add the renderable to the new anchor you just created

In code:

private AnchorNode moveRenderable(AnchorNode markAnchorNodeToMove, Pose newPoseToMoveTo) {
        //Move a renderable to a new pose
        if (markAnchorNodeToMove != null) {
            arFragment.getArSceneView().getScene().removeChild(markAnchorNodeToMove);
        } else {
            Log.d(TAG,"moveRenderable - markAnchorNode was null");
            return null;
        }
        Frame frame = arFragment.getArSceneView().getArFrame();
        Session session = arFragment.getArSceneView().getSession();
        Anchor markAnchor = session.createAnchor(newPoseToMoveTo.extractTranslation());
        AnchorNode newMarkAnchorNode = new AnchorNode(markAnchor);
        newMarkAnchorNode.setRenderable(andyRenderable);
        newMarkAnchorNode.setParent(arFragment.getArSceneView().getScene());

        return newMarkAnchorNode;
    }

The above is an edited extract from an example app - you can find the full source and modify it etc here: https://github.com/mickod/LineView

One other note - zooming in and out on a renderable may be a little confusing in an AR context. The renderable is like an object in the real world, so you could maybe talk about zooming in and out the entire camera view, or about making the renderable itself bigger or smaller.

Mick
  • 24,231
  • 1
  • 54
  • 120