www.jpct.net

jPCT-AE - a 3d engine for Android => Support => Topic started by: loongy on April 03, 2011, 05:01:42 pm

Title: projecting rays into the screen
Post by: loongy on April 03, 2011, 05:01:42 pm
i want to project a ray into the 3d world by touching the screen and using those 3d co ordinates.
i am not trying to select objects, but i want to move an object to the projected position.
i know the y component of the resulting projected vector (cuz the object must always be at a specific y height)

any ideas?
Title: Re: projecting rays into the screen
Post by: Kaiidyn on April 03, 2011, 07:44:29 pm
Take a look at my topic here, it might help
http://www.jpct.net/forum2/index.php/topic,1803.0.html
Title: Re: projecting rays into the screen
Post by: loongy on April 04, 2011, 11:18:08 am
that won't work for this situation.
i started this thread because none of the other threads seem to work when i implemented their code.
i am trying to touch the screen (2d co-ordinates) and then cast a ray into the 3d world perpendicular to the screen.
its similar to the method of 2d to 3d object picking except i am now trying to move the object i have picked by clicking the screen
Title: Re: projecting rays into the screen
Post by: EgonOlsen on April 04, 2011, 11:30:03 am
It's actually a simple vector equation once you have the position and direction vector. The position vector should be the camera position and the direction vector is the vector returned by the reproject...WS-method. If y of the target plane is known, you end up with three equations and two unknown variables x and z...that's pretty easy to solve on paper. I have some code lying around that does this iirc...i just can't post it right now, because i'm on holiday. Maybe wednesday if you still need it then.
Title: Re: projecting rays into the screen
Post by: loongy on April 04, 2011, 11:38:11 am
no its okay i found out how to do it.
i followed the method for object picking and it didnt really work.
i sat down and re did it all and now it works so i guess there was something simple that i just overlooked.
thanks all!