Hi,

I’m trying to project my cursor in 3D world since few days and I’ve got some problems to detect ray/box intersection.

To present my problem, I will show you how I proceed:

First, I create my ray from my camera informations:

```
const glm::vec3 position = glm::vec3( mouse.x, screenH - mouse.y, 0.f );
const glm::mat4& view = camera.getViewMatrix();
const glm::mat4& projection = camera.getProjectionMatrix();
const glm::vec4& viewPort = camera.getViewport();
ray.origin = glm::unProject( glm::vec3( position.x, position.y, 0.f ),
view,
projection,
viewPort );
ray.direction = glm::unProject( glm::vec3( position.x, position.y, 1.f ),
view,
projection,
viewPort );
```

After that, I compute bounding box for every model and I test intersection :

```
BoundingBox box;
box.setScale(model->getScale());
box.setTranslation(model->getPosition());
if( box.intersectLine( ray.getOrigin(), ray.getDirection() ) )
{
// …
}
```

The problem appear when mouse is “far” from center, I think problem is here because I compare my ray (in world space) to my models (in local space),

[ul]

[li]How can I transform the result of glm::unproject to local space? [/li][li]Am I using “glm::unproject” correctly? [/li][/ul]

I’ve tried to draw the computed ray, it is correctly draw where I click.

Thanks a lot for your time!