Log in or register to post comments

How do JPCT-AE work on Vuforia 8

January 22, 2019 - 5:19pm #1

I fellowed "Build an AR App using JPCT-AE & Vuforia 7 on Android under 10 minutes (https://medium.com/sourcebytes/build-an-ar-app-using-jpct-ae-vuforia-7-on-android-under-10-minutes-fcff6cd5ad76)" and "Extract the camera position and orientation (https://library.vuforia.com/content/vuforia-library/en/articles/Solution/Working-with-the-Camera.html#How-To-Determine-Camera-Pose)", but it do not work on Vuforia 8. I think the reason is "New Coordinate System (https://library.vuforia.com/content/vuforia-library/en/articles/Solution/how-migrate-vuforia-7_2.html)".

somebody could help me?

 

public void renderFrame(State state, float[] projectionMatrix) {

        GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT | GLES20.GL_DEPTH_BUFFER_BIT);

        // Renders video background replacing Renderer.DrawVideoBackground()

        mSampleAppRenderer.renderVideoBackground(state);

        float[] modelviewArray = new float[16];

        // Set the device pose matrix as identity

        Matrix44F devicePoseMatrix = SampleMath.Matrix44FIdentity();

        Matrix44F modelMatrix;

        // Read device pose from the state and create a corresponding view matrix (inverse of the device pose)

        if (state.getDeviceTrackableResult() != null) {

            int statusInfo = state.getDeviceTrackableResult().getStatusInfo();

            int trackerStatus = state.getDeviceTrackableResult().getStatus();

            mActivityRef.get().checkForRelocalization(statusInfo);

            if (trackerStatus != TrackableResult.STATUS.NO_POSE) {

                modelMatrix = Tool.convertPose2GLMatrix(state.getDeviceTrackableResult().getPose());

                Logger.printMatrix44F("devicePose", modelMatrix);

                // We transpose here because Matrix44FInverse returns a transposed matrix

                devicePoseMatrix = SampleMath.Matrix44FTranspose(SampleMath.Matrix44FInverse(modelMatrix));

                Logger.printMatrix44F("deviceMatrix", devicePoseMatrix);

            }

        }

        // Did we find any trackables this frame?

        TrackableResultList trackableResultList = state.getTrackableResults();

        for (TrackableResult result : trackableResultList) {

            if (result.isOfType(ImageTargetResult.getClassType())) {

                modelMatrix = Tool.convertPose2GLMatrix(result.getPose());

                Logger.printMatrix44F("modelMatrix", modelMatrix);

                Matrix44F modelViewMatrix = Tool.multiplyGL(devicePoseMatrix, modelMatrix);

                Logger.printMatrix44F("modelViewMatrix", modelViewMatrix);

                updateModelviewMatrix(SampleMath.Matrix44FTranspose(SampleMath.Matrix44FInverse(modelViewMatrix)).getData());

                SampleUtils.checkGLError("Image Targets renderFrame");

            }

        }

        if (state.getNumTrackableResults() == 0) {

            final float m[] = {

                    1, 0, 0, 0,

                    0, 1, 0, 0,

                    0, 0, 1, 0,

                    0, 0, -10000, 1

            };

            modelviewArray = m;

            updateModelviewMatrix(modelviewArray);

        }

    }

Log in or register to post comments