ok ill try that thanks for help
 Home
 » Viewing Profile: Posts: WiredCat
WiredCat
Member Since 09 Apr 2011Online Last Active Today, 03:23 AM
Community Stats
 Group Members
 Active Posts 226
 Profile Views 4,897
 Submitted Links 0
 Member Title Member
 Age 27 years old
 Birthday August 8, 1987

Gender
Not Telling
Posts I've Made
In Topic: Force to slide on collision between sphere and poly side
21 October 2014  02:40 AM
In Topic: Force to slide on collision between sphere and poly side
20 October 2014  04:12 PM
First: the formula you posted (if you want the sphere to continue from A to B should use normalize(BA), not normalize(AB). The vector AB 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 (BA) to determine it's new position. Assuming you want the sphere to always be at a minimum distance of sphereradius 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 airplane) 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?
In Topic: Ray plane intersection problem (need verification to the code)
19 October 2014  01:58 PM
it doesnt throw any error, plane intersection point is situated outside of test face
t3dpoint Ap = ProjectPointOntoPlane(n,pop, rA); t3dpoint Bp = ProjectPointOntoPlane(n,pop, rB); t3dpoint AB = vectorAB(Ap,Bp); float dstA = float(n3dPoint_plane_distance(rA, model>MATH_FACE_NORMALS[faceindex], model>MATH_FACE_DISTANCES[faceindex])); float dstAB = n3ddistance(rA, rB); float perDST = dstA / dstAB; t3dpoint PointOnPlane = Ap + AB*perDST; ProjectPointOntoPlane is shown in the first post
btw i made a mix of old function and new function (old calculates the ray plane intersection point) new one checks for collision and it works uuuuuuu
In Topic: Ray plane intersection problem (need verification to the code)
19 October 2014  01:33 PM
well there was an error in the code i tried to read array[3] index the function works fine for small numbers but it fails when i want to test a face that is sitouated 6 500 000 from 0,0,0 point
bool __fastcall RayIntersectsFaceFromModel(TachoGLModel * model, int faceindex, t3dpoint rA, t3dpoint rB, t3dpoint & res) { TPlane plane[4]; int index = model>VBO_BE[faceindex].INDEX_START; t3dpoint pop = model>VBO_V[index]; t3dpoint A = vectorAB(model>VBO_V[index],model>VBO_V[index+1]); t3dpoint B = vectorAB(model>VBO_V[index],model>VBO_V[index + model>VBO_BE[faceindex].length  1]); t3dpoint n = Normalize(A * B); t3dpoint Ap = ProjectPointOntoPlane(n,pop, rA); t3dpoint Bp = ProjectPointOntoPlane(n,pop, rB); t3dpoint AB = vectorAB(Ap,Bp); float dstA = float(n3dPoint_plane_distance(rA, model>MATH_FACE_NORMALS[faceindex], model>MATH_FACE_DISTANCES[faceindex])); float dstAB = n3ddistance(rA, rB); float perDST = dstA / dstAB; t3dpoint PointOnPlane = Ap + AB*perDST; res = PointOnPlane; // t3dpoint point,t3dpoint normal,float distance) t3dpoint tA,tB,tC; int i; for (i=0; i < model>VBO_BE[faceindex].length; i++) { tA = model>VBO_V[index+i]; if (i == model>VBO_BE[faceindex].length1) tB = model>VBO_V[0]; else tB = model>VBO_V[index+i+1]; tC = tA + (n*1000.0); plane[i].calc_plane(tA,tB,tC,false); } int side1 = plane[0].ClassifyPoint(PointOnPlane); for (i=1; i < model>VBO_BE[faceindex].length; i++) if (plane[i].ClassifyPoint(PointOnPlane) != side1) return false; return true; } struct TPlane { double A; double B; double C; double D; double x; double y; double z; t3dpoint n; t3dpoint N; t3dpoint tmp; void calc_plane(t3dpoint p0, t3dpoint p1, t3dpoint p2, bool normalized) { n = Normal(p0,p1,p2, normalized); if (normalized == false) N = Normalize(n); else N = n; // n = reverse_point(n); x = (double)p0.x; y = (double)p0.y; z = (double)p0.z; A = (double)n.x; B = (double)n.y; C = (double)n.z; D = (A*x + B*y + C*z); } int __fastcall ClassifyPoint(t3dpoint point) { float costam = dotproduct(point,n)+float(D); if (costam > 0) return isFront; if (costam < 0) return isBack; if (betweenorequal(SPECIAL_FEATURE,SPECIAL_FEATURE,costam) == true) return isOnPlane; } };
In Topic: Ray plane intersection problem (need verification to the code)
19 October 2014  09:40 AM
pls buckeye dont eat me lol ok ill debug it