Author Topic: Cardboard ,CardboardView support  (Read 2400 times)

Offline mxar

  • int
  • **
  • Posts: 78
    • View Profile
Cardboard ,CardboardView support
« 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



Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Cardboard ,CardboardView support
« Reply #1 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?

Offline mxar

  • int
  • **
  • Posts: 78
    • View Profile
Re: Cardboard ,CardboardView support
« Reply #2 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

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Cardboard ,CardboardView support
« Reply #3 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.

Offline mxar

  • int
  • **
  • Posts: 78
    • View Profile
Re: Cardboard ,CardboardView support
« Reply #4 on: December 06, 2018, 10:53:05 am »
Many thanks!!! :)