PDA

View Full Version : How to explode your model



reign_bow
05-14-2001, 10:55 PM
I saw a rather cool effect in the game GLTron ( if you don't know it, take a look at http://www.gltron.org )

It's a kind of motorcycle game. When you crash, it paints a bitmap onto the wall you crashed into and, most importantly, it causes the polygons making up the cycle to fly away as if they were exploding. The key thing is that the polygon do not change size, so they lose contact to each other. My question is, how do you do that? My best guess would be something like this:

float timeSinceCrash;
vector<MyPolyClass> polys;
...
for(int i=0; i<POLYGON_NUMBER; i++){
glScalef(timeSinceCrash, timeSinceCrash, timeSinceCrash);
translatef(polys[i].x, polys[i].y, polys[i].z);
glScalef(1/timeSinceCrash, 1/timeSinceCrash, 1/timeSinceCrash);
polys[i].drawItself();
}

So when you translate to the polygon's position, the coordinate system is distorted, but when you actually draw it, it's back to normal, so the polygons are the same size as always.

Thug
05-17-2001, 06:33 AM
I am a little confused on your data structure that you are using but I will give it a shot.

You will need to loop through your polys but instead of scaling the points you may want to translate the points via a vector away from the center of gravity of the object or perhaps a more realisic explosion using a vector from the point of contact. After all adding is faster than multiplying.

Other than that the theory looks good.

Like I said before I am not sure how you are storing your data, but you may want to keep in mind that when the original object was together the polys were sharing the same point with adjacent polys. When the object is exploding, each point that is used by another poly will indeed split into two or more points possibly traveling in a different direction when the explosion occurs.

rts
05-17-2001, 07:59 AM
Uh...

why don't you download the source code? (http://prdownloads.sourceforge.net/gltron/gltron-0.61-source.tar.gz)

bsperlin
05-18-2001, 04:57 AM
Just to get a minor detail in the discussion out of the way, the data structure is fine. I use it for a model with hundreds of thousands of polys and the speed and access work well.
Barry