WPF capabilities - wpf

In my company we have in mind a redesign of the user interface of an application and we would like to make it ... let say "fancy". We have in mind a simple story board but I doubt between WPF, XNA or DirectX. I prefer WPF so I'd need to know if it support the following capabilities and how difficult to implement are they:
Transparency: We'd like to display information layers on top of the main display.
3D support: We want network nodes (part of the interface is a network graphic) to be simple spheres connected with lines in a 3D enviroment, and the ability to control the camera so rotation of the screen is possible.
Effects: Such as shading, lens flare or glow to "signal" the discovery or deletion of a node.
Text animations: Specifically the ability to display the text as if it's being written... You know, the information text will be "filling" the panel top down, left to right...

Good news. WPF is the technology you want and it can handle your requirements with relative ease.
Transparency is simple.
3D support is good as well. For an example, check out Tim Sneath: Five Great WPF 3D Nuggets. You even get hardware acceleration.
Effects are definitely do-able via timeline animations.
The previous statement goes double for Text Animations.
...the hardest part would be the 3D support, but it's still going to be a lot easier than getting things done in XNA or using DirectX libraries directly.

AFAIK WPF 3.5 supports all of this, and even leverages hardware acceleration to get a decent performance.

It's possible to embed an XNA application in a WPF form so you could use XNA for the representation of your network and WPF controls for the GUI in front of it.

Related

WPF real-time rendering

I'm designing a game and thinking about using WPF for making a simple prototype of the basic gameplay.
Is it possible to render basic 2d-graphics in WPF in real-time? By basic graphics I mean simple shapes such as lines, circles, etc. By "real-time" I mean things are rendered based on parameters such as velocity, acceleration, etc. that changes depending on player input - which I assume means I can't use storyboards for the animations.
Thanks
Check out the previous question High Performance Graphics using the WPF Visual Layer for a good related discussion. While WPF provides a great framework for rich vector graphics, it lacks somewhat for real-time 2D performance.
There are workarounds, for instance, depending on your scene complexity you may get away with using DrawingVisuals or virtualized Shape classes (WPF Vector graphics) to draw your sprites. Going a little lower level, you could cache sprites using the BitmapCache mode available in .NET4.0, or pre-prendering them to Bitmaps and using various optimization patterns to improve throughput.
Going lower level still, you can mix Vector/Raster graphics using the fantantastic WriteableBitmapEx project, or Vector/GPU graphics using the D3DImage.
Regarding how to update your scene, you'll need to write a primitive game engine where on the CompositionTarget.Rendering event (fired on redraw of the screen) you get the updated parameters and compute positions/orientations of your sprites. Something that might help with this is this great codeplex project which integrates WPF/Silverlight and Farseer physics.

When should I go for Silverlight and when XNA?

I don't have much knowledge about Windows Phone 7 development. I know there exist two paths for an app development. Silverlight or XNA. Before I start I would like to know for what scenarios Silverlight is the best choice and for what kind of apps it makes more sense to use XNA?
Silverlight is designed around building applications. As such, it includes a retained graphics model (re-drawing is handled for you) and wide range of user interface elements including both interactive controls and controls that perform layout logic.
XNA is designed around building games. As such, it includes an immediate graphics model (you must draw every frame) and game-friendly features like a content pipeline for importing graphics and low level audio support.
There is nothing stopping you using Silverlight for games and XNA for applications, but unless you have a good reason for switching it around you'll find yourself fighting against the framework while trying to do simple things.
Neil Knight mentioned you can use mix them in Mango, though the mix involves using XNA in a Silverlight application and not the other way around.
Microsoft provided a handy chart just for this type of question :)
http://msdn.microsoft.com/en-us/library/ff402528(v=VS.92).aspx
Use Sliverlight if
You want a XAML-based, event-driven application framework.
You want rapid creation of a Rich Internet Application-style user interface.
You want to use Windows Phone controls.
You want to embed video inside your application.
You want to use an HTML web browser control.
Use XNA if
You want a high-performance game framework.
You want rapid creation of multi-screen 2D and 3D games.
You want to manage art assets such as models, meshes, sprites, textures, effects, terrains, or animations in the XNA Content Pipeline.
Combine Silverlight and XNA if
You want a XAML-based, event-driven application integrated with a high-performance game framework.
You want to create a multi-screen 2D or 3D game that incorporates a Rich Internet Application-style user interface.
You want to use Windows Phone controls along with art assets such as models, meshes, sprites, textures, effects, terrains, or animations in the XNA Content Pipeline.
You want to use Silverlight text rendering, including international text, instead of sprite fonts.
You want the page navigation model of a Silverlight application combined with the rich graphics power of an XNA Framework application.
Silverlight has a rich set of objects for building 2-d interfaces, especially 2-d interfaces composed of text, buttons, images. It's great for displaying data and taking in data.
XNA is meant for building out games or simulations, in particular 3-d, and gives you access to the device at a level somewhat closer to the hardware. XNA lacks the kind of objects that Silverlight does, but you get the flexibility to do more interesting things if you spend the time.
You may find this post useful further.

