Sign in to follow this  
dposton70

Looking to display a live webpage as a texture on a 3d object in WPF

Recommended Posts

I'm trying to map a live webpage to a 3d shape in a WPF window.

I'm using [url="http://awesomium.com/"]http://awesomium.com/[/url] (1.7 RC2) for the webview and [url="http://perspective.codeplex.com/"]http://perspective.codeplex.com/[/url] for the 3d objects.

XAML:
[CODE]
<p:Workshop3D>
<p:Spherical3D ParallelCount="30" DefaultTextureMapping="True">
<p:Spherical3D.Material>
<DiffuseMaterial>
<DiffuseMaterial.Brush>
<ImageBrush TileMode="None" Stretch="Fill"
ImageSource="{Binding Path=WebTexture, ElementName=MyWpfWindow}" />
</DiffuseMaterial.Brush>
</DiffuseMaterial>
</p:Spherical3D.Material>
</p:Spherical3D>
</p:Workshop3D>
[/CODE]


Code Behind:
[CODE]
public MainWindow()
{
_webView = WebCore.CreateWebView(800, 600);
_webView.LoadURL(new Uri(@"http://www.youtube.com"));
while (_webView.IsLoading)
WebCore.Update();
var buffer = (BitmapSurface)_webView.Surface;
var bitmap = new WriteableBitmap(800, 600, 96, 96, PixelFormats.Bgra32, null);
buffer.CopyTo(bitmap.BackBuffer, 800, 4, false, false);
WebTexture = bitmap;
InitializeComponent();
}

private ImageSource _webTexture;
public ImageSource WebTexture
{
get
{
return _webTexture;
}
set { _webTexture = value; RaisePropertyChanged("WebTexture"); }
}
[/CODE]

I know I'm loading the webpage correctly, and the Spherical3D object shows up just fine if I use a jpg as the ImageSource for the ImageBrush (no binding). But for some reason the GET request isn't being called, so I can't even test to see if my copy is working.

So, question #1, how do you turn a WriteableBitmap into the texture for an ImageBrush?
Or is there a better way to do all this?

2 hours of google/bing/duckduckgo didn't bring up anything so any help would be great.
Thanks.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this