Coordinate conversion

Started by mxar, October 08, 2015, 11:27:58 AM

Previous topic - Next topic

mxar


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

EgonOlsen

In case of a translation, you can simply invert y and z.

mxar

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


EgonOlsen

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.

mxar


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.








 

EgonOlsen

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.

mxar



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

EgonOlsen

No, the solution with just tweaking the model view matrix in the shader will. Or maybe I didn't get your point...

mxar


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

EgonOlsen

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.

mxar


mxar

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 

EgonOlsen

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.

mxar

Thanks for your answer.

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

Thanks in Advance

EgonOlsen

None that I know of. A rotateX(Math.PI) is needed in most cases, but not in all.