Most desktop applications are flat and two dimensional. But they don't have to be that way, at least not if they're WPF applications. This video shows some WPF 3D examples.
- [Narrator] WPF is built on the DirectX 3D rendering engine which means that the pixels rendered to the screen are coming from DirectX. This results in fast, dynamic UI because WPF can leverage the DirectX accelerated 3D rendering pipeline and 2D bitmap rending. This enables WPF to take advantage of the modern graphics cards. Most line of business applications stay in the 2D realm and don't venture over to the 3D side very often. But the 3D system is available when needed. Here are some examples.
I'll run this VideoWrapping.exe. So this is a WPF application. Let me maximize it so it can see everything. And it is a normal two-dimensional application. But it's being rendered as a 3D surface. And I can build a scene that looks more three-dimensional by using what's called a 3D viewport. And I'll go over here to this Cube A demonstration. And this is an example of a viewport, this black area on the screen is the viewport, and what I have here is that viewport inside my WPF application and then inside my viewport I've created some 3D objects.
I've got a camera in here that's pointing at the screen. I've got a model which is a cube model which is showing in here. I have to have some lights shining on the cube so that I can see the surface. And I've painted the outside of the cube with a radial gradient brush so it looks like this. I can manipulate the items by moving the camera around in the 3D viewport or by moving the model, one or the other. And I do that in this simple example by using these scrollbars. I'll grab the scrollbar and I'm changing our perspective on that cube.
Grab this scrollbar over here, spin it in another direction. I can take that same concept and start building more complex scenes. For instance, instead of one cube, what if I cloned that cube and made one model and then I made a thousand copies of it? That's what we're showing here in this CubeScatterPlot.exe. So here you can see it's the same idea. I've got a viewport. I've got a bunch of cube models in there. I've got lights shining on it and a camera.
In this case I'm animating it so I don't have to grab the scrollbars and spin it, it's automatically spinning. And you can see several new interesting things here. It's fast, there's not much jitter on the screen, and you'll notice that not all these cubes are the same. Some of the cubes are opaque and some of the cubes are transparent. They're a little harder to see but if you look near the edges you can see that there's a lot of really semitransparent cubes in there. If I want to zoom in I can use my mouse wheel and I can zoom in closer and see those transparent cubes easier. I can also zoom out and then I can spin the cube with my mouse.
Rather than having scrollbars I can spin it directly with my mouse. You can see it's very quick, very efficient. That's because we're taking advantage of the DirectX pipeline and the graphics GPU on this computer. I'll go back to VideoWrapping and next I want to show you that I don't have to paint the outside of the shape with solid colors or gradient colors, I can use anything. There's a concept in WPF called a video brush, so that's what I'll show you in this example.
It's the same cube but now I'm painting the outside of the cube with a video. And you can see it's on all sides of this cube. It's over here on this side, it's on the back side, and again it's very fluid, very quick. And then finally we'll go back here and I'll click on this example. And this shows a different shape. I don't have to work with cubes, I can work with any shapes. If I know how to use a modelling tool I can create the model. In this case it's a multi-sided shape. And again it has a video brush painting the outside of it. And the other thing happening here of course is I've got an animation that's spinning it so I don't have to touch it with my mouse.
To conclude, 3D is possible. In order to build it into your app you'll have to learn new concepts like modelling, materials, camera types and lighting. These concepts are different from the typical UI developer vocabulary but worth learning if you need 3D in your desktop application.
- Recognize the pluses of choosing Windows Presentation Foundations over other Microsoft UI frameworks.
- Evaluate the different options available with Windows Presentation Foundation project types.
- Devise a Windows Presentation Foundation project in Visual Studio.
- Break down the assemblies and parts of Windows Presentation Foundations.
- Use XAML editor and editor settings.
- Selecting data binding to present data.
- Compiling interaction code for an application.
- Use control templates, 3D parts, and effects in Windows Presentation Foundations.