Esempio n. 1
0
 public virtual void GenerateGroup(ChunkGroup cGroup)
 {
     foreach (Chunk c in cGroup.ChunkDict.Values)
     {
         GenerateChunk(cGroup, c);
     }
 }
Esempio n. 2
0
        public override void GenerateChunk(ChunkGroup cGroup, Chunk c)
        {
            for (int i = 0; i < m_Slices; i++)
            {
                float theta = i / (float)m_Slices * 360f * Mathf.Deg2Rad;

                for (int j = 0; j < m_Stacks; j++)
                {
                    float phi = j / (float)m_Stacks * 360f * Mathf.Deg2Rad;

                    GenerateChunkUV(cGroup, theta, phi);
                }
            }
        }
//        public override void GenerateGroup(ChunkGroup cGroup)
//        {
//            base.GenerateGroup(cGroup);
//        }

//        public override void GenerateChunk(ChunkGroup cGroup, Chunk c)
//        {
//            int gridSize = cGroup.ChunkSize;
//
//            for (int x = 0; x < gridSize; x++)
//            {
//                for (int y = 0; y < gridSize; y++)
//                {
//                    for (int z = 0; z < gridSize; z++)
//                    {
//                        Vector3Int worldCoord = c.ConvertChunkToWorldCoord(x, y, z);
//
//                        // will fill the sphere
//                        if (worldCoord.magnitude <= m_Radius)
//                            c.SetPieceRollover(x, y, z, ChunkPiece.TypeList.Values.Shuffle().FirstOrDefault()());
//                    }
//                }
//            }
//        }

        protected override void GenerateChunkUV(ChunkGroup cGroup, float u, float v)
        {
            /*
             * Currently this will only create the shell of the shape
             */

            float x = Mathf.Cos(u) * Mathf.Sin(v);
            float y = Mathf.Sin(u) * Mathf.Sin(v);
            float z = Mathf.Cos(v);

            float stepSize = cGroup.ChunkScale;// / m_Radius;

            for (float step = m_Radius; step >= 0; step -= stepSize)
            {
                float xStep = x * step;
                float yStep = y * step;
                float zStep = z * step;

                Vector3Int[] pair =
                    cGroup.ConvertWorldCoordToGroupAndChunk(
                        Mathf.RoundToInt(xStep),
                        Mathf.RoundToInt(yStep),
                        Mathf.RoundToInt(zStep)
                        );

                Chunk ch = null;

                try
                {
                    ch = cGroup [pair [0]];
                }
                catch (NoChunkException nce)
                {
                    ch = cGroup.TrySpawnChunk(pair [0]);
                }

                ch.SetPieceRollover(pair [1], ChunkPiece.TypeList.Values.Shuffle().FirstOrDefault()());

                if (ShellOnly)
                {
                    break;
                }
            }
        }
//        public override void GenerateGroup(ChunkGroup cGroup)
//        {
//            base.GenerateGroup(cGroup);
//        }

        protected override void GenerateChunkUV(ChunkGroup cGroup, float u, float v)
        {
            float stepSize = cGroup.ChunkScale;// / m_Radius;

            for (float step = m_InnerRadius; step >= 0; step -= stepSize)
            {
                float x = (m_TorusRadius + step * Mathf.Cos(v)) * Mathf.Cos(u);
                float y = (m_TorusRadius + step * Mathf.Cos(v)) * Mathf.Sin(u);
                float z = step * Mathf.Sin(v);

                Vector3Int[] pair =
                    cGroup.ConvertWorldCoordToGroupAndChunk(
                        Mathf.RoundToInt(x),
                        Mathf.RoundToInt(y),
                        Mathf.RoundToInt(z)
                        );

                Chunk ch = null;

                try
                {
                    ch = cGroup [pair [0]];
                }
                catch (NoChunkException nce)
                {
                    ch = cGroup.TrySpawnChunk(pair [0]);
                }

                ch.SetPieceRollover(pair [1], ChunkPiece.TypeList.Values.Shuffle().FirstOrDefault()());

                if (ShellOnly)
                {
                    break;
                }
            }
        }
 public override void GenerateGroup(ChunkGroup cGroup)
 {
     base.GenerateGroup(cGroup);
 }
 public override void GenerateChunk(ChunkGroup cGroup, Chunk c)
 {
     throw new System.NotImplementedException();
 }
Esempio n. 7
0
 public abstract void GenerateChunk(ChunkGroup cGroup, Chunk c);
Esempio n. 8
0
 protected abstract void GenerateChunkUV(ChunkGroup cGroup, float u, float v);