themirrortruth
Topic Author
Posts: 8
Joined: 26 May 2015, 11:56

Manipulation and RenderTransform

20 Jul 2015, 16:47

Hello.
I'm trying to made an app that use manipulation to change RenderTransform of some objects.
I'm doing it using your tutorial http://www.noesisengine.com/docs/Gui.Co ... orial.html but it's not working. When i'm starting manipulation the object does not react. Also I looked this topic viewtopic.php?f=3&t=751 and I tried to make do like it says but again it not work. I do not understand what the problem is. Can you help with this please. The project is spread here.
https://www.dropbox.com/s/3a6l5ggzjpoio ... n1.7z?dl=0
 
User avatar
jsantos
Site Admin
Posts: 3905
Joined: 20 Jan 2012, 17:18
Contact:

Re: Manipulation and RenderTransform

20 Jul 2015, 18:11

What platform are you testing? Manipulation is based in touch events, and Unity only generates touch events in Android, iOS and Windows Mobile.
 
themirrortruth
Topic Author
Posts: 8
Joined: 26 May 2015, 11:56

Re: Manipulation and RenderTransform

21 Jul 2015, 02:15

Yes, of course I know that. I'm running it on android.
 
User avatar
jsantos
Site Admin
Posts: 3905
Joined: 20 Jan 2012, 17:18
Contact:

Re: Manipulation and RenderTransform

21 Jul 2015, 02:55

Does the tutorial sample work for you? What version of NoesisGUI are you using?
 
themirrortruth
Topic Author
Posts: 8
Joined: 26 May 2015, 11:56

Re: Manipulation and RenderTransform

21 Jul 2015, 04:36

Noesis 1.2.3, Unity 5.0.1f1 (64-bit). It feels like I'm doing something wrong. Because if i execute this code, the values of the rotation, scale and translation for some reason very little, as if they are always somewhere to zero.
        private Rectangle rectangle;
        private Rectangle manipulationRectangle;
        private TextBlock rotate;
        private TextBlock scale;
        private TextBlock translate;

        public void OnPostInit()
        {
            rectangle = FindName("rectangle") as Rectangle;

            manipulationRectangle = FindName("manipulationRectangle") as Rectangle;

            rotate = FindName("rotate") as TextBlock;
            scale = FindName("scale") as TextBlock;
            translate = FindName("translate") as TextBlock;

            manipulationRectangle.ManipulationStarting += delegate(object sender, ManipulationStartingEventArgs e)
            {
                e.Mode = ManipulationModes.All;
                e.Handled = true;
            };
           
            manipulationRectangle.ManipulationDelta += delegate(object sender, ManipulationDeltaEventArgs e)
            {
                rotate.Text = "Rotate: " + e.DeltaManipulation.rotation.ToString();
                scale.Text = "Scale: " + e.DeltaManipulation.scale.ToString();
                translate.Text = "X: " + e.DeltaManipulation.translation.X.ToString() + "  Y: " +              e.DeltaManipulation.translation.Y.ToString();

                e.Handled = true;
            };
        }
<Grid x:Name="LayoutRoot"><Rectangle x:Name="rectangle" Fill="Red" IsManipulationEnabled="True" RenderTransformOrigin="0.5,0.5" HorizontalAlignment="Center" VerticalAlignment="Center" Width="300" Height="300"/>
	<TextBlock x:Name="rotate" HorizontalAlignment="Left" TextWrapping="Wrap" VerticalAlignment="Top" Foreground="White" FontSize="26.667"><Run Text="Rotate:"/><LineBreak/><Run/></TextBlock>
	<TextBlock x:Name="translate" HorizontalAlignment="Left" TextWrapping="Wrap" VerticalAlignment="Top" Foreground="White" FontSize="26.667" Text="X: Y:" Margin="0,48,0,0"/>
	<TextBlock x:Name="scale" HorizontalAlignment="Left" TextWrapping="Wrap" VerticalAlignment="Top" Foreground="White" FontSize="26.667" Margin="0,102,0,0"><Run Text="Scale:"/><LineBreak/><Run/></TextBlock>
	<Rectangle x:Name="manipulationRectangle" Fill="#FF1919E0" Opacity="0" IsManipulationEnabled="True" Width="640" Height="480" HorizontalAlignment="Center" VerticalAlignment="Center"/>
Image
Last edited by themirrortruth on 21 Jul 2015, 04:42, edited 1 time in total.
 
themirrortruth
Topic Author
Posts: 8
Joined: 26 May 2015, 11:56

Re: Manipulation and RenderTransform

21 Jul 2015, 04:37

 
themirrortruth
Topic Author
Posts: 8
Joined: 26 May 2015, 11:56

Re: Manipulation and RenderTransform

21 Jul 2015, 05:31

I solved the problem. Code
public class ViewControl : UserControl
    {
        private Rectangle rectangle;
        private Rectangle manipulationRectangle;
        private TextBlock rotate;
        private TextBlock scale;
        private TextBlock translate;
        private TextBlock source;
        private TextBlock container;

        private float translateX = 0f;
        private float translateY = 0f;
        private float angle = 0f;
        private float zoom = 1f;

        public void OnPostInit()
        {
            rectangle = FindName("rectangle") as Rectangle;

            manipulationRectangle = FindName("manipulationRectangle") as Rectangle;

            rotate = FindName("rotate") as TextBlock;
            scale = FindName("scale") as TextBlock;
            translate = FindName("translate") as TextBlock;
            source = FindName("source") as TextBlock;
            container = FindName("container") as TextBlock;

            manipulationRectangle.ManipulationStarting += delegate(object sender, ManipulationStartingEventArgs e)
            {
                e.Mode = ManipulationModes.All;
                source.Text = "Source: " + ((Rectangle)e.Source).Name;
                container.Text = "Container: " + e.ManipulationContainer.GetType().Name;

                e.Handled = true;
            };

            manipulationRectangle.ManipulationCompleted += delegate(object sender, ManipulationCompletedEventArgs e)
            {

            };

            manipulationRectangle.ManipulationDelta += delegate(object sender, ManipulationDeltaEventArgs e)
            {
                translateX += e.DeltaManipulation.translation.X;
                translateY += e.DeltaManipulation.translation.Y;
                angle += e.DeltaManipulation.rotation;
                zoom *= e.DeltaManipulation.scale;
                zoom = Mathf.Clamp(zoom, 1f, 2f);

                rotate.Text = "Rotate: " + angle;
                scale.Text = "Scale: " + zoom;
                translate.Text = "X: " + translateX + "  Y: " + translateY;

                TransformGroup group = new TransformGroup();
                group.Children.Add(new RotateTransform { CenterX = rectangle.Width / 2f, CenterY = rectangle.Height / 2f, Angle = angle});
                group.Children.Add(new ScaleTransform { CenterX = rectangle.Width / 2f, CenterY = rectangle.Height / 2f, ScaleX = zoom, ScaleY = zoom });
                group.Children.Add(new TranslateTransform { X = translateX, Y = translateY});

                rectangle.RenderTransform = group;

                e.Handled = true;
            };
        }
 
User avatar
jsantos
Site Admin
Posts: 3905
Joined: 20 Jan 2012, 17:18
Contact:

Re: Manipulation and RenderTransform

23 Jul 2015, 00:05

As you discovered, DeltaManipulation provides changes since the last frame. If you want the cumulative changes since the manipulation started you can use the property CumulativeManipulation.

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot] and 95 guests