Esempio n. 1
0
        static public void ApplyNoiseToSphere(SurfaceMap sphereLayer, Vector3Int center)
        {
            foreach (int contourPoint in sphereLayer.contour3D)
            {
                Vector3Int contourStartPoint = new Vector3Int(contourPoint % sphereLayer.resolution,
                                                              (contourPoint / sphereLayer.resolution) % sphereLayer.resolution,
                                                              contourPoint / sphereLayer.resolution2);
                Vector3 direction = contourStartPoint - center;
                direction = direction.normalized;

                Vector3    contourEndPointF = (contourStartPoint + direction * NoiseSettings.noiseMethod(contourStartPoint, NoiseSettings.frequency) * NoiseSettings.gain);
                Vector3Int contourEndPoint  = new Vector3Int(Mathf.RoundToInt(contourEndPointF.x),
                                                             Mathf.RoundToInt(contourEndPointF.y),
                                                             Mathf.RoundToInt(contourEndPointF.z));

                Cylinder(sphereLayer, contourStartPoint, contourEndPoint, 1,
                         sphereLayer.ReadMaterial(contourStartPoint.x, contourStartPoint.y, contourStartPoint.z));
            }
            Vector3Int point = new Vector3Int(sphereLayer.contour3D[0] % sphereLayer.resolution,
                                              (sphereLayer.contour3D[0] / sphereLayer.resolution) % sphereLayer.resolution,
                                              sphereLayer.contour3D[0] / sphereLayer.resolution2);

            Sphere(sphereLayer, center,
                   (int)((point - center).magnitude),
                   (int)((point - center).magnitude + 1),
                   /*sphereLayer.ReadMaterial(point.x, point.y, point.z)*/ 1,
                   false);
        }
Esempio n. 2
0
    public void InstantiateCubes()
    {
        GameObject obj = GameObject.CreatePrimitive(PrimitiveType.Cube);

        obj.transform.parent = transform;

        for (int z = 0; z < resolution; z++)
        {
            for (int y = 0; y < resolution; y++)
            {
                for (int x = 0; x < resolution; x++)
                {
                    int material = surfaceMap.ReadMaterial(x, y, z);
                    switch (material)
                    {
                    case 1:
                        obj.GetComponent <MeshRenderer>().material.color = Color.green * 0.65f;
                        Instantiate(obj, new Vector3(x, y, z), new Quaternion(), transform);
                        break;

                    case 2:
                        obj.GetComponent <MeshRenderer>().material.color = new Color(98.0f / 256.0f, 46.0f / 256.0f, 3.0f / 256.0f);
                        Instantiate(obj, new Vector3(x, y, z), new Quaternion(), transform);
                        break;

                    case 3:
                        obj.GetComponent <MeshRenderer>().material.color = Color.grey * 0.80f;
                        Instantiate(obj, new Vector3(x, y, z), new Quaternion(), transform);
                        break;
                    }
                }
            }
        }
    }