title: ARCore object tracking without a plane
body: <p>I am very new to this ARCore and I have been looking at the HelloAR Java Android Studio project provided in the SDK.</p>
  
  <p>Everthing works OK and is pretty cool, however, I want to place/drop an object when I touch the screen even when no planes have been detected. Let me explain a little better...</p>
  
  <p>As I understand ARCore, it will detect horizontal planes and ONLY on those horizontal planes I can place 3D objects to be motion tracked.</p>
  
  <p>Is there any way (perhaps using PointCloud information) to be able to place an object in the scene even if there are no horizontal planes detected? Sort of like these examples?
  <a href="https://experiments.withgoogle.com/ar/flight-paths" rel="noreferrer">https://experiments.withgoogle.com/ar/flight-paths</a>
  <a href="https://experiments.withgoogle.com/ar/arcore-drawing" rel="noreferrer">https://experiments.withgoogle.com/ar/arcore-drawing</a></p>
  
  <p>I know they are using Unity and openFrameworks, but could that be done in Java?</p>
  
  <p>Also, I have looked at
  <a href="https://stackoverflow.com/questions/46008630/how-to-put-an-object-in-the-air">How to put an object in the air?</a>
  and
  <a href="https://stackoverflow.com/questions/46017301/how-to-check-ray-intersection-with-object-in-arcore/46028084#46028084">how to check ray intersection with object in ARCore</a></p>
  
  <p>but I don't think I'm understanding the concept of Ancor (I managed to drop the object on the scene, but it either disappears immediately or it is just a regular OpenGL object with no knowledge about the real world.</p>
  
  <p>What I want to understand is:
  - How and is it possible to create a custom/user defined plane, that is, a plane that is NOT automatically detected by ARCore?
  - How can I create an Ancor (the sample does it in the PlaneAttachment class, I think) that is NOT linked to any plane OR that is linked to some PointCloud point?
  - How do I draw the object and place it at the Ancor previously created?</p>
  
  <p>I think this is too much to ask but looking at the API documentation has not helped me at all</p>
  
  <p>Thank you!</p>
  
  <p><strong>Edit</strong>:</p>
  
  <p>Here is the code that I added to HelloArActivity.java (Everything is the same as the original file except for the lines after // ***** and before ...</p>
  
  <pre><code>@Override
  public void onDrawFrame(GL10 gl) {
  ...
          MotionEvent tap = mQueuedSingleTaps.poll();
  
          // I added this to use screenPointToWorldRay function in the second link I posted... I am probably using this wrong
          float[] worldXY = new float[6];
  ...
          if (tap != null &amp;&amp; frame.getTrackingState() == TrackingState.TRACKING) {
  
              // ***** I added this to use screenPointToWorldRay function
              worldXY = screenPointToWorldRay(tap.getX(), tap.getY(), frame);
  ...
  
          }
  ...
  
          // Visualize anchors created by touch.
          float scaleFactor = 1.0f;
          for (PlaneAttachment planeAttachment : mTouches) {
  ...
          }
  
          // ***** This places the object momentarily in the scene (it disappears immediately)  
          frame.getPose().compose(Pose.makeTranslation(worldXY[3], worldXY[4], worldXY[5])).toMatrix(mAnchorMatrix, 0);
  
          // ***** This places the object in the middle of the scene but since it is not attached to anything, there is no tracking, it is always in the middle of the screen (pretty much expected behaviour)
          // frame.getPose().compose(Pose.makeTranslation(0, 0, -1.0f)).toMatrix(mAnchorMatrix, 0);
  
          // *****I duplicated this code which gets executed ONLY when touching a detected plane/surface.
          mVirtualObject.updateModelMatrix(mAnchorMatrix, scaleFactor);
          mVirtualObjectShadow.updateModelMatrix(mAnchorMatrix, scaleFactor);
          mVirtualObject.draw(viewmtx, projmtx, lightIntensity);
          mVirtualObjectShadow.draw(viewmtx, projmtx, lightIntensity);
  ...
  }
  </code></pre>