hello everybody…
I'm having some problems translating an object using my camera location…
I want to translate a sphere, checking my pick results and distance of that object from camera… and if the Ray hits it, i want to translate that sphere while my mouse button pressed… but when I do this, I can't see the sphere, and when I release the mouse, the sphere continues translating…
here is the full code…
public class BolinhaPick extends InputAction {
private Camera camera;
private Node bolinhas;
private float shotTime = 0;
private String hitItems;
private float hitDistance;
private Timer timer;
private Geometry porta;
public BolinhaPick(Camera camera, Node bolinhas, Timer timer) {
this.camera = camera;
this.bolinhas = bolinhas;
this.timer = timer;
}
/* (non-Javadoc)
* @see com.jme.input.action.MouseInputAction#performAction(float)
*/
public void performAction(InputActionEvent evt) {
//Pega o tempo em que foi resgitrado o evento
shotTime += evt.getTime();
String actionString;
if ( !evt.getTriggerAllowsRepeats() ) {
actionString = evt.getTriggerPressed() ? "pressionado" : "solto";
} else {
actionString = "baixo";
}
System.out.println( evt.getTriggerDevice() + " " + evt.getTriggerName() + " (" + evt.getTriggerIndex() + ":" + evt.getTriggerCharacter() + ") " + actionString + " em " + timer.getTime() );
if( evt.getTriggerName().equals("BUTTON0") && actionString.equals("pressionado")) {
shotTime = 0;
Ray ray = new Ray(camera.getLocation(), camera.getDirection()); // camera direction is already normalized
//Resultado das Bolinhas
PickResults res_Bolinhas = new BoundingPickResults();
//Seta que a distancia