Saturday, July 28, 2007

jMonkey Camera Vector3f Gotcha

I was seeing some crazy behavior when applying force to my marble according to the current camera orientation. The marble would just shoot off as if force being applied the marble were suddenly increasing exponentially. After lots of System.out.println'ing I discovered that Camera.getDirection() and Camera.getLeft() do not return new Vector3f instances but pointers to the actual instances! So when I thought I was only changing the force quantity, I was in fact changing the actual camera properties. I was able to fix this by using Vector3f.clone().

No comments: