My camera, mParentCamera, is not centered on this bounding box.

Now, I would like to move my camera backward (or forward) to view all my scene on the screen (or the bounding box). Could you tell me how to do that, please?

Note: I already implemented the function to move backward and forward (itâ€™s working ).

It moves the camera to try to get the whole tree in view. The view matrix m11 tells sort of the ratio needed as explained in the comments. Itâ€™s hard to explain quickly better than the code does.

Thank you but your solution was not working for me â€¦

After almost two days of debugging to understand whatâ€™s was wrong, itâ€™s working â€¦

Here is how I proceed:

get the bounding box of my world

generate the 8 points of this bounding box
For each point:

compute the distances of the point between the camera plane, the x-plane (dir and up camera vectors) and the y-plane (dir and left camera vectors)

I also compute the distance between the point and the center of the bounding box.

After that I compute the distance which is needed to view x and y distance and I choose the maximum taking in to account the distance between the point and the center of the bounding box.

The position of the camera is equals to the center of the bounding box minus the normalized dir vector of the camera multiply by my computed distanceâ€¦

Also if the field of view about y (FOVy) is know, the FOVx is not equal to: