2017-09-24 11 views
0

안녕하세요 저는 nft jpg 이미지를 기반으로 마커를 렌더링하기 위해 ARToolKit v6을 사용하고 있습니다. 그러나 매우 잘 작동하지만 .. 화면 (보기)에서 마커의 위치를 ​​가져 와서 사용자 정의 textView를 추가해야합니다. 그게 가능하니? projectionMatrix와 modelViewMatrix를 기반으로 마커의 2 차원 위치를 얻는 방법?마커의 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

내가, 당신이 무엇을 달성하고자하는 모르지만 어쩌면 [OpenGL에서 큐브의 어떤면이 클릭 될지 알 수 있습니까?] (https://stackoverflow.com/questions/45893277/is-it-possble-get-which-surface-of-cube-will-be- Open-in-line/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 
      }