コード例 #1
0
        public void Result(Vector3[] hullVertices, int[] hullIndices)
        {
            _wavefrontWriter.OutputObject(hullVertices, hullIndices);

            // Calculate centroid, to shift vertices around center of mass
            Vector3 centroid = CalculateCentroid(hullVertices);

            ConvexCentroids.Add(centroid);

            List <Vector3> outVertices = hullVertices.Select(v => v * LocalScaling - centroid).ToList();

            // This is a tools issue:
            // due to collision margin, convex objects overlap, compensate for it here.
#if false
            outVertices = ShrinkObjectInwards(hullVertices);
#endif

            var convexShape = new ConvexHullShape(outVertices);
            convexShape.Margin = 0.01f;
            ConvexShapes.Add(convexShape);
        }