I have a bounding box in model space and I want to intersect it with a ray. I have tried to transform the ray like this. Rotating and scaling works well, but transition does not.
Here is my code:
Xbouding = new BoundingBox(new Vector3(50, 10, 10), new Vector3(120, -10, -10)); ray.Position = Vector3.Transform(ray.Position, Matrix.Invert(MathUtil.CreateWorldMatrix(Position, Rotation, Scale))); ray.Direction= Vector3.Transform(ray.Direction, Matrix.Invert(MathUtil.CreateWorldMatrix(Position, Rotation, Scale))); float? dist = ray.Intersects(Xbouding);
I have this:
I want to know if the ray from the mouse intersects with the boxes shown in the image. Pick works fine unless the model is translated (rotating and scaling works).
Another little question: what does
float? mean? What's the difference between