AB4D Forum

Full Version: Bug/Scale Gizmo Axis
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

I've ran into an issue with the group of ModelScalar, ModelMover and ModelRotator in the case of transformation hierarchies and moving in local transformation space.

The issue is, that the axis does not correspond to the axis you drag your mouse in (the transformation matrix of the Model* is not taken into consideration when doing raycast for events). ModelMover and ModelRotator has a workaround: ModelMover can be created anew anytime you want to move object, ModelRotator has 3 static variables that can be set, but ModelScalar has none of it.

Added attachment: So in the case, when Y-axis is rotated into a position of X-axis, you have to drag your mouse vertically on the screen, which does not correspond to the Y-axis being horizontal.

Best regards,
Janovský Roman
I have improved the Ab3d.PowerToys library so that all ModelScalar, ModelMover and ModelRotator support the same way of setting the axes: it is possible to set the static Vector3D properties to set the axes when the default constructor is used (for example in XAML) or create each object with passing the custom axes values to the constructor.

This change will be available in the next version. If you want to have that before the next release, write me a PM or email and I will send you a pre-release version.
the new version works with setting new axes but they still need to be parallel with the original axes - so you can change the direction of axes and their order.

To use custom transformation and orient the ModelScalarVisual3D in any direction, you can add transformation to ModelScalarVisual3D  (or ModelMoverVisual3D or ModelRotatorVisual3D) - for example:

<visuals:ModelScalarVisual3D x:Name="SelectedModelScalar"
                            AxisLength="60" CenterBoxWidth="16" InnerBoxWidth="4" OuterBoxWidth="12"
                            CenterBoxColor="Gray" XAxisColor="Red" YAxisColor="Green" ZAxisColor="Blue"
                            IsCenterBoxShown="{Binding ElementName=IsCenterBoxShownCheckBox, Path=IsChecked}"
                            IsXAxisShown="{Binding ElementName=IsXAxisShownCheckBox, Path=IsChecked}"
                            IsYAxisShown="{Binding ElementName=IsYAxisShownCheckBox, Path=IsChecked}"
                            IsZAxisShown="{Binding ElementName=IsZAxisShownCheckBox, Path=IsChecked}">

           <RotateTransform3D x:Name="ScaleRotation">
                   <AxisAngleRotation3D Axis="0 1 0" Angle="30" />
           <TranslateTransform3D x:Name="ScaleTranslation" />


After that in code instead of setting the SelectedModelScalar.Position, set the translation:

//SelectedModelScalar.Position = boxPosition;
ScaleTranslation.OffsetX = boxPosition.X;
ScaleTranslation.OffsetY = boxPosition.Y;
ScaleTranslation.OffsetZ = boxPosition.Z;

Of course, you can change the RotateTransform3D with any other transform.