How to Scroll a Viewport
In the sample project (see test1.gif), I create a rectangle.   In test2.gif I run the app.  Notice that the rectangle is fully displayed.   In test3 I use the mouse scroll wheel to expand the rectangle so that it does not fit on the screen.  I would like to now horizontally scroll to see uncover the hidden part of the rectangle.  How do I do this?  The ScrollViewer that I included in the XAML does not help.    Thanks for your help.

Attached Files Thumbnail(s)
To use ScrollViewer with Viewport3D you need to set the Width and Height of the Viewport3D to fixed values.

But I would strongly advise you not to use ScrollViewer on Viewport3D - the 3D world is not a 2D canvas with its limits - you can rotate the camera around and come and if you rotate to the right you come to the initial view. I have never seen a 3D application that would have scroll viewers on the 3D views.

An exception to the above would be if you use 3D scene to render 2D lines - for example with using Ab3d.DXEngine that can render millions of lines and with using a top-down Orthographic camera to make an impression of a 2D view. There it would be possible to define a limited 2D area where the user would be able to navigate.
Andrej Benedik
Thanks for your response.  It made me think and I have now found the answer to my question.  All I have to do is to click an arrow key in the left-most control in your CameraControlPanel (see attached snap1).  This will move the scene left-right-up-down and thus allow access to any "hidden" part of the display without having to zoom in.  This achieves the scrolling effect I am looking for.

I can also configure your system to allow right-left-up-down movement to be achieved by simply dragging the mouse.  All I have to do is specify in the XAML definition of the MouseCameraController  the following:


I suggest that you add to you samples solution a project that is dedicated solely to camera movement.   The scene would consist of only a ColoredAxisVisual3D object and a CameraControlPanel.  The user can move, rotate and zoom using the CameraControlPanel.   The user can also move, zoom and rotate by dragging the mouse.  Exactly how the mouse is operated to achieve this is specified in the object MouseCameraControl, specifically the parameters MoveCameraConditions, RotateCameraConditions, and QuickZoomConditions.  Therefore, your sample app could have input controls that display the initial XAML values of these parameters .  Then these input controls could be manipulated to use code-behind to change their values (for example, change RotateCameraConditions to "RightMouseButtonPressed, ControlKey".  This would then do a scene rotate if the user holds down the Ctrl key and the right mouse button and drags the mouse).

Attached Files Thumbnail(s)
There are already many samples in the Ab3d.PowerToys that demonstrate the use of MouseCameraController and CameraControlPanel.

For example, the "MouseCameraController / Main properties" sample demonstrates the usage of RotateCameraConditions and MoveCameraConditions.
Andrej Benedik

Forum Jump:

Users browsing this thread:
1 Guest(s)