Collision Response
Hi,
I''m able to detect a collision right now but I don''t know how to handle it. If two complex objects (e.g. spaceships)collide, they should bounce from each other. I know that I have to check what triangles intersect each other and then I have do create some kind of reflection vector on the surface of one of the two triangles right ?
But what if several triangles collide or what if one triangle collides with the edge of another triangle ?
The only solution that I can imagine is to average all the Normals of the colliding triangles and refelect the veclocity vector of the other object on that normal.
Any ideas to that problem ?
Well you have a problem... how real do you want the results to be?
All materials do not collide the same way, so you may need to add something about this to your models. ie You don't want an aluminum antenea to react the same way as a titanium rod. The antenea should crumple with minimal damage to the ship, and maybe the rod is bent and the ship explodes?
So you need a way to determine the affects of the collison on the objects, because that has a dramatic effect on the resultant forces.
Assuming everything is indestructable and you have ellastic collisions, you would find all the faces that hit (really can only be one, rarely might be a few more) and treat each one independantly then sum them to determine the result.
ie if a ship is hit by two other ships at precisely the same time, and both of those ships have the same momentum, and they hit at precisely 180o from eachother, the middle ship would not move at all under ideal conditions. And that's the result you'd get by adding the two resultant forces together.
In the case that an edge hits a face, you have a complicated scenario, because in reality it will produce a torque on the colliding objects (unless it hits precisely square between the faces). If it hits on a point to a face, then you have a two dimensionally torque. The objects will start to rotate until two faces collide, or the resultant forces pull the objects away from each other. (Objects that spin after colliding take less damage then square hits.)
Under ideal conditions, an edge is no different than a face, nor a point. You are correct to find the 'average' normal of the adjent faces for edges collisions.
...
Maybe you could abuse bump mapping to stimulate RL collisions.
Magmai Kai Holmlor
- The disgruntled & disillusioned
Edited by - Magmai Kai Holmlor on January 9, 2001 8:16:20 PM
All materials do not collide the same way, so you may need to add something about this to your models. ie You don't want an aluminum antenea to react the same way as a titanium rod. The antenea should crumple with minimal damage to the ship, and maybe the rod is bent and the ship explodes?
So you need a way to determine the affects of the collison on the objects, because that has a dramatic effect on the resultant forces.
Assuming everything is indestructable and you have ellastic collisions, you would find all the faces that hit (really can only be one, rarely might be a few more) and treat each one independantly then sum them to determine the result.
ie if a ship is hit by two other ships at precisely the same time, and both of those ships have the same momentum, and they hit at precisely 180o from eachother, the middle ship would not move at all under ideal conditions. And that's the result you'd get by adding the two resultant forces together.
In the case that an edge hits a face, you have a complicated scenario, because in reality it will produce a torque on the colliding objects (unless it hits precisely square between the faces). If it hits on a point to a face, then you have a two dimensionally torque. The objects will start to rotate until two faces collide, or the resultant forces pull the objects away from each other. (Objects that spin after colliding take less damage then square hits.)
Under ideal conditions, an edge is no different than a face, nor a point. You are correct to find the 'average' normal of the adjent faces for edges collisions.
...
Maybe you could abuse bump mapping to stimulate RL collisions.
Magmai Kai Holmlor
- The disgruntled & disillusioned
Edited by - Magmai Kai Holmlor on January 9, 2001 8:16:20 PM
- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara
January 10, 2001 08:23 AM
Well the collision response does not have to be realistic. All the faces are of the same material.
I only want the objects to bounce form each other. Torque and rotations are not important and not required. You recommend to calculate the different, reflected velocitie-vectors of two colliding triangles and add them together am I right ?
But how can I get these vectors ? I won''t get correct result for edge=>face collisions if I would reflect the veclocity vector on the surface normal of a triangle. But for a point=>face collision this would work. I really need no torque, only a pseudo realistic collsision response.
Imagine a "frontal collsion" of a triangle with the edge of another one. The colliding triangle would move straight forward without to bounce if I would reflect the velocity-vector on the normal.
How can I solve this collision problem in an easy, fast and good looking way ??
Would it work if I first do the following:
- add the normals of all colliding triangles together if the angle of the veclocity vector and the surface normal is between 0° and 180° in order to get the average normal
- reflect the velocity vector of the colliding object at this normal in order to get the new direction after the collision
I only want the objects to bounce form each other. Torque and rotations are not important and not required. You recommend to calculate the different, reflected velocitie-vectors of two colliding triangles and add them together am I right ?
But how can I get these vectors ? I won''t get correct result for edge=>face collisions if I would reflect the veclocity vector on the surface normal of a triangle. But for a point=>face collision this would work. I really need no torque, only a pseudo realistic collsision response.
Imagine a "frontal collsion" of a triangle with the edge of another one. The colliding triangle would move straight forward without to bounce if I would reflect the velocity-vector on the normal.
How can I solve this collision problem in an easy, fast and good looking way ??
Would it work if I first do the following:
- add the normals of all colliding triangles together if the angle of the veclocity vector and the surface normal is between 0° and 180° in order to get the average normal
- reflect the velocity vector of the colliding object at this normal in order to get the new direction after the collision
I would just treat them as point sources, & bounce them off each other as though they were spongy balls. It''ll be less true to the real world, but results won''t be spurious and they will ''feel'' more realistic (even though they aren''t).
You in 2D or 3D?
Magmai Kai Holmlor
- The disgruntled & disillusioned
You in 2D or 3D?
Magmai Kai Holmlor
- The disgruntled & disillusioned
- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara
Thank you. I will try it out but would this also work if a ship bounces against the edge of another object ?
BTW I'm in 3D-space.
Edited by - Christian Hofrichter on January 11, 2001 5:35:32 PM
BTW I'm in 3D-space.
Edited by - Christian Hofrichter on January 11, 2001 5:35:32 PM
If you''re in 3D space and your ships are mainly convex in nature, then what are you messing around with separate triangles for?
Imagine the two ships are spheres, when they hit each other they rebound like pool balls hitting each other. Just take the vector between the two centre points of your ships and rebound with 1/2 your forward velocity.
It''s not perfect, but it''s how most space games do it ;-)
---Strange
Imagine the two ships are spheres, when they hit each other they rebound like pool balls hitting each other. Just take the vector between the two centre points of your ships and rebound with 1/2 your forward velocity.
It''s not perfect, but it''s how most space games do it ;-)
---Strange
---Strange
Ok, here we go, I needed to work these out for mine game, so here ya go:
(If its possible to do subscripts or superscripts please let me know!)
Magmai Kai Holmlor
- The disgruntled & disillusioned
Again, I'd start by treating the ships as spheres, if two ships get with their 'sphere' of eachother they collide. All the more realistic if the ships have force shields.
If you want to get fancy you could mess with 3D elipsiods (could use the same math for shields too )
I was thinking about the results that would produce, and you're going to be dissapointed. It won't seem very 3D at all without accounting for torque and making the ships spin after colliding.
Magmai Kai Holmlor
- The disgruntled & disillusioned
Edited by - Magmai Kai Holmlor on January 12, 2001 12:24:19 AM
(If its possible to do subscripts or superscripts please let me know!)
p = v*m //p:momentum = v:velocity * m:massGiven:Pa = Va * MaPb = Vb & MbAnd that an ideal ellastic collision has occured, the equations are:Conservation of Momentum:Pa + Pb = Par + Pbr //r means resultantConservation of Kinetic Energy:.5PaVa + .5PbVb = .5ParVar + .5PbrVbrAfter some twiddling (TG for Ti-92s)Var = Va*(Ma-Mb)/(Ma+Mb) + Vbr*2Mb/(Ma+Mb)Vbr = Vb*(Mb-Ma)/(Ma+Mb) + Var*2Ma/(Ma+Mb)Either use overloaded vector math or perform once for each dimension you have.
Magmai Kai Holmlor
- The disgruntled & disillusioned
Again, I'd start by treating the ships as spheres, if two ships get with their 'sphere' of eachother they collide. All the more realistic if the ships have force shields.
If you want to get fancy you could mess with 3D elipsiods (could use the same math for shields too )
I was thinking about the results that would produce, and you're going to be dissapointed. It won't seem very 3D at all without accounting for torque and making the ships spin after colliding.
Magmai Kai Holmlor
- The disgruntled & disillusioned
Edited by - Magmai Kai Holmlor on January 12, 2001 12:24:19 AM
- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara
Using spheres is not appropriate. Imagine a small space flyer and a huge, long battle ship. If I will use spheres they will collide too early (because the sphere of the battle ship is too large).
The surface of the battleship is also not taken into account by unsing spheres.
BTW, I''m using an axis alligned bounding box hierarchy in order to perform collsision detection. So I already have the two boxes and also the triangles in both boxes that collide. Maybe I can treat each box as a small sphere and perform collision response on those spheres only. Each box cantains only a few triangles, so this could be a good approximation. Would this work ?
The surface of the battleship is also not taken into account by unsing spheres.
BTW, I''m using an axis alligned bounding box hierarchy in order to perform collsision detection. So I already have the two boxes and also the triangles in both boxes that collide. Maybe I can treat each box as a small sphere and perform collision response on those spheres only. Each box cantains only a few triangles, so this could be a good approximation. Would this work ?
Axis aligned bounding boxes are cool, until you collide with another bounding box. To get any kind of accurate collision you must rotate the boxes with the ships… this can be slow. Traditionally to speed up the collision using two boxes, you’ll rotate one so that it’s axis aligned and de-rotate the other by the same amount.
Instead, you can use a ‘bubble list’. Represent your ships with a series of small spheres. If you have a large, long ship, represent it with 2 or 3 spheres aligned along the length of the ship. When it comes time to collide, you only have to rotate the local co-ordinates of each sphere and perform a simple radius check with the other objects spheres.
The only time you should really use bounding boxes is if they will always be axis aligned, or you need them in some kind of culling method, (as in a scene-graph or quad/oct-tree).
It sounds inexact, but it works… especially in the heat of battle ;-)
The problem with collisions is never the actual algorithm or method you use, but how fast it is. What happens when you have a scene with 20 ships, each firing weapons at each other?
That ‘accurate’ bounding box collision suddenly seems very slow!
---Strange
Instead, you can use a ‘bubble list’. Represent your ships with a series of small spheres. If you have a large, long ship, represent it with 2 or 3 spheres aligned along the length of the ship. When it comes time to collide, you only have to rotate the local co-ordinates of each sphere and perform a simple radius check with the other objects spheres.
The only time you should really use bounding boxes is if they will always be axis aligned, or you need them in some kind of culling method, (as in a scene-graph or quad/oct-tree).
It sounds inexact, but it works… especially in the heat of battle ;-)
The problem with collisions is never the actual algorithm or method you use, but how fast it is. What happens when you have a scene with 20 ships, each firing weapons at each other?
That ‘accurate’ bounding box collision suddenly seems very slow!
---Strange
---Strange
Well I don't thinkt AABB are so slow. I'm using a box tree so I can perform a collision test in O(nlog(n))time. To perform a test I'm using the separating axis test which requires only 15 simple checks in the worst case in order to determine if two boxes will overlap (boxes are rotated with the local axis of the ship).
Of course I will do a quick and dirty sphere test before performing the box test because a sphere test is faster and most of the object are too far away in order to be able to collide. But a sphere test or a sphere hierarchy is too inaccurate for an exact collision test, even if a sphere surrounds one triangle only. I have tested the speed and it takes 8 µsec (Duron 600 Mhz) to test one box against 3000 boxes and determine a collision. (... if a collision really happens with one of these 3000 boxes, otherwise it is faster of course as it can abort sooner).
So a tree search in O(nlog(n)) time and an overlap test with 6-15
checks per box pair which can even be optimised a lot if the boxes are alligned with the local axis of the ship doesn't sound slow to me at all.
Perhaps I will use the for culling too.
Even if 20 ships fire weapons this should be fast as I can skip a lot of tests by a simple sphere check. There will also be few colision at the same time so the collision tests should abort early in the branch.
However the subject and the problem is not collision detection but collision response.
Do you use your spheres for a collision response ?
Edited by - Christian Hofrichter on January 16, 2001 11:34:08 AM
Of course I will do a quick and dirty sphere test before performing the box test because a sphere test is faster and most of the object are too far away in order to be able to collide. But a sphere test or a sphere hierarchy is too inaccurate for an exact collision test, even if a sphere surrounds one triangle only. I have tested the speed and it takes 8 µsec (Duron 600 Mhz) to test one box against 3000 boxes and determine a collision. (... if a collision really happens with one of these 3000 boxes, otherwise it is faster of course as it can abort sooner).
So a tree search in O(nlog(n)) time and an overlap test with 6-15
checks per box pair which can even be optimised a lot if the boxes are alligned with the local axis of the ship doesn't sound slow to me at all.
Perhaps I will use the for culling too.
Even if 20 ships fire weapons this should be fast as I can skip a lot of tests by a simple sphere check. There will also be few colision at the same time so the collision tests should abort early in the branch.
However the subject and the problem is not collision detection but collision response.
Do you use your spheres for a collision response ?
Edited by - Christian Hofrichter on January 16, 2001 11:34:08 AM
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement