Saturday, March 03, 2007

Pulp Friction

Karl in a comment asked what I'm doing for collision, so here's a brief run down.

I export the levels from Max as a simple XML file with triangles, load that and parse them into a friendly structure. I store all the parsed triangles in a balanced binary tree, subdividing cells on longest axis. I would use an octree, but that requires subdiving for effect, and I haven't yet invested in writing a triangle splitter.

My movable physical objects are all spheres.

After I move any of the physical entities, I do a constraint pass against the level, i.e. for each triangle, check to see if my sphere is intersecting with it. If it is, move me out of the triangle, using the direction I'm coming from, i.e. the direction from where I currently am, to where the intersection happened. This works just fine as long as none of the entities can move farther than their diameter in a single frame.

I do the same thing with any other dynamic physical barriers, but they are represented by boxes.

I also provide ray-tracing onto the level mesh, which allows for queries like, "find the closest point on the level beneath me".

Entity to entity collision is straightforward sphere to sphere intersection tests. Again, works just fine if no one can travel faster than their diameter in a single frame.

To avoid noise, separation between entities isn't direct collision response as it is with the level, rather it is applied as a separating force over time.
In effect, the wolves are flocking away from each other rather than strictly colliding. The thinking here is that it's better to have two wolves intersect briefly rather than bounce back and forth as they're corrected violently each frame. This also means that by and large they can't get each other stuck.

6 comments:

Anonymous said...

Hi! I stumbled across your blog from a random Google search. You've got some good stuff going on here! I've enjoyed what I've read so far. I just wanted to let you know that I've added your blog to my blog's blogroll. Did that make any sense? :) Anyway, stop by and say hi sometime!

-Brian L.

Gamey Little Hacker said...

Thanks Brian. This blog is still on pause until I settle down from a trans Atlantic move (and into a nice new home computer), but I'll be back in the near future.

I'll make a note to swing by your blog when I get a free moment as well.

Anonymous said...

Your work inspires me to learn C# and do indie game development with it. Keep up the great work and always post more visual goodies :)

Anonymous said...

Hopefully you haven't left us for good! I know I sure am eagerly anticipating your return.

Great work you're doing here.

Anonymous said...

Hi, where are you man? We've waited enough, haven't we?

Come on, show your self.

Keep up the fantastic work.

-Daniel J.

Verious said...

Have you made any further progress on RPG Zero?