www.jpct.net

jPCT-AE - a 3d engine for Android => Support => Topic started by: mxar on December 05, 2018, 01:26:17 pm

Title: Cardboard ,CardboardView support
Post by: mxar on December 05, 2018, 01:26:17 pm
Hi,

I try to develop a Virtual Reality application using Google's Cardboard Java API.

Do you have any example?

I have a big problem adjusting JPCT's coordination system with Cardboard's Java API coordinate system.

I think the solution exists in the method
public void onDrawEye(Eye eye)

My code is:

 @Override
    public void onDrawEye(Eye eye) {

       com.threed.jpct.Matrix camBack = world.getCamera().getBack();
        camBack.setIdentity();
        tempTransform.setDump(eye.getEyeView());

        tempTransform.transformToGL();
        camBack.matMul(tempTransform);

        world.getCamera().setBack(camBack);

         fb.clear(RGBColor.BLACK);
         fb.clearZBufferOnly();

         world.renderScene(fb);
         world.draw(fb);

         fb.display();
}


The Objects3D models added to the world  don't look ok according to the XYZ positions a I have set.


I suppose the problem is because JPCT uses a different coordinate system than OpenGL.

Can you suggest a solution?

Thanks in advance


Title: Re: Cardboard ,CardboardView support
Post by: EgonOlsen on December 06, 2018, 08:15:38 am
Might be because the matrix from the cardboard API is a view matrix while jPCT's camera matrix is a rotation matrix. Have you looked at this example: http://www.jpct.net/wiki/index.php?title=Example_for_Google_Cardboard (http://www.jpct.net/wiki/index.php?title=Example_for_Google_Cardboard)?
Title: Re: Cardboard ,CardboardView support
Post by: mxar on December 06, 2018, 08:38:22 am

Many thanks!!!

Great example.

Also I have another question:

Primitives.getCube(scale) method, creates a cube rotated 45 degrees around Y axis?

Thanks in advance
Title: Re: Cardboard ,CardboardView support
Post by: EgonOlsen on December 06, 2018, 08:59:07 am
Yes. That's caused by the way in which these objects are build. I think ExtendedPrimitives does it differently.
Title: Re: Cardboard ,CardboardView support
Post by: mxar on December 06, 2018, 10:53:05 am
Many thanks!!! :)