For 3d-picking I planned to do this:
-Get touch coordinates (x, y)
-Choose vertex from vertex buffer of my model (xM, yM, zM).
-Then project by my own hands (xM, yM, zM) on the screen coords
(xM, yM, zM) ---> (xP, yP, ...)
and then check match (for example sqrt((x - xP)^2 + (y - yP)^2) < SOME_EPS)
For projecting I saved Frustum Matrix in mProjectionMatrix:
gl.glFrustumf(-ratio / q, ratio / q, -1 / q, 1 / q, 1, 25);
Matrix.frustumM(mProjectionMatrix, 0, -ratio / q, ratio / q, -1 / q, 1 / q, 1, 25);
and saved Transform coordinates in mAccRotation:
gl.glLoadMatrixf(mAccRotation, 0);
So the testing function turned into this: (TESTIFY_VERT is one of ones in my model)
public void touch(float x, float y){
float TESTIFY_VERT[] = {0.0f, 0.0f, -1.5f, 1.0f}; //first vert in L0
float Resulted[] = new float[4];
float rMatrix[] = new float[16];
Matrix.multiplyMM(rMatrix, 0, mProjectionMatrix, 0, mAccRotation, 0);
Matrix.multiplyMV(Resulted, 0, rMatrix, 0, TESTIFY_VERT, 0);
}
So I tried to use Resulted[0], Resulted[1] as (xP, yP)
and tried to use (Resulted[0] + 1) * ( WIDTH / 2.0f ), (-Resulted[1] + 1) * ( HEIGHT / 2.0f )
And this don't work. Why? Can you give an advice?
PS I have seen ALL such a questions and they don't answer my problem.