New Display Toys
One of my tasks at my company is to develop new techniques and leverage new technologies in the development, design and use of our products. Though most of my companies development efforts are now handled by other company employees, almost everything my company now does, started as a project within my own computer. To that end I am always looking at new stuff and for one reason or another I tend to gravitate to techniques and technologies that can enhance the user interface experience. One of our most successful products ClaimsExplorer heavily leverages a flat time line style of UI element that shows Claim activity in data lined up with corresponding authorization, clinical notations, eligibility, and insurance premium payment information at the day level for our clients. I have always felt that the time line approach was a good one but has its limitations. There is only so much information you can cram into a little icon about the occurrences of the period. Diversity and pattern in a dataset as varied as a typical health care claims database become as blurred as the screens full of textual data in spreadsheet form that most claims browsing system present to the user. Its just a little more colorful perhaps in the time line.
The availability of development libraries that leverage the fantastic 3D rendering power of todays modern desktop/laptop pc's have existed for some time, and I have always felt that 3D was the direction to go to bring our visualization elements to the next level. The problem with these libraries has always been that they are squarely aimed at Gamers and Game development. Not that their is anything wrong with games, for I believe we would all be working on timeshared, green screen terminals if it were not for games continuously pushing the envelope for the rest of us more mundane developers out there. The problem has been that the display power does not play well with our boilerplate windows applications where grids of textual data mix with arrays of labels and buttons and text boxes, and check boxes, and other business like attire. (How boring but for me its what pays the bills) Another problem with these development libraries has always been that they represent themselves as a game engine. And they don't integrate well into a business application that has a familiar UI feel. They also typically required programming to them in C++ and as I said before I am a mundane developer not a C++ propeller head, having graduated from VB to VB.NET and C#.
Along comes Dark Basic....
A few years ago I bought Dark Basic Professional. (www.thegamecreators.com) and I really liked the power the language offered but it suffered the same issues noted above, I left it alone for anything work related. Windows Presentation Foundation has promise but its cookies are not done yet and the support for my favorite development environment Visual Studio is spotty and downright buggy at the moment. Given that Vista has taken so long to see the light of day I am not holding my breath. Then the other day on a lark I popped over to the Game Creators site again to see what was new. My eyes could hardly believe what they were seeing. These wonderful folks had actually taken the DarkBasic code base and made a COM Library exposing nearly its entire functionality to the .Net development environment of your choice. This new offering is called DarkGDK.net (http://darkgamesdk.thegamecreators.com/?f=dgdk_net)
DarkGDK.net (DGDK) is a Com library that interop's well with .NET either 1.1 or 2.0. As such you have a choice as to what development language you want to use when interacting with the DGDK library. I have exercised both VB.Net and C# in my exploration with DGDK. Because DGDK is a com library it allows the functionality to be used in a host of development environments.
- The Express Versions of VB.NET and C#
- Visual Studio 2003
- Visual Studio 2005
- Sharp Develop
- Freeware License
allowing development of freeware games only 60$ us - Full Commercial License
allowing unrestricted development royalty free 200$ us - Upgrade a Freeware License to Commercial
for those of you who succumb to the dark side and want to
start selling your offerings 140$ us
About 1 hour later I popped over to the website again and checked on the status of my order (So much for whats a few more days). So I spent the next few days spending all spare time looking at the forums and reading what I could about the product.
- One thing that struck me was that the product is very new. I had not seen any specific release dates but it feels like maybe 1 or 2 months old tops.
- Another point is that the website and forums seem to breed confusion over what product does what. Apparently they already have a product called DarkSDK which is a C++ product exclusively and this is a derivative of that item. The distinction is subtle on their web site, in their forums, and even in the name itself. To the uninitiated this breeds the confusion.
The library is signed using a Private/Public keying mechanism that introduced some small additional complexities on development efforts.
- Manually add the necessary references to your application
- Manually add an existing c# (in my case) class that ships with the development library
- Tweak the build properties of the application to turn off Visual Studio Hosting for debugging. I don't believe this is required in the other development environments like Sharp Develop or even the Express editions but Visual studio is what I have.
- Configure the projects assembly information like Company, Version Number, Description and what not.
- Build the Application ( don't run it yet )
- Run an application they ship with the library called the Authenticator and point it at the .EXE file you just built.
- It crafts a file called {App name}.dgdk Add this file to your project and set its compile properties to embedded resource
- The authenticator also showed you a very long string in the public key box. This string needs to be cut out of the Authenticator interface and pasted into a specific spot in the above included C# class. (speaking from experience, be careful to get the entire string copied and pasted correctly otherwise it won't work)
- Finally build the application again now it should run.
On completing the above steps you have what is basically simple application loop where you have manually created a simple cube and, within a loop, are slowly rotating that cube about its geometric center.
Now the fun begins
The samples included with the product have a slightly more complex project that extends the tutorial project by creating a windows form that has a picture box. Within this picture box object, the 3D surface will be rendered. This ability is the primary reason for my interest in the library as its integration into established applications and UI's is visually seamless using this technique. Visual seamlessness and interactivity are two different things however, while the picture box object happily will show whatever objects you build into it, getting the ability to interact viathe UI with those things takes programming. Thats where the rich API provided by DBGK comes into play.
The DBGK API is broken out into a number of Classes that expose a number of methods organized into functional groups.
- 3D.
- 2D.
- Sprites.
- Sound.
- Text.
- Math.
- etc.
As mentioned above, the documentation is a bit sparse. Many of the API calls are documented in name only without the benefit of any form of explanation or example usage. Think of Microsoft's MSDN documentation devoid of any examples and in many cases missing any of the explanatory text. In other words its bad. I don't want to beat them up to badly on this point after all I am sure the same can be said about our own documentation for the things we have written at Tidgewell Associates. I am also sure that the documentation will improve as time moves along. Until then however the forums are your friend.
There are also cases where an API call has several versions of the call with differing argument signatures that have subtly different names for example...
- PlayObject(iID)
- PlayObjectB(iID, Start)
- PlayObjectC(iID, Start, End)
The Library also supports the reading in of external media in varying formats depending on type. Image types can be accessed via the LoadImage API call contained in the oDBImage class (one of the static classes instanced by the included source files ). Supported image file formats are
- BMP
- JPG
- TGA
- DDS
- DIB
- PNG
Supported Sounds and Music in the oDBSound and oDBMusic classes are
- WAV
- MIDI
- MP3
Supported 3D shape/objects can be read in via the LoadObject method in the 0DB3D class. Formats include
- X (Direct X format)
- 3DS
- MDL
- MD2
- MD3
I will admit that many of my attempts to get anything but X objects to load in failed in one way or another, I am not sure if my 3DS exporting from my now ancient Lightwave 7.5 is broken in some way so I have had to stick with X format for my experimentations. Another thing I have noticed is that it helps to have your object composed of triangles, a simple enough task in Lightwave I just triple the polygons.
Putting it all together
In the end, DGDK makes it fairly easy to instance and manipulate the 3D realm and integrate that realm into standard .Net applications. In our case I have some particular needs that the library fulfills nicely after some experimentation.
- I need to be able to ask the library to tell me if some object is under the mouse
This is accomplished using the PickObject call within the oDB3D class. One thing I had to do was to keep track of the size of the picture box object as it shrank and expanded in anchor with the containing form. Then each time I asked about a mouse coordinate I had to scale the coordinates asked about by the current scaling factor of the canvas in relation to how large that canvas was at the time the 3d surface was initialized. (The canvas stretches and shrinks but the 3D context displayed within is a fixed size at startup) - I need to be able to clear the canvas of objects so I can reload with perhaps a different set of objects
Use the DeleteObject or the DeleteObjects method in the oDB3d class - I need to have the objects placed anywhere within the 3D space
Use PlaceObject in the oDB3d class - I need to have the objects animate in some way (Maybe rotate or scale down or up)
Use the ScaleObject and RotateObject methods in the oDB3D class - I need to move the viewing position (camera) around within the 3D world
Use the PositionCamera and PointCamera methods of the oDBCamera class
Below is a screenshot of my testing application that wraps up my experimentations to date and creates a simple scene with a number of objects loaded, instanced, and animating with mouse interactivity on the objects (The one under the mouse gets rendered as a wireframe, the others as solid objects).