ARCore-Location icon indicating copy to clipboard operation
ARCore-Location copied to clipboard

Draw line between markers

Open fkojic opened this issue 7 years ago • 3 comments

Is there a possibility to connect two marker locations with a line?

fkojic avatar Oct 19 '18 08:10 fkojic

just use ModelRenderable.Builder.

ashif-ismail avatar Oct 24 '18 03:10 ashif-ismail

Do you gave any example of that? LocationMarker point1 = new LocationMarker( 20.501925, 44.792181, new AnnotationRenderer("point1 ") ); LocationMarker point2 = new LocationMarker( 20.502972, 44.790873, new AnnotationRenderer("point2 ") );

fkojic avatar Nov 19 '18 09:11 fkojic

you can do it like this -

Vector3 point1, point2; point1 = lastAnchorNode.getWorldPosition(); point2 = anchorNode.getWorldPosition(); Node line = new Node(); /* 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()); final Renderable[] lineRenderable = new Renderable[1]; / Then, create a rectangular prism, using ShapeFactory.makeCube() and use the difference vector to extend to the necessary length. / MaterialFactory.makeOpaqueWithColor(this, color) .thenAccept( material -> { lineRenderable[0] = 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 . */ line.setParent(anchorNode); line.setRenderable(lineRenderable[0]); line.setWorldPosition(Vector3.add(point1, point2).scaled(.5f)); line.setWorldRotation(rotationFromAToB);

ilamaheshwari avatar Dec 11 '18 07:12 ilamaheshwari