public PerlinNoise3D(float scale, bool randomize, ProtoVector2[] noise3dRandomValues)
        {
            this.scale = scale;
            for (int i = 0; i < GradientSizeTable; i++)
            {
                float z, r, theta;

                if (randomize)
                {
                    randVals[i] = new ProtoVector2(Utils.Random.value, Utils.Random.value);
                }
                else
                {
                    randVals[i] = noise3dRandomValues[i];
                }

                z     = 1f - 2f * randVals[i].x;
                r     = Mathf.Sqrt(1 - z * z);
                theta = 2 * Mathf.PI * randVals[i].y;

                gradients[i * 3]     = r * Mathf.Cos(theta);
                gradients[i * 3 + 1] = r * Mathf.Sin(theta);
                gradients[i * 3 + 2] = z;
            }
        }
Beispiel #2
0
        public static ProtoVector2 ToProtoVector2(TSVector source)
        {
            ProtoVector2 result = new ProtoVector2();

            result.x = source.x.ToSourceLong();
            result.y = source.z.ToSourceLong();
            return(result);
        }
Beispiel #3
0
        public static TSVector ToTSVector(ProtoVector2 source)
        {
            TSVector result = new TSVector();

            result.x = FP.FromSourceLong(source.x);
            result.y = 0;
            result.z = FP.FromSourceLong(source.y);
            return(result);
        }
Beispiel #4
0
 public PerlinNoise2D(float scale, bool randomize, ProtoVector2 randomValues)
 {
     this.scale = scale;
     if (randomize)
     {
         offset = new ProtoVector2(Utils.Random.Range(-100f, 100f), Utils.Random.Range(-100f, 100f));
     }
     else
     {
         offset = randomValues;
     }
 }