Simple renderer in .net with SharpGL (openGL)

Re: Simple renderer in .net with direct3d
#22
I can't directly answer your question, since I don't know Direct3D. However, I can give an overview of what LDView does.

IIRC, LDView first calculates the bounding box for the whole model. Next, using the center of that box, it calculates the bounding sphere for the whole model. It then moves the camera to the center of the sphere, then backs it up by an amount calculated based on the FOV and the sphere radius. I believe that the distance to move back is:

Note that I believe fov in the above is either the horizontal FOV (if the window is taller than it is wide) or the vertical FOV (if the window is wider than it is tall). OpenGL expects you to always give it the vertical FOV, so LDView calculates that based on the horizontal FOV when the window is taller than it is wide. I suspect that Direct3D also wants the vertical FOV. If you always use the same FOV value, no matter what the window shape, I believe you'll get a cropped image if you use that in the above calculation when the window is taller than it is wide.

If have have the horizontal FOV, the vertical FOV can be calculated like so:

VFOV = 2*atan(tan(hfov/2)/(width/height))

Note also that LDView's default zoom level (calculated as per above) is set up so that no matter how you rotate the model, it will always be fully visible (which is why it uses the bounding sphere).

LDView's "zoom to fit" functionality uses an algorithm I got from Lars C. Hassing that solves numerous equations for numerous unknowns to move the view pyramid around until at least two points on the model are exactly at the edge of the view. (Those two points are either at the top and bottom of the view, or at the left and right.) The pyramid is moved in such a way that the view direction remains constant, but the camera position moves in all three dimensions, so the look-at point also moves.
« Next Oldest | Next Newest »

 Messages In This Thread Simple renderer in .net with SharpGL (openGL) - by Michael Heidemann - 2013-11-23, 12:48 Re: Simple renderer in .net with direct3d - by Roland Melkert - 2013-11-23, 17:47 Re: Simple renderer in .net with direct3d - by Michael Heidemann - 2013-11-23, 18:16 Re: Simple renderer in .net with direct3d - by Roland Melkert - 2013-11-23, 18:36 Re: Simple renderer in .net with direct3d - by Michael Heidemann - 2013-11-23, 18:39 Re: Simple renderer in .net with direct3d - by Michael Heidemann - 2013-11-23, 18:48 Re: Simple renderer in .net with direct3d - by Roland Melkert - 2013-11-23, 19:15 Re: Simple renderer in .net with direct3d - by Michael Heidemann - 2013-11-23, 19:19 Re: Simple renderer in .net with direct3d - by Roland Melkert - 2013-11-23, 19:22 Re: Simple renderer in .net with direct3d - by Michael Heidemann - 2013-11-23, 19:32 Re: Simple renderer in .net with direct3d - by Roland Melkert - 2013-11-23, 19:40 Re: Simple renderer in .net with direct3d - by Michael Heidemann - 2013-11-23, 19:54 Re: Simple renderer in .net with direct3d - by Michael Heidemann - 2013-11-23, 19:59 Re: Simple renderer in .net with direct3d - by Roland Melkert - 2013-11-23, 20:27 Re: Simple renderer in .net with direct3d - by Michael Heidemann - 2013-11-23, 20:16 Re: Simple renderer in .net with direct3d - by Roland Melkert - 2013-11-23, 20:25 Re: Simple renderer in .net with direct3d - by Michael Heidemann - 2013-11-23, 20:30 Re: Simple renderer in .net with direct3d - by Roland Melkert - 2013-11-23, 20:50 Re: Simple renderer in .net with direct3d - by Michael Heidemann - 2013-11-23, 20:58 Re: Simple renderer in .net with direct3d - by Roland Melkert - 2013-11-23, 21:06 Re: Simple renderer in .net with direct3d - by Michael Heidemann - 2013-11-23, 21:13 Re: Simple renderer in .net with direct3d - by Travis Cobbs - 2013-11-26, 7:45 Re: Simple renderer in .net with direct3d - by Michael Heidemann - 2013-11-26, 17:36 Re: Simple renderer in .net with direct3d - by Michael Heidemann - 2013-11-29, 11:18 Re: Simple renderer in .net with direct3d - by Roland Melkert - 2013-11-29, 18:22 Re: Simple renderer in .net with direct3d - by Michael Heidemann - 2013-11-30, 10:55 Re: Simple renderer in .net with direct3d - by Michael Heidemann - 2013-11-30, 15:08 Re: Simple renderer in .net with openTK (openGL) - by Michael Heidemann - 2013-11-30, 15:48 Re: Simple renderer in .net with openTK (openGL) - by Roland Melkert - 2013-11-30, 18:40 Re: Simple renderer in .net with openTK (openGL) - by Michael Heidemann - 2013-11-30, 19:44 Re: Simple renderer in .net with openTK (openGL) - by Roland Melkert - 2013-11-30, 20:04 Re: Simple renderer in .net with SharpGL (openGL) - by Michael Heidemann - 2013-12-01, 12:33 Re: Simple renderer in .net with SharpGL (openGL) - by Michael Heidemann - 2013-12-01, 16:34 Re: Simple renderer in .net with SharpGL (openGL) - by Michael Heidemann - 2013-12-01, 16:58 Re: Simple renderer in .net with SharpGL (openGL) - by Roland Melkert - 2013-12-01, 17:51 Re: Simple renderer in .net with SharpGL (openGL) - by Michael Heidemann - 2013-12-01, 17:54 Re: Simple renderer in .net with SharpGL (openGL) - by Travis Cobbs - 2013-12-02, 5:08 Re: Simple renderer in .net with SharpGL (openGL) - by Michael Heidemann - 2013-12-02, 17:58 Re: Simple renderer in .net with SharpGL (openGL) - by Roland Melkert - 2013-12-02, 18:05 Re: Simple renderer in .net with SharpGL (openGL) - by Steffen - 2013-12-03, 7:58 Re: Simple renderer in .net with SharpGL (openGL) - by Michael Heidemann - 2013-12-03, 16:53 Re: Simple renderer in .net with SharpGL (openGL) - by Steffen - 2013-12-07, 9:57 Re: Simple renderer in .net with SharpGL (openGL) - by Michael Heidemann - 2013-12-07, 11:10 Re: Simple renderer in .net with SharpGL (openGL) - by Roland Melkert - 2013-12-02, 17:59 Re: Simple renderer in .net with SharpGL (openGL) - by Michael Heidemann - 2013-12-06, 17:30 Re: Simple renderer in .net with SharpGL (openGL) - by Roland Melkert - 2013-12-06, 18:20 Re: Simple renderer in .net with SharpGL (openGL) - by Michael Heidemann - 2013-12-06, 19:30 Re: Simple renderer in .net with SharpGL (openGL) - by Roland Melkert - 2013-12-06, 20:27 Re: Simple renderer in .net with SharpGL (openGL) - by Michael Heidemann - 2013-12-06, 21:22 Re: Simple renderer in .net with SharpGL (openGL) - by Travis Cobbs - 2013-12-06, 23:25 Re: Simple renderer in .net with SharpGL (openGL) - by Michael Heidemann - 2013-12-07, 7:06 Re: Simple renderer in .net with SharpGL (openGL) - by Roland Melkert - 2013-12-07, 18:11 Re: Simple renderer in .net with SharpGL (openGL) - by Michael Heidemann - 2013-12-08, 10:46

Forum Jump:

Users browsing this thread: 1 Guest(s)