Saturday, March 29, 2014

Ground control to Major Tom. Come in, Major Tom.

finally buckled down and reworked the camera and ship control code in the space game, and I think I have something promising at long last. There were really two major broken things, the ship control itself and the chase camera. I pulled them apart into their own classes and addressed their problems separately, which shockingly turned out to be a cleaner way to deal with them.

At a fundamental level, ship motion is Ace Combat-style. You maintain a constant velocity forward but can hold the left or right analog trigger to temporarily decelerate (all the way to a stop, in my game’s case) or accelerate using afterburners. I’ve always found that monitoring my ship’s speed is a giant hassle I can never keep up with in space sims, and the AC model means it’s simply not a problem. You know your speed at all times because you are personally holding the analog triggers that set it, just like you know whether your car is stopped or accelerating based on the pedals you’re pushing down with your feet. As far as velocity and inertia goes, right now you simply lerp to your new velocity at a constant rate. This is utterly nonsensical from a physics point of view but it sure was simple to program and it’s not hard to understand what’s going on, an important factor when you’re in interplanetary space without a lot of landmarks around.

The other nice thing about this is that all the ship behavior is based on a set of constants. Reducing the steering lerp rate, say, makes the difference between a nimble fighter and a heavy barge. This’ll make it easy to support different “flight models” for different ships, or even the same ship equipping different types of equipment.

As for the chase camera, it’s a simple affair that monitors its target and lerps (sensing a pattern here?) to the desired chase position and angle. This works nicely in that by adjusting the lerp rate I can tweak to what extent you see the ship pivoting and reeling about on the screen, and the more violently you maneuver the more the camera lags to give you a sense that you’re making tough maneuvers. I might make the lerp rate dependent on your speed, so the ship feels a little out of control at top speed. It would be easy to explore, at any rate.

Lack of decent, non-hacked in camera and ship control was a huge blocker for the game, so maybe I’ll feel better about exploring different areas of gameplay now.

Friday, February 14, 2014
It was a good idea to take a little break from the still-unnamed space thingy; I sat back and turned it over in my head and I believe I have a good concept for the whole thing that fits the art style and what I want to create, as well as a better idea of scale and gameplay. I’m going to try to get an important part of that working for Screenshot Saturday tomorrow. Wish me luck!
As part of that, here’s a simple player ship model I slapped together in Wings 3D and imported into the game. I’ve gotten rid of the remains of my last failed attempt at a lighting system and the ship is now correctly lit by the sun. Also fixed a dumb bug in my importer code which kept me from being able to import quad-based models.
I am very pleased with Wings 3D, by the way. I’m not an especially great 3D modeler and I definitely don’t enjoy the mechanics of doing 3D modeling, but Wings 3D makes the experience of just getting some simple damn models out the door as painless as one could reasonably hope for.

It was a good idea to take a little break from the still-unnamed space thingy; I sat back and turned it over in my head and I believe I have a good concept for the whole thing that fits the art style and what I want to create, as well as a better idea of scale and gameplay. I’m going to try to get an important part of that working for Screenshot Saturday tomorrow. Wish me luck!

As part of that, here’s a simple player ship model I slapped together in Wings 3D and imported into the game. I’ve gotten rid of the remains of my last failed attempt at a lighting system and the ship is now correctly lit by the sun. Also fixed a dumb bug in my importer code which kept me from being able to import quad-based models.

I am very pleased with Wings 3D, by the way. I’m not an especially great 3D modeler and I definitely don’t enjoy the mechanics of doing 3D modeling, but Wings 3D makes the experience of just getting some simple damn models out the door as painless as one could reasonably hope for.

Sunday, January 26, 2014

Eh… Then again, this is probably close enough (near plane setting: 0.005.) At this distance, you’re on the verge of seeing the individual triangles that make up the planetary sphere and that wouldn’t benefit anyone really. For the Earthlike planet, which is ten times larger than its tiny moon, you’re almost inside the atmospheric halo and the clouds are close enough it feels like re-entry could happen at any moment. So I suppose this will be fine.

I have no idea what to do next!

Saturday, January 11, 2014

Made a couple passes through the gas giant code today to make them more procedural.

  • A basic cloud complexity value is computed based on the size of the planet and its distance from the sun, with the general idea that larger/closer planets will have more heat and thus a more complex and interesting atmosphere.
  • This complexity value in turn connects to most of the parameters that describe the clouds’ appearance. The higher the complexity value, the more intricate and strong cloud details and color variation become. Conversely, as complexity drops towards zero the twisty cloud details go away, the bands themselves get broader and the color variation drops to make a blander-looking planet.
  • Up to four “storms” are randomly placed on the surface, which simply push the color value towards one end of the scale or the other when the pixel we’re drawing is within the storm’s area of effect. This is the trick from my old planetary raytracer I mentioned last time, and I’m pleased to report that it gets the job done nicely.

The above photos have all the same parameters, except the sun’s radiation increases from 0.1 (top) through 0.7 (middle) to 3.0 (bottom), creating an increasingly stormy and chaotic atmosphere.

I’m generally satisfied with how this turned out, except that the base color selection is kind of meh — it’s purely random, mid-brightness colors, and some of them aren’t especially attractive. It would also be nice to have something that picked complementary colors, perhaps, for a more intriguing contrast.

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.