原文:WPF特效-鱼游动动画3

WPF不支持骨骼,故使用3DMax导出了序列模型文件(.mtl;.obj)。

方法1:

使用Blend 2013打开所有obj文件,拖动排列一下即可在usercontrol中显示,使用RenderTargetBitmap生成png的序列图,使用Timer播放序列图即可。

方法2:

 WPF有很多动态加载obj模型文件的类库,使用循环方法,动态加载所有obj文件,动态生成每个obj对应的序列图。(尚未尝试,理论毫无问题)。

方法3:

  使用Unity3D 打开导出的带骨骼的模型文件,生成png序列图在WPF中加载(尚未尝试)。

方法一详细:

1、Blend打开obj序列并排列(blend项目可以用vs打开,下图为VS中呈现的效果,使用了5个Obj文件,用于测试)

2、使用RenderTargetBitmap生成png序列图

 string sTargetFile = AppDomain.CurrentDomain.BaseDirectory + "Fish1.png";

            RenderTargetBitmap oRenderTargetBitmap = new RenderTargetBitmap((int)this.GdMainZm.Width,
(int)this.GdMainZm.Height, 96, 96, PixelFormats.Pbgra32);
oRenderTargetBitmap.Render(this.GdMainZm); PngBitmapEncoder oPngEncoder = new PngBitmapEncoder();
oPngEncoder.Frames.Add(BitmapFrame.Create(oRenderTargetBitmap));
using (Stream stm = File.Create(sTargetFile))
{
oPngEncoder.Save(stm);
stm.Close();
}

 运行后生成的png效果图如下:

3、使用Timer播放序列图

   private ImageSource ImageSrc;
private DispatcherTimer TimerPlay;
private int Index = -1; private void FishItem8_Loaded(object sender, RoutedEventArgs e)
{
this.Loaded -= FishItem8_Loaded; AsynchUtils.AsynchDelayExecuteFunc(() => {
this.TimerPlay = new DispatcherTimer(DispatcherPriority.SystemIdle);
this.TimerPlay.Interval = TimeSpan.FromSeconds(0.3);
this.TimerPlay.Tick += TimerPlay_Tick;
this.TimerPlay.Start();
}, Utilitys.GetRandomSeed().NextDouble());
} private void TimerPlay_Tick(object sender, EventArgs e)
{
Index++;
if (Index >= 5)
Index = 0; BitmapSource oSource = new CroppedBitmap(BitmapFrame.Create((BitmapSource)ImageSrc),
new Int32Rect(300*Index, 0, 300, 180));
this.ImgMainZm.Source = oSource;
}

4、最终效果演示

                                            

5、只使用了5个obj文件用于测试,序列帧数量过少,所以鱼动作比较呆板,足够多时可避免,例如在我开始之前下载的Winform版的Demo:

http://download.csdn.net/download/staricqxyz/1433772

  该码友采用的序列图如下(约20,帧,游动效果很赞):

  

   

WPF特效-鱼游动动画3的更多相关文章

  1. WPF特效-鱼游动动画

    原文:WPF特效-鱼游动动画   实现思路:           通过VisualBrush Binding方式获取鱼局部图像,在Viewport3D中创建ModelVisual3D块并把获取到的局部 ...

  2. WPF特效-鱼游动动画2

    原文:WPF特效-鱼游动动画2           纯代码撸动画实践2:           原图:(png格式)                                            ...

  3. WPF特效:流光动画效果

    今天有人问我想实现一个流光效果.我简单的录了一下他想实现效果的GIF. 实际效果如下:因为今天有事情,只是大概实现了一个效果.主要使用PointAnimationUsingKeyFrames动画效果来 ...

  4. WPF特效-粒子动画

    原文:WPF特效-粒子动画 WPF实现泡泡龙小游戏效果.     /// -Ball to Ball Collision - Detection and Handling    /// http:// ...

  5. 【WPF】两则动画效果

    原文:[WPF]两则动画效果 引言 利用WPF的动画可以轻而易举的实现各种各样的特效,如擦除,滑动进入等,先看两个效果图 第一个效果 这个动画其实利用了OpacityMask和LinearGradie ...

  6. WPF 加载等待动画

    原文:WPF 加载等待动画 版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.net/qq_29844879/article/details/80216587 ...

  7. WPF实现射线效果动画

    原文:WPF实现射线效果动画 最近的一个项目中有个需求是:从一个点向其它多个点发出射线,要求这些射线同时发出,同时到达. 我就想到了用WPF的动画来实现.WPF中有Line类用于绘制直线,但这个类中好 ...

  8. WPF特效-实现弧形旋转轮播图

    原文:WPF特效-实现弧形旋转轮播图 版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.net/u013224722/article/details/77004 ...

  9. WPF 3D 平移模型+动画(桥梁检测系统)

    原文:WPF 3D 平移模型+动画(桥梁检测系统) 关于WPF 3D,网上有很多旋转的例子,但是关于平移的例子并不是太多.本文并非WPF 3D扫盲篇,因此需要对WPF 3D有一定了解,至少知道View ...

随机推荐

  1. [Vue] Preload Data using Promises with Vue.js and Nuxt.js

    Nuxt.js allows you to return a Promise from your data function so that you can asynchronously resolv ...

  2. php模拟post提交文件图片等

    <?php /** * Email net.webjoy@gmail.com * author jackluo * 2014.11.21 * */ //* function curl_post( ...

  3. 【41.43%】【codeforces 560C】Gerald's Hexagon

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  4. svn pre commit

    windows下的必须要用.bat文件,pre-commit.bat ================================================== @echo off set ...

  5. 关于MD5值加密算法

    public static string getMD5(string str)//该方法获取字符串的md5加密 通经常使用来验证数据     {         System.Security.Cry ...

  6. [React] Use Jest's Snapshot Testing Feature

    Often when testing, you use the actual result to create your assertion and have to manually update i ...

  7. 温故而知新-String类

    String不算是一种类型,而算是一个类.就是说String不仅能够表示string类型,另一些自带的方法能够调用.温故而知新.如今给大家总结了String类应该注意的地方. (1)"==& ...

  8. 微信公众号开发之怎样将本机IP映射成外网域名

    近期一个项目须要用到微信公众号的网页授权登录,在研究这个公众号的时候遇到各种困难,现将自己的一些心得总结一下. 我想进行微信公众号开发遇到的第一个困难就是微信公众号必须输入一个外网能够訪问的域名,在网 ...

  9. Erlang 聊天室程序

    Erlang 聊天室程序( 一) Erlang 聊天室程序(二) 客户端的退出 Erlang 聊天室程序(三) 数据交换格式---json的decode Erlang 聊天室程序(四) 数据交换格式- ...

  10. 小强的HTML5移动开发之路(25)—— AppCan开发环境

    一.工具下载: 官方下载地址:http://www.appcan.cn/experience.html 按照安装指导默认安装即可 二.建立项目 启动AppCan SDK 建立项目 填入在appcan官 ...