Welcome! Log In Create A New Profile

Advanced
Re: Simple renderer in .net with direct3d
avatarNovember 25, 2013 11:45PM
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:

radius / sin(fov/2)

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.
SubjectAuthorViewsPosted
Simple renderer in .net with SharpGL (openGL) Michael Heidemann421November 23, 2013 04:48AM
Re: Simple renderer in .net with direct3d Roland Melkert166November 23, 2013 09:47AM
Re: Simple renderer in .net with direct3d Michael Heidemann139November 23, 2013 10:16AM
Re: Simple renderer in .net with direct3d Roland Melkert148November 23, 2013 10:36AM
Re: Simple renderer in .net with direct3d Michael Heidemann122November 23, 2013 10:39AM
Re: Simple renderer in .net with direct3d Michael Heidemann202November 23, 2013 10:48AM
Re: Simple renderer in .net with direct3d Roland Melkert94November 23, 2013 11:15AM
Re: Simple renderer in .net with direct3d Michael Heidemann112November 23, 2013 11:19AM
Re: Simple renderer in .net with direct3d Roland Melkert115November 23, 2013 11:22AM
Re: Simple renderer in .net with direct3d Michael Heidemann115November 23, 2013 11:32AM
Re: Simple renderer in .net with direct3d Roland Melkert104November 23, 2013 11:40AM
Re: Simple renderer in .net with direct3d Michael Heidemann108November 23, 2013 11:54AM
Re: Simple renderer in .net with direct3d Michael Heidemann112November 23, 2013 11:59AM
Re: Simple renderer in .net with direct3d Roland Melkert106November 23, 2013 12:27PM
Re: Simple renderer in .net with direct3d Michael Heidemann102November 23, 2013 12:16PM
Re: Simple renderer in .net with direct3d Roland Melkert110November 23, 2013 12:25PM
Re: Simple renderer in .net with direct3d Michael Heidemann123November 23, 2013 12:30PM
Re: Simple renderer in .net with direct3d Roland Melkert109November 23, 2013 12:50PM
Re: Simple renderer in .net with direct3d Michael Heidemann116November 23, 2013 12:58PM
Re: Simple renderer in .net with direct3d Roland Melkert99November 23, 2013 01:06PM
Re: Simple renderer in .net with direct3d Michael Heidemann130November 23, 2013 01:13PM
Re: Simple renderer in .net with direct3d Travis Cobbs216November 25, 2013 11:45PM
Re: Simple renderer in .net with direct3d Michael Heidemann167November 26, 2013 09:36AM
Re: Simple renderer in .net with direct3d Michael Heidemann149November 29, 2013 03:18AM
Re: Simple renderer in .net with direct3d Roland Melkert140November 29, 2013 10:22AM
Re: Simple renderer in .net with direct3d Michael Heidemann115November 30, 2013 02:55AM
Re: Simple renderer in .net with direct3d Michael Heidemann100November 30, 2013 07:08AM
Re: Simple renderer in .net with openTK (openGL) Michael Heidemann160November 30, 2013 07:48AM
Re: Simple renderer in .net with openTK (openGL) Roland Melkert145November 30, 2013 10:40AM
Re: Simple renderer in .net with openTK (openGL) Michael Heidemann118November 30, 2013 11:44AM
Re: Simple renderer in .net with openTK (openGL) Roland Melkert244November 30, 2013 12:04PM
Re: Simple renderer in .net with SharpGL (openGL) Michael Heidemann187December 01, 2013 04:33AM
Re: Simple renderer in .net with SharpGL (openGL) Michael Heidemann155December 01, 2013 08:34AM
Re: Simple renderer in .net with SharpGL (openGL) Michael Heidemann142December 01, 2013 08:58AM
Re: Simple renderer in .net with SharpGL (openGL) Roland Melkert148December 01, 2013 09:51AM
Re: Simple renderer in .net with SharpGL (openGL) Michael Heidemann257December 01, 2013 09:54AM
Re: Simple renderer in .net with SharpGL (openGL) Travis Cobbs162December 01, 2013 09:08PM
Re: Simple renderer in .net with SharpGL (openGL) Michael Heidemann155December 02, 2013 09:58AM
Re: Simple renderer in .net with SharpGL (openGL) Roland Melkert160December 02, 2013 10:05AM
Re: Simple renderer in .net with SharpGL (openGL) Steffen146December 02, 2013 11:58PM
Re: Simple renderer in .net with SharpGL (openGL) Michael Heidemann167December 03, 2013 08:53AM
Re: Simple renderer in .net with SharpGL (openGL) Steffen257December 07, 2013 01:57AM
Re: Simple renderer in .net with SharpGL (openGL) Michael Heidemann128December 07, 2013 03:10AM
Re: Simple renderer in .net with SharpGL (openGL) Roland Melkert189December 02, 2013 09:59AM
Re: Simple renderer in .net with SharpGL (openGL) Michael Heidemann199December 06, 2013 09:30AM
Re: Simple renderer in .net with SharpGL (openGL) Roland Melkert141December 06, 2013 10:20AM
Re: Simple renderer in .net with SharpGL (openGL) Michael Heidemann118December 06, 2013 11:30AM
Re: Simple renderer in .net with SharpGL (openGL) Roland Melkert149December 06, 2013 12:27PM
Re: Simple renderer in .net with SharpGL (openGL) Michael Heidemann122December 06, 2013 01:22PM
Re: Simple renderer in .net with SharpGL (openGL) Travis Cobbs145December 06, 2013 03:25PM
Re: Simple renderer in .net with SharpGL (openGL) Michael Heidemann198December 06, 2013 11:06PM
Re: Simple renderer in .net with SharpGL (openGL) Roland Melkert140December 07, 2013 10:11AM
Re: Simple renderer in .net with SharpGL (openGL) Michael Heidemann225December 08, 2013 02:46AM



Sorry, only registered users may post in this forum.

Click here to login