Monday, October 29, 2012
I know I’ve said this several times before, but now lighting is REALLY fixed in my engine, seriously for reals you guys. What you see in the image above is a screen choked with debugging information that I used in the process: the yellow arrows are the face normals, and the red lines point towards the light source. I also wish to note that online resources were of little help in wrangling all the issues that were interacting here, so don’t get your hopes up if you think this is the sort of problem the Internet will fix for you.
The other “new” thing in this shot is the barely recognizable untextured fighter model: it was modeled in Blender, exported with my Python script, and imported with my new model import code. I should be able to dispose of the old and busted Milkshape stuff now.
As a side note, Shamus Young’s Blender rant is old (it’s from 2006) but while the specifics have all changed, he’s still right about his description of the user interface: 

I’ve learned to regard my keyboard as a device which I may use to punish myself in humorous ways. It’s like a cartoon control panel where all of the levers will drop anvils, open trap doors, or deploy humorous hammers against the hapless user. After enough smacks to the head and pies in the face I’ve learned to avoid pressing keys unless I really need to.

Nothing in Blender works the way you’d naïvely expect it to. If you see a little doodad at the corner of a viewport which looks like a resize widget, for God’s sake don’t press it — it’ll duplicate the viewport, instead. And then if you try to operate the widget again to close the new viewport, it’ll duplicate another one, and another one, Sorcerer’s Apprentice-style. Or just try undoing something. Earlier versions of Blender apparently didn’t have an undo function at all, and its users took some sort of sick, superior pride in this. Supposedly one has been added now, and supposedly it’s mapped to the system’s standard undo key, but I’ve never once seen it have any effect. Better yet, once when flailing around trying to find undo I managed to overwrite Blender’s default scene (incomprehensibly, there’s a simple hotkey for this feature) and the only way to get it back to normal also overwrites all of your preference settings, including the one that makes standard Mac mice work. I’ve gotten in the habit now of just reloading a previous save instead of trying to use the undo.
Oh yes, and as far as undo coming and going: Blender’s interface, right down to hotkeys and menu setup, seems to change dramatically every couple of releases. This of course means that the correctness of any information you may happen to find on the Web is gonna be a hopeless crapshoot. Usually, the online docs and books will refer to functionality that disappeared or moved somewhere else years ago.
So why am I using Blender, given all this UI grief? Again, it’s simply because once you struggle past the interface it is functional on a basic level — something I can’t say about any other free 3D app I’ve tried. I could model stuff, I could visualize and modify normals (though Blender’s functionality for that isn’t optimal, it’s at least capable of doing it without too much hassle), I could write an exporter pretty easily. And it never crashed once during the whole process. I realize that “has basic features and didn’t crash” is a humiliatingly low bar, but what does it say about the state of 3D applications that most don’t even clear that?

I know I’ve said this several times before, but now lighting is REALLY fixed in my engine, seriously for reals you guys. What you see in the image above is a screen choked with debugging information that I used in the process: the yellow arrows are the face normals, and the red lines point towards the light source. I also wish to note that online resources were of little help in wrangling all the issues that were interacting here, so don’t get your hopes up if you think this is the sort of problem the Internet will fix for you.

The other “new” thing in this shot is the barely recognizable untextured fighter model: it was modeled in Blender, exported with my Python script, and imported with my new model import code. I should be able to dispose of the old and busted Milkshape stuff now.

As a side note, Shamus Young’s Blender rant is old (it’s from 2006) but while the specifics have all changed, he’s still right about his description of the user interface: 

I’ve learned to regard my keyboard as a device which I may use to punish myself in humorous ways. It’s like a cartoon control panel where all of the levers will drop anvils, open trap doors, or deploy humorous hammers against the hapless user. After enough smacks to the head and pies in the face I’ve learned to avoid pressing keys unless I really need to.

Nothing in Blender works the way you’d naïvely expect it to. If you see a little doodad at the corner of a viewport which looks like a resize widget, for God’s sake don’t press it — it’ll duplicate the viewport, instead. And then if you try to operate the widget again to close the new viewport, it’ll duplicate another one, and another one, Sorcerer’s Apprentice-style. Or just try undoing something. Earlier versions of Blender apparently didn’t have an undo function at all, and its users took some sort of sick, superior pride in this. Supposedly one has been added now, and supposedly it’s mapped to the system’s standard undo key, but I’ve never once seen it have any effect. Better yet, once when flailing around trying to find undo I managed to overwrite Blender’s default scene (incomprehensibly, there’s a simple hotkey for this feature) and the only way to get it back to normal also overwrites all of your preference settings, including the one that makes standard Mac mice work. I’ve gotten in the habit now of just reloading a previous save instead of trying to use the undo.

