Sign in to follow this  
GMaker0507

Ellipsoid Collision Problems ( C# & XNA )

Recommended Posts

GMaker0507    263
Ive been having some prolems with my collision detection code between my ellipsoid and a triangle. So far,if i want the ellipsoids center to rest onthe triangle it works fine, however when i try and set it up so the ellipsoids bottom rests on the triangle it doesnt work. I Get The Triangle In eSpace Vector3 ePoint1 = ellipsoid.ConvertToEllipsoidSpace(Triangle[0]); Vector3 ePoint2 = ellipsoid.ConvertToEllipsoidSpace(Triangle[1]); Vector3 ePoint3 = ellipsoid.ConvertToEllipsoidSpace(Triangle[2]); Then i find the triangle's normal using the cross product of two of its edges. Vector3 edge1 = ePoint2 - ePoint1; Vector3 edge2 = ePoint3 - ePoint1; Vector3 TriangleNormal = Vector3.Cross(edge2, edge1); TriangleNormal.Normalize(); I get the ellipsoids position and velocity in eSpace Vector3 eVel= ellipsoid.ConvertToEllipsoidSpace(Velocity); Vector3 ePos1 = ellipsoid.ConvertToEllipsoidSpace(ellipsoid.Position); I find the point in time ( along the velocity vector ) at which the ellipsoid should hit the plane float SignedDistanceToBasePoint=Vector3.Dot(ePos1-ePoint1,TriangleNormal); float T0 =SignedDistanceToBasePoint / Vector3.Dot(TriangleNormal, eVel); I make sure its within a certain range. if ( Math.Abs(T0) < 0 || Math.Abs(T0) > 1) return null; Then i find where the ellipsoid should rest on the plane Vector3 EllipsoidRestingPoint=ePos1+(T0*eVel); EllipsoidRestingPoint = ellipsoid.ConvertToVector3Space(EllipsoidRestingPoint); When i test this, the ellipsoid's center rest on the triangle, however when i try and change Vector3 EllipsoidRestingPoint=ePos1+(T0*eVel); EllipsoidRestingPoint = ellipsoid.ConvertToVector3Space(EllipsoidRestingPoint); to: Vector3 EllipsoidRestingPoint=ePos1+TriangleNormal+(T0*eVel); EllipsoidRestingPoint = ellipsoid.ConvertToVector3Space(EllipsoidRestingPoint); It doesnt work. I figured it should make the ellipsoids bottom rest on the triangle plane, but apparently im wrong. NOTE: I know i didnt check if the point was in the triangle yet,im still getting to that. If that is the problem, tell me.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this