Using Gluunproject To Map Touches To X,y Cords On Z=0 Plane In Android Opengl Es 2.0
Solution 1:
There is nothing particularly special about what gluUnProject (...)
does. If you have all of the matrices and the viewport dimensions (x,y and width,height) I can walk you through the process of implementing it yourself.
NOTE: I tend to call each coordinate space by a different name than you might be used to, understand that screen space is another name for window space, view space is another name for eye space, object space is another name for model space.
Step 1:
Screen Space to NDC space (Undo Viewport Transform)
NDCX = (2.0 × (ScreenX - ViewportX) / ViewportW) - 1.0
NDCY = (2.0 × (ScreenY - ViewportY) / ViewportH) - 1.0
Screen Space to NDC space (Undo Depth Range Mapping)
Typically in screen space, the Depth Range will map z=0 to near and z=1 to far:
NDCZ = 2.0 × ScreenZ - 1.0
Step 2:
NDC space to Object space (Undo Projection, View and Model Transforms)
(Projection Matrix) × NDCXYZ1 = ViewXYZW
(ModelView Matrix) × ViewXYZW = ObjectXYZW
† This can actually be combined into a single step, as you will see below...
ObjectXYZw = (Projection Matrix × ModelView Matrix) × NDCXYZ1
Now, you may notice that I crossed-out
Post a Comment for "Using Gluunproject To Map Touches To X,y Cords On Z=0 Plane In Android Opengl Es 2.0"