When should I go for Silverlight and when XNA? - silverlight

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.

Related

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.

Is there a library to display a Virtual Human [WPF]

While there are a lot of 3D libraries out there, I'm in struggle to find one suitable for WPF.
Basically, I want a Character Animation engine, which loads bone hierarchy and allows me to manipulate the skinned mesh.
I know, this is a classic topic for all the 3D engines. And they are made for building games.
How do I display a Skinned Character in a WPF application?
Depends on how broadly you want to distribute your app, provide installation support for it - and how much work you want to do
1) You can always do it yourself - but you've probably already decided you don't want to spend 2 years of your life building a render pipeline, learning the vagaries of IK, etc
2) You could target XNA - this is sort of WPF, will run on windows, and the xbox to boot - one package you could consider for XNA is Visual 3D - you can find a list of engines here
3) IFF you either can access the target machines directly, or can release your app as a standalone WPF application, you've got a lot of options - all you need is a C# wrapper that allows you to call a native implementation - the one thing you'll loose is WPF ability to superimpose controls, because your render surface will most likely be a winform control embedded in a WPF UI - you will need to get the wrapper DLL into the GAC if you want to distribute the app broadly -
3a) check out the Blender community - the entire tool is open source, and there's a lot of smart people playing in that space
4) I'd tout my own engine but it's undergoing a thorough revision and won't be out again for quite a few months - we'd provide WPF/Silverlight support via option 3 - .Net wrapper over C++ core directly installed into GAC - which makes it available for WPF/Silverlight - I believe we'll still have to pretend to be a winform control to allow the D3D render surfaces to punch through onto the screen
Hope this helps
PS - one side question - You capitalized Virtual Human -- you aren't referencing the NIH Visible Human Project, are you ? If so, last I knew you had to assemble the geometry/bones yourself , all it supplies is the tomagraphic slices
Well you could try this:
OGRE Game engine in WPF
If that OGRE engine supports bones, you should be good to go.
More about the OGRE Engine
Good Luck!
There is no support for skinned meshes in WPF. But you can animate other things like robots well in WPF (see the ape walk example at www.okino.com ).
You can make meshes deform in WPF by changing the position values. I have done this by creating a control which exposes properties to the WPF animation system. It just takes a lot of effort.
Here is my unfinished WPF app. Notice the ball joints in the robot. The only place I really need mesh deformations is in the face, so she can talk.
Since MS dropped support for WPF 3D in Visual Studio its really hard to make realistic animations. Although with UIElement3D you could write an app that allows you to let people drag the robots limbs around and then take a snapshot. An animation system on top of the WPF animation system.
I have written a plugin for blender which allows you to export 3D models from Blender.
So if you want to write a skinned mesh for WPF, you will have to write your own. Bones are really just transforms which work on part of the mesh.

WPF capabilities

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.

What is the difference between WPF and WinForms?