Oh yes, and as far as undo coming and going: Blender’s interface, right down to hotkeys and menu setup, seems to change dramatically every couple of releases. This of course means that the correctness of any information you may happen to find on the Web is gonna be a hopeless crapshoot. Usually, the online docs and books will refer to functionality that disappeared or moved somewhere else years ago.

So why am I using Blender, given all this UI grief? Again, it’s simply because once you struggle past the interface it is functional on a basic level — something I can’t say about any other free 3D app I’ve tried. I could model stuff, I could visualize and modify normals (though Blender’s functionality for that isn’t optimal, it’s at least capable of doing it without too much hassle), I could write an exporter pretty easily. And it never crashed once during the whole process. I realize that “has basic features and didn’t crash” is a humiliatingly low bar, but what does it say about the state of 3D applications that most don’t even clear that?

Saturday, October 27, 2012
Okay. Finally got around to writing that Blender exporter I’ve been needing to do for six months. I can now export objects created in Blender into an arbitrary format suitable for my engine: in this case, just good ol’ XML. I’ll need to write an import side tomorrow but with that done I can abandon the old broken Milkshape meshes with their screwed-up normals and hopefully that’ll be the end of it.
As an aside, Blender is a usability disaster with its philosophy of “screw the platform interface standards, a couple of guys at one company prefer the GUI equivalent of vi so that’s how it’s going to be.” But it beats out all its competitors in the low-priced 3D modeler field by being actually, you know, functional. Looks like I’m just going to have to grin and bear it.

Okay. Finally got around to writing that Blender exporter I’ve been needing to do for six months. I can now export objects created in Blender into an arbitrary format suitable for my engine: in this case, just good ol’ XML. I’ll need to write an import side tomorrow but with that done I can abandon the old broken Milkshape meshes with their screwed-up normals and hopefully that’ll be the end of it.

As an aside, Blender is a usability disaster with its philosophy of “screw the platform interface standards, a couple of guys at one company prefer the GUI equivalent of vi so that’s how it’s going to be.” But it beats out all its competitors in the low-priced 3D modeler field by being actually, you know, functional. Looks like I’m just going to have to grin and bear it.

Monday, February 27, 2012

Oh hey I should update this.

I figured out that I can’t implement any more stuff on spec in the space game. Before it goes any farther, I’m going to have to design it so I know what to implement and how it should feel. And that means proper design, like “here are all the ships and weapons.” While I’m thinking about that issue I’ll be working on other game projects. So… yeah, that’s pretty much how it is.

I realize this is a bit troublesome, but to make up for it I’ll give you a recommendation: you should play Here Comes Launchman because it is simply love.

Saturday, February 18, 2012
Not too much flashy to show you: I’ve been fixing some bugs in the particle system, fighting with Milkshape’s annoying eagerness to trash vertex normals, designing the odd ship, and finally (finally!) rewriting the vector font class so that SVG files are no longer used anywhere and the last vestiges of the old Republic Inkscape legacy code can be swept away. But really, the big issue on my mind is something that was pointed out to me by the same friend who suggested a Wing Commander-style game originally: I really ought to settle on a story concept for this game.
Because, you know. I’m only a half-assed AI away from having actual gameplay, and moving forward a lot of decisions about gameplay systems should be informed by what the game is, you know, about. I’m rapidly reaching the end of the line for stuff which can just be implemented on spec.
I’ve been working through this be thinking about what individual elements I’d like to see in a story about science-fictiony fighter pilots, and have come up with something. Wing Commander and most of its brethren were pretty straight-up war stories — one big fancy organization vs. another big fancy organization, Earth military vs. Kilrathi military, et cetera. Sometimes it’s humans vs. humans but there’s a giant surprise alien enemy out of nowhere, that sort of thing. The example that stands out from the rest for me is Wing Commander IV, which was about a conspiracy within the Earth military. Now, I liked WCIV a lot but I’m generally not a fan of that storyline any more: these days “Gosh, WE’RE the REAL bad guys” is lazy, obvious, and agonizingly overused, not to mention borderline offensive. Still, in the context of space combat, a storyline that’s not necessarily “OMG WE HAEV MET TEH EMENY AND HE IS US” but still has elements such as intelligence failures, conspiracies, black operations, political machinations, cyberpunk atmosphere, mass casualty terrorism? That has not been overdone. Not at all.
And it’s also an excuse to really mix things up, find unique mission types beyond “destroy the thing” and “escort the thing.” That’s the other problem with space combat: it’s very hard to invent original situations. But the black ops angle lets us take it at right angles. I’m picturing strikes against concealed asteroid bases, flying an experimental bomber to attack planetary targets, crazy three-way fleet battles, really big explosions. Hooking up with a small task force trying to get to the truth behind a brutal and increasing wave of terrorism and civil war in a formerly peaceful star colony. Doing crazy stuff that just wouldn’t make sense in the context of a large, well-organized, and publicly operating military force. I think this has distinct possibilities.
Now, I just need a name already…

