I am looking to port the Silverlight 5 / XNA example Solar Wind to WPF using the Helix3d toolkit.
The Solar Wind example is here:
http://code.msdn.microsoft.com/Solar-Wind-3D-Sample-4cb56170
I watched the video demonstrating the example and one of the great features is that the 3d geometry is expressed as XML and can be changed at runtime. This makes it possible for example to change terrain height or color at runtime based on sets of data.
I have been looking at the Helix 3d toolkit which looks amazing.
It can be found at:
http://helixtoolkit.codeplex.com/
I am aware that 3d geometry can be expressed as XAML in the Helix 3d toolkit. Is it possible to change the Geometry dynamically at runtime to support similar behaviour as the Solar Wind example does in XNA?
#user1306322 that just looks like a plug for Unity3d. Unity is a great engine, but I was suggested Helix 3d because it is built to integrate with WPF applications.
A beter suggestion in terms of porting the Solar Winds example would actually be Monogame, because it fully (well almost) supports the XNA framework, but supports DirectX 11 and multi platforms.
Related
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
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.
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.
I'd like to draw a high-framerate (30fps+) graph/chart in a Windows Forms app.
How?
Windows Forms gets TERRIBLE frame rates drawing a clear-background drawing over a window.
(I come from the land of GNU, so I apologize if this is obvious.)
If you're using Windows Forms (as said in your question):
If you need to get >30FPS, you'll probably need to change to a different technology. GDI+ drawing is not too efficient.
DirectX would work well for this. You can do the charting in Direct3D using DirectX embedded in a Window. SlimDX is a good way to do this from C#.
That being said, you tagged this with WPF - if you're using WPF, everything is retained mode graphics, so there should be no "clear-background drawing" required. You would just put in the chart elements as needed. In that case, 30FPS should be doable.
Running full tilt I get about 180FPS using a System::Windows::Forms::DataVisualization::Charting::Chart plotting 128bins of an FFT using a 'FastLine' style for the series of data. That's running on an Intel Core 2 Duo (2.53Ghz) IBM Thinkpad.
I guess this is a multi-part question.
I can import a 3D model into my WPF application but how do I apply an ambient occlusion shader effect to it?
I know with .NET 3.5 SP1 you can do custom effects but that's limited to pixel shaders and doesn't include vertex shaders.
I think i can do this with an XNA application but Im not familiar with XNA so the second question is:
How much different is WPF and XNA? I don't seem to have any notion of XAML in XNA. How much ramp up would moving from WPF to XNA take?
Thanks,
Chris
To answer your second question:
WPF and XNA are completely different. They do share the following:
Built upon .net
Use DirectX
Can access hardware acceleration of the video card
XNA does not have any GUI support built in and is really aimed at games (for PC and XBOX-360) whilst WPF is usable in business style applications. As you've discovered XNA does not have any XAML support, indeed it is mainly an abstract .net wrapper for DirectX.
If you have an understanding of terms like "ambient occlusion" then you should probably be working with XNA.
XNA as an API is not difficult to learn, but as was mentioned, it is intended for game development. There are lots of great XNA tutorials out there.
You can use both WPF and XNA in concert, read more about that here.
Can you tell us more about what you are trying to do?