I am programming simple Windows apps. I don't need DB support. Why would I use WPF instead of WinForms?
One obvious answer is that WPF offers a richer user experience than WinForms, allowing for animations (even 3D) in the user interface, for example.
From a development perspective, it goes a long way to enforce the separation of the User Interface (in the XAML) from the business logic (in VB.NET or C#), which is always a good thing.
A Google search for "WPF vs WinForms" brings up lots of pages that discuss this issue. I won't repeat all their findings here, but this page raises some interesting points:
Databinding in WPF is superior to what Windows Forms offers.
UI and C# business logic can be cleanly separated in WPF
Storyboard
Data/control templates – a much cleaner way than anything Windows
Forms can offer.
Styles – cool and simple. Its so easy to style all your buttons in an
application to have the same look and
feel.
Even if the VS designer breaks, its easy to code XAML.
UI virtualization – I’ve got grids with 100K rows, ticking off a moving
market. Performance would be dreadful
if it wasn’t for UI visualization
which come for free.
3D support.
Nothing scientific but, UI development feels quicker in WPF –
maybe its just because a WPF
application looks cooler at the end of
an iteration, or maybe its because
development really is quicker.
I can add a User Experience engineer to my team, and with no C#
knowledge he can work magic in
Expression Blend and give the
front-office trading application a
makeover that is guaranteed to win
over the business users.
WPF is the current platform for developing Windows desktop applications. It is a modern, advanced, hardware accelerated framework for developing applications that maintain separation of concerns. It supports advanced rendering of 2D vector and 3D graphics, providing an immense range of capabilities for building rich, interactive, and quality user interfaces.
WinForms, on the other hand, provides a basic platform for developing "classic" Windows apps with your standard look and feel using standard controls. It does not offer the rich, hardware accelerated, vector 2D and 3D capabilities that WPF offers. WinForms applications tend to have much greater coupling between application behavior and UI (view), which presents a less flexible platform upon which to develop applications.
As for which one you choose, it entirely depends on your needs. If you need vector graphics, 3D rendering, the ability to create rich, interactive, animated, modern user interfaces, and/or wish to maintain separation of concerns, WPF is definitely the right choice. If you need none of that, and just need to create a simple UI that solves a simple problem, WinForms will meet your needs just fine.
To learn.
To have greater (i.e. any) control over the appearance of your program
To benefit from easier data binding, triggers, styles
(I don't see what DB support has got to do with it)
WPF can utilize hardware acceleration to some degree, but that is expected to improve over time.
Also, because of XAML, you have more options for "doing stuff", declarative vs. programmatic, or a mixture of both.
Microsoft no longer does active development on WinForms, they are strongly pushing WPF, and for good reason.
WPF allows for much easier "resolution agnostic" designing. To achieve that in WinForms, it is a lot more work.
The MVVM pattern was already mentioned in one of the comments, this allows one to do real unit testing vs. GUI-based testing on your code, that is a big win, in my experience.
Nobody mentioned about better testing capabilities of the WPF applications (if they are written in the correct way, for example based on the MVVM pattern).
A
Anywhere Execution due to XAML.
Can be used as WinApp, WebApp, Mobile.
Whereas WindowsForm Internal UI representation is in C#.
B
Binding -->Simple object to object data transfer.
C
Common look and feel(Styles) -->can define look and feel styles commonly and use it for bunch of controls.
D
Directive Programming -->Binding objects in XAML.
E
Expression blend and Animation-->WPF uses DirectX, and DirectX can be used for animation.
F
Faster Execution(Hardware Rendering)
WPF internally uses DirectX (Hardware rendering) while Winform internally uses GDI (mostly uses Software rendering).
There are two ways by which a computer renders display on monitor.
1) (CPU) Software rendering -->In case of CPU rendering ,the CPU drives the whole logic of rendering display on monitor.CPU also does other operations like running applications,performing memory management,running OS. So on top of it its extra load to display things on monitor.
2)(GPU) Hardware rendering -->Its Specialized kinda processor, specifically meant for rendering and display faster on monitor.
Now in WPF, this rendering is further optimised in
>Tier 0 mode (Software rendering) uses DirectX7 internally,
>Tier 1 mode (Partial Hardware rendering) uses DirectX7 to DirectX9 internally,
>Tier 2 mode (Hardware rendering) uses DirectX9 internally.
G
Graphic Independence (DIP) -->Means resolution independence
Resolution --> Total number of pixels that fits into screen/monitor
Pixel --> Simple dot on screen.
Windows form uses pixels as a measurement unit, so when pixel changes then win forms has to adjust itself that means we have to write logic for it.
But WPF does not use pixels as a measurement unit but uses DIP(Device independent pixels)
1 DIP = 1/96th of the inch.
At last Testing --> Better unit testing with use of MVVM pattern.
If you want to have a rich user interface like the image posted in your previous question, I'd recommend going with WPF. Aside from making it easier to create a nice-looking application, it's also the technology Microsoft will push in the future. There's almost no new development for Winforms.
The single most important difference between WinForms and WPF is the fact that while WinForms is simply a layer on top of the standard Windows controls (e.g. a TextBox), WPF is built from scratch and doesn't rely on standard Windows controls in almost all situations.
A great example of this is a button with an image and text on it. This is not a standard Windows control, so WinForms doesn't offer you this possibility out of the box. Instead, you will have to draw the image yourself, implement your own button that supports images or use a 3rd party control. With WPF, a button can contain anything because it's essentially a border with content and various states (e.g. untouched, hovered, pressed).
check this article it will help you:
https://www.wpf-tutorial.com/about-wpf/wpf-vs-winforms/#:~:text=The%20single%20most%20important%20difference,controls%20in%20almost%20all%20situations.

Resources