[SOLVED] Why is adding a vector to another vector not working?

Hi,

Why is this code not working?

 Vector3f planeDirection = new Vector3f(0, 0, 0);
 public void someMethod(){
  Vector3f add = new Vector3f(Mouse.getX(), Mouse.getY(), 0);
  planeDirection.add(add); 
  System.out.println(planeDirection + "" + add);
}

When I print out the values, it just prints out this:

(0.0, 0.0, 0.0)(129.0, 143.0, 0.0)

So, even though I am adding a positive vector to a vector of 0, the vector I am adding to does not seem to change.

It’s probably a stupid mistake, but I can’t seem to work this out.

Thanks.

addLocal()

Thanks, but could you explain why that is? add() on your conventional vecmath or LWJGL Vector3f has always worked for me in the past.

If only there were some documentation or something that one could look at to read all about it…

http://javadoc.jmonkeyengine.org/com/jme3/math/Vector3f.html#addLocal(float,%20float,%20float)
http://javadoc.jmonkeyengine.org/com/jme3/math/Vector3f.html#add(float,%20float,%20float)

1 Like