Exemplo n.º 1
0
        private void SetupParticles()
        {
            particleSystem.Clear(true);
            particleSystem.gravityModifier = 0;

            Vector3 offset = voxelData.pivot;

            if (center)
            {
                offset.x = (float)voxelData.width / 2f;
                offset.y = (float)voxelData.height / 2f;
                offset.z = (float)voxelData.depth / 2f;
            }

            List <ParticleSystem.Particle> voxs = new List <ParticleSystem.Particle>();

            for (int x = 0; x < voxelData.width; x++)
            {
                for (int y = 0; y < voxelData.height; y++)
                {
                    for (int z = 0; z < voxelData.depth; z++)
                    {
                        if (voxelData.FilledVoxel(x, y, z))
                        {
                            if (removeHidden && !voxelData.IsVisible(x, y, z))
                            {
                                continue;
                            }

                            Vector3 pos = new Vector3(x, y, z);
                            pos -= offset - new Vector3(.5f, .5f, .5f);
                            pos *= scale;
                            //pos += this.transform.root.position;

                            ParticleSystem.Particle p = new ParticleSystem.Particle
                            {
                                startLifetime     = float.PositiveInfinity,
                                remainingLifetime = float.PositiveInfinity,

                                startSize  = scale,
                                startColor = voxelData.VoxelColor(x, y, z),

                                position = pos,
                                velocity = Vector3.zero
                            };

                            voxs.Add(p);
                        }
                    }
                }
            }

            voxelParticles = voxs.ToArray();
            UpdateVoxels();
        }
Exemplo n.º 2
0
 private void MakeMap(int ox, int oy, int oz)
 {
     for (int x = 0; x < w; x++)
     {
         for (int y = 0; y < h; y++)
         {
             for (int z = 0; z < d; z++)
             {
                 if (!data.FilledVoxel(x + ox, y + oy, z + oz))
                 {
                     map[x, y, z] = data.IsVisible(x, y, z);
                 }
             }
         }
     }
 }