First: the formula you posted (if you want the sphere to continue from A to B should use normalize(B-A), not normalize(A-B). The vector A-B points to A from B. As a result, it appears that what you're seeing is the sphere "backing up" slightly (back towards A) and colliding again and again. EDIT: You can determine if that's the problem by debugging - setting breakpoints, examining values, etc. Hmm. Think I've heard that before somewhere...
yes i am moving it back towards A, and yes it gets collision again and again and again, i dont need to check it, actually code is written to do that.
BTW BUCKEYE you should only see last two youtube videos and text above and below.
Second: if the formula were corrected as suggested above, it will result in the sphere passing through the edge of the polygon.
indeed and thats the result:
Can you describe what you mean by "sliding effect"? That is, what do you want the sphere to do in the situation you posted above?
maybe these videos will tell you what i mean but sliding, btw i am wondering how was that made by point sphere slide liek shown in paint animation (since it can be done with such type of collision)
If you don't want the sphere to pass through the polygon, you don't want to use vector (B-A) to determine it's new position. Assuming you want the sphere to always be at a minimum distance of sphere-radius from any collision point, I'd suggest setting the direction of travel for the sphere parallel with the tangent to the surface of the sphere at the collision point (the point on the surface of the sphere where it makes contact with the polygon) for that particular situation.
wait what? you mean find a pararell plane to the poly (somewhat called a poly side plane) and then project moevement vector onto it?
this gives me such result (AB direction - your suggestion corrected)
EDIT: In general, one might resolve the collision of a sphere with a plane (flat surface, not air-plane) by adding a force to the sphere in the direction of the plane normal sufficient to prevent penetration of the plane by the sphere.
Well, somehow i cant see this working, i didint even check it (maybe if you would explain how i should calculate the point of new sphere pos and then add that face normal vetor multiplied by something i could check it, for now i have no idea how to deal that.
buckeye section
Maybe we could focus on that sphere point so it would always
Now what i did get actually: i put a fixed point in the 0, 10, 0
then wrote
if (n3ddistance(t3dpoint(0,10,0),pos) <= 4.0f)
{
pos =t3dpoint(0,10,0) + Normalize( vectorAB(t3dpoint(0,10,0), pos)) *4.0f;
}
now collision looks how its supposed to look like:
so i came with the formula of
find all distances for all sides of face against ray movement segment, pick up the closest one check if its smaller than sphere_radius then
calculated the point on the face side and
apply that formula above
that is:
pos =point_on_side + Normalize( vectorAB(point_on_side, B)) * sphere_radius;
and the result is:
now i just wonder if its properly done or not?