🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

New visualization toolkit possibility: Horde3D

Published June 06, 2011
Advertisement
I use Lua. Like, a lot. I use it to generate procedural textures for my poor attempts at 3D modeling and isometric art creation. I use Lua to compile renders into compact little isometric sprite packages and animations. I use Lua to write games, to write demos, just to tinker around with crap. If I could, I would use Lua to make me a sandwich and a glass of Tang. I can't, but rest assured that as soon as someone uploads that module extension to Sourceforge, I will be there.

My current visualization "library" (as I typed that, I made the little quote-fingers in the air; unfortunately, this required that I finish typing the word with my elbows) is a sort of hacked together conglomeration. I've got bits of partially finished binding code exposing SFML, other naughty little bits exposing parts of Ogre. Sometimes, when I want to visualize something, I'll load up those modules and start feeding data around. Often, what appears on my screen is vaguely related to what I was trying to display; other times, not so much.

I also have bindings to other bits of code that I have written in the past. Bits of OpenGL-based rendering engines I have cobbled together seemingly out of grease and mud, infusing them with a sort of unholy life and turning them loose to lurch from project to project, smashing delicate ideas to so much assorted code kindling. You can even see, so help me God, bits of the original Golem engine in there. Oh, the humanity.

A couple days ago I happened to catch an announcement (somewhere, somehow; the particulars escape me) about a recent release of a beta candidate of version 1 of the Horde3D engine. Not knowing much about Horde3D, I took a look. I have to say, I kind of like it. The chief thing about it that has impressed me is the absolute ease with which I was able to bind it to Lua (with a couple of caveats, of course). I group-selected one block of text in the main Horde3D.h header file, deleted it, then ran a search-replace on a couple of the macros that libraries use to sort out calling conventions. I changed a couple const ints to #defines, ran the header through tolua++, and to my amazement the package was parsed without a hitch and the binding code linked without any major problems. I have found few libraries that have been this easy to bind.

Now, the caveats were that there were a couple functions that dealt with void pointers or pointers-to-pointers. Querying for transformation matrices, mapping a resource to a void pointer for upload of data, etc... There were a few functions that took float arrays, and also took array-length parameters; these are easy enough to bind in tolua if the array length parameter comes first. Sadly, this was not the case with these functions, but a simple proxy function swapping the order of the array and count parameters solved the issue easily enough.

The end result was a near complete binding of Horde3D to Lua, in about 20 minutes. Not bad at all. Now, the only reason this was so simple is that the Horde3D engine isn't like your Ogre/Irrlicht/Panda etc... It's not a meticulously organized hierarchy of scene nodes, inherited classes, etc... Horde3D is a handle-based system, where objects are represented using integer handles that are manipulated via procedural functions. Very C style. It's been awhile since I worked with a library that took such a C approach, and I honestly found it refreshing. I no longer code C-style myself, but I do have to admit that the procedural approach makes binding to Lua an absolute dream.

With this addition, and the expunging of my bastardized bindings to Ogre (which I still think is a fantastic library, just a little on the heavyweight side for my simple little games and demos) I have a much cleaner visualization library, and the Accidental library has taken a small step toward greater usability and clarity.
0 likes 2 comments

Comments

evolutional
I always found C-style bindings to work better with script languages
June 07, 2011 08:21 PM
JTippetts
Yeah. I think everyone should just switch back to C. lulz.
June 08, 2011 02:49 AM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Profile
Author
Advertisement
Advertisement