たけし
unread,Apr 15, 2011, 2:20:30 PM4/15/11Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to 日本Androidの会
gluUnProjectの使い方がわかりません。
public boolean mousePick(GL10 gl,float curX,float curY,int width,int
height,Vector3D dir)
{
int i;
int[] bits = new int[16];
int[] bits2 = new int[16];
float[] model = new float[16];
float[] proj = new float[16];
((GL11)gl).glGetIntegerv(GL11.GL_MODELVIEW_MATRIX_FLOAT_AS_INT_BITS_OES,
bits, 0);
for(i = 0; i < bits.length; i++)
{
model[i] = Float.intBitsToFloat(bits[i]);
}
((GL11)gl).glGetIntegerv(GL11.GL_PROJECTION_MATRIX_FLOAT_AS_INT_BITS_OES,
bits2, 0);
for( i = 0; i < bits2.length; i++)
{
proj[i] = Float.intBitsToFloat(bits2[i]);
}
float[] ret = new float[3];
int[] view = {0, 0, width, height};
try
{
GLU.gluUnProject(
curX, curY, 0f,
model, 0, proj, 0,
view, 0, ret, 0);
}
catch(Exception e)
{
GLU.gluErrorString(gl.glGetError());
}
int x = (int)(ret[0] * 0x10000);
int y = (int)(ret[1] * 0x10000);
int z = (int)(ret[2] * 0x10000);
dir.normalize();
return "(intersect(new Vector3D(x,y,z),dir))";
}
こうすると例外が発生するのですが、エラーの内容は「No Error」です。
Android 2.2のGalaxy Tabを使っています。
最終的にマウスピッキングにしますが、まずはスクリーン座標から空間上の座標に変換するにはどうしればいいでしょうか?