title: How to anchor an object using Cardboard Java SDK
body: <p>I'm currently working on a project with the Cardboard SDK, and I'm relatively struck right now.</p>
  
  <p>I want to display a cross in the center of the sight, like in a FPS, and keep it in the center of the sight when the user moves his head.</p>
  
  <p>I know that in this code : </p>
  
  <pre><code>public void onNewFrame(HeadTransform headTransform) {
      float[] headView = new float[16];
      headTransform.getHeadView(headView, 0);
  }
  </code></pre>
  
  <p>the headView param will contains the transformation matrix (rotation + translation) of the head (thanks to this SO : <a href="https://stackoverflow.com/questions/25085108/android-vr-toolkit-headtransform-getheadview-matrix-representation">Android VR Toolkit - HeadTransform getHeadView matrix representation</a> ).</p>
  
  <p>I tried to do this : </p>
  
  <pre><code>private float[] mHeadView = new float[16];
  
  public void onNewFrame(HeadTransform headTransform) {
      headTransform.getHeadView(mHeadView, 0);
  }
  
  public void onDrawEye(Eye eye) {
      float[] mvpMatrix = new float[16];
      float[] modelMatrix = new float[16];
      float[] mvMatrix = new float[16];
      float[] camera = new float[16];
      Matrix.setLookAt(camera, 0, 0, 0, -2, 0, 0, -1, 0, 1, 0);
      Matrix.multiplyMM(modelMatrix, 0, mHeadView, 0, camera, 0);
      Matrix.multiplyMM(mvMatrix, 0, eye.getEyeView(), 0, modelMatrix, 0);
      Matrix.multiplyMM(mvpMatrix, 0, eye.getEyePerspective(0.1, 100), 0, mvMatrix, 0);
  
      // Pass the mvpMatrix and vertices buffer to the vertex shader.
  }
  </code></pre>
  
  <p>And here is my vertex shader : </p>
  
  <pre><code>uniform mat4 uMatrix;
  attribute vec4 vPosition;
  attribute vec4 vColors;
  varying vec4 color;
  void main() {
      color = vColors;
      gl_Position = uMatrix * vPosition;
  }
  </code></pre>
  
  <p>But the cross is still anchored to its initial position and doesn't follow the head.</p>
  
  <p>Am I missing something ? 
  How can I make my cross follow my head and stay in the center of the sight ?</p>
  
  <p>Thanks in advance for your answers :)</p>
  
  <p>(PS : I don't want to use Unity because this project must only use the Java SDK).</p>