开发者

WPF and 3D question about animations

I have a few 3D meshes in my WPF application, and I need to add some animations to them, not the typical animations, but rather a sequence of PNG images for creating a graphical animation.

Think of it like I need to add a cartoon animation to the side of a Cube.

I know very well about the Viewport2DVisual3D, but when I replace my normal ModelVisual3D with a V开发者_高级运维iewport2DVisual3D, I get horrible performance! Around the 5 FPS mark.

As soon as I remove the material with IsVisualHostMaterial set to true, the frame rate is restored to a normal state.

Performance is always a tricky subject, but what I was thinking was creating a Visual Brush with an image source of a WriteableBitmap or RenderTargetBitmap and then draw my PNG's to that sequence.

Does this sound OK, or should I not be getting the poor performance that I'm getting?


Actually, come to think of it, have you tried using this?

<DiffuseMatrial>
  <DiffuseMaterial.Brush>
    <VisualBrush ...>
      <VisualBrush.Visual>
        ...

I know that MILCore handles VisualBrush by rendering the backing Visual as a separate operation, so I wouldn't be surprised if it worked very efficiently with 3D.

Update

It also occurs to me you might try:

<DiffuseMaterial>
  <DiffuseMaterial.Brush>
    <DrawingBrush ...>
      <DrawingBrush.Drawing>
        <ImageDrawing ImageSource="{Binding ...} />

This would bypass the use of Visual entirely and possibly run much faster than Viewport2DVisual3D or VisualBrush.


I haven't yet had a need to dig deeply into WPF's 3D optimizations, but I know that Direct3D is capable of rendering using a writable buffer so if MILCore implements it correctly your idea of WritableBitmap or RenderTargetBitmap have a reasonable chance of working. Vista's Flip 3D is able to make this work with high performance using arbitrary applications (even GDI applications) and also uses a writable buffer.

If that doesn't work, another idea for you is to convert your animation into a video, either the traditional way or by creating a DirectShow stream from a sequence of BitmapFrames.

Hopefully someone else can come along and give you a better answer.


If your PNGs are representing a video stream, why not convert them to a video format at the outset? Creating an AVI from frames is easy. Horses for courses, as they say. It could be the PNG decoder slowing you down.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