Draw line between location markers in ArCore?











up vote
0
down vote

favorite












Is there a possibility to connect two marker locations with a line? I have two location marker:



LocationMarker point1 = new LocationMarker(
20.501925,
44.792181,
new AnnotationRenderer("point1 ")
);

LocationMarker point2 = new LocationMarker(
20.502972,
44.790873,
new AnnotationRenderer("point2 ")
);


Any example? I use ArCore Location










share|improve this question




























    up vote
    0
    down vote

    favorite












    Is there a possibility to connect two marker locations with a line? I have two location marker:



    LocationMarker point1 = new LocationMarker(
    20.501925,
    44.792181,
    new AnnotationRenderer("point1 ")
    );

    LocationMarker point2 = new LocationMarker(
    20.502972,
    44.790873,
    new AnnotationRenderer("point2 ")
    );


    Any example? I use ArCore Location










    share|improve this question


























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      Is there a possibility to connect two marker locations with a line? I have two location marker:



      LocationMarker point1 = new LocationMarker(
      20.501925,
      44.792181,
      new AnnotationRenderer("point1 ")
      );

      LocationMarker point2 = new LocationMarker(
      20.502972,
      44.790873,
      new AnnotationRenderer("point2 ")
      );


      Any example? I use ArCore Location










      share|improve this question















      Is there a possibility to connect two marker locations with a line? I have two location marker:



      LocationMarker point1 = new LocationMarker(
      20.501925,
      44.792181,
      new AnnotationRenderer("point1 ")
      );

      LocationMarker point2 = new LocationMarker(
      20.502972,
      44.790873,
      new AnnotationRenderer("point2 ")
      );


      Any example? I use ArCore Location







      java android location arcore






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 19 at 11:12









      Kling Klang

      32.1k156287




      32.1k156287










      asked Nov 19 at 9:24









      Filip Kojic

      93




      93
























          1 Answer
          1






          active

          oldest

          votes

















          up vote
          0
          down vote













          The code below will draw a line between two points - the points are associated with anchors in Sceneform - this is adapted from the answer here https://stackoverflow.com/a/52816504/334402:



          private void drawLine(AnchorNode node1, AnchorNode node2) {
          //Draw a line between two AnchorNodes
          Log.d(TAG,"drawLine");
          Vector3 point1, point2;
          point1 = node1.getWorldPosition();
          point2 = node2.getWorldPosition();


          //First, find the vector extending between the two points and define a look rotation
          //in terms of this Vector.
          final Vector3 difference = Vector3.subtract(point1, point2);
          final Vector3 directionFromTopToBottom = difference.normalized();
          final Quaternion rotationFromAToB =
          Quaternion.lookRotation(directionFromTopToBottom, Vector3.up());
          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(TAG,"drawLine insie .thenAccept");
          ModelRenderable model = ShapeFactory.makeCube(
          new Vector3(.01f, .01f, difference.length()),
          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 . */
          Anchor lineAnchor = node2.getAnchor();
          nodeForLine = new Node();
          nodeForLine.setParent(node1);
          nodeForLine.setRenderable(model);
          nodeForLine.setWorldPosition(Vector3.add(point1, point2).scaled(.5f));
          nodeForLine.setWorldRotation(rotationFromAToB);
          }
          );

          }





          share|improve this answer





















          • Thanks, how to transofrm location marker to Anchor mode?
            – Filip Kojic
            Nov 19 at 12:46










          • @FilipKojic - can you explain a little more what you mean, I'm not sure I understand your comment question?
            – Mick
            Nov 19 at 14:45











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53371583%2fdraw-line-between-location-markers-in-arcore%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          0
          down vote













          The code below will draw a line between two points - the points are associated with anchors in Sceneform - this is adapted from the answer here https://stackoverflow.com/a/52816504/334402:



          private void drawLine(AnchorNode node1, AnchorNode node2) {
          //Draw a line between two AnchorNodes
          Log.d(TAG,"drawLine");
          Vector3 point1, point2;
          point1 = node1.getWorldPosition();
          point2 = node2.getWorldPosition();


          //First, find the vector extending between the two points and define a look rotation
          //in terms of this Vector.
          final Vector3 difference = Vector3.subtract(point1, point2);
          final Vector3 directionFromTopToBottom = difference.normalized();
          final Quaternion rotationFromAToB =
          Quaternion.lookRotation(directionFromTopToBottom, Vector3.up());
          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(TAG,"drawLine insie .thenAccept");
          ModelRenderable model = ShapeFactory.makeCube(
          new Vector3(.01f, .01f, difference.length()),
          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 . */
          Anchor lineAnchor = node2.getAnchor();
          nodeForLine = new Node();
          nodeForLine.setParent(node1);
          nodeForLine.setRenderable(model);
          nodeForLine.setWorldPosition(Vector3.add(point1, point2).scaled(.5f));
          nodeForLine.setWorldRotation(rotationFromAToB);
          }
          );

          }





          share|improve this answer





















          • Thanks, how to transofrm location marker to Anchor mode?
            – Filip Kojic
            Nov 19 at 12:46










          • @FilipKojic - can you explain a little more what you mean, I'm not sure I understand your comment question?
            – Mick
            Nov 19 at 14:45















          up vote
          0
          down vote













          The code below will draw a line between two points - the points are associated with anchors in Sceneform - this is adapted from the answer here https://stackoverflow.com/a/52816504/334402:



          private void drawLine(AnchorNode node1, AnchorNode node2) {
          //Draw a line between two AnchorNodes
          Log.d(TAG,"drawLine");
          Vector3 point1, point2;
          point1 = node1.getWorldPosition();
          point2 = node2.getWorldPosition();


          //First, find the vector extending between the two points and define a look rotation
          //in terms of this Vector.
          final Vector3 difference = Vector3.subtract(point1, point2);
          final Vector3 directionFromTopToBottom = difference.normalized();
          final Quaternion rotationFromAToB =
          Quaternion.lookRotation(directionFromTopToBottom, Vector3.up());
          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(TAG,"drawLine insie .thenAccept");
          ModelRenderable model = ShapeFactory.makeCube(
          new Vector3(.01f, .01f, difference.length()),
          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 . */
          Anchor lineAnchor = node2.getAnchor();
          nodeForLine = new Node();
          nodeForLine.setParent(node1);
          nodeForLine.setRenderable(model);
          nodeForLine.setWorldPosition(Vector3.add(point1, point2).scaled(.5f));
          nodeForLine.setWorldRotation(rotationFromAToB);
          }
          );

          }





          share|improve this answer





















          • Thanks, how to transofrm location marker to Anchor mode?
            – Filip Kojic
            Nov 19 at 12:46










          • @FilipKojic - can you explain a little more what you mean, I'm not sure I understand your comment question?
            – Mick
            Nov 19 at 14:45













          up vote
          0
          down vote










          up vote
          0
          down vote









          The code below will draw a line between two points - the points are associated with anchors in Sceneform - this is adapted from the answer here https://stackoverflow.com/a/52816504/334402:



          private void drawLine(AnchorNode node1, AnchorNode node2) {
          //Draw a line between two AnchorNodes
          Log.d(TAG,"drawLine");
          Vector3 point1, point2;
          point1 = node1.getWorldPosition();
          point2 = node2.getWorldPosition();


          //First, find the vector extending between the two points and define a look rotation
          //in terms of this Vector.
          final Vector3 difference = Vector3.subtract(point1, point2);
          final Vector3 directionFromTopToBottom = difference.normalized();
          final Quaternion rotationFromAToB =
          Quaternion.lookRotation(directionFromTopToBottom, Vector3.up());
          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(TAG,"drawLine insie .thenAccept");
          ModelRenderable model = ShapeFactory.makeCube(
          new Vector3(.01f, .01f, difference.length()),
          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 . */
          Anchor lineAnchor = node2.getAnchor();
          nodeForLine = new Node();
          nodeForLine.setParent(node1);
          nodeForLine.setRenderable(model);
          nodeForLine.setWorldPosition(Vector3.add(point1, point2).scaled(.5f));
          nodeForLine.setWorldRotation(rotationFromAToB);
          }
          );

          }





          share|improve this answer












          The code below will draw a line between two points - the points are associated with anchors in Sceneform - this is adapted from the answer here https://stackoverflow.com/a/52816504/334402:



          private void drawLine(AnchorNode node1, AnchorNode node2) {
          //Draw a line between two AnchorNodes
          Log.d(TAG,"drawLine");
          Vector3 point1, point2;
          point1 = node1.getWorldPosition();
          point2 = node2.getWorldPosition();


          //First, find the vector extending between the two points and define a look rotation
          //in terms of this Vector.
          final Vector3 difference = Vector3.subtract(point1, point2);
          final Vector3 directionFromTopToBottom = difference.normalized();
          final Quaternion rotationFromAToB =
          Quaternion.lookRotation(directionFromTopToBottom, Vector3.up());
          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(TAG,"drawLine insie .thenAccept");
          ModelRenderable model = ShapeFactory.makeCube(
          new Vector3(.01f, .01f, difference.length()),
          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 . */
          Anchor lineAnchor = node2.getAnchor();
          nodeForLine = new Node();
          nodeForLine.setParent(node1);
          nodeForLine.setRenderable(model);
          nodeForLine.setWorldPosition(Vector3.add(point1, point2).scaled(.5f));
          nodeForLine.setWorldRotation(rotationFromAToB);
          }
          );

          }






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 19 at 10:46









          Mick

          11.8k12458




          11.8k12458












          • Thanks, how to transofrm location marker to Anchor mode?
            – Filip Kojic
            Nov 19 at 12:46










          • @FilipKojic - can you explain a little more what you mean, I'm not sure I understand your comment question?
            – Mick
            Nov 19 at 14:45


















          • Thanks, how to transofrm location marker to Anchor mode?
            – Filip Kojic
            Nov 19 at 12:46










          • @FilipKojic - can you explain a little more what you mean, I'm not sure I understand your comment question?
            – Mick
            Nov 19 at 14:45
















          Thanks, how to transofrm location marker to Anchor mode?
          – Filip Kojic
          Nov 19 at 12:46




          Thanks, how to transofrm location marker to Anchor mode?
          – Filip Kojic
          Nov 19 at 12:46












          @FilipKojic - can you explain a little more what you mean, I'm not sure I understand your comment question?
          – Mick
          Nov 19 at 14:45




          @FilipKojic - can you explain a little more what you mean, I'm not sure I understand your comment question?
          – Mick
          Nov 19 at 14:45


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53371583%2fdraw-line-between-location-markers-in-arcore%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          "Incorrect syntax near the keyword 'ON'. (on update cascade, on delete cascade,)

          Alcedinidae

          Origin of the phrase “under your belt”?