Silverlight 5, WPF or XNA for 2d/3d NUI visualization app?

I'm currently in the early stages of a project and have difficulty deciding which framework to use. I hear people say WPF is dead, yet it seems to be the (only?) way to program a Microsoft Surface app. This is one of the possible future aims of the project, but not the main focus.
The main focus however is: both 2d and 3d objects in the same view (and kinect/voice support). Some of the 2d objects are SVG files. From what I have read online so far it's not easy to render SVG graphics in XNA (nor Silverlight 5 3D for that matter). I've seen some SVG to XAML converters, but could the result of this be used in a 3d view? Or vice versa?
Considering it's not going to be a game, but a business application I'm tempted to rule out XNA, but then again I also require good performance as there will be quite some graphical stuff going on and if possible support for high resolutions/video wall. Taking a video wall into consideration would maybe rule out WPF as I've read that it will only use hardware acceleration if the resolution is lower than the texture size limit of the GPU.
There is no intend to run the application in the browser or phone, as such i'm tempted to rule out Silverlight 5.
Any tips would be greatly be appreciated.
Thanks!
I wouldn't rule out XNA on the basis that it's "for games". You can simply use only the parts required for hardware-accelerated 3D rendering and ignore the rest. This is in fact what Silverlight 5 does!
So you may find that your 3D rendering code is the same between XNA and SL5 in any case.
Here is a question about SVG in XNA. Basically answer is: you have to write your own hardware-accelerated SVG renderer - a stupidly difficult task. But if your SVG files never change, you could just use an existing software renderer to render them to a texture.
If you converted your SVG to XAML, you would have to render it to a texture to use it in a SL5 3D view anyway (unless it's an overlay). So there is no big win there. I don't know how 2D-3D compositing works in WPF.
Your decision really depends on whether you would find the built-in functionality that SL5 or WPF provides for user interfaces useful? Seeing as you are basically making your own user interface, you probably would not get much use from the provided 2D interface.
The 3D API that SL5 provides is basically a cut-down version of XNA. The 3D API for WPF looks like it just renders models for you - it does not seem to buy you much over XNA. If you have a compelling reason to use XAML, then WPF may be a good choice. Otherwise I'd go with XNA.

Is silverlight better or wpf for graphics, 3d?

I learning wpf/silverlight currently. I want to ask which one of them is better for graphics, 3d, ... ?
People say "Silverlight is a subset of WPF" -- what they mean is that the programming model is the same (code + XAML), but Silverlight generally has a smaller API / less features than WPF.
I think a good example would be creating a reflection. In WPF you could use a VisualBrush, but Silverlight doesn't support it. Still you can create the same effect by creating a 2nd transformed element. You can pretty much acomplish the same task in both, although for Silverlight you may have to do some processing tasks on the server.
The choice of platform depends more on whether you want to target web deployment or not and possibly performance.
3D isn't implemented in Silverlight 4 (though there are 3D libraries out there). 3D will be part of Silverlight 5. (Beta coming soon, probably at MIX, and to be released this year.)
i would sugest wpf in WPF you have all the Viewport sutff where you can do real 3d, In Silverlight you have PlaneTransformation but it is not close to real 3d
WPF 3d tutorial
The deal is more deeper as I understand.
We will speak about WPF and Silverlight 5. There are two mechanisms of 3D Graphics. Before WPF it was a single one - so named pipeline graphics. It includes DirectX, OpenGL and multiple derivative and independent realizations (XNA from DirectX, for example). Although WPF is based internally on DirectX it realizes absolutely different conception of smart graphics. What is the difference for a pipeline and smart mechanism? The pipeline mechanism consists of infinity loop of drawing objects - typically primitives like vertex, triangles. It works by initialization of so named infinity loop by calling something like OnDraw/ReDraw method.
WPF does not use ReDraw and does not draw anything until we directly detect it. It is single correct way to use it. Therefore WPF allows to draw UI Elements with internal support of hundreds events, methods and full freedom of management (like usual WPF control - textbox, for example). (Helix 3D is good library for easy way to WPF 3D) And vice versa, Silverlight 5 has some API of XNA graphics - pipeline way without UIElement support for 3D objects.
There is Kit3D library http://kit3d.codeplex.com/ as very good idea for smart graphic realization for Silverlight and there are many other realizations (Balder, Babylon) on pipeline mechanism. If you are interesting to code an application like web 3D Game - choose pipeline Silverlight 3D graphics, if you are interesting about smart 3D applications - choose WPF 3D.
Author of WPF 3D CAE system TIMO Structural.

WPF Architecture and Direct3D graphics acceleration

After reading the wikipedia article on WPF architecture, I am a bit confused with the benefits that WPF will offer me. (wikipedia is not a good research reference, but i found it useful). I have some questions
1) WPF uses d3d surfaces to render. However, the scenegraph is rendered into the d3d surface by the media integrated layer, which runs on the CPU. Is this true ?
2) I just found out by asking a question here that bitmaps dont use native resources. Does this mean that if i use alot of images, the MIL will copy each when rendering, rather than storing the bitmaps on the video card as a texture ?
3) The article mentions that WPF uses the painters algorithm which is back to front. Thats painfully slow. Is there any rational why WPF omits using Z-buffering and rendering front to back ? I am guessing its because the simplest way to handle transparency, but it seems weak.
The reason i ask is that i am thinking it wont be wise for me to put hundreds of buttons on a screen even though my colleagues are saying its directx accelerated. I dont quite believe that whole directx accelerated bit about WPF. I used to work on video games and my memory of writing d3d and opengl code tells me to be cautious.
For questions #1 and #3 you might want to check out this section of the SDK that discusses the Visual class and how it's rendering instructions are exchanged between the higher level framework and the media integration layer (MIL). It also discusses why the painters algorithm is used.
For #2, no that is most definitely not the case. The bitmap data will be moved to the hardware and cached there.
I tested that, I wrote two programs that show 1,000 buttons on screen, one in WinForms and one in WPF, both worked just fine.
I then pushed that up to 10,000 buttons, at that point the WPF app took a few seconds to start but run just fine, the WinForms app didn't start.
Win32 itself (and WinForms) isn't built for applications with hundreds of controls (believe me I wrote such an app), at some point it just stops working, WPF on the other hand, keeps working even if it slows down a bit at some point.
So, if you do need to put a lot of controls on screen WPF is your best bet (unless you want to roll your own UI framework - and you think you can do better than the entire MS perf team).
Also, WPF has many advantages other than graphics acceleration: richer graphics, drawing model that is easier to work with, animations, 3d and my personal favorite - amazing data-binding.
This will let you develop richer UIs faster - and I think that will make a much bigger difference than the painting algorithm used.
BTW, if you need to put hundreds of buttons on the screen this is likely to be a bad user experience and you may want to reconsider your UI design,

Resources