示例#1
0
    void RandomToFillCircle(float Raduis, Vector3 Position)
    {
        float ParticleArea = SnowConstants.PARTICLE_DIAM * SnowConstants.PARTICLE_DIAM;
        float ParticleMass = SnowConstants.DENSITY * ParticleArea * 0.03f;

        float CricleArea       = Mathf.PI * Raduis * Raduis / 100000;
        uint  NumberOfParticle = (uint)(CricleArea / ParticleArea);

        int Count = 0;

        Vector3[] CriclePos =
        { Position, new Vector3(80, 50, 0), new Vector3(0, 0, 0) };


        Vector3[] CricleSpeed =
        { new Vector3(200, -150, 0), new Vector3(0, 0, 0), new Vector3(0, 0, 0) };

        for (uint i = 0; i < this.particle_input_data_.Length; ++i)
        {
            if (i < NumberOfParticle * (Count + 1))
            {
                MaterialPointParticleData it = this.particle_input_data_[i];
                Vector3 rand = new Vector3(UnityEngine.Random.Range(-Raduis, Raduis), UnityEngine.Random.Range(-Raduis, Raduis), 0);
                //rand = UnityEngine.Random.insideUnitSphere * Raduis;
                while (Vector3.Dot(rand, rand) > Raduis * Raduis)
                {
                    rand = new Vector3(UnityEngine.Random.Range(-Raduis, Raduis), UnityEngine.Random.Range(-Raduis, Raduis), 0);
                }
                it.position_ = new Vector3(rand.x + CriclePos[Count].x, rand.y + CriclePos[Count].y, rand.z + CriclePos[Count].z);
                it.velocity_ = new Vector3(CricleSpeed[Count].x, CricleSpeed[Count].y, CricleSpeed[Count].z);

                it.mass_ = ParticleMass;
                this.particle_input_data_[i] = it;
            }
            else
            {
                Count++;
            }
        }
    }
示例#2
0
    void RandomToFillOneCircle(float Raduis, Vector3 Position)
    {
        float ParticleArea = SnowConstants.PARTICLE_DIAM * SnowConstants.PARTICLE_DIAM;
        float ParticleMass = SnowConstants.DENSITY * ParticleArea * 0.03f;

        float CricleArea       = Mathf.PI * Raduis * Raduis / 100000;
        uint  NumberOfParticle = (uint)(CricleArea / ParticleArea);

        for (uint i = 0; i < this.particle_input_data_.Length; ++i)
        {
            MaterialPointParticleData it = this.particle_input_data_[i];
            Vector3 rand = new Vector3(UnityEngine.Random.Range(-Raduis, Raduis), UnityEngine.Random.Range(-Raduis, Raduis), 0);
            while (Vector3.Dot(rand, rand) > Raduis * Raduis)
            {
                rand = new Vector3(UnityEngine.Random.Range(-Raduis, Raduis), UnityEngine.Random.Range(-Raduis, Raduis), 0);
            }

            rand         = UnityEngine.Random.insideUnitSphere * Raduis;
            it.position_ = rand + Position;
            it.mass_     = ParticleMass;

            this.particle_input_data_[i] = it;
        }
    }