私は現在、JOGL から世界座標を取得する方法を考え出そうとしています。現時点では、どこをクリックしても x = 0.0、y= 0.0、z = 0.0 しか返されません。私は何を間違っていますか?
public double[] getMousePosition(int x, int y){
int viewport[] = new int[4];
double modelview[] = new double[16];
double projection[] = new double[16];
float winX, winY, winZ;
float posX, posY, posZ;
double wcoord[] = new double[4];
gl.glGetDoublev( GL2.GL_MODELVIEW_MATRIX, modelview, 0 );
gl.glGetDoublev( GL2.GL_PROJECTION_MATRIX, projection, 0 );
gl.glGetIntegerv( GL2.GL_VIEWPORT, viewport, 0 );
winX = (float)x;
winY = (float)viewport[3] - (float)y;
float[] depth = new float[1];
// gl.glReadPixels(winX, winY, 1, 1, gl.GL_DEPTH_COMPONENT, GL2.GL_FLOAT, depth);
boolean test = glu.gluUnProject( winX, winY, 0.0, modelview, 0, projection, 0, viewport, 0, wcoord, 0);
System.out.println("x: " + wcoord[0] +"y: "+wcoord[1]+" worked? "+test);
System.out.println(modelview[0]);
return wcoord;
}
EDIT :: glu.gluUnproject がブール値を返すことに気付いたことを忘れていたので、false を返す test というブール値に割り当てました。
EDIT2 :: 別のデバッグ ステートメントを追加しました - System.out.println(modelview[0]); また、0.0を返しています
ご協力ありがとうございました
ジェームズ