I have three cubes rotating in my 3D scene. What I'm trying to achieve is calculating which one (if any) of the cubes that has been pressed.
I think I understand how gluUnproject works, I simply have to run gluUnproject twice, once for the near plane and once for the far plane and whatnot. The only problem I have is understanding which modelView to use.
The function prototype looks like this (I'm developing for Android):
public static int gluUnProject (float winX, float winY, float winZ,
float[] model, int modelOffset,
float[] project, int projectOffset,
int[] view, int viewOffset,
float[] obj, int objOffset)
What I don't understand is what modelView matrix I'm supposed to be using for the fourth argument. Do I have to calculate a ray once for every cube, using the modelView matrix of each cube?