   Brush - Brush Collision Detection
  I''m using brushes as a collision volume in a simulation that I''m doing (defined by a number of planes, forming a convex solid). What I need to do now is detect whether two brushes are intersecting each other. Does anyone know how I can determine this? 
  What I did is if one brush is moving and the other is not, then I collide the moving brush's aabb against the non moving brush.  If they're both moving, I just collide their bounding boxes, but I treat the bounding box as a brush and do swept volume.  If they're rotating, I wouldn't use brushes at all.   EDIT: I'm just wondering, were the explanations I gave at gametuts not good enough or something?  Posting here seems like you are trying to get away.  for what it's worth I have this fully implemented and can actually help. [edited by - Shadow12345 on February 18, 2004 1:35:08 PM] [edited by - Shadow12345 on February 18, 2004 1:39:05 PM];  You see, I'm only using a brush as the collision volume, and this isn't necessarily a box-shape, it can be any convex volume. Because of this, a AABB or even a OBB wouldn't suffice for this problem, I want to use brushes because of how simple they are to define, and the fact that thye can be virtually any shape (Well, a concave one when more than one brush is used).By the way, your help on brushes did help a lot, just not as far as this problem was concerned.(PS. I posted the topic here because the forum at GameTutorials was suppose to be about OpenGL specifically, whereas the Maths/Physics forum here seemed to suit it better)  [edited by - Barguast on February 18, 2004 1:57:46 PM];  two brushes are intersecting each other if all planes from the two brushes form another brush. so the problem is reduced to a test of some oriented planes forming a brush.if you take one plane A and then go through all the other planes, always computing the (oriented) intersection line of A and the current plane, and you store the projected inside of the planes as a 2D brush (or better as a convex polygon) on plane A, you've got a brush if there's something left of the polygon after you've gone through all planes. if there's nothing left that doesn't mean it's no brush because there are possibly planes which are completely outside the brush volume. you can discard plane A and do the whole thing you've done with A with the next plane. [edited by - ga on February 18, 2004 2:12:20 PM];  Ah, good. So it''s possible!Well, I''ve got to admit I''m having a really hard time trying to understand this. I''ve got a few questions about the process you described - I mught have misunderstood entire sections of it altogether so bear with me!- When you say to compute the oriented intersection line, do you mean the line along which Plane A cuts into Plane B?- When all of the lines above are formed into a polygon shape, then the brushes are colliding if the polygon is ''incomplete'' (missing some edges)? (I''m not sure about this bit...)- If the first Plane from Brush A does''t detect a collision, then I must repeat the entire test for the next plane in Brush A.. and so on until I''ve tested all of the planes, or a collision is detected.I''m not sure if I''m miss the point completely. But thanks for trying to help me out. If you have implemented this before then I''d appreciate looking at the code for it - it usually helps me understand better. Also, if you''ve learnt that from a website or book, then please tell me which so I can have a go at learning it!Thanks for bearing with me so far! ;  I don''t know how much you understood of what he said, so I drew a picture demonstrating the basic idea of what he means.  It''s posted here:www.thedevelopersalliance.com/~shadow12345/brush.JPGThe region in blue is the ''new brush'' where the two brushes overlap.  Note that because this is a convex volume, you *only* need to test planes that have plane normals with a dotproduct of less than 0 (meaning they are pointing in opposite directions).  The planes that have normals with dotproducts of <0 will have plane distances that overlap.  I''ll say this once, but I think this is the worst possible approach to collision detection and isn''t very intuitive.  Plus, how are you supposed to know what plane normal you actually hit if you aren''t doing swept volume?  If you don''t have the plane normal hit, then you cannot do any sort of nifty collision response, only coarse binary ''hit or not hit'' coldet.  That''s my two cents, but I''ll let it rest because it seems you really want to do this.  I''ll continue trying to help.;quote:Original post by Barguast  - When you say to compute the oriented intersection line, do you mean the line along which Plane A cuts into Plane B?yes, and the orientation of the line has to be the same as of the plane (that means you need a convention, e.g. everything left of the direction vector on plane A is the "outside" of the intersecting plane).quote:- When all of the lines above are formed into a polygon shape, then the brushes are colliding if the polygon is ''incomplete'' (missing some edges)? (I''m not sure about this bit...)the polygon won''t be incomplete if the original brushes were finite.the process of forming the polygon: go through all lines and always remember which part of the plane is on the right hand side (if you''re using the convention mentioned above). The intersecton of all those right half-planes is the polygon we''re computing.You can do this by storing the polygon as a list of line segments (which may also be infinite in one or both directions) and always cutting off pieces with new lines.If the existing polygon is completely on the left of the current line, you''ve to discard the complete polygon and the current plane A is completely outside of the intersection brush we''re searching. if there''s something left of the polygon after you''ve gone through all intersection lines, this polygon is actually a face of the intersection brush so the intersection brush exists and the brushes are colliding. ;quote:I'll say this once, but I think this is the worst possible approach to collision detection and isn't very intuitive.  Plus, how are you supposed to know what plane normal you actually hit if you aren't doing swept volume? I was hoping that this could be done... And since it's a simulation I'm doing I'm pretty much going to need it. Sorry if I've wasted your time(s), but it looks as though this isn't what I'm after. However, I do still need a way of detecting collisions between objects. Even a mesh-mesh collision detection will do, if need be. What would you recommend as a particularly versatile method of collision detection? [edited by - Barguast on February 19, 2004 1:17:20 PM] [edited by - Barguast on February 19, 2004 1:17:51 PM];  I don''t really know what to tell you because I have not done mesh to mesh collision detection.  You can either try some variant of swept volume, but if you are sweeping a mesh against another mesh, then you can still treat each mesh as a brush, or do the ''point in polygon'' collision routine, but this seems costly and I cannot forsee all of the implementation details.