AB4D Forum

Full Version: Can we zoom to a rectangle with Ab3d.DXEngine only?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi, I'm currently evaluating the product and I was wonder if it was possible to zoom to a drawn rectangle if I get the Ab3d.DXEngine product only?

Or do I need the ZoomControl too?
It is highly recommended to use DXEngine with Ab3d.PowerToys. The Ab3d.PowerToys provides many tools that are very helpful when developing a 3D application. The time that you will save with the library should easily justify the cost of the library.

But if you are skilled, you can use the pure WPF 3D objects or even low level DXEngine objects to define the 3D scene.

Regarding the zoom to a rectangle, you can try to use ZoomPanel control as it is described in the following forum post: https://forum.ab4d.com/showthread.php?tid=4055

With some math it should be also possible to define a camera from a specified rectangle. Especially with orthographic camera this is not so hard because the size of the size of the rectangle can be easily transformed into CameraWidth: 

CameraWidth = (rectangleWidth / viewportWidth) * currentCameraWidth; // you should also take into account the rectangle height - so in case user would select very tall rectangle, you should adjust the width so that all the height is shown.

After you have CameraWidth, you also need to adjust the look direction. This can be get from the center position of the rectangle. Simply cast a ray from this screen position into the scene and the direction of the ray is your new camera's direction vector.

You can get the ray from Ab3d.PowerToys camera with using CreateMouseRay3D method. To get camera angles (heading, attitude, bank - needed for TargetPositionCamera from Ab3d.PowerToys; but not for FreeCamera) from camera direction, you can use Ab3d.Utilities.CameraUtils.CalculateCameraAngles method.

You can also get a ray with SharpDX: