Pick and bouldin volume

hi,



need to check if the User has clicked on a model. I’m using this function:



public class pickit extends InputAction {



public void performAction( InputActionEvent evt ) {

System.out.println(“pick”);

Vector2f mousePos = new Vector2f();

mousePos.x = MouseInput.get().getXAbsolute();

mousePos.y = MouseInput.get().getYAbsolute();

Ray pickRay = new Ray();

DisplaySystem display = DisplaySystem.getDisplaySystem();

display.getWorldCoordinates(mousePos, 0, pickRay.getOrigin());

display.getWorldCoordinates(mousePos, 1, pickRay.getDirection());

pickRay.getDirection().subtractLocal(pickRay.getOrigin()).normalizeLocal();



// Does the mouse’s ray intersect the box’s world bounds?

TrianglePickResults pr = new TrianglePickResults();

pr.clear();

pr.setCheckDistance(true);

andares[indexAndar].pegaApIndex().pegaComodoIndex().getNode().findPick(pickRay, pr);

if(pr.getNumber() > 0)

{

for(int j=0; j<pr.getNumber(); j++)

{

click(pr.getPickData(0).getTargetMesh().getName());



}

}

}

}





it works well, but only when I create a box with size 1,1,1 … example:



Box cubo = new Box(codModeloComodo,new Vector3f(0,0,0),new Vector3f(1,1,1));

cubo.setModelBound(new BoundingBox());

cubo.updateWorldBound();

cubo.updateModelBound();

cubo.updateRenderState();

cubo.updateGeometricState( 0, true );




when I put larger or smaller size to create the box, the function does not identify click on the model …



how I could solve this problem ?



I’m using JME2.



thanks.