![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
| |
| | #1 (permalink) |
| | Render Visuals in ASP.NET I'm trying to create a 3D scene in an ASP.NET application, then generate a GIF to send to the browser. I create a Viewport3DVisual, set up the camera and add childrten. This works, since it render if I add it to a windows Window. To generate the image I use RenderTargetBitmap.Render. This also work in a windows Window. In the ASP.NET HttpHandler which output the image. I've tried RenderTargetBitmap.Render(Viewport3DVisual) which generates a black image. I can simmulate this in a windows application by saving the image before the windows is rendered. I assume (after some Reflector-ing) that the visual need a context to render in, and thats why it's not rendered. How do I get the visuals to render? |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Render Visuals in ASP.NET In theory, what you're describing should work. That is, you should be able to build a 3d scene in a Viewport3DVisual and immediate render it to a RenderTargetBitmap. We'll see if we can reproduce this issue. Which CTP are you using? Also, are any of the Materials in your 3d scene VisualBrushes? Neither *should* matter, but it'd be good to know. Thanks, -Adam Smith [MS] "Willie" <Willie@discussions.microsoft.com> wrote in message news:7F36A0B6-5536-400F-AA47-6D6CEE147651@microsoft.com... > I'm trying to create a 3D scene in an ASP.NET application, then generate a > GIF to send to the browser. > > I create a Viewport3DVisual, set up the camera and add childrten. This > works, since it render if I add it to a windows Window. > > To generate the image I use RenderTargetBitmap.Render. This also work in a > windows Window. > > In the ASP.NET HttpHandler which output the image. I've tried > RenderTargetBitmap.Render(Viewport3DVisual) which generates a black image. > I > can simmulate this in a windows application by saving the image before the > windows is rendered. > > I assume (after some Reflector-ing) that the visual need a context to > render > in, and thats why it's not rendered. How do I get the visuals to render? |
My System Specs![]() |
| | #3 (permalink) |
| | Re: Render Visuals in ASP.NET I'm using the December CTP (I've read that there were no changes to the Avalon binaries in the Jan CTP, so I didn't bother with the 1GB download). I don’t use any VisualBrushe’s in the ViewPort3D. Below is a windows Window class to simulate the problem. The SaveToDisk in the constructor does not work, it just generates a balnk image. The second one, in the Actived event does work. public partial class Window2 : Window { private Viewport3D viewport3D = new Viewport3D(); public Window2() { InitializeComponent(); this.Activated += new EventHandler(OnActivatedHandler); PerspectiveCamera camera = new PerspectiveCamera(new Point3D(0, 0, 7), new Vector3D(0, 0, -7), new Vector3D(0, 1, 0), 40); camera.FarPlaneDistance = 20; camera.NearPlaneDistance = 1; viewport3D.Camera = camera; ModelVisual3D visual3D = new ModelVisual3D(); visual3D.Content = new DirectionalLight(Colors.White, new Vector3D(0, 0, -5)); Cylinder3D cylinder = new Cylinder3D(); DiffuseMaterial material = new DiffuseMaterial(); material.Brush = Brushes.Blue; cylinder.Material = material; visual3D.Children.Add(cylinder); viewport3D.Children.Add(visual3D); this.AddChild(viewport3D); SaveToDisk(viewport3D, "c:\\inConstrictor.jpg"); //THIS DOES NOT WORK } protected void OnActivatedHandler(object sender, EventArgs e) { SaveToDisk(this.viewport3D, "c:\\inActivated.jpg"); //THIS WORKS } private void SaveToDisk(Visual visual, String fileName) { JpegBitmapEncoder encoder = new JpegBitmapEncoder(); RenderTargetBitmap rtb = new RenderTargetBitmap(800, 800, 96d, 96d, PixelFormats.Default); rtb.Render(visual); BitmapFrame frame = BitmapFrame.Create(rtb); encoder.Frames.Add(frame); FileStream file = new FileStream(fileName, FileMode.Create); encoder.Save(file); file.Close(); } } Thanks "Adam Smith [MS]" wrote: > In theory, what you're describing should work. That is, you should be able > to build a 3d scene in a Viewport3DVisual and immediate render it to a > RenderTargetBitmap. We'll see if we can reproduce this issue. Which CTP > are you using? Also, are any of the Materials in your 3d scene > VisualBrushes? Neither *should* matter, but it'd be good to know. > > Thanks, > -Adam Smith [MS] > > "Willie" <Willie@discussions.microsoft.com> wrote in message > news:7F36A0B6-5536-400F-AA47-6D6CEE147651@microsoft.com... > > I'm trying to create a 3D scene in an ASP.NET application, then generate a > > GIF to send to the browser. > > > > I create a Viewport3DVisual, set up the camera and add childrten. This > > works, since it render if I add it to a windows Window. > > > > To generate the image I use RenderTargetBitmap.Render. This also work in a > > windows Window. > > > > In the ASP.NET HttpHandler which output the image. I've tried > > RenderTargetBitmap.Render(Viewport3DVisual) which generates a black image. > > I > > can simmulate this in a windows application by saving the image before the > > windows is rendered. > > > > I assume (after some Reflector-ing) that the visual need a context to > > render > > in, and thats why it's not rendered. How do I get the visuals to render? > > > |
My System Specs![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Problems with visuals downloaded from microsoft (wmp 11) | Media Center | |||
| Vista corrupt visuals | Vista General | |||
| visuals | Vista performance & maintenance | |||
| Vista Visuals - What are they using? | Vista General | |||