简体   繁体   中英

Helix Toolkit Animations

I'm trying to animate a fish in my WPF world in C# I'm using the helixtoolkit to import and show the objects

the code now to create is the following:

public MainViewModel()
{
   var worldGroup = new Model3DGroup();
   var fishGroup = new Model3DGroup();

   Model3D world = ModelImporter.Load(@".\Models\1.obj");
   Model3D fish = ModelImporter.Load(@".\Models\2.obj");

   worldGroup.Children.Add(world);
   fishGroup.Children.Add(fish);

   WorldModel = worldGroup;
   FishModel = fishGroup;
}

But I don't know how to animate it, I would love to have it let the fish swim in a custom path defined by points (or if possible by just importing a spline from 3ds max)

And is it possible to just use keyframes from 3dsmax to let the fish swim or have some animation in the model itself (like an animated body)

Was able to simple animate it with following XAML:

<Window x:Class="_3D.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:HelixToolkit="clr-namespace:HelixToolkit.Wpf;assembly=HelixToolkit.Wpf"
    Title="MainWindow" Height="350" Width="525">

<Grid>

    <HelixToolkit:HelixViewport3D ZoomExtentsWhenLoaded="True" Name="MyAnimatedObject">

        <HelixToolkit:SunLight />

        <ModelVisual3D Content="{Binding FishModel}">
            <ModelVisual3D.Transform>
                <TranslateTransform3D x:Name="MyTranslateTransform3D" OffsetX="0" OffsetY="0" OffsetZ="0" />
            </ModelVisual3D.Transform>
        </ModelVisual3D>
        <ModelVisual3D Content="{Binding WorldModel}" />

        <HelixToolkit:HelixViewport3D.Triggers>
            <EventTrigger RoutedEvent="HelixToolkit:HelixViewport3D.Loaded">
                <BeginStoryboard>
                    <Storyboard>
                        <DoubleAnimation
                            Storyboard.TargetName="MyTranslateTransform3D"
                            Storyboard.TargetProperty="OffsetX"
                            To="10"
                            AutoReverse="True" RepeatBehavior="Forever" />
                    </Storyboard>
                </BeginStoryboard>
            </EventTrigger>
        </HelixToolkit:HelixViewport3D.Triggers>
    </HelixToolkit:HelixViewport3D>
</Grid>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM