Camera.getPosition

Started by Mr_Chaos, August 14, 2014, 02:22:44 PM

Previous topic - Next topic

Mr_Chaos

Is there an easy way to get the worldspace position of the camera in JPCT-AE ?

I would like to use it to see how far the camera is from an object, but getPosition doesn't give me the correct values. If I use the same code in JPCT is works as expected, but not in JPCT-AE.


EgonOlsen

getPosition() does give you the position in world space in both APIs and i'm not aware of any issues with it. I'm using it all the time and haven't had any problems. Maybe you can specify "doesn't work" a little more? Or can you create some test case where both APIs show different results?

Mr_Chaos

Quote from: EgonOlsen on August 14, 2014, 03:40:31 PM
getPosition() does give you the position in world space in both APIs and i'm not aware of any issues with it. I'm using it all the time and haven't had any problems. Maybe you can specify "doesn't work" a little more? Or can you create some test case where both APIs show different results?

I'll get you some more data, just wanted to know if it was a known problem.

An example

If I use camera.setPosition and then camera.getPosition the SimpleVectors are different, but i'll get some more data and return

EgonOlsen

No, that can't be. The method returns the exact same values.


public void setPosition(SimpleVector pos) {
backBx = pos.x;
backBy = pos.y;
backBz = pos.z;
}



public SimpleVector getPosition() {
return SimpleVector.create(backBx, backBy, backBz);
}