AB4D Forum

Full Version: Autofit visible models to screen
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello Ab4d Team,

I have a Model and dimmensions displayed in a viewport. I can calculate the distance of the camera based on the width of the model, but this does not respect the camera settings (attitude/heading/bank). So eventually it has too large margins or the model is chopped off.

[Image: http://abload.de/img/3drgzvw.png]

Is there a possibility to fit the "visible" model to screen?

Thanks and regards
Johannes
You can check the "Scene editor" sample that comes with Ab3d.PowerToys library - it contains a sample code that can be used to achieve "Fit to view" functionality.

But because this works on scene's bounding box, you should not expect that your models with be shown from edge to edge - there will almost always be an empty margin around your scene.
(12-11-2015, 10:52 AM)abenedik Wrote: [ -> ]You can check the "Scene editor" sample that comes with Ab3d.PowerToys library - it contains a sample code that can be used to achieve "Fit to view" functionality.

But because this works on scene's bounding box, you should not expect that your models with be shown from edge to edge - there will almost always be an empty margin around your scene.

I already have that code implemented in my solution :) And it works good but it is exactly the problem you mentioned. Some times the models are quite large or the minimum resolution is set, so it is important that the model fits to the bounds and nothing is hidden, even with different camera settings.

Is it possible that the camera makes a 2D projection from its look direction to calculate the bounding box of the visible area?
Is it possible to calculate the visible rectanlge with the usage of the camera's "Rect3DTo2D" method? As shown in the Example "Camera 3D to 2D"?