Hi, I am again.
I am doing a test about picking with JPCT-AE , so I consulted the threads(
http://www.jpct.net/forum2/index.php?topic=1601.0 and
http://www.jpct.net/wiki/index.php/Picking) about picking.
I did like the thread discussed, but I always get the null result! I don't know why.
This is the code sample.
I get two objects of Object3D from the 3ds file: cube[0] and cube[1], I want to pick the cube[1] in the world.
so I set the cube[1] to be picked:
try {
cube = Loader.load3DS(
new FileInputStream("/sdcard/jpct/sphere.3ds"), 1);
Loader.clearCache();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
cube[0].setTexture("texture");
cube[0].strip();
cube[0].build();
world.addObject(cube[0]);
cube[1].setTexture("mark");
cube[1].strip();
cube[1].build();
world.addObject(cube[1]);
cube[1].setCollisionMode(Object3D.COLLISION_CHECK_OTHERS);
and then I was doing picking like this as the thread
http://www.jpct.net/wiki/index.php/Picking did.
SimpleVector dir=Interact2D.reproject2D3DWS(world.getCamera(), fb, (int)AppConfig.screenX, (int)AppConfig.screenY ).normalize();;
Object[] res = world.calcMinDistanceAndObject3D(world.getCamera().getPosition(), dir, 10000 /*or whatever*/);
judgePicking(res[1]);
public void judgePicking(Object object)
{
if(object.equal(cube[1]))
{
Log.i("Path", "Picking");
}
else {
Log.i("Path", "NULL");
}
}
I always get "null" from the function of "judgePicking()". I don't know what goes wrong.
anyone could help me? Thanks very much.