Sign in to follow this  
Toji

"Fragmenting" a polygon

Recommended Posts

Toji    535
Looking for some theory here, not nessicarily a hard equation or anything. I've recently switched gears in my programming and have started working on a simple "Scorched Earth"-like game with some friends. (I must say that working in 2D definately has it's advantages! It's been moving very quickly thus far!) In any case, one of the things we want to be able to do is "Fragment" or "Shatter" a chunk of land into several smaller peices. I've puzzled this one over for several days, and I have to admit that I have no idea how to do it convincingly! I guess some technical infromation would be helpful: All of the landscape and/or destructable objects in our engine thus far are defined as "surfaces". A surface is simply an array of points that define the boundries of the polygon (connect the dots! Whee!) Surfaces can be any shape and size, concave or convex. I've got a very nice rendering method in place that can handle any shape you throw at it, so no problems there. ^_^ Visuals Aids! I've also already got a function that can do a boolean intersection between two surfaces, which allows me to "cut" a chunk out of one peice of land and turn it into a new piece. The idea is that when the landscape is shot we create a temporary surface that is a jittered circle, subtract it from the surface that was just hit, and then shatter the smaller chunk that we've just subtracted, so the peices can go flying every which way! Destruction is fun! So... How might one go about shattering a surface in a "realistic" manner? Several thoughts I've had thus far: -Randomly overlay several lines on the surface and divide it up based on that. Simple, and relativly fast, but if you ask me it would look too synthetic. -Scatter a few random points inside the surface and connect them to boundry points, breaking it up into new surfaces from there. I'm not sure how I would determine the connectivity, though (closest points, maybe?) I it seems like this would still look a little fake. -Create several other randomly generated surfaces (again jittered circles) and recursively subtract them from the surface to be shattered. Sounds good, but seems fairly processor intensive, and I need something realtime. Any thoughts?

Share this post


Link to post
Share on other sites
w00f    176
A project my friend worked on (Saturn Storm at www.gamecreation.org) had buildings that shattered in what seems like a similar way. I don't remember exactly how it worked, but iirc basically you have the artist define the landscape, and then manually break it apart into a bunch of fragments (just split the polygon up to whatever granularity you want). Give each fragment a health, and when you do damage calculations vs the ground you'd deal damage from each fragment in a certain radius or something. When the health goes below zero, add them to a particle system, give them a velocity (random or based on bullet velocity), and simulate them with gravity, deleting them when they go offscreen or when they fade out.

Share this post


Link to post
Share on other sites
Toji    535
I've thought of that, but the problem is I need a fully dynamic solution. All of the fragments are going to be treated as their own surfaces, complete with physics simulations and the ability to be shot and fragment themselves. Not to mention we're trying to work in a "random landscape" generator, so artist created fragments are out of the question. :(

Thanks for the suggestion, though!

Share this post


Link to post
Share on other sites

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

Sign in to follow this