Пример #1
0
    void Awake()
    {
        createPatchMesh();

        bodyMeshTriangles   = bodyMeshFilter.sharedMesh.triangles;
        bodyMeshVertices    = bodyMeshFilter.sharedMesh.vertices;
        bodyVertexDistances = new float[bodyMeshVertices.Length];
        // Calculate each of the body triangle's area for the slamming force
        slammingForceData = new List <SlammingForceData>();
        for (int i = 0; i < bodyMeshTriangles.Length / 3; i++)
        {
            Vector3 p1   = bodyMeshVertices[bodyMeshTriangles[i * 3]];
            Vector3 p2   = bodyMeshVertices[bodyMeshTriangles[i * 3 + 1]];
            Vector3 p3   = bodyMeshVertices[bodyMeshTriangles[i * 3 + 2]];
            float   area = TriangleData.GetTriangleArea(p1, p2, p3);
            slammingForceData.Add(new SlammingForceData(area));
            bodySurfaceArea += area;
        }
    }