At 16:59 06/06/99 +0100, you wrote:
>I 'm trying to detect the collision of two shapes. The problem is that I
>have to detect it very accurately (just when the one shape enters the
>other) and I can't. I just get a collision detection as soon as the one
>shape is about at the middle of the other.
>I have tried the USE_GEOMETRY flag but it does not work...
>
>Thanks in advance,
>
>Dimitris
Been there, done that!

I had a similar problem Dimitris.  The problem is that collisions can only
be detected when the scene is redrawn (ie at the start of a frame).  If you
have a moving shape then you must be recalculating the position on a
regular basis.  The best approach is to wake up on each elapsed frame and
recalculate the position of the moving object.  That way you have the best
chance of picking up the collision, but it will still sometimes miss.  The
faster your object is moving, the more chance of missing the moment of
collision.

I had the same problem.  What I did to get round it was when I updated the
movement (and this was a falling shape so it accelerated) I also updated
the collision bounds so that there was a bounding sphere with a radius
equal to the maximum distance the object could move in one frame.  This
meant I was sure of picking up the collision (otherwise the falling object
could pass right through a table top if the speed was right, but it still
didn't pick up the moment of collision.

The API collision detection is very minimal here.  When a collision is
detected
a) find what surface the object collided with
b) backtrack the movement of the object until the two surfaces involve just
touch
c) now you have the point and time of collision

Don't ask me how, I haven't done it yet, though I'm working on it.  An
alternative is to look at something like V-Clip which will give you the
penetration depth between two objects and you can backtrack from there.
But you can never guarantee to pick up a collision as it happens because
motion is continuous and animation happens in time slices.

Tony

PS get back to me in a month or so and I might have figured it out.

=====================================================================
To subscribe/unsubscribe, send mail to [EMAIL PROTECTED]
Java 3D Home Page: http://java.sun.com/products/java-media/3D/

Reply via email to