Ray Collision – Max Distance? (SOLVED)

Using the TestMousePick.java example as a guide, I’m trying to select an object. It works fine when the camera is within 10,000 wu of the object, but it doesn’t work at all if it’s outside of that.



Is there a maximum distance on ray collision tests?



(Sorry if this double posted - I posted it a minute ago but I couldn’t even find the new thread in my own profile)

I don’t remember but there might be a ray limit set in that test. Make sure the ray has unlimited length.

If it still doesn’t work, please post a test case that demonstrates the issue.

Apparently I was just doing it wrong. I had a set of crosshairs in the center of the screen, and pressing spacebar is supposed to select the object at the center of the screen under the crosshairs.



Apparently this doesn’t send a ray straight from the center of the screen:



[java]Vector3f origin = cam.getWorldCoordinates(new Vector2f(settings.getWidth() / 2, settings.getHeight() / 2), 0.0f);

Vector3f direction = cam.getWorldCoordinates(new Vector2f(settings.getWidth() / 2, settings.getHeight() / 2), 0.3f);

direction.subtractLocal(origin).normalizeLocal();

Ray ray = new Ray(origin, direction);[/java]



However, this works quite well:



[java]Vector3f origin = cam.getLocation();

Vector3f direction = cam.getDirection();

Ray ray = new Ray(origin, direction);[/java]



doh… :roll: