Recently I have been working on a small WPF project involving the visualization and manipulation of 3d objects. For 2d ojects, this can be easily achieved with a Canvas warpped in a ViewBox or some nice 3rd party controls. But I can't find any free, ready-to-use solution for 3d objects. There is a likely one in WpfToolKit from XceedSoftware(https://github.com/xceedsoftware/wpftoolkit), but no information is given.
I know WPF has some 3D support, like ViewPort3D and other classes in Media3D namespace, and I did find a book, '3D Programming for Windows'(http://www.charlespetzold.com/3D/index.html), by Charles Petzold introducing the concept and basic knowledge. However, many tricky tasks like adjusting camera according to mouse and keyboard input is not presented. So before I start building my own control, I want to at least confirm that I'm not wasting my time doing something already perfectly done. And how to properly config the mouse and keyboard events to make the control behaves as if using some professional CAD softwares?
In short:
1.Any free 3d control for WPF
2.How to build my own ones
Can anyone help me?
Related
I wrote an WPF app using all the 3D stuff of WPF which contains several Views displaying 3D data. IMHO WPF is not the platform for further development of the app so I am searching for some ways to port it to a Universal App/Windows Store App/UWP.
The way, Microsoft is promoting, is to use Unity meaning a complete redevelopment and complicated workflows because it should be a 2D-App with some 3D views.
The other way I was looking at way using Helix-Toolkit, because it does not just offer the WPF-way of displaying 3D but also the DirectX way using SharpDX. Unfortunately the progress concerning UWP is pretty low and not currently usable in the extend I need (like displaying custom geometries etc.).
Is anybody out there who got the same problem and found a workaround?
TY!
You may also like to consider Monogame. Like Helix-Toolkit it's based on SharpDX (when it's on Windows anyway). It's not quite as "componentised" as Helix-Toolkit but it's possible to make your app UWP-first and Monogame-second.
what would be my options if i would like to create a 2D action game in WPF(for the ease of building UI Layout) without having noticeable performance loss? The game should'nt have heavy physics calculations.
I did create XNA game in the past, and i know about the MonoGame project, but i am still unsure how to use WPF as a host for MonoGame and i didnt find a downloadable example of MonoGame in WPF.
Beside MonoGame, what will be the other options, if any?
Thanks in advance!
Have a look at SlimDX, both 3D and 2D are supported.
The tutorials have examples on integrating with WPF.
You could take a look at Nick Gravelyn's article which renders XNA inside of a WPF application. I believe MonoGame's API is very similar, if not identical, to XNA, so it shouldn't be a huge problem fixing any porting issues.
http://blogs.msdn.com/b/nicgrave/archive/2010/07/25/rendering-with-xna-framework-4-0-inside-of-a-wpf-application.aspx
or
http://www.jfmajor.com/post/38447851593/monogame-in-wpf
I do remember reading somewhere that a team attempting to render WPF controls over XNA/MonoGame (I forget which) did encounter some perf issues.
I think the approach taken by many (from what I've seen) is not to use WPF for rendering a UI and instead build the UI as part of the game/engine. WPF/WinForms can be used to build an editor, but again I believe the rendering of the game/world is embedded within a WPF/WinForms application using a UserControl similar to the articles mentioned above.
I'm writing a tile editor for a game and would like to be able to select which level file to open. Once open I would load the level into an XNA window and click to add/remove tiles to the level. When the editing is finished I would save the file layout back to the original file.
Currently I don't see a way to integrate windows forms and XNA. Is this even possible?
When I was working on a small, "2.5D" isometric game in XNA, I found it worth while to also have a separate WinForms version that would just render a 2D top-down view using GDI. This was due to my inexperience with XNA and my (relative) comfort using WinForms.
This approach also had the useful side-effect of enforcing separation between logic and rendering code. It made it easier (for me, at least) to test changes without having to worry about how to deal with the XNA rendering aspects.
It may not be exactly what you had in mind, but it might be something to consider.
WinForms and Xna can cooperate, but it's not recommended to use Xna's built in Game class with WinFroms. There are two samples demonstrating it:
http://xbox.create.msdn.com/en-US/education/catalog/sample/winforms_series_1
http://xbox.create.msdn.com/en-US/education/catalog/sample/winforms_series_2
I've been making heavy use of the interactive 3D controls, made by some guys on the WPF team, found here http://channel9.msdn.com/posts/Charles/Daniel-Lehenbauer-and-Kurt-Berglund-Interactive-2D-controls-on-WPF-3D-Surfaces/
I've noticed there hasn't been any updates to this lately, and with WPF and .Net 4.0 just around the corner, I was just wondering if there is a better way to do 2D controls on 3D objects, or is this still the best way to do it?
Perhaps you're looking for Viewport2DVisual3D.
Viewport2DVisual3D enables you to
place interactive 2-D content on a 3-D
object. Its counterpart is the
Viewport3DVisual class, which is a 2-D
visual with 3-D children.
[EDIT] You can see an example in Matthew MacDonald's book Pro WPF in C# 2008 here on page 851. You may or may not be able to view it (not sure) but I won't reproduce here as it's not my work.
I am currently developing a 3d game using C#/SlimDX (The target is Direct3D 9). I've been looking for a suitable Game UI toolkit for a while, but I was unable to make up my mind.
The Game UI will be for a roleplaying game, so it'll be fairly complex and will involve quite a few controls (text boxes, inventory grids, list boxes, select boxes, scrollable areas, etc.).
I previously (When i was still using C++/OpenGL) looked at GameSWF and very much liked the idea, but for my current game it's out of the question.
Does anyone know a good GUI toolkit for use with SlimDX?
I would be especially interested in using WPF/Silverlight for this, since there are good IDEs available for both. But a quick google search didn't reveal any information on embedding these.
You can use WPF (but not Silverlight) for this.
The way to go about this is to use SlimDX in conjunction with D3DImage. You then let WPF handle all of your final composition, including overlaying the WPF UI over the top of your SlimDX scene.
SlimDX basically just renders to a brush in this situation, which can be used on any WPF element. (This doesn't work for Silverlight, as Sliverlight doesn't support D3DImage.)