public bool GetNearestPoint_HullToHull(out Point3D?contactPointThis, out Point3D?contactPointOther, out Vector3D?normal, CollisionHull otherHull, int threadIndex, Transform3D thisTransform, Transform3D otherTransform) { float[] finalOffsetThis = thisTransform == null ? new NewtonMatrix(Matrix3D.Identity).Matrix : new NewtonMatrix(thisTransform.Value).Matrix; // not including the member's offset, because newton is already accounting for it. float[] finalOffsetOther = thisTransform == null ? new NewtonMatrix(Matrix3D.Identity).Matrix : new NewtonMatrix(otherTransform.Value).Matrix; NewtonVector3 contactANewt = new NewtonVector3(); NewtonVector3 contactBNewt = new NewtonVector3(); NewtonVector3 normalNewt = new NewtonVector3(); int retVal = Newton.NewtonCollisionClosestPoint(_world.Handle, _handle, finalOffsetThis, otherHull.Handle, finalOffsetOther, contactANewt.Vector, contactBNewt.Vector, normalNewt.Vector, threadIndex); // Exit Function if (retVal == 1) { contactPointThis = contactANewt.ToPointWPF(); contactPointOther = contactBNewt.ToPointWPF(); normal = normalNewt.ToVectorWPF(); return(true); } else { contactPointThis = null; contactPointOther = null; normal = null; return(false); } }
/// <summary> /// This is the axis aligned box in world coords /// </summary> public void GetAABB(out Point3D minPoint, out Point3D maxPoint) { NewtonVector3 newtMin = new NewtonVector3(); NewtonVector3 newtMax = new NewtonVector3(); Newton.NewtonBodyGetAABB(_handle, newtMin.Vector, newtMax.Vector); minPoint = newtMin.ToPointWPF(); maxPoint = newtMax.ToPointWPF(); }
public Point3D GetFarthestVertex(Vector3D direction) { // Look this up on the web page, it explains it pretty well (this method is useful for calculating custom bounding surfaces) NewtonVector3 retVal = new NewtonVector3(); Newton.NewtonCollisionSupportVertex(_handle, new NewtonVector3(direction).Vector, retVal.Vector); return(retVal.ToPointWPF()); }
public void CalculateAproximateAABB(out Point3D minPoint, out Point3D maxPoint, Transform3D transform) { float[] finalOffset = transform == null ? new NewtonMatrix(Matrix3D.Identity).Matrix : new NewtonMatrix(transform.Value).Matrix; // not including _offsetMatrix, because newton is already accounting for it. NewtonVector3 minNewt = new NewtonVector3(); NewtonVector3 maxNewt = new NewtonVector3(); Newton.NewtonCollisionCalculateAABB(_handle, finalOffset, minNewt.Vector, maxNewt.Vector); minPoint = minNewt.ToPointWPF(); maxPoint = maxNewt.ToPointWPF(); }
/// <summary> /// Vectors are in world coords /// </summary> public void GetContactPositionAndNormalWorld(out Point3D position, out Vector3D normal, out double normalSpeed, Body body) { NewtonVector3 newtPos = new NewtonVector3(); NewtonVector3 newtNormal = new NewtonVector3(); Newton.NewtonMaterialGetContactPositionAndNormal(_handle, body.Handle, newtPos.Vector, newtNormal.Vector); position = newtPos.ToPointWPF(); normal = newtNormal.ToVectorWPF(); normal.Normalize(); normalSpeed = this.ContactNormalSpeed; normal *= normalSpeed; }
public bool GetNearestPoint_PointToHull(out Point3D?contactPoint, Vector3D?normal, Vector3D point, int threadIndex, Transform3D transform) { float[] finalOffset = transform == null ? new NewtonMatrix(Matrix3D.Identity).Matrix : new NewtonMatrix(transform.Value).Matrix; // not including _offsetMatrix, because newton is already accounting for it. NewtonVector3 contactNewt = new NewtonVector3(); NewtonVector3 normalNewt = new NewtonVector3(); int retVal = Newton.NewtonCollisionPointDistance(_world.Handle, new NewtonVector3(point).Vector, _handle, finalOffset, contactNewt.Vector, normalNewt.Vector, threadIndex); // Exit Function if (retVal == 1) { contactPoint = contactNewt.ToPointWPF(); normal = normalNewt.ToVectorWPF(); return(true); } else { contactPoint = null; normal = null; return(false); } }
public Point3D GetFarthestVertex(Vector3D direction) { // Look this up on the web page, it explains it pretty well (this method is useful for calculating custom bounding surfaces) NewtonVector3 retVal = new NewtonVector3(); Newton.NewtonCollisionSupportVertex(_handle, new NewtonVector3(direction).Vector, retVal.Vector); return retVal.ToPointWPF(); }
public bool GetNearestPoint_HullToHull(out Point3D? contactPointThis, out Point3D? contactPointOther, out Vector3D? normal, CollisionHull otherHull, int threadIndex, Transform3D thisTransform, Transform3D otherTransform) { float[] finalOffsetThis = thisTransform == null ? new NewtonMatrix(Matrix3D.Identity).Matrix : new NewtonMatrix(thisTransform.Value).Matrix; // not including the member's offset, because newton is already accounting for it. float[] finalOffsetOther = thisTransform == null ? new NewtonMatrix(Matrix3D.Identity).Matrix : new NewtonMatrix(otherTransform.Value).Matrix; NewtonVector3 contactANewt = new NewtonVector3(); NewtonVector3 contactBNewt = new NewtonVector3(); NewtonVector3 normalNewt = new NewtonVector3(); int retVal = Newton.NewtonCollisionClosestPoint(_world.Handle, _handle, finalOffsetThis, otherHull.Handle, finalOffsetOther, contactANewt.Vector, contactBNewt.Vector, normalNewt.Vector, threadIndex); // Exit Function if (retVal == 1) { contactPointThis = contactANewt.ToPointWPF(); contactPointOther = contactBNewt.ToPointWPF(); normal = normalNewt.ToVectorWPF(); return true; } else { contactPointThis = null; contactPointOther = null; normal = null; return false; } }
public bool GetNearestPoint_PointToHull(out Point3D? contactPoint, Vector3D? normal, Vector3D point, int threadIndex, Transform3D transform) { float[] finalOffset = transform == null ? new NewtonMatrix(Matrix3D.Identity).Matrix : new NewtonMatrix(transform.Value).Matrix; // not including _offsetMatrix, because newton is already accounting for it. NewtonVector3 contactNewt = new NewtonVector3(); NewtonVector3 normalNewt = new NewtonVector3(); int retVal = Newton.NewtonCollisionPointDistance(_world.Handle, new NewtonVector3(point).Vector, _handle, finalOffset, contactNewt.Vector, normalNewt.Vector, threadIndex); // Exit Function if (retVal == 1) { contactPoint = contactNewt.ToPointWPF(); normal = normalNewt.ToVectorWPF(); return true; } else { contactPoint = null; normal = null; return false; } }