Exemplo n.º 1
0
    IEnumerator Start()
    {
        while (!softVolume.Ready())
        {
            yield return(null);
        }

        Vector3[] vertices = softVolume.GetWireFrameVertices();
        Partix.VehiclePointLoad[] loads = softVolume.GetPointLoads();

        // boundingbox
        BoundingBox bb = new BoundingBox(vertices);

        for (int i = 0; i < vertices.Length; i++)
        {
            Vector3 v  = vertices[i];
            Vector3 np = bb.CalculateNormalizedPosition(v);
            loads[i].friction   = 0.2f;
            loads[i].fix_target = np.y < 0.1f ? 1 : 0;
            // loads[i].fix_target = 0;
        }
        softVolume.SetPointLoads(loads);

        Partix.EntityFeatures ef = new Partix.EntityFeatures();
        ef.stretch_factor = 0.1f;
        ef.restore_factor = 0.8f;
        ef.alive          = 1;
        ef.positive       = 1;
        ef.influential    = 1;
        ef.auto_freezing  = 1;
        ef.frozen         = 1;
        // ef.auto_freezing = 0;
        // ef.frozen = 0;
        softVolume.SetFeatures(ef);
    }
Exemplo n.º 2
0
    IEnumerator Start()
    {
        while (!sv.Ready())
        {
            yield return(null);
        }

        Vector3[] vertices = sv.GetWireFrameVertices();
        Partix.VehiclePointLoad[] loads = sv.GetPointLoads();

        // boundingbox
        BoundingBox bb = new BoundingBox(vertices);

        // weight設定
        for (int i = 0; i < vertices.Length; i++)
        {
            Vector3 np = bb.CalculateNormalizedPosition(vertices[i]);

            float w = 1.0f;
            float z = 1.0f - np.z;
            float y = 1.0f - np.y;
            w += z * z * y * 6.0f;
            loads[i].weight     = w * 0.2f;
            loads[i].friction   = w * 0.2f;
            loads[i].fix_target = 0;
        }
        sv.SetPointLoads(loads);
    }
Exemplo n.º 3
0
    public static void Fix(
        Partix.SoftVolume sv, float friction, float threshold)
    {
        Vector3[] vertices = sv.GetWireFrameVertices();
        Partix.VehiclePointLoad[] loads = sv.GetPointLoads();

        // boundingbox
        var bb = new BoundingBox(vertices);

        for (int i = 0; i < vertices.Length; i++)
        {
            Vector3 v  = vertices[i];
            Vector3 np = bb.CalculateNormalizedPosition(v);
            loads[i].friction   = 0.2f;
            loads[i].fix_target = np.y < threshold ? 1 : 0;
            // loads[i].fix_target = 0;
        }
        sv.SetPointLoads(loads);
    }