Not too much flashy to show you: I’ve been fixing some bugs in the particle system, fighting with Milkshape’s annoying eagerness to trash vertex normals, designing the odd ship, and finally (finally!) rewriting the vector font class so that SVG files are no longer used anywhere and the last vestiges of the old Republic Inkscape legacy code can be swept away. But really, the big issue on my mind is something that was pointed out to me by the same friend who suggested a Wing Commander-style game originally: I really ought to settle on a story concept for this game.

Because, you know. I’m only a half-assed AI away from having actual gameplay, and moving forward a lot of decisions about gameplay systems should be informed by what the game is, you know, about. I’m rapidly reaching the end of the line for stuff which can just be implemented on spec.

I’ve been working through this be thinking about what individual elements I’d like to see in a story about science-fictiony fighter pilots, and have come up with something. Wing Commander and most of its brethren were pretty straight-up war stories — one big fancy organization vs. another big fancy organization, Earth military vs. Kilrathi military, et cetera. Sometimes it’s humans vs. humans but there’s a giant surprise alien enemy out of nowhere, that sort of thing. The example that stands out from the rest for me is Wing Commander IV, which was about a conspiracy within the Earth military. Now, I liked WCIV a lot but I’m generally not a fan of that storyline any more: these days “Gosh, WE’RE the REAL bad guys” is lazy, obvious, and agonizingly overused, not to mention borderline offensive. Still, in the context of space combat, a storyline that’s not necessarily “OMG WE HAEV MET TEH EMENY AND HE IS US” but still has elements such as intelligence failures, conspiracies, black operations, political machinations, cyberpunk atmosphere, mass casualty terrorism? That has not been overdone. Not at all.

And it’s also an excuse to really mix things up, find unique mission types beyond “destroy the thing” and “escort the thing.” That’s the other problem with space combat: it’s very hard to invent original situations. But the black ops angle lets us take it at right angles. I’m picturing strikes against concealed asteroid bases, flying an experimental bomber to attack planetary targets, crazy three-way fleet battles, really big explosions. Hooking up with a small task force trying to get to the truth behind a brutal and increasing wave of terrorism and civil war in a formerly peaceful star colony. Doing crazy stuff that just wouldn’t make sense in the context of a large, well-organized, and publicly operating military force. I think this has distinct possibilities.

Now, I just need a name already…

Wednesday, February 15, 2012
Should I wait until I fix the myriad problems, such as low-res particle systems, bad in-ship camera angles, no cockpit graphics, weird normals on that model? Aah, who cares, let’s roll anyway.
The latest feature I wanted to get in is missiles. I want them to be visibly attached to your ship, then launch as needed. To do this I took the child object system from Neon Galaxy and then pushed it backwards so it can be used on both 2D and 3D entities. Really wasn’t too tough, and there we are, functional missiles.
I would theoretically like to get it so that, by GDC, it’s possible to duel a functional enemy ship in this game. I also… need a name for this game, seriously. Usually naming isn’t that tough for me, but not this time.

Should I wait until I fix the myriad problems, such as low-res particle systems, bad in-ship camera angles, no cockpit graphics, weird normals on that model? Aah, who cares, let’s roll anyway.

