예제 #1
0
        void IntegrateVertex(VertexTransform v)
        {
            if (v.position < size.y / 2 + lowerLimit * waveHeight && v.velocity < 0)
            {
                v.acceleration = Random.Range(1 - randomness, 1 + randomness);
            }
            else if (v.position > size.y / 2 + upperLimit * waveHeight && v.velocity > 0)
            {
                v.acceleration = -Random.Range(1 - randomness, 1 + randomness);
            }

            if ((v.acceleration < 0 && v.velocity > -speedMultiplier) || (v.acceleration > 0 && v.velocity < speedMultiplier))
            {
                v.velocity += v.acceleration * Time.deltaTime * accelerationMultiplier;
            }



            v.position += v.velocity * Time.deltaTime * speedMultiplier;
        }
예제 #2
0
        void Update()
        {
            for (int i = 0; i < vertexCount; i++)
            {
                v1 = vertexTransforms[i];

                IntegrateVertex(v1);

                vertices[i * softFacesPerSegment * 2].y = v1.position;
            }

            for (int i = 0; i < softVertexCount; i++)
            {
                if (i % softFacesPerSegment == 0)
                {
                }
                else
                {
                    vertices[i * 2].y = GetCurvedValue(vertexTransforms[i / softFacesPerSegment].position, vertexTransforms[i / softFacesPerSegment + 1].position, (i % softFacesPerSegment) / (float)softFacesPerSegment);
                }
            }

            mesh.vertices = vertices;
        }