AB4D Forum

Full Version: Combination of ModelMover and ModelRotate and ModelResizer
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I couldn't find a simple way to combine those two controls. When using the rotator, it moves the decorator to an incorrect position.

Also is there the possibility for like a ModelResizer, for easier resizing?
I would guess that the problem is in the order of transformations.

You need to be sure that you first rotate your model and then translate it. If you rotate a translated model, the model will be also moved with the rotation because it was already moved away from the center of rotation.

If you are using Transform3DGroup to add transformations, you can use the following method to add transformations:
        // Add rotateTransform3D in front of any other transformations
        private void AddRotateTransform(Visual3D visual3D, RotateTransform3D rotateTransform3D)
            if (visual3D.Transform == null)
                visual3D.Transform = rotateTransform3D;

            var transform3DGroup = visual3D.Transform as Transform3DGroup;
            if (transform3DGroup == null)
                // If there is already some other transformation, then create a new Transform3DGroup
                transform3DGroup = new Transform3DGroup();

                visual3D.Transform = transform3DGroup;

            // Insert rotation as the first transformation - this way we are sure that it gets before any translations
            if (transform3DGroup.Children.Count > 0)
                transform3DGroup.Children.Insert(0, rotateTransform3D);

This method is an updated version of the method that is define in the Ab3d.PowerToys.Samples.Utilities.ModelRotatorSample class (in PowerToys v8.0). 

I did not yet have time to implement ModelResizer. I am planning to implement it for the next version.