The latest feature I wanted to get in is missiles. I want them to be visibly attached to your ship, then launch as needed. To do this I took the child object system from Neon Galaxy and then pushed it backwards so it can be used on both 2D and 3D entities. Really wasn’t too tough, and there we are, functional missiles.

I would theoretically like to get it so that, by GDC, it’s possible to duel a functional enemy ship in this game. I also… need a name for this game, seriously. Usually naming isn’t that tough for me, but not this time.

Monday, February 6, 2012
Got particle systems working on a basic level. Once fleshed out more, will be used for engine exhaust, missile trails, explosion debris, and who knows what-all.
About those sentence fragments.

Got particle systems working on a basic level. Once fleshed out more, will be used for engine exhaust, missile trails, explosion debris, and who knows what-all.

About those sentence fragments.

Sunday, February 5, 2012
Mang I thought just making 3D models was a pain. Then I tried texturing one. I don’t know if this resolution level looks particularly good or not but I do know that it’s just about as much as I can stand to make.

Mang I thought just making 3D models was a pain. Then I tried texturing one. I don’t know if this resolution level looks particularly good or not but I do know that it’s just about as much as I can stand to make.

Saturday, February 4, 2012
Text can now be drawn into the HUD. Both “world” text, a virtual 3D object such as the helpful instructions on the navigation tunnel, and “local” text, text projected onto the glass canopy such as the waypoint label, are supported: to do this I repurposed the vector text drawing system from Neon Galaxy, making it capable of sending line draw requests to an arbitrary target such as Space’s HUD. That is all for now because I am too sick and miserable to say more.
Oh yes: Thanks for the suggestion of trying Wine to run Milkshape under OSX. I was kinda hesitant originally because previous attempts to get it working were disastrous. This time, I gave in and used MacPorts, and amazingly it all downloaded, compiled, and installed smooth as silk. However, even though other Windows apps run, Milkshape itself won’t start — the computer just sits. I’ve posted on the Wine forums to see if anyone can help, but I’m not expecting much there; should probably post on the Milkshape forums as well. Might get lucky!

Text can now be drawn into the HUD. Both “world” text, a virtual 3D object such as the helpful instructions on the navigation tunnel, and “local” text, text projected onto the glass canopy such as the waypoint label, are supported: to do this I repurposed the vector text drawing system from Neon Galaxy, making it capable of sending line draw requests to an arbitrary target such as Space’s HUD. That is all for now because I am too sick and miserable to say more.

Oh yes: Thanks for the suggestion of trying Wine to run Milkshape under OSX. I was kinda hesitant originally because previous attempts to get it working were disastrous. This time, I gave in and used MacPorts, and amazingly it all downloaded, compiled, and installed smooth as silk. However, even though other Windows apps run, Milkshape itself won’t start — the computer just sits. I’ve posted on the Wine forums to see if anyone can help, but I’m not expecting much there; should probably post on the Milkshape forums as well. Might get lucky!

Wednesday, February 1, 2012
Man, I seriously don’t enjoy making 3D models. I had to bully and cajole myself for hours to make this trivial little ship. Is that thing even a hundred polygons? I mean seriously.
This is the first “real” model I’ve produced in Milkshape. And see, here’s the thing. Milkshape is a shareware program, that is PC-only and so requires me to boot into Windows, and which was abandoned without warning by its developers in 2009. Its interface is full of annoying little gotchas. And yet it’s still the least agonizing 3D program I’ve ever used, with the possible exception of Lightwave 3D on the old Amiga Video Toaster. (I say “possible” there because I was, like, 22, and still in the throes of Amiga fanboyism, so I probably wasn’t able to evaluate it dispassionately.)
What does Milkshape have to recommend it? Well, so far: a) It has never crashed, or even obviously glitched out, in my admittedly brief time using it. b) The undo functionality works and includes multi-level undo and redo, so when I stumble over the interface I don’t end up screwing myself permanently. And c) there are plenty of tutorials and resources for it on the Web, since it’s popular among the FPS-modding crowd. I might also add d) it’s not outrageously ambitious modeling-wise: it lets you do obvious things to vertices, faces, and groups of those things, and that’s it. I’m happy with that. I don’t want to do ambitious modeling. I want to make hundred-polygon spaceships and then go home, and this is really looking like just the ticket.
All that aside, this thing is clearly going to need some textures. Back to the grindstone tomorrow.

