標記

2017-09-24 49 views
0

嗨的2D位置有我使用V6的ARToolKit基於NFT JPG圖片它工作得很好,但呈現標記.. 我需要標記的位置在屏幕(視圖),然後添加自定義的TextView有那可能嗎 ?如何基於projectionMatrix和modelViewMatrix獲取標記的2d位置?標記

或者,我可以得出的,而不是一個立方體文字或圖像?

代碼

@Override 
public void draw() { 
    super.draw(); 

    GLES20.glEnable(GLES20.GL_CULL_FACE); 
    GLES20.glEnable(GLES20.GL_DEPTH_TEST); 
    GLES20.glFrontFace(GLES20.GL_CCW); 


    boolean show = false; 
    for (int trackableUID : trackableUIDs) { 
     if (ARToolKit.getInstance().queryMarkerVisible(trackableUIDs.get(trackableUID))) { 
      float[] projectionMatrix = ARToolKit.getInstance().getProjectionMatrix(); 
      float[] modelViewMatrix = ARToolKit.getInstance().queryMarkerTransformation(trackableUIDs.get(trackableUID)); 
      Log.i("INFOOOOO", projectionMatrix.toString()); 
      Log.i("INFOOOOO", modelViewMatrix.toString()); 
      cube.draw(projectionMatrix, modelViewMatrix); 
      show = true; 
     } 
    } 
} 
+0

我不知道你想達到的目標,但也許[難道possble獲得其立方體的表面將在OpenGL被點擊?(https://stackoverflow.com/questions/45893277/is-it-possble-get-which-surface-of-cube-will-be-點擊中的OpenGL/45946943#45946943)可以提供幫助。 – Rabbid76

回答

0

@sturner感謝這麼多,我發現下面的解決方案是代碼,如果有人正在尋找解決方案

  final float[] projectionMatrix = ARToolKit.getInstance().getProjectionMatrix(); 
      final float[] modelViewMatrix = ARToolKit.getInstance().queryMarkerTransformation(trackableUIDs.get(trackableUID)); 

      if (view == null) { 
       view = new int[4]; 
       view[0] = 0; 
       view[1] = 0; 
       view[2] = ARTrackingActivity.width; 
       view[3] = ARTrackingActivity.height; 
      } 

      int i = GLU.gluProject(0, 0, 0, modelViewMatrix, 0, projectionMatrix, 0, view, 0, floats, 0); 
      if (i == GLES20.GL_TRUE) { 
       // draw the object in screen 
      }