locked
Smooth animations RRS feed

  • Question

  • Hi, all.

     

    I'm having some issues achieving really smooth animations using wpf. How big the problem is varies a bit on

    different computers, but it is never actually perfect. What I'm trying to do shouldn't require much of a high-end

    PC, anyways.

     

    Basically, I'm trying to create a scrolling text at the bottom of the screen (say, for instance 100 pixels high).

    I've created a GlyphRun with my static text, and hooked into the CompositionTarget.Rendering with my method.

    This method only adjusts the OriginX-property (subtracts 2) of the GlyphRun and returns.

     

    Since this should be a plain frame-based animation, I would assume that it should be as smooth as baby

    skin. But it's not. Could post code samples, but it's real basic stuff (taken right out of frame-based tutorials).

     

    Anyone have an idea? Is wpf impossible to use if I am to achieve 100% smootheness?

     

    My thoughts are

     

    1. They say wpf is directx-based. But it seems I cannot use a DirectDraw-window overlaying a wpf-window.

    Airspace, they say.

     

    2. Is DirectX/DirectDraw the only way to achieve smootheness?

     

    3. I believe that the basic cause for this is that the frame rate of the lcd monitor on my PCs are not

    exactly in sync with windows'. What it seems like, is that the animation is smooth for approx 1.5 seconds,

    then it jumps ahead twice the amount of pixels it should. Is there any way of fine-tuning refresh rates?

     

    Using the wpfperf perforator analyzer, it says the application runs with frame rate of approx 67 hz. But

    the LCD monitor says it has 60 hz (this computer runs Windows XP). On another computer (with Vista),

    it reportes 58-60 hz, here the monitor also should run at 60 hz exactly. The scrolling is much smoother

    on the Vista-box, although still not perfect.

     

    Any ideas are greatly appreciated!

     

    Regards,

    Chocolate Eater

     

     

    Tuesday, October 9, 2007 9:55 PM

Answers

  • Hello, try to use the built in animation. It’s much easier to use, and renders better. Try this simple one in XamlPad:

             <Page.Triggers>

                       <EventTrigger RoutedEvent="Page.Loaded">

                                <BeginStoryboard>

                                         <Storyboard RepeatBehavior="Forever">

                                                   <DoubleAnimation Storyboard.TargetName="textBlock1" Storyboard.TargetProperty="(UIElement.RenderTransform).(TranslateTransform.X)" From="0" To="400" Duration="00:00:03"/>

                                         </Storyboard>

                                </BeginStoryboard>

                       </EventTrigger>

             </Page.Triggers>

     

             <Grid>

                       <TextBlock Margin="100,0,0,40" Text="Some Text" VerticalAlignment="Bottom" RenderTransformOrigin="0.5,0.5" x:Name="textBlock1">

                                <TextBlock.RenderTransform>

                                         <TranslateTransform X="0" Y="0"/>

                                </TextBlock.RenderTransform>

                       </TextBlock>

             </Grid>

     

    Thursday, October 11, 2007 5:58 AM

All replies

  • Do you have .NET 3.5 installed?  If not, it might benefit you to install it and see if it improves your animations.  I honestly don't think the Hz has anything to do with it.

    Thursday, October 11, 2007 12:44 AM
  • Hello, try to use the built in animation. It’s much easier to use, and renders better. Try this simple one in XamlPad:

             <Page.Triggers>

                       <EventTrigger RoutedEvent="Page.Loaded">

                                <BeginStoryboard>

                                         <Storyboard RepeatBehavior="Forever">

                                                   <DoubleAnimation Storyboard.TargetName="textBlock1" Storyboard.TargetProperty="(UIElement.RenderTransform).(TranslateTransform.X)" From="0" To="400" Duration="00:00:03"/>

                                         </Storyboard>

                                </BeginStoryboard>

                       </EventTrigger>

             </Page.Triggers>

     

             <Grid>

                       <TextBlock Margin="100,0,0,40" Text="Some Text" VerticalAlignment="Bottom" RenderTransformOrigin="0.5,0.5" x:Name="textBlock1">

                                <TextBlock.RenderTransform>

                                         <TranslateTransform X="0" Y="0"/>

                                </TextBlock.RenderTransform>

                       </TextBlock>

             </Grid>

     

    Thursday, October 11, 2007 5:58 AM