Use MatrixCamera with LineSelectorData
#1
I have implemented a view using a DxScene with a MatrixCamera and some PolyLineVisual3D elements directly attached to the scene. 

I have hit the snag that LineSelectorData expects a Ab3d.Cameras.BaseCamera which the MatrixCamera cannot be typecasted to.

The only solution I can think of is using 2 cameras - a primary MatrixCamera with a TargetPositionCamera synced to it (if that is even possible?)

I cannot assign a TargetPositionCamera to the DxScene as it fails when typecast to ICamera
#2
As it is shown in the LineSelector sample, the CalculateScreenSpacePositions method has two overloads:
one that takes BaseCamera (used in line 149) and one that takes worldToViewportMatrix (used in line 143):

Because you are using a MatrixCamera, you will need to use the second option.

You can calculate worldToViewportMatrix by using the following:

Code:
var worldToViewportMatrix = viewMatrix * projectionMatrix * GetViewportMatrix(new Size(MainViewport.ActualWidth, MainViewport.ActualHeight));

_lineSelectorData.CalculateScreenSpacePositions(ref worldToViewportMatrix, transform: null);


public static Matrix3D GetViewportMatrix(Size viewportSize)
{
    if (viewportSize.IsEmpty)
        return Ab3d.Common.Constants.ZeroMatrix;
    return new Matrix3D(viewportSize.Width / 2, 0, 0, 0,
        0, -viewportSize.Height / 2, 0, 0,
        0, 0, 1, 0,
        viewportSize.Width / 2,
        viewportSize.Height / 2, 0, 1);
}
Andrej Benedik
#3
I am developing a graphics view in a Winforms app - so went the RenderFormSample way in the Winforms samples - working with DxScene objects directly.

It does seem that rather going with a WPF control (hosted by ElementHost) will actually be the better route in the long run as the AB3D libraries seem to more 'biased' towards WPF. 

I am correct in thinking that?
#4
Ab3d.PowerToys and Ab3d.DXEngine are both build for WPF. But as you can see, they can also work fine for WinForms.

If you will be shown only 3D graphics then I think that there are no significant differences. But if you also want to show UI elements on top of the 3D scene, the WPF is surely better because it much harder to do that with WinForms (see DXEngineOther/OverlayControlsSample sample).

Also for other UI elements WPF is much more capable then WinForms.

So, the librarries are surely more "biased" towards WPF, but it is hard to provide a general advise if you should use it instread of WinForms - it depands heavily on other aspects of your application and your knowlage and preferences there.
Andrej Benedik
  


Forum Jump:


Users browsing this thread:
1 Guest(s)