|
Post by shadow008 on Mar 25, 2011 10:01:04 GMT -5
As the title implies, I've been trying to implement sliding collision detection into my engine. I only get moderately successful results. Here is the function I've been using:
function DeflectVectorAlongSlope(Vector() as single, Normal() as single)() as single dim Vec(2) as single = Vector dim Norm(2) as single = Normal dim DirNormal(2) as single = Normalize(Vec) dim DirMirror(2) as single = DirNormal*-1 dim DotProduct as single = Dot(DirMirror, Norm)
return Normalize(Norm*DotProduct+DirNormal) endfunction
Basically you pass in the initial velocity (Character movement) and the normal of the collided triangle. And it outputs the desired velocity...
Any ideas? Please dont give me a link to some sight claiming to have an algorithm, because I've probably already seen it...
|
|
|
Post by matthew on Mar 25, 2011 10:34:59 GMT -5
Have you seen this post on the forum by Xeno? He created a 3D scene with a ramp which a ball could roll up & down on.
|
|
|
Post by shadow008 on Mar 31, 2011 11:51:27 GMT -5
Well, its been spring break so I haven't been on in forever (since i last posted or so XD) Matthew: Yes, i have seen that. And actually i had come up with that concept completely on my own so i feel pretty good about it. My issue actually was my function (named "DeflectSphereOnTriangle()") which basically did exactly what Xeno did in his demo. My issue was with the ColDet plugin. It only tested the closest triangle to the sphere. When i moved it exactly as far as it had penetrated, it was still technically touching the plane so it would still only check that triangle for collision rather than the other nearby triangles (am i making any sense?) Fired up my code and 10 seconds later i figured out what the issue was. So all i did was fudge it a little bit like this: **get all the collision stuff here and penetration distance ect...** SpherePos = SpherePos + (Deflection * 1.01) After it was fudged a bit, it no longer touched the same triangle . And a few iterations later, the sphere was at the correct spot! If this post didnt make any sense, or if I made horrible grammer mistakes, i apologize. I'm still on spring break and have been milking the sleeping in for all its worth.
|
|