360 panorama viewer with rajawali + VR howto change FieldOfView

482 Views Asked by At

I am trying to create a 360 image viewer using rajawali + vr (Cardboard toolkit). When i disable the VR-Mode on the CardboardView the changes i made on Field of View property in the renderer has no effect. in the Google Cardboard docs i found the the view will ignore it

For monocular rendering, the implementor should feel free to ignore the FieldOfView and instead create a perspective matrix with whatever field of view is desired for monocular rendering

My Question is how can i do this? and where should i implement it, neither the renderer nor the CardboardView has a method to set an perspectiveMatrix (float[])?

1

There are 1 best solutions below

1
On

updating the device param seems to always get overwritten by the gvr view

but if you decompile the FieldOfView class, you get this:

public void toPerspectiveMatrix(float near, float far, float[] perspective, int offset) {
    if(offset + 16 > perspective.length) {
        throw new IllegalArgumentException("Not enough space to write the result");
    } else {
        float l = (float)(-Math.tan(Math.toRadians((double)this.left))) * near;
        float r = (float)Math.tan(Math.toRadians((double)this.right)) * near;
        float b = (float)(-Math.tan(Math.toRadians((double)this.bottom))) * near;
        float t = (float)Math.tan(Math.toRadians((double)this.top)) * near;
        Matrix.frustumM(perspective, offset, l, r, b, t, near, far);
    }
}