Arun Kumar

Arun Kumar

  • NA
  • 20
  • 1.7k

How to draw an animated GIF file into the ViewPort3d in WPF

Apr 19 2015 10:56 AM
How I can draw an aniamted gif on WPF I tried this following code but that draw the image without any animation. Is it possible to draw a gif animation in WPF?
 
 
private void DrawPanelSurface(Model3DGroup model_group)
{ // Make a mesh to hold the surface.
MeshGeometry3D mesh = new MeshGeometry3D();
// Triangle 1.
// Set the triangle's points.
mesh.Positions.Add(new Point3D(-10, -10, -10));
mesh.Positions.Add(new Point3D(-10, -10, 10));
mesh.Positions.Add(new Point3D(10, -10, 10));
// Set the points' texture coordinates.
mesh.TextureCoordinates.Add(new System.Windows.Point(0, 0));
mesh.TextureCoordinates.Add(new System.Windows.Point(0, 1));
mesh.TextureCoordinates.Add(new System.Windows.Point(1, 1));
// Create the triangle.
mesh.TriangleIndices.Add(0);
mesh.TriangleIndices.Add(1);
mesh.TriangleIndices.Add(2);
// Triangle 2.
// Set the triangle's points.
mesh.Positions.Add(new Point3D(-10, -10, -10));
mesh.Positions.Add(new Point3D(10, -10, 10));
mesh.Positions.Add(new Point3D(10, -10, -10));
// Set the points' texture coordinates.
mesh.TextureCoordinates.Add(new System.Windows.Point(0, 0));
mesh.TextureCoordinates.Add(new System.Windows.Point(1, 1));
mesh.TextureCoordinates.Add(new System.Windows.Point(1, 0));
// Create the triangle.
mesh.TriangleIndices.Add(3);
mesh.TriangleIndices.Add(4);
mesh.TriangleIndices.Add(5);
// Make the surface's material using an image brush.
ImageBrush imagebrush = new ImageBrush();
imagebrush.ImageSource =
new BitmapImage(new Uri("giphy.gif", UriKind.Relative));
DiffuseMaterial image_material = new DiffuseMaterial(imagebrush);
GeometryModel3D surface_model = new GeometryModel3D(mesh, image_material);
// Make the surface visible from both sides.
surface_model.BackMaterial = image_material;
// Add the model to the model groups.
model_group.Children.Add(surface_model);
}
 

Answers (2)