Man, I seriously don’t enjoy making 3D models. I had to bully and cajole myself for hours to make this trivial little ship. Is that thing even a hundred polygons? I mean seriously.

This is the first “real” model I’ve produced in Milkshape. And see, here’s the thing. Milkshape is a shareware program, that is PC-only and so requires me to boot into Windows, and which was abandoned without warning by its developers in 2009. Its interface is full of annoying little gotchas. And yet it’s still the least agonizing 3D program I’ve ever used, with the possible exception of Lightwave 3D on the old Amiga Video Toaster. (I say “possible” there because I was, like, 22, and still in the throes of Amiga fanboyism, so I probably wasn’t able to evaluate it dispassionately.)

What does Milkshape have to recommend it? Well, so far: a) It has never crashed, or even obviously glitched out, in my admittedly brief time using it. b) The undo functionality works and includes multi-level undo and redo, so when I stumble over the interface I don’t end up screwing myself permanently. And c) there are plenty of tutorials and resources for it on the Web, since it’s popular among the FPS-modding crowd. I might also add d) it’s not outrageously ambitious modeling-wise: it lets you do obvious things to vertices, faces, and groups of those things, and that’s it. I’m happy with that. I don’t want to do ambitious modeling. I want to make hundred-polygon spaceships and then go home, and this is really looking like just the ticket.

All that aside, this thing is clearly going to need some textures. Back to the grindstone tomorrow.

Sunday, January 29, 2012
I deliberately go on an all-day caffeine-fueled programming binge and the result is to rewrite the HUD system which I already had working? Jeez.
Okay, so that isn’t remotely what I was planning to work on, but on the other hand, I’m pleased that I got it all functioning the way I wanted it for reals. Today’s work implements a “glass cockpit” system where, rather than just being immediately translated into 2D, points of interest out in the world are actually projected onto a sphere surrounding the player’s seat in the ship. So, if you tilt your head and look around, or move in your seat for whatever reason, the objects in the glass cockpit distort appropriately — note how the waypoint indicator in the bottom right is distorted, being in the corner of the player’s vision. It’s also worth pointing out that rather than being immediately drawn, all HUD artwork is cached and drawn in a single step after drawing the 3D world so it’s easy to sort and apply unique effects to.
The other HUD element, the chain of rectangles, is a “landing corridor” I implemented as a lark a few days ago. It’ll be used when the player is docking with larger ships or doing an atmospheric re-entry: each rectangle has a required speed and orientation, and the player needs to maintain the requested parameters to complete the docking or re-entry successfully. In the near future I’d like to repurpose the 2D text code from Neon Galaxy to draw text onto the HUD as well.
I should also mention that I went back and re-did the lighting so it’s now in model space. Bam, it all worked, just like that, and the math made a lot more sense as well as reducing shader cost.

I deliberately go on an all-day caffeine-fueled programming binge and the result is to rewrite the HUD system which I already had working? Jeez.

Okay, so that isn’t remotely what I was planning to work on, but on the other hand, I’m pleased that I got it all functioning the way I wanted it for reals. Today’s work implements a “glass cockpit” system where, rather than just being immediately translated into 2D, points of interest out in the world are actually projected onto a sphere surrounding the player’s seat in the ship. So, if you tilt your head and look around, or move in your seat for whatever reason, the objects in the glass cockpit distort appropriately — note how the waypoint indicator in the bottom right is distorted, being in the corner of the player’s vision. It’s also worth pointing out that rather than being immediately drawn, all HUD artwork is cached and drawn in a single step after drawing the 3D world so it’s easy to sort and apply unique effects to.

The other HUD element, the chain of rectangles, is a “landing corridor” I implemented as a lark a few days ago. It’ll be used when the player is docking with larger ships or doing an atmospheric re-entry: each rectangle has a required speed and orientation, and the player needs to maintain the requested parameters to complete the docking or re-entry successfully. In the near future I’d like to repurpose the 2D text code from Neon Galaxy to draw text onto the HUD as well.

I should also mention that I went back and re-did the lighting so it’s now in model space. Bam, it all worked, just like that, and the math made a lot more sense as well as reducing shader cost.