Exemplo n.º 1
0
    private void Update()
    {
        if (m_noise == null)
        {
            m_noise = new PerlinScript();
        }

        float timex = Time.time * Speed * 0.1365143f;
        float timey = Time.time * Speed * 1.21688f;
        float timez = Time.time * Speed * 2.5564f;

        for (int i = 0; i < m_particles.Length; i++)
        {
            Vector3 position = Vector3.Lerp(transform.position, Target.position, m_oneOverZigs * (float)i);
            Vector3 offset = new Vector3(m_noise.Noise(timex + position.x, timex + position.y, timex + position.z),
                                        m_noise.Noise(timey + position.x, timey + position.y, timey + position.z),
                                        m_noise.Noise(timez + position.x, timez + position.y, timez + position.z));

            position += (offset * Scale * ((float)i * m_oneOverZigs));

            m_particles[i].position = position;
            m_particles[i].color = Color.white;
            m_particles[i].energy = 1f;
        }

        particleEmitter.particles = m_particles;

        // Reposiciona as luzes conforme as partículas correspondentes.
        for (int i = 0; i < m_lightsNumber; i++)
        {
            m_lights[i].transform.position = m_particles[i * m_lightsEveryParticles].position;
        }
    }
Exemplo n.º 2
0
    private void Update()
    {
        if (m_noise == null)
        {
            m_noise = new PerlinScript();
        }

        float timex = Time.time * Speed * 0.1365143f;
        float timey = Time.time * Speed * 1.21688f;
        float timez = Time.time * Speed * 2.5564f;

        for (int i = 0; i < m_particles.Length; i++)
        {
            Vector3 position = Vector3.Lerp(transform.position, Target.position, m_oneOverZigs * (float)i);
            Vector3 offset   = new Vector3(m_noise.Noise(timex + position.x, timex + position.y, timex + position.z),
                                           m_noise.Noise(timey + position.x, timey + position.y, timey + position.z),
                                           m_noise.Noise(timez + position.x, timez + position.y, timez + position.z));

            position += (offset * Scale * ((float)i * m_oneOverZigs));

            m_particles[i].position = position;
            m_particles[i].color    = Color.white;
            m_particles[i].energy   = 1f;
        }

        particleEmitter.particles = m_particles;

        // Reposiciona as luzes conforme as partículas correspondentes.
        for (int i = 0; i < m_lightsNumber; i++)
        {
            m_lights[i].transform.position = m_particles[i * m_lightsEveryParticles].position;
        }
    }
Exemplo n.º 3
0
    public FractalNoise(float inH, float inLacunarity, float inOctaves, PerlinScript noise)
    {
        m_Lacunarity = inLacunarity;
        m_Octaves    = inOctaves;
        m_IntOctaves = (int)inOctaves;
        m_Exponent   = new float[m_IntOctaves + 1];
        float frequency = 1.0F;

        for (int i = 0; i < m_IntOctaves + 1; i++)
        {
            m_Exponent[i] = (float)Math.Pow(m_Lacunarity, -inH);
            frequency    *= m_Lacunarity;
        }

        if (noise == null)
        {
            m_Noise = new PerlinScript();
        }
        else
        {
            m_Noise = noise;
        }
    }