Answered by:
Disable autoresize / autoscale in Viewport3D
Question
Answers

This auto scaling is a consequence of the way perspective works.
The default field of view is 45 and the default near plane distance is 0.125. This means that a point (x, 0, 0.125) will be visible at the right side of the viewport when its x coordinate is tan(45/2) * 0.125 = 0.051776. Note how the viewport width doesn't play a part in this computation, if you make it wider the point (0.051776, 0, 0.125) will still be visible at the right side of the viewport, that's why the teapot appears larger.
You could compensate for a width increase by changing the field of view and near plane distance, something along these lines:
double newWidth = grid.ActualWidth; double originalWidth = 509.0; double originalNearPlaneDistance = 0.125; double originalFieldOfView = 45.0; double scale = newWidth / originalWidth; double fov = Math.Atan(Math.Tan(originalFieldOfView / 2.0 / 180.0 * Math.PI) * scale) * 2.0; camera.FieldOfView = fov / Math.PI * 180.0; camera.NearPlaneDistance = originalNearPlaneDistance * scale;
 Marked as answer by rhue Monday, September 03, 2012 10:22 AM
All replies

Hi rhue,
Thank you for your post.
But in your post it is not clear that why this SD object getting bigger, it can't be auto change, right?
Could you please post relatie code here about this 3D object so that we can better help?
Thank you.
Have a nice day.
Annabella Luo[MSFT]
MSDN Community Support  Feedback to us

Hey Annabella,
Thanks for the response, I've almost given up on the question.
The code is basically only for rendering the object with no attached logic behind it (taken from Adam Nathan's "WPF Unleashed": http://pastebin.com/BhTtFqRU
My problem is that the object gets bigger depending on the width, so if you make the window wider the teapot will grow in size (although if I increase the height, it stays the same). How can I turn this off or why is that?

This auto scaling is a consequence of the way perspective works.
The default field of view is 45 and the default near plane distance is 0.125. This means that a point (x, 0, 0.125) will be visible at the right side of the viewport when its x coordinate is tan(45/2) * 0.125 = 0.051776. Note how the viewport width doesn't play a part in this computation, if you make it wider the point (0.051776, 0, 0.125) will still be visible at the right side of the viewport, that's why the teapot appears larger.
You could compensate for a width increase by changing the field of view and near plane distance, something along these lines:
double newWidth = grid.ActualWidth; double originalWidth = 509.0; double originalNearPlaneDistance = 0.125; double originalFieldOfView = 45.0; double scale = newWidth / originalWidth; double fov = Math.Atan(Math.Tan(originalFieldOfView / 2.0 / 180.0 * Math.PI) * scale) * 2.0; camera.FieldOfView = fov / Math.PI * 180.0; camera.NearPlaneDistance = originalNearPlaneDistance * scale;
 Marked as answer by rhue Monday, September 03, 2012 10:22 AM