100 Experience Points
An Adventure in Indie Game Development

Day 25: 27 February 2013

How does this happen? At the end of today, I’ll be 1/4 of the way done.

Timewise, that is. It seems like I have almost nothing to show for it. Here’s to hoping that I feel a lot less that way at the half way mark.

On the bright side, there’s still 3/4 of the time to go.

7:16: That early morning coding thing yesterday was actually quite fun. So I’m doing it again today. It’s probably a fair disclaimer to say that this really isn’t that early. I know, some of you out there are thinking, You think 7:15 is early? Ha. Try 5:00. You’re right. Probably not much to brag about here.

In other news, I had an interesting experience last night after I got done working on my game. As you saw, I am working on bounding box collisions/intersections. This is a key building block to a lot of other things, like being able to make sure that a player can’t stick things on top of other things in their ship, and allowing the player to select parts of their ship.

As I sat there last night, trying to sleep, my mind couldn’t quit doing math. I kept working through my hyperplane separation theorem code in my head. But of course, doing math in your head means you get a step or two in and can’t keep track of it all, so you end up starting over a billion times until you find a piece of paper or a whiteboard.

So as my sleepy brain was doing this, it decided to drift back into 2D land. And I thought, how would all of this work in 2D? This hyperplane thing seems a lot more tricky than regular old point-in-polygon code.

And then lightning struck. Duh. I don’t need to do this hyperplane separation crap. I just need to extend the point-in-polygon code to 3D, and do point-in-polyhedron code instead. I was all ready to jump out of bed to write this code, but my wife banned me. Something about keeping her warm or something. Sheesh. Who needs to be warm when there’s math to be done?

But here I am, actually refreshed from, you know, sleeping all night, ready to do some math! (Am I weird?)

7:58: Stupid sleepy brain. You didn’t think this all the way through, did you?

I made the assumption that two bounding boxes don’t overlap if one doesn’t contain any points from the other. But that’s not entirely true. It’s possible that they sort of make a cross. The line segments intersect, but the points are all outside of each other.

Perhaps that plane separation theorem is right after all…

8:08: I’ve got untested code for bounding box intersection detection written. I went back to the plane separation theorem to get it to work, but what I did this morning, going down the wrong path, was instructive anyway. I was able to do some things that resulted in much cleaner code. So it wasn’t a total waste.

8:09: If this ends up working, I’m planning on doing a little write-up about the process/algorithm that I’m using. But I want to test it first. Heck, I probably want to see it working in my game first. Just so you know, in case you’re wondering what the heck the plane separation theorem is. If it turns out to be useful, you’ll get an explanation of what it is and why.

8:24: It worked! Unit tests written and passed. Now I can use it to make sure that my objects don’t intersect. But first, I need a bounding box for all of my models. Easy enough, but perhaps this calls for a system that is a little more flexible than just hard coding the bounding box for each object.

Hmm… I can see where this is going. I think I’ll have a small (small == don’t get too excited) surprise, along these lines, coming within a couple of days. Hopefully tonight, but for sure in this weekend’s development release.

8:43: I’d better go to work, once again. But I’ve begun building bounding boxes for my objects so that I can actually check if they intersect. Yesterday, I said that I had hoped to get this piece working today, so that you can’t put things on a ship where they already are. It’s actually kind of sort of starting to look like that’s going to happen. There’s a lot of unknowns still, so we’ll see how things go.

21:35: I’ve been working on this overlapping objects for about a half hour now, tonight. It’s really coming along. There will be some screenshots tonight. I’m in the process of getting the bounding boxes actually set up correctly (and modifiable from outside of the code). But the actual intersection detection appears to be working exactly as it should. I want to write a few more unit tests for it, and I want to color the model that you’re trying to attach red or something when it fails.

Oh… and I need to make it so that it doesn’t respond to the click… I kind of forgot about the most important part. But with what I’ve got, it’s pretty clear that it’s detecting it correctly. I’m actually pretty excited about this!

22:11: I’m winding things down right now. Everything is working like it should, but I want to make some screenshots and I want to write a few more unit tests before calling this particular piece done.

22:19: I’ve got my screenshots now, but I’m going to make you wait a few more minutes. I’m going to write up some unit tests first. Then I’ll post the pics before going to sleep.

22:30: I’ve got my unit tests done, and I’ve got everything cleaned up and ready to move on to the next task. That will be tomorrow, and it will be giving the user the ability to select objects. This is in preparation for doing things like moving existing objects around and deleting them. This, too, will be based on the bounding box code that I just wrote, but I’ll also need to do bounding box and ray intersection detection. That shouldn’t be too hard. Anyway, that’s a bit of a preview of what else is coming up soon.

Here’s the goods:

A couple of shots of the actual bounding boxes being transformed and rendered. (They probably won’t be in the actual game.)

Bounding Boxes 1

Bounding Boxes 2

And here’s some doofus trying to place a gun where one already is at:

Banned Placement

Categories