Hiya guys.
I was pretty bored last night, and as per normal, my mind started wandering towards Blender. I started thinking about how to do polygon collision detection in Blender.
Up until this point (unless I’m wrong - please correct me if I am), we’ve only been able to detect collisions through ‘bounding spheres’ - that is, we assume that an object is roughly spherical, and calculate to see if any object lies within the bounding sphere that we’ve defined for this object. It’s not particularly elegant, though, since the majority of objects that we make in Blender aren’t spherical. Most aren’t even close. Sure, you can model collisions using a collection of spheres for sub-parts of the object, but it’s messy, and you end up with the same results anyway - unrealistic collision detection and sloppy looking animations.
The script I was thinking about would probably be far too large/slow for GameBlender, but I think it might just be possible for animations…
Right, it works like this. First you need to define what objects you want to monitor for collision (eg. an if statement seeing if any of the objects are within an arbitrary distance of each other, say 5 units).
Now this is the part I thought up last night. What if you checked for collisions by comparing the position of each vertex in the ‘collidor’ object against the face position and normal angle of each face in the ‘collidee’ object? I know the math would be quite complex, but by knowing the face centre (eg average the positions of the vertices that make up that face) and using the face normal, you would be able to calculate if the vertex falls in front of or behind the face in question - ie see if a collision has taken place.
Obviously, you’d only be able to count it as a collision if the vertex was within a fairly small distance of the face (otherwise you’d get faces on the opposite side of the object registering collisions!). Either that, or you only measure faces which are on the same side of the object centre as the vertex in question is. Both would achieve the same effect.
Now this obviously wouldn’t be very good in GameBlender because of the sheer size of the script - you’re checking the position of each vertex in one object against the position and normal of each face in another object - for dense objects this would be far too slow for decent frame-rates. It would only work on one side of 2 dimensional objects eg. planes/triangles. But for scripts that simply need to know when a collision is happening on complex objects (eg. physics scripts) and need realistic results, then this script would be ideal.
I think that this idea could really go somewhere. What do you people think? Is the idea feasible, or is there some sort of basic principle I’ve just completely missed (it wouldn’t be the first time!! )
So, comments?
LethalSideParting