Friday, September 30, 2005

Managed DirectX - Direct3D Windows Control written in C#

I created a windows control to hopefully simplify adding Direct3D to .Net applications. This control has a lot of functionality, but it by no means has everything that I intended on putting in. It is my first real Managed DirectX project so be a little forgiving if you find something that is not done just right.

The purpose of this control is to provide a Direct3D surface that can be added to any .Net windows form. It has a lot of features that can do most of the busy work for you. One thing to note is that this library is not intended for hard core games, but more for windowed applications.

This library has been sitting around for the last six months unfinished, but still in a good working state. I have been to busy with other things to work on it, so I decided to put it up here in case some one could learn from it. I know I learned a lot making it.

The library consists of a user control which handles the render loop, direct3d initialization on so on, as well as a bunch of mesh classes and a camera class. I don't have a lot of time to go over how to use it but included in the download are four sample applications that use the control, so you should be able to figure it out.

To use it all you have to do is add the control to your tool box. Add event handlers for the OnSceneUpdateReady and OnRender events and then you are ready to go. By default a camera class will be created and set in the controls ActiveCamera property. The default settings is to automatically add the transforms for the active camera before the OnRender event is fired, however this is configurable. The OnSceneUpdateReady event is fired before teh OnRender and is intended for updating the scene and doing all of your program logic. The OnRender event is fired between the BeginScene and Present methods and is intended for rendering the objects.

The included mesh objects all implement the ID3DMesh interface and can be rendered using the Render() method. There is a RenderSettings property that you can use to sett some render settings such as wireframe, solid, autoset transform, and so on. The ID3DMesh interface also has a parameter for rendering planar shadows as well as a bunch of other stuff.

One of the best features of the control is that it enumerated all the supported hardware configurations on start up and stores all the combinations in a DataTable, which can be used for setting the best device settings. In addition to this there is a ShowDeviceSettingsForm() method which will open a dialog that will allow the user to choose from the supported settings. It can be seen in the Mesh Viewer screen shot below. The Mesh Viewer is one of the test apps that is included in the download.

Please send all feed back and code updates to rccode [at] gmail . com

Download Here - Updated 10/4/2005: This has been compiled using the October SDK, for other releases a recompile may be needed.













6 Comments:

At 2/28/2006 10:00 PM , Anonymous Anonymous said...

Excellent. So many rapid changes in DirectX and .NET/Visual Studio versions lately that finding code examples out there that work. I was really impressed with this. It's a great cross-spectrum example for lighting, motion, collision etc., etc.

good work.

 
At 3/01/2006 12:23 PM , Blogger quamtar said...

Thanks, There is an update that I hav not made completely public yet. It address many issues such as multiple controls on a form and adjustable pivot points on the mesh objects. The url where you can get the download is at:

http://quamtar.googlepages.com/d3dcontrols-main

I have am planning on putting up some info when I get the chance.

 
At 8/29/2006 7:24 PM , Anonymous Anonymous said...

hello;
yes it is good sample that works and compile vs2005

you have a .dll component of the control.

is the source code is available to study?

 
At 9/01/2006 12:44 AM , Anonymous Anonymous said...

hello again

the dll is dedx9 30.dll

is this microsoft components? or the source code available to examine?

 
At 7/27/2007 1:04 PM , Anonymous Anonymous said...

Great Work. I am a newbie to directx and after going through your code I understood lot of topis which i found hard when reading the books.

But things missing in this is mesh subtraction, unions (Constructive solid geometry). RC please include these in your furure versions.

 
At 4/10/2008 9:43 PM , Anonymous Anonymous said...

hello,
I am a beginner in DirectX, and I am really happy to find your work.
I have a question, can this control display any animations jus like as in a original DirectX screen? I am learning Dx now to show a plant animation such as pipeline water flow.
One more, I use a VS2005 csharp complier, the robot simulation example file has dll error. Because I am a beginner, I cannot fix the error. I would appeciate if you could give me a source which is compatible to VS2005.
I think this sample will be really helpful to me when it has no error.

krkim@kaeri.re.kr

 

Post a Comment

Links to this post:

Create a Link

<< Home