Jump to content
  • Advertisement
Sign in to follow this  

Ellipsoid Collision Problems ( C# & XNA )

This topic is 3775 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!