Quick Tip: How to map video on 3D surface (workaround)

May 13, 2009 at 9:24 AM
Edited May 13, 2009 at 9:25 AM

Suppose we created 3D model "model3D" (type of Kit3D.Windows.Media.Media3DGeometryModel3D) and we want to paint some video on it:

// define invisible media player
var video = new MediaElement
{
AutoPlay = true,
Source = new Uri("http://[some_video_path].wmv"),
Name = "player",
Height = 0,
Width = 0
};

// add media player to main grid (can be same that is used for ViewPort3D)
LayoutRoot.Children.Add(video);

// define video brush (link it to "player" - media element)
var br = new VideoBrush
{
SourceName = "player",
Stretch = Stretch.Fill,
};

// set meterial of 3D model material with DiffuseMaterial that will use VideoBrush
model3D.Material = new DiffuseMaterial(new Kit3DBrush(br));

Enjoy,
Maxim.

PS
The video will be mapped on 3D surface on each polygons, because we're using "DiffuseMaterial".