Display object always in front of the camera Google Cardboard VR SDK


Good! I'm developing a virtual reality app using Google's VR SDK for Android, the problem is that I have an object that I show in my application, but that object is static, I need to know how to handle the functions provided by the HeadTransform object within the method onNewFrame to get my object always shown in the center of the screen. Thanks in advance. Greetings!

Here I get the quaternion that produces the rotation of the head:

public void onNewFrame(HeadTransform headTransform) {
    // Build the camera matrix and apply it to the ModelView.
    Matrix.setLookAtM(camera, 0, 0.0f, 0.0f, CAMERA_Z, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f);

    headTransform.getHeadView(headView, 0);

    headTransform.getQuaternion(headRotation, 0);

            headRotation[0], headRotation[1], headRotation[2], headRotation[3]);
    // Regular update call to GVR audio engine.


Inside the method onDrawEye is where I must apply the rotation to the object so that it moves in accordance with the direction of vision of the camera, but I do not know how to do it:

public void onDrawEye(Eye eye) {


    // Apply the eye transformation to the camera.
    Matrix.multiplyMM(view, 0, eye.getEyeView(), 0, camera, 0);

    // Set the position of the light
    Matrix.multiplyMV(lightPosInEyeSpace, 0, view, 0, LIGHT_POS_IN_WORLD_SPACE, 0);

    // Build the ModelView and ModelViewProjection matrices
    float[] perspective = eye.getPerspective(Z_NEAR, Z_FAR);

    --> Aplicar rotacion al objeto aqui <--

    Matrix.multiplyMM(modelView, 0, view, 0, model, 0);
    Matrix.multiplyMM(modelViewProjection, 0, perspective, 0, modelView, 0);
asked by Manuel Navas Damas 06.06.2016 в 23:31

0 answers