www.jpct.net

jPCT-AE - a 3d engine for Android => Support => Topic started by: saadasif21 on November 07, 2017, 07:33:33 am

Title: getting world coordinates of point at specific distance from camera
Post by: saadasif21 on November 07, 2017, 07:33:33 am
Hi geeks,
i have been trying to get world coordinates at specific distance from camera. i cant use collision detection because i do not have object at that point. I’m at my wits’ end!

let me explain briefly,
lets suppose my camera is at (0,0,-50) and i cant have any object in my world. If i tap anywhere on my 2d screen, where in the world space at z=0 that tap goes. please help
please ask if you need further clarification.
Title: Re: getting world coordinates of point at specific distance from camera
Post by: EgonOlsen on November 07, 2017, 07:40:45 am
You can use this for example: http://www.jpct.net/jpct-ae/doc/com/threed/jpct/Interact2D.html#reproject2D3DWS(com.threed.jpct.Camera, com.threed.jpct.FrameBuffer, int, int, float) (http://www.jpct.net/jpct-ae/doc/com/threed/jpct/Interact2D.html#reproject2D3DWS(com.threed.jpct.Camera, com.threed.jpct.FrameBuffer, int, int, float))

I'm not sure if it does exactly what you want, because you are talking about z=0 in world space here!? However, this method takes z in camera space (which is actually natural, because that's the space into which your taps are going). Just remember that z=0 in camera space isn't a bright idea, so use 1 for 10 or whatever fits you instead.
Title: Re: getting world coordinates of point at specific distance from camera
Post by: EgonOlsen on November 07, 2017, 07:55:56 am
This thread contains some example code btw (for desktop jPCT, but the idea still applies): http://www.jpct.net/forum2/index.php/topic,2413.0.html (http://www.jpct.net/forum2/index.php/topic,2413.0.html)
Title: Re: getting world coordinates of point at specific distance from camera
Post by: saadasif21 on November 08, 2017, 10:09:33 am
Thanks for your help,
I got out of that mess by using
Interact2D.reproject2D3D(world.getCamera(), fb, x, y);
 Thanks again :)