public unsafe static bool IsInside(this PolyhedralConvexShape obj, ref OpenTK.Vector3 pt, float tolerance)
 {
     fixed(OpenTK.Vector3 *ptPtr = &pt)
     {
         return(obj.IsInside(ref *(BulletSharp.Math.Vector3 *)ptPtr, tolerance));
     }
 }
 public unsafe static void GetVertex(this PolyhedralConvexShape obj, int i, out OpenTK.Vector3 vtx)
 {
     fixed(OpenTK.Vector3 *vtxPtr = &vtx)
     {
         obj.GetVertex(i, out *(BulletSharp.Math.Vector3 *)vtxPtr);
     }
 }
 public unsafe static void GetEdge(this PolyhedralConvexShape obj, int i, out OpenTK.Vector3 pa, out OpenTK.Vector3 pb)
 {
     fixed(OpenTK.Vector3 *paPtr = &pa)
     {
         fixed(OpenTK.Vector3 *pbPtr = &pb)
         {
             obj.GetEdge(i, out *(BulletSharp.Math.Vector3 *)paPtr, out *(BulletSharp.Math.Vector3 *)pbPtr);
         }
     }
 }
 public unsafe static void GetPlane(this PolyhedralConvexShape obj, out OpenTK.Vector3 planeNormal, out OpenTK.Vector3 planeSupport, int i)
 {
     fixed(OpenTK.Vector3 *planeNormalPtr = &planeNormal)
     {
         fixed(OpenTK.Vector3 *planeSupportPtr = &planeSupport)
         {
             obj.GetPlane(out *(BulletSharp.Math.Vector3 *)planeNormalPtr, out *(BulletSharp.Math.Vector3 *)planeSupportPtr, i);
         }
     }
 }
Ejemplo n.º 5
0
        private static UnityEngine.Vector3[] CreatePolyhedralConvexShape(PolyhedralConvexShape polyhedralConvexShape, out int[] indices)
        {
            int numVertices = polyhedralConvexShape.NumVertices;
            UnityEngine.Vector3[] vertices = new UnityEngine.Vector3[numVertices * 3];
            for (int i = 0; i < numVertices; i += 4)
            {
                Vector3 v0, v1, v2, v3;
                polyhedralConvexShape.GetVertex(i, out v0);
                polyhedralConvexShape.GetVertex(i + 1, out v1);
                polyhedralConvexShape.GetVertex(i + 2, out v2);
                polyhedralConvexShape.GetVertex(i + 3, out v3);

                UnityEngine.Vector3 v01 = (v0 - v1).ToUnity();
                UnityEngine.Vector3 v02 = (v0 - v2).ToUnity();
                UnityEngine.Vector3 normal = UnityEngine.Vector3.Cross(v01, v02);

                int i3 = i * 3;
                vertices[i3] = v0.ToUnity();
                vertices[i3 + 1] = normal;
                vertices[i3 + 2] = v1.ToUnity();
                vertices[i3 + 3] = normal;
                vertices[i3 + 4] = v2.ToUnity();
                vertices[i3 + 5] = normal;
                vertices[i3 + 6] = v0.ToUnity();
                vertices[i3 + 7] = normal;
                vertices[i3 + 8] = v2.ToUnity();
                vertices[i3 + 9] = normal;
                vertices[i3 + 10] = v3.ToUnity();
            }
            indices = null;
            return vertices;
        }
Ejemplo n.º 6
0
        private static Vector3[] CreatePolyhedralConvexShape(PolyhedralConvexShape polyhedralConvexShape, out uint[] indices)
        {
            int numVertices = polyhedralConvexShape.NumVertices;
            Vector3[] vertices = new Vector3[numVertices * 3];
            for (int i = 0; i < numVertices; i += 4)
            {
                Vector3 v0, v1, v2, v3;
                polyhedralConvexShape.GetVertex(i, out v0);
                polyhedralConvexShape.GetVertex(i + 1, out v1);
                polyhedralConvexShape.GetVertex(i + 2, out v2);
                polyhedralConvexShape.GetVertex(i + 3, out v3);

                Vector3 v01 = v0 - v1;
                Vector3 v02 = v0 - v2;
                Vector3 normal = Vector3.Cross(v01, v02);

                int i3 = i * 3;
                vertices[i3] = v0;
                vertices[i3 + 1] = normal;
                vertices[i3 + 2] = v1;
                vertices[i3 + 3] = normal;
                vertices[i3 + 4] = v2;
                vertices[i3 + 5] = normal;
                vertices[i3 + 6] = v0;
                vertices[i3 + 7] = normal;
                vertices[i3 + 8] = v2;
                vertices[i3 + 9] = normal;
                vertices[i3 + 10] = v3;
            }
            indices = null;
            return vertices;
        }