Hi master :
i want to know the model do some reply when i touch it on the screen, so i use the Picking of jpct-ae to realized it.
example
i add a cube with six diff. faces and add setCollisionMode respectively :
// Front
front = new Object3D(2);
front.addTriangle(upperLeftFront,0,0, lowerLeftFront,0,1, upperRightFront,1,0, TextureManager.getInstance().getTextureID("frontt"));
front.addTriangle(upperRightFront,1,0, lowerLeftFront,0,1, lowerRightFront,1,1,TextureManager.getInstance().getTextureID("frontt"));
cube.addChild(front);
world.addObject(front);
front.setCollisionMode( Object3D.COLLISION_CHECK_SELF);
// Back...
// Upper...
// Lower...
// Left...
// Right ...
cube.strip();
cube.build();
world.addObject(cube);
cube.setCulling(false);
cube.scale( 0.05f);
cube.setCollisionMode( Object3D.COLLISION_CHECK_SELF);
and then , i use the touch event to know which face was triggered when i touched the screen :
public int Pickint( int fX, int fY){
//fY = fb.getHeight() - fY;
SimpleVector dir = Interact2D.reproject2D3DWS( cam, fb, fX, fY).normalize();
Object[] res=world.calcMinDistanceAndObject3D(cam.getPosition(), dir, 10000 );
Object3D picked = (Object3D)res[1];
Object3D picked = (Object3D)res[1];
if( picked == null){
return -1;
}
if( picked.getID() == front.getID())
Log.i("jpctae", "touch front");
else if( picked.getID() == back.getID())
Log.i("jpctae", "touch back");
else if( picked.getID() == upper.getID())
Log.i("jpctae", "touch upper");
else if( picked.getID() == lower.getID())
Log.i("jpctae", "touch lower");
else if( picked.getID() == left.getID())
Log.i("jpctae", "touch left");
else if( picked.getID() == right.getID())
Log.i("jpctae", "touch right");
return 1;
}
However, the questions is :
1- the picked.getID() output only have some respond when i touch the top left corner of every face of cube.
2- or some time the picked always = null