I need to show points array in three-dimensional coordinate system. Which component or library should I use for it(Winforms/WPF)?
Here is a tutorial for Direct3D in C#, it's for winforms: http://msdn.microsoft.com/en-us/library/ms920768.aspx. I don't think it matters whether you use winforms or wpf, the trick is to get your videocard do you drawing and that bypasses wpf.
Related
I just have a question:
I need to draw some WPF geometries in a canvas, and each geometry's surface is a complicate Texture2D in Direct3D 11. I'm using SharpDX and just convert the Texture2D into a MemoryStream then Convert to a WPF ImageSource, because I'm using Compute Shader, the Format.Bgra isn't supported with UAV texture, so I can't use a D3DImage. Since there're performance issue, how can I bind a Texture2D to a WPF Geometry directly? Thanks.
For performance reasons, you should perform the whole rendering with SharpDX and not using WPF Geometries, only D3DImage to synchronize the result of rendering with WPF. If you need to convert a texture from one format to another to match WPF formats, you can simply render a full quad with a simple shader copying the texture. If you are doing this with SharpDX Toolkit, it is fairly easy to develop it as it is providing a WPF control.
Short answer is you can't, WPF 3D is still in its infancy and custom shader support is available for 2D effects only. Best advice I can offer at the moment is to render your geometry onto an XNA surface and display it in an AirspacePopup with your WPF controls on top.
I need to visualize constructive geometry in 3d using C#. And for that I want choose a library. Ideally, that library should be able to provide the following:
Rendering arbitrary polygons in 3d. Wireframe representation.
Orhtographic projection
Camera control. I need to be able to zoom-in/out, set center of rotation to turn camera around it.
Pick my polygons, edges, vertices with a mouse.
Draw text on top of vertices, edges and polygons.
Efficency isn't the priority, so it can be resonably slow if it can do these things right out of the box or provide a good high level service for it.
I tried to look at XNA. But as far as I understood it doesn't support visualization of polygons directly.
XNA does support visualization of polygons directly by providing access to the underlying Direct3D 9 GraphicsDevice object. You can also dynamically create a mesh and draw it in a managed way, however that will be slower.
See:
http://msdn.microsoft.com/en-us/library/windowsphone/develop/microsoft.xna.framework.graphics.graphicsdevice.drawprimitives.aspx
and related methods.
There's several DirectX wrappers in c#. I would avoid Managed DirectX since it's deprecated, and you have only access to direct3d9.
The two most common libraries for DirectX are:
SlimDX
SharpDX
Both work pretty well, and support latest DirectX feature set (SlimDX up to 11, SharpDX supports windows 8 and 11.1).
They both support what you need to do, it of course implies a bit of coding on your side.
I have to create library that render static, simple shapes with some 3d effects such as rotation and bevels. Shapes can contains text or image on it.
Something similar to this:
I think that with GDI+ it will be hard to implement so is there any CLS compliant library that will help me with rendering?
P.S. I can not use WPF.
Try to read the following stackoverflow page to choose the engine:
What to use? Tao, SharpGL, OpenTK, DirectX P/Invoke, XNA, MDX, SlimDX, Windows API Codec Pack
One example for the Tao framework with C# can be found in codeproject:
OpenGL 3D Navigation with Tao and C#
You could try SFML: main page - features (includes bindings).
It's got a Shape primitive, is based on OpenGL rendering and includes support for shaders.
I have to write a faster canvas in wpf for my upcoming project. The canvas will be similar to adobe photoshop canvas. It should have layers and objects and also direct drawing methods.
I am thinking to write the canvas in vc++ or in c# and use it into wpf. Is it a good idea to write the canvas in any other language and use it with wpf? Or should I extend the existing canvas of wpf? If using other language, then vc++ will be better or c#?
Thanks
You are looking for the writeable bitmap - see http://msdn.microsoft.com/en-us/library/system.windows.media.imaging.writeablebitmap.aspx
This allows direct pixel level manipulation of graphical data, basically designed for what you want to do.
I suggest you use QT. :)
I would like to do something like this: a rotating cube on a form. I don't want to use any external library or dll, just pure .NET 3.5 (without directx). And a cube build with lines only. Could you please tell me how to do this?
I don't want to use external libraries because I don't need > 100 MB library to do this thing right? I want only to animate a rotating cube made with lines.
This is how you go about making a Cube in GDI+
C# 3D Drawing with GDI+ Euler Rotation
http://www.vcskicks.com/3d-graphics-improved.html
C# 3D-Drawing Cube with Shading
http://www.vcskicks.com/3d_gdiplus_drawing.html
Study assignment? This can be done with some simple 3D maths. You just need to understand the basics of matrix algebra, 3D transformations, and 3D->2D view transformation. The DirectX tutorial covers this, but you can google for it and you'll get plenty of other tutorials.
Added: Just to clarify - I'm not suggesting to use DirectX or anything. You can do this with standard System.Drawing tools. You just need to understand the math, and that's explained in the DirectX tutorials.
You might try using WPF and the 3D Tools source code released by the WPF team.
3DTools
Assuming you are using WPF for your GUI:
Make an animated PNG of the cube using a graphics program.
Use the APNG WPF Control to insert the image into your GUI.
This will yield a small assembly size and transparent background if needed.
You need a way to represent 3d points. There is no ready struct for that in .NET unless you use directx or WPF.
Then with a standard euler rotation matrix applied to the points you get the transformed points. If you only do rotations you can get away with 3x3 matrix, but if you want translation you better use 4x4 matrices and homogenous points.
After this you need a way to project those 3d points to the 2d canvas. Depending whether you are using perspective or orthographic projection the projection matrix will look a bit different.
Look into WPF in general, it will help you do this with a few measly lines of code. You can also host a WPF window in Forms.
http://msdn.microsoft.com/en-us/library/aa970268.aspx