Beispiel #1
0
    void Start()
    {
        m_softbody = GetComponent <Softbody>();
        //m_particles = m_softbody.GetParticles();

        m_particleMeshes = new GameObject[m_particles.Length];

        for (int i = 0; i < m_particleMeshes.Length; i++)
        {
            m_particleMeshes[i] = Instantiate(ParticleMesh, new Vector3(m_particles[i].x.x, m_particles[i].x.y, 0), Quaternion.identity) as GameObject;
        }
    }
Beispiel #2
0
    void Update()
    {
        float invStiffness = 1 / (Stiffness * Stiffness);

        Softbody.SoftBodyUpdate(m_particles, m_constraints, Iterations, invStiffness);

        Vector3[] vertices = m_mesh.vertices;
        for (int i = 0; i < vertices.Length; i++)
        {
            vertices[i] = m_meshFilter.transform.InverseTransformPoint(m_particles[i].x);
        }
        m_mesh.vertices = vertices;
    }
Beispiel #3
0
    void Update()
    {
        m_particles[0].x = transform.position;

        float stiffness = 1f / (InvStiffness * InvStiffness);

        Softbody.SoftBodyUpdate(m_particles, m_constraints, Iteration, stiffness);

        for (int i = 0; i < numSegments - 1; i++)
        {
            float c = 1f;//i / (float)numSegments;
            Debug.DrawLine(m_particles[i].x, m_particles[i + 1].x, new Color(c, c, c));
        }
    }