New in WPF: Build a True 3D Application

New in WPF: Build a True 3D Application

  • Comments 6

Well, it's finally here. As mentioned yesterday, the WPF 3D team had a very special announcement to make today. In the last hour, the bits have gone live on CodePlex. So what have we been getting excited about?

It's now possible to build a fully 3D application that includes controls like textboxes, sliders, buttons etc. With this major advance, there's almost no limit to what you can create in a 3D environment beyond your imagination and the power of the machine.

As a crude example, the screenshot to the right shows a flat plane, a sphere, a cylinder and a cone in a 3D space. The sphere, cylinder and cone each have a button on them, and they're real buttons with a Windows Vista look and feel - hover over them and they light up blue, move the mouse away and the blue fades slowly back to gray. Underneath the button on the cylinder is a textbox - you can really click on it and type in text, you can even select that text by dragging the mouse around the cylinder! Right-click works - everything is hooked up. The flat plane (in the top left corner) shows a series of sliders databound to a box; the sliders edit the dimensions of the box. You can right-click and drag the mouse to change the orientation of the 3D scene, and use the scrollwheel to zoom in and out of the view. This sample is included with the source code, so you can take it apart and play with it to your heart's content.

How do you do this? By adding an Interactive3DDecorator element around a Viewport3D, you can include a subclass of ModelVisual3D that enables any 2D visuals to be added. This means that you can have an object like a button, textbox or a slider appearing on a 3D object and have full hit-testing and interaction working on it. The 3D team implemented this by creating a hidden layer that contains the 2D content and is positioned in (and moved to) exactly the right place to allow hit testing to occur.

Karsten Januszewski and Ernie Booth's Channel 9 interview explains the workings of this in full detail.

Oh, and the neatest thing about this - it runs as is on the WPF 1.0 bits. There's no additional patch or binaries needed beyond the source code at CodePlex. Future releases will embed this capability, but it's testament to the extensibility of the framework that this is something that you can add without needing to touch any of the core class infrastructure.

Have fun - and let us know what you think...

  • Un mystère court depuis hier sur la plupart des blogs US parlant de WPF ( Windows Presentation Foundation

  • Hi Tim, Can I test it on OS-WinXP

  • It works fine on WinXP Pro with WPF 1.0 bits installed

  • Interesting, but (in my opinion) useless. Can we use shaders here?

  • Cool~

    Greate job!!~

  • Can the projects be opened and manipulated in Expression Blend?

Page 1 of 1 (6 items)