Drawing lines and points in 3D space still impossible with pure WPF? - wpf

I've read few (old) posts and tutorials about drawing lines and points in WPF 3D.
They all say, that its impossible in pure WPF, and I have to use 3D Tools.
Has anything changed in that matter? (I mean .NET versions released after 3.0/3.5)

You are right, there is still no support in WPF 3D for proper lines and points in 3D scenes. WPF 3D has not gotten much love in recent versions.
However, you might want to have a look at the Helix Toolkit, which is a great set of helpers and controls for WPF 3D, including support for screen-space points and lines (improved from the 3D Tools versions). The old 3D Tools library has not been updated in many years, while the Helix Toolkit is continuously being improved.

Related

Confused about XNA (is it just a Direct3D wrapper?)

I have an industrial C#/WPF application written that needs to render thousands of 3D lines. (N.B. these are not a wireframe - they do not necessarily represent a 3D surface, so I don't want to tesselate polygons into triangles, or do lighting a shading, but I do want hardware acceleration) I've been looking at OpenGL and Direct3D but I keep seeing XNA suggested on Stack Overflow, e.g., here and here
I went to https://en.wikipedia.org/wiki/Microsoft_XNA to try to understand it but I'm still confused. Is it just a wrapper for something I should be using directly, like Direct3D? Does it give me access to the underlying graphics API? Can it even do lines? Can I run it in a WPF object like a Panel or Canvas?
Is it just a wrapper for something I should be using directly, like Direct 3D
XNA is not a 1:1 of DirectX.
Though XNA uses DirectX under the hood it's generally not correct to think of it as "just a wrapper" for DirectX. XNA does a few things that DirectX doesn't, like content pipelines; a clearly-defined separate game loop and draw point; content load and unload callbacks; and 2D sprites. (Microsoft ditched 2D drawing DirectDraw for a time and only now have released Direct2D)
XNA consists of a series of layers starting with Platform being the lowest and includes APIs such as Direct3D 9; XACT; and XInput.
Building upon Platform you'll find Core Framework; Extended Framework; and Games which abstract; encapsulate the lower layers whilst adding new features that result in "making game development easier". [1]
The end result is so far removed from DirectX (except perhaps for the shaders) you would not be aware you are using DirectX. You can have a game window up and running in a few lines of code compared to DirectX's pages and pages of code.
Does it give me access to the underlying graphics API?
If you mean can you talk directly to DirectX COM API then no, you can't. You can however write shaders that when compiled, the GPU will understand indirectly.
Can it even do lines?
Yes.
Can I run it in a WPF object like a Panel or Canvas?
Apparently so. I should point out that WPF already is hardware accelerated and uses DirectX for rendering. Even those drop shadow effects you see in WPF are actually DirectX GPU shaders.
Today
As you have probably read, XNA is deprecated and though Monogame is active is not 100% compatible with XNA (just look for the many posts on SO regarding XNA Content Pipeline issues for one).
Therefore if you are wishing to do 3D in WPF, well you don't need XNA for that.
More
[1] Cookiecups, "what is the xna framework", MSDN Blogs

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.

What are the advantages of combination WPF + XNA?

I'm porting my application from Winforms+XNA to WPF (+ XNA?) and I would like to know if the combination WPF + XNA makes sense or not. If it brings some advantages or if it is rather a bad choice.
A few points about my game:
It's a desk game with simple 2D animations (movement)
Main window contains panels like available games/players etc. + console.
I would like to add some fancy scenes to my program (at end of game, ...)
http://www.codeproject.com/KB/WPF/XnaInWPF.aspx is the code I would like my program base on.
So the appearance is quite similar to a chess program.
Thank you for suggestions!
The approach in that article works quite for XNA/WPF integration. There really aren't major issues, and WPF will perform quite well.
That being said, depending on what you're doing, you could potentially do your graphics directly in WPF without XNA - I just mention this, since WPF provides quite rich 2D graphics, and is very easy to use. If you're working in 3D, however, XNA is far superior.
If you want to do more elaborate integration, there are still some issues. Unfortunately, XNA uses the DirectX Managed Pool for resource management, which means it's still (so far) incompatible with D3DImage. There is no way to do fancy WPF brush style usage (like you can with DX) safely with XNA.
Look at this : How well does WPF blend with XNA in real life?

Silverlight - Perspective 3D

I am considering using Silverlight for a project I am working on. This project will need to show a 3-Dimensional cube. Is this possible in Silverlight?
I see a lot of examples that a basically 2-sides of one item. Kind of like a sheet of paper. Is this what "perspective" 3D is? How is perspective 3D different than normal 3D?
Thank you!
You should look at Kit3D for Silverlight. Someone also created a silverlight3d.com site, but it current just has three reference articles and a link to Kit3D.
It is also possible to emulate 3D as demonstrated by this MSDN article.
The feature that was added in Silverlight 3 is referred to as "perspective 3D" to avoid confusion that might arise with someone expecting it be some kind of full scale 3d rendering API (like DirectX or OpenGl etc.) or something like WPFs UIElement3D.
The "perspective 3D" feature in Silverlight allows you to take any regular 2D UIElement and rotate it in 3D dimensions; you can think of it like a more powerful RenderTransform. There are two ways of setting a "Projection" on a UIElement, with a PlaneProjection (simple) or with a Matrix3DProjection (more complex).
You could certainly use this feature to create a 3D cube, where each face of the cube is a UIElement with a Projection applied to it. However you would not use this feature to create something that required complex 3d models such as a 3D game.

Resources