www.jpct.net

jPCT-AE - a 3d engine for Android => Support => Topic started by: mxar on October 08, 2015, 11:27:58 am

Title: Coordinate conversion
Post by: mxar on October 08, 2015, 11:27:58 am

Hi,

I have an issue with the jPCT-AE coordinate system.

In my application the Object3Ds are positioned from an application using the Opengl coordinate system.

How can i convert the opengl coordinate system to jPCT-AE coordinate system?


For example , when the third party application calls the Object3D.translate(float x, float y, float z) method then what steps i have to follow

to do the conversion?

Thanks in advance
Title: Re: Coordinate conversion
Post by: EgonOlsen on October 08, 2015, 01:22:19 pm
In case of a translation, you can simply invert y and z.
Title: Re: Coordinate conversion
Post by: mxar on October 08, 2015, 01:54:18 pm
Thanks for the quick answer.

This  solution I have to apply for camera position and direction?

I mean all the position , rotation ( any similar methods ) can use this solution?

Thanks in advance

Title: Re: Coordinate conversion
Post by: EgonOlsen on October 08, 2015, 02:09:13 pm
You can't invert z and y on a rotation, so...the right way of doing it is to rotate PI around X. Inverting z and y is just a shortcut for translations.
Title: Re: Coordinate conversion
Post by: mxar on October 08, 2015, 02:21:46 pm

Thanks

but I think , (because it is an Augmented Reality project) ,if rotating the Camera's object  Model View matrix 180 degrees around X  axis
will be a good solution. (Like the one integrating Vuforia with jPCT-AE).

In this case no Y,Z inverting needed, or rotating PI around X.

Am I right?


So there are 2 solutions:

1) Just rotate 180 degrees around X axis the modelview matrix applied to Camera object.
2) Dont to any changes to camera. Just Invert Y and Z and in case of rotating PI around X in case of rotation.

Thanks in Advance.








 
Title: Re: Coordinate conversion
Post by: EgonOlsen on October 08, 2015, 02:44:46 pm
Whatever you do, you have to make sure that the world that you render is the world how jPCT-AE sees it. Modifying the matrix in the last stage isn't a good idea, because it will screw up culling and such.
Title: Re: Coordinate conversion
Post by: mxar on October 08, 2015, 02:51:55 pm


Thanks but in case of integrating jPCT-AE with Vuforia ,the solution of rotating 180 degrees around X axis  will screw up culling and such?

Thanks in Advance
Title: Re: Coordinate conversion
Post by: EgonOlsen on October 08, 2015, 02:53:11 pm
No, the solution with just tweaking the model view matrix in the shader will. Or maybe I didn't get your point...
Title: Re: Coordinate conversion
Post by: mxar on October 08, 2015, 03:07:11 pm

My Application is an Augmented 3D application.

But the part of inserting 3d objects in the renderer's world is not created by me.Unfortunately this part uses the opengl coordinate system.

So reading the jPCT-AE integration with Vuforia tutorial i had in my mind that rotating the marker's  modelview matrix  (returned by the AR engine) 180 degrees around X axis  to set camera position and direction will be finally a good solution .

Am I right?

Thanks for your time
Title: Re: Coordinate conversion
Post by: EgonOlsen on October 08, 2015, 05:41:10 pm
Sounds fine to me the then. Just keep in mind that matrices in jPCT are row major, while OpenGL's matrices are column major. Depending on your actual code, you might have to use Matrix.transformToGL() to convert between both formats. But the Wiki tutorial should actually cover this in some way.
Title: Re: Coordinate conversion
Post by: mxar on October 08, 2015, 08:35:29 pm
Ok

thank you
Title: Re: Coordinate conversion
Post by: mxar on October 12, 2015, 01:47:59 pm
Hi again.

I need some clarificaion on loading Object3Ds.

I noticed that when i add to the world an Object3D  ( .obj,.3ds ,...) then in rendering the Object3D is displayed upside down.
So I have to call the Object3D.rotateX(Math.PI) method.

This is something expected?

This is because of the jPCT's coordinate system?

Thanks in advance 
Title: Re: Coordinate conversion
Post by: EgonOlsen on October 12, 2015, 03:33:10 pm
Depends on the model and the exporter. Sometimes you don't have to do anything, sometimes a rotateX(Math.PI), sometimes a rotateX(Math.PI/2f)...it depends. So yes, this is to be expected.
Title: Re: Coordinate conversion
Post by: mxar on October 12, 2015, 03:55:51 pm
Thanks for your answer.

But generally, is there any specific rule when we have to do the rotation?

Thanks in Advance
Title: Re: Coordinate conversion
Post by: EgonOlsen on October 12, 2015, 09:27:40 pm
None that I know of. A rotateX(Math.PI) is needed in most cases, but not in all.