I am prototyping on JMonkeyEngine 3 (version 3.2.2-stable), studying it in parallel, and bumped with an issue. Here is a link to the source code.
I have a simple terrain. Initially is was attached to rootNode with default position and rotation. Camera is looking on terrain from the “top”:
camera.setLocation(new Vector3f(0f, 200f, 0f)); camera.lookAt(new Vector3f(0f, 0f, 0f), new Vector3f(0f, 0f, 1f));
Also, I have an analog listener which is literally copy-pasted from here. So I click on the terrain and detect a collision of ray with it.
Everything worked flawlessly, until I decided to turn the whole scene so that z axis direction would be towards the camera instead of y axis. I changed camera location:
camera.setLocation(new Vector3f(0f, 0f, 200f)); camera.lookAt(new Vector3f(0f, 0f, 0f), new Vector3f(0f, 0f, 1f));
…and rotated the terrain:
terrain.rotate(FastMath.HALF_PI, 0, 0);
Visually, the scene looks the same. However, ray doesn’t collide with terrain anymore. I checked the ray’s origin and direction - theoretically it should hit the terrain, yet it doesn’t.
What am I missing?