Sign in to follow this  
  • entries
    271
  • comments
    969
  • views
    189138

T3h Engine!

Sign in to follow this  
Sir Sapo

76 views

Hey everybody!

As promised, here's the huge post I promised you guys, and relatively early in the day too!

The Dogfight Engine Primer


The HeightMap
The most obvious part of A22 that seperates it from A20 is that the terrain is not completely flat, and in fact can be quite bumpy. In Angels 20, the "engine" was tile-based, there was a 1D array of ground tiles that made up the entire "terrain". This worked okay for small little islands, but eventually we wanted to try and put some mountains in there, but that didn't go so well, so we stuck with flat terrain the entire game... which sucked. The engine running Angels 22 however, uses a different approach to terrain, what I call the "Cookie Cutter HeightMap".. or something like that.

The terrain in A22 is a 2D heightmap. A heightmap is a way of modeling terrain, by having a bunch of interconnected "points" with an equal distance between them, but each one having its own height. Now the one thing that was stopping me from having Angels 20 use a heightmap was that I couldn't figure out a good way to texture the thing without having the texture look stretched. Finally, about 2 months ago, I was bored in Calculus, so I started thinking up a way to nicely texture a 2D heightmap. The method I eventually came up with actually worked really well, I call it "The Cookie Cutter Method".

It works by taking a texture that is as wide as the distance between 2 adjacent height points, and as tall as the terrain can possibly be. This terrain is essentially a slab of ground with rock layers, grass, snow , etc. When rendering the heightmap, each segment of the heightmap is used to "trim" the slab texture to the shape of the segment. The trimmed texture is then applied to that heightmap segment, and since it is trimmed, there's no stretching in the final polygon. You can see the process in the screen below:



Now, while the terrain is technically a heightmap, it is also semi-tiled, because the same slab texture is used on alot of segments, in fact you can sort of see the seams between the heightmap segments in some of the screenshots we released.

Collision With The HeightMap
Testing for collisions with the heightmap is actually pretty easy and straightforward. Whenever an object needs to see if it has hit the heightmap, it just draws a vertical line at it's xposition. Then, a line intersection test is used to determine the ycoord of the terrain for that xposition. If the object's old y-position was above the terrain altitude, and its current y-position is below the terrain altitude, then there was a collision, and the object reacts accordingly. It's pretty simple, but effective.

Entities
The entities in A22 all derive from a base class called "Thing", and are all stored in various std::vectors of "Things". There's a vector for all the inactive objects like trees, rocks, etc. This saves me from doing all the collision detection and updating for those objects. Then there's the "active vector", which contains stuff like the planes, bullets, buildings, etc. The final vector is the "Combatants vector", which contains all the "attackable" objects. Every "Thing" has a reference to this vector, which allows them to internally decide what to attack, what to defend, where to go, etc. While the entities may look like they are in tiled positions in the screenshots, they can be placed anywhere on the map. Yeah, entities are pretty boring... until they start shooting at you!

The Wrap Up
Well thats about all you really need to know about the Dogfight Engine at this point, but if anyone has any questions, feel free to ask, I yearn for human contact......


The Air Force Academy

Well, as many of you may (not) have noticed, I was gone all last week. I went up to Colorado to go to the Air Force Academy for 1 week to see what it is like being a cadet there, and I must say, I have an assload of respect for anyone who goes there for college. It was pretty hardcore, both academically, and physically.

My days there consisted of waking up at 5AM and going outside to do an our of PT(Physical Training). Then we proceeded to go to breakfast, which lasted about 30 minutes. After breakfast, we would be rounded up by some officers and sent to a seminar hosted by a teacher at the academy. The seminars were mainly what one would expect from an engineering oriented school, there was Biology, Physics, Aeronautical Engineering, Astronautical Engineering(which was really cool), etc. Some of the cooler subjects you can major in were, Military Strategic Studies, Ops Research, Military Aquisitions, etc. All in all, the classes were fucking awesome. Anyways, after that first class, we would proceed to go to lunch, which was followed by another 3 hours of classes. At ~4PM, we would go play an intramural sport against other "squadrons". After 2 hours of that, it was off to dinner, which was followed by about 2 hours of briefings on Academy life. Then there were assorted leadership activities until about 10PM, after which we went to sleep and then repeated the whle process the next day.

It sounds like hell, and some of it was (2011 pushups anyone?), but at the end of the day I felt pretty damn accomplished. The facilities there are kickass (although the dorms suck), and hey, it's free! I still have a lot to think about, but I'm definitely considering going there (provided I can get a Congressional nomination, which isn't that hard in New Mexico[grin]).


Anyways, it's good to be back, and now if you'll excuse me, I've got some journals to read. Peace Out!
Sign in to follow this  


4 Comments


Recommended Comments

You were gone for a week? Didn't even notice[wink].

2011 pushups? Was that the whole week combined, or what? Either way that is a lot of pushups.

Thats a nifty map system you guys have.

Share this comment


Link to comment
You can easily reduce the striping/seams problem by doing a dirty little trick: make your ground texture wider than 32 pixels. Then, instead of having each terrain "slice" use 0.0 to 1.0 of the texture's coordinates, have the first one use, say 0.0 to 0.1, the second 0.1 to 0.2, and so on (whatever the actual numbers come out to be).

This gives you some sneaky potential. First and most obviously it eliminates seams. Second, it leaves the door open for doing texture blending or other vertex-level shader effects if you ever care to. Third, you can use two different terrain texture blocks and alternate between them in random patterns to help further reduce the "aaagh tiled texture" thing - you only need to worry about a few borders every 256 pixels or so instead of a border every 32 which is much harder to conceal. Finally, and probably most immediately useful to you, it gives you the ability to introduce transitional regions, where the terrain slowly adapts from one style to another over the space of multiple vertical strips.



Nifty trick, though - looking forward to playing the game once you guys get it all finished [smile]

Share this comment


Link to comment
Quote:
You were gone for a week? Didn't even notice.

2011 pushups? Was that the whole week combined, or what? Either way that is a lot of pushups.

Thats a nifty map system you guys have.


You cut me deep.... but thanks for the comment! The 2011 pushups were over the course of one day... it sucked

Quote:
You stole my < center> tags! I thought of that first!


Thats true, you did do it first, but I needed a way to seperate the 2 sections of the entry, and thats what came to mind.... I promise I wont use the center tag anymore in my entries....

@ApochPic - Thats a pretty good idea, we do need a way to transition between slab textures, so I'll probably give your method a shot sooner or later. And thanks for the kind words!

Share this comment


Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now