ulfek at ifm.liu.se
Mon Oct 4 09:15:59 EDT 2004
Development has been sleeping for a while, but maybe it's time to
start it again.
> I recently read that you were after some help with the collision
It's not the collision detection in itself, that is already working,
but rather the mechanics that need to be fixed a bit.
> I'll say right out that I have never programmed a game before,
> nor have I ever written in C, but I figure I'll have to learn sometime.
> The one thing I have that might be useful is a background in maths, so if
> I could get a better idea of the problem I might have a chance at finding
> a solution.
I think you could help as long as you can download the code
and compile it yourself. I will summarize the actual problem:
The collision detection code in the game gives us only one quantity:
The number of overlapping pixels (Let's call it A, for area). This
means that we do _not_ have the point of collision. This doesn't
matter so much since it's anyway hard to define a single point of
collision in a robust way (The objects are soft in reality, so they are
colliding along a surface). So what can we do?
If we have the overlapping area A between two objects we can calculate
the change in A with some small movement of the two colliding objects.
Since the grad A points in the direction where the overlap is
increasing fastest we can use -grad A as a collision normal. This
works very well in practice (You can download the CVS version and test
for yourself), but the problem is that in the current formulation
rotation is not included in collisions, or only included in an ad hoc
way. For non-rotating motion I have set up the following algorithm:
Determine the overlap gradient by finite difference, let n = - grad A.
Assume that the objects will change velocity only along n. Write down
the change in kinetic energy for a change in velocity along n (with
conservation of momentum this gives a single parameter determining the
energy loss). It turns out that there is exactly two points for this parameter
where the energy is conserved, one trivial point with no change in
velocity (not what we want), and on point which is totally elastic collision.
Halfway between these two points there is the point of maximum energy loss
which is totally plastic collision.
1) How can rotations be included? The gradient can of course be
computed also for rotation, but it get complicated further on.
2) How can we add friction without knowing a point of collision?
If you have any simple technical questions please adress them directly
to me instead of to the list.
More information about the airstrike