I am trying to create a cube chunk generation system and this keeps giving me errors
using System;
using System.Collections.Generic;
using System.Text;
public class PerlinNoise
{
static Random random = new Random();
// Tools
public static T[ ][ ] GetEmptyArray(int width, int height)
{
T[ ][ ] image = new T[width][ ];
for (int i = 0; i < width; i++)
{
image = new T[height];
}
return image;
}
public static float Interpolate(float x0, float x1, float alpha)
{
return x0 * (1 - alpha) + alpha * x1;
}
// Perlin Noise Generation
public static float[ ][ ] GenerateWhiteNoise(int width, int height)
{
float[ ][ ] noise = GetEmptyArray(width, height);
for (int i = 0; i < width; i++)
{
for (int j = 0; j < height; j++)
{
noise*[j] = (float)random.NextDouble() % 1;*
}
}
return noise;
}
public static float[ ][ ] GenerateSmoothNoise(float[ ][ ] baseNoise, int octave)
{
int width = baseNoise.Length;
int height = baseNoise[0].Length;
float[ ][ ] smoothNoise = GetEmptyArray(width, height);
int samplePeriod = 1 << octave; // calculates 2 ^ k
float sampleFrequency = 1.0f / samplePeriod;
for (int i = 0; i < width; i++)
{
//calculate the horizontal sampling indices
int sample_i0 = (i / samplePeriod) * samplePeriod;
int sample_i1 = (sample_i0 + samplePeriod) % width; //wrap around
float horizontal_blend = (i - sample_i0) * sampleFrequency;
for (int j = 0; j < height; j++)
{
//calculate the vertical sampling indices
int sample_j0 = (j / samplePeriod) * samplePeriod;
int sample_j1 = (sample_j0 + samplePeriod) % height; //wrap around
float vertical_blend = (j - sample_j0) * sampleFrequency;
//blend the top two corners
float top = Interpolate(baseNoise[sample_i0][sample_j0],
baseNoise[sample_i1][sample_j0], horizontal_blend);
//blend the bottom two corners
float bottom = Interpolate(baseNoise[sample_i0][sample_j1],
baseNoise[sample_i1][sample_j1], horizontal_blend);
//final blend
smoothNoise*[j] = Interpolate(top, bottom, vertical_blend);
_}
}*_
return smoothNoise;
}
public static float[ ][ ] GeneratePerlinNoise(float[ ][ ] baseNoise, int octaveCount)
{
int width = baseNoise.Length;
int height = baseNoise[0].Length;
float[ ][ ][ ] smoothNoise = new float[octaveCount][ ][ ]; //an array of 2D arrays containing
float persistance = 0.45f;
//generate smooth noise
for (int i = 0; i < octaveCount; i++) { smoothNoise = GenerateSmoothNoise(baseNoise, i); } float[ ][ ] perlinNoise = GetEmptyArray(width, height); //an array of floats initialised to 0 float amplitude = 1.00f; float totalAmplitude = 0.0f; //blend noise together for (int octave = octaveCount - 1; octave >= 0; octave–)
{
amplitude *= persistance;
totalAmplitude += amplitude;
for (int i = 0; i < width; i++)
{
for (int j = 0; j < height; j++)
{
perlinNoise[j] += smoothNoise[octave][j] * amplitude;;
}
}
}
return perlinNoise;
}
public static float[ ][ ] GeneratePerlinNoise(int width, int height, int octaveCount)
{
float[ ][ ] baseNoise = GenerateWhiteNoise(width, height);
return GeneratePerlinNoise(baseNoise, octaveCount);
}
}