public static bool Intersects(Ray ray, Vector3 vertex1, Vector3 vertex2, Vector3 vertex3, out float distance, out float barycentricU, out float barycentricV) { unsafe { fixed(float *pinnedDist = &distance) { fixed(float *pinnedU = &barycentricU) { fixed(float *pinnedV = &barycentricV) { if (IDllImportApi.v3dxIntersectTri(&vertex1, &vertex2, &vertex3, &ray.Position, &ray.Direction, pinnedU, pinnedV, pinnedDist) != 0) { return(true); } else { return(false); } } } } } }
/// <summary> /// 重载"*"号操作符 /// </summary> /// <param name="plane">平面对象</param> /// <param name="scale">缩放值</param> /// <returns>返回计算后的平面对象</returns> public static Plane operator *(Plane plane, float scale) { Plane result; unsafe { IDllImportApi.v3dxPlaneScale((Plane *)(&result), (Plane *)(&plane), scale); } return(result); }
public static Plane Multiply(Plane plane, float scale) { Plane result; unsafe { IDllImportApi.v3dxPlaneScale((Plane *)&result, (Plane *)&plane, scale); } return(result); }
public static void Multiply(ref Plane plane, float scale, out Plane result) { unsafe { fixed(Plane *pResult = &result) { fixed(Plane *pPlane = &plane) { IDllImportApi.v3dxPlaneScale(pResult, pPlane, scale); } } } }
/// <summary> /// 根据点列表建立球体包围盒 /// </summary> /// <param name="points">点列表</param> /// <returns>返回建立的球体包围盒</returns> public static BoundingSphere FromPoints(Vector3[] points) { BoundingSphere sphere; unsafe { fixed(Vector3 *pinnedPoints = &points[0]) { int hr = IDllImportApi.v3dxComputeBoundingSphere(pinnedPoints, (UInt32)points.Length, sizeof(float) * 3, &sphere.Center, &sphere.Radius); if (hr != 0) { return(BoundingSphere.DefaultSphere); } } } return(sphere); }
public static bool Intersects(ref Plane plane, ref Vector3 start, ref Vector3 end, out Vector3 intersectPoint) { unsafe { fixed(Plane *pPlane = &plane) { fixed(Vector3 *pStart = &start) { fixed(Vector3 *pEnd = &end) { fixed(Vector3 *pIntersectPoint = &intersectPoint) { if (0 == (int)IDllImportApi.v3dxPlaneIntersectLine(pIntersectPoint, pPlane, pStart, pEnd)) { return(false); } return(true); } } } } } }