本文整理汇总了C#中ITerrainChannel类的典型用法代码示例。如果您正苦于以下问题:C# ITerrainChannel类的具体用法?C# ITerrainChannel怎么用?C# ITerrainChannel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ITerrainChannel类属于命名空间,在下文中一共展示了ITerrainChannel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FloodEffect
public void FloodEffect (ITerrainChannel map, UUID userID, float north,
float west, float south, float east, float strength)
{
float sum = 0;
float steps = 0;
int x, y;
for (x = (int)west; x < (int)east; x++) {
for (y = (int)south; y < (int)north; y++) {
if (!map.Scene.Permissions.CanTerraformLand (userID, new Vector3 (x, y, 0)))
continue;
sum += map [x, y];
steps += 1;
}
}
float avg = sum / steps;
float str = 0.1f * strength; // == 0.2 in the default client
for (x = (int)west; x < (int)east; x++) {
for (y = (int)south; y < (int)north; y++) {
if (!map.Scene.Permissions.CanTerraformLand (userID, new Vector3 (x, y, 0)))
continue;
map [x, y] = (map [x, y] * (1 - str)) + (avg * str);
}
}
}
示例2: FloodEffect
public void FloodEffect(ITerrainChannel map, bool[,] fillArea, double strength,
int startX, int endX, int startY, int endY)
{
double sum = 0.0;
double steps = 0.0;
int x, y;
for (x = startX; x <= endX; x++)
{
for (y = startY; y <= endY; y++)
{
if (fillArea[x, y])
{
sum += map[x, y];
steps += 1.0;
}
}
}
double avg = sum / steps;
double str = 0.1 * strength; // == 0.2 in the default client
for (x = startX; x <= endX; x++)
{
for (y = startY; y <= endY; y++)
{
if (fillArea[x, y])
map[x, y] = (map[x, y] * (1.0 - str)) + (avg * str);
}
}
}
示例3: GetBilinearInterpolate
public static double GetBilinearInterpolate(double x, double y, ITerrainChannel map)
{
int w = map.Width;
int h = map.Height;
if (x > w - 2.0)
x = w - 2.0;
if (y > h - 2.0)
y = h - 2.0;
if (x < 0.0)
x = 0.0;
if (y < 0.0)
y = 0.0;
const int stepSize = 1;
double h00 = map[(int) x, (int) y];
double h10 = map[(int) x + stepSize, (int) y];
double h01 = map[(int) x, (int) y + stepSize];
double h11 = map[(int) x + stepSize, (int) y + stepSize];
double h1 = h00;
double h2 = h10;
double h3 = h01;
double h4 = h11;
double a00 = h1;
double a10 = h2 - h1;
double a01 = h3 - h1;
double a11 = h1 - h2 - h3 + h4;
double partialx = x - (int) x;
double partialz = y - (int) y;
double hi = a00 + (a10 * partialx) + (a01 * partialz) + (a11 * partialx * partialz);
return hi;
}
示例4: FloodEffect
public void FloodEffect(ITerrainChannel map, bool[,] fillArea, double strength)
{
double sum = 0.0;
double steps = 0.0;
int x, y;
for (x = 0; x < map.Width; x++)
{
for (y = 0; y < map.Height; y++)
{
if (fillArea[x, y])
{
sum += map[x, y];
steps += 1.0;
}
}
}
double avg = sum / steps;
double str = 0.1 * strength; // == 0.2 in the default client
for (x = 0; x < map.Width; x++)
{
for (y = 0; y < map.Height; y++)
{
if (fillArea[x, y])
map[x, y] = (map[x, y] * (1.0 - str)) + (avg * str);
}
}
}
示例5: Compare
public bool Compare(ITerrainChannel terrainChannel)
{
if (m_terrainChannel != terrainChannel)
return false;
else
return false;
}
示例6: FloodEffect
public void FloodEffect(ITerrainChannel map, UUID userID, float north,
float west, float south, float east, float strength)
{
float area = strength;
float step = strength/4;
for (int x = (int) west; x < (int) east; x++)
{
for (int y = (int) south; y < (int) north; y++)
{
if (!map.Scene.Permissions.CanTerraformLand(userID, new Vector3(x, y, 0)))
continue;
float average = 0;
int avgsteps = 0;
float n;
for (n = 0 - area; n < area; n += step)
{
float l;
for (l = 0 - area; l < area; l += step)
{
avgsteps++;
average += TerrainUtil.GetBilinearInterpolate(x + n, y + l, map);
}
}
map[x, y] = average/avgsteps;
}
}
}
示例7: PaintEffect
public void PaintEffect(ITerrainChannel map, bool[,] mask, double rx, double ry, double rz,
double strength, double duration, int startX, int endX, int startY, int endY)
{
strength = TerrainUtil.MetersToSphericalStrength(strength);
int x, y;
for (x = startX; x <= endX; x++)
{
for (y = startY; y <= endY; y++)
{
if (!mask[x, y])
continue;
// Calculate a sphere and add it to the heighmap
double z = strength;
z *= z;
z -= ((x - rx) * (x - rx)) + ((y - ry) * (y - ry));
double noise = TerrainUtil.PerlinNoise2D(x / (double) map.Width, y / (double) map.Height, 8, 1.0);
if (z > 0.0)
map[x, y] += noise * z * duration;
}
}
}
示例8: SaveFile
public virtual void SaveFile(ITerrainChannel m_channel, string filename,
int offsetX, int offsetY,
int fileWidth, int fileHeight,
int regionSizeX, int regionSizeY)
{
throw new System.Exception("Not Implemented");
}
示例9: CreateBitmapFromMap
private static Bitmap CreateBitmapFromMap(ITerrainChannel map)
{
Bitmap gradientmapLd = new Bitmap("defaultstripe.png");
int pallete = gradientmapLd.Height;
Bitmap bmp = new Bitmap(map.Width, map.Height);
Color[] colours = new Color[pallete];
for (int i = 0; i < pallete; i++)
{
colours[i] = gradientmapLd.GetPixel(0, i);
}
for (int y = 0; y < map.Height; y++)
{
for (int x = 0; x < map.Width; x++)
{
// 512 is the largest possible height before colours clamp
int colorindex = (int) (Math.Max(Math.Min(1.0, map[x, y] / 512.0), 0.0) * (pallete - 1));
bmp.SetPixel(x, map.Height - y - 1, colours[colorindex]);
}
}
return bmp;
}
示例10: ModifyTerrain
public override string ModifyTerrain(ITerrainChannel map, string[] args)
{
string result;
if (args.Length < 3)
{
result = "Usage: " + GetUsage();
}
else
{
TerrainModifierData data;
result = this.parseParameters(args, out data);
// Context-specific validation
if (result == String.Empty)
{
if (data.shape == String.Empty)
{
data.shape = "rectangle";
data.x0 = 0;
data.y0 = 0;
data.dx = map.Width;
data.dy = map.Height;
}
}
// if it's all good, then do the work
if (result == String.Empty)
{
this.applyModification(map, data);
}
}
return result;
}
示例11: PaintEffect
public void PaintEffect(ITerrainChannel map, bool[,] mask, double rx, double ry, double rz,
double strength, double duration, int startX, int endX, int startY, int endY)
{
int s = (int) (Math.Pow(2, strength) + 0.5);
int x, y;
for (x = startX; x <= endX; x++)
{
for (y = startY; y <= endY; y++)
{
if (!mask[x, y])
continue;
// Calculate a cos-sphere and add it to the heighmap
double r = Math.Sqrt((x-rx) * (x-rx) + ((y-ry) * (y-ry)));
double z = Math.Cos(r * Math.PI / (s * 2));
if (z > 0.0)
{
double newz = map[x, y] - z * duration;
if (newz < 0.0)
map[x, y] = 0.0;
else
map[x, y] = newz;
}
}
}
}
示例12: PaintEffect
public void PaintEffect(ITerrainChannel map, bool[,] mask, double rx, double ry, double rz, double strength, double duration)
{
strength = TerrainUtil.MetersToSphericalStrength(strength);
int x;
for (x = 0; x < map.Width; x++)
{
int y;
for (y = 0; y < map.Height; y++)
{
if (!mask[x,y])
continue;
// Calculate a sphere and add it to the heighmap
double z = strength;
z *= z;
z -= ((x - rx) * (x - rx)) + ((y - ry) * (y - ry));
double noise = TerrainUtil.PerlinNoise2D(x / (double) Constants.RegionSize, y / (double) Constants.RegionSize, 8, 1.0);
if (z > 0.0)
map[x, y] += noise * z * duration;
}
}
}
示例13: FloodEffect
public void FloodEffect(ITerrainChannel map, bool[,] fillArea, double strength)
{
double area = strength;
double step = strength / 4.0;
int x, y;
for (x = 0; x < map.Width; x++)
{
for (y = 0; y < map.Height; y++)
{
if (!fillArea[x, y])
continue;
double average = 0.0;
int avgsteps = 0;
double n;
for (n = 0.0 - area; n < area; n += step)
{
double l;
for (l = 0.0 - area; l < area; l += step)
{
avgsteps++;
average += GetBilinearInterpolate(x + n, y + l, map);
}
}
map[x, y] = average / avgsteps;
}
}
}
示例14: PaintEffect
public void PaintEffect(ITerrainChannel map, bool[,] mask, double rx, double ry, double rz, double strength, double duration, float BrushSize)
{
strength = TerrainUtil.MetersToSphericalStrength(BrushSize);
duration = 0.03; //MCP Should be read from ini file
if (duration > 1.0)
duration = 1.0;
if (duration < 0)
return;
int x;
for (x = 0; x < map.Width; x++)
{
int y;
for (y = 0; y < map.Height; y++)
{
if (!mask[x,y])
continue;
// Calculate a sphere and add it to the heighmap
double z = 0;
if (duration < 4.0)
z = TerrainUtil.SphericalFactor(x, y, rx, ry, strength) * duration * 0.25;
if (z > 0.0)
{
map[x, y] = (map[x, y] * (1.0 - z)) + (m_revertmap[x, y] * z);
}
}
}
}
示例15: PaintEffect
public void PaintEffect (ITerrainChannel map, UUID userID, float rx, float ry, float rz, float strength,
float duration, float BrushSize)
{
int x;
int xFrom = (int)(rx - BrushSize + 0.5);
int xTo = (int)(rx + BrushSize + 0.5) + 1;
int yFrom = (int)(ry - BrushSize + 0.5);
int yTo = (int)(ry + BrushSize + 0.5) + 1;
if (xFrom < 0)
xFrom = 0;
if (yFrom < 0)
yFrom = 0;
if (xTo > map.Width)
xTo = map.Width;
if (yTo > map.Height)
yTo = map.Height;
for (x = xFrom; x < xTo; x++) {
int y;
for (y = yFrom; y < yTo; y++) {
if (!map.Scene.Permissions.CanTerraformLand (userID, new Vector3 (x, y, 0)))
continue;
// Calculate a cos-sphere and add it to the heightmap
double r = Math.Sqrt ((x - rx) * (x - rx) + ((y - ry) * (y - ry)));
double z = Math.Cos (r * Math.PI / (BrushSize * 2));
if (z > 0.0)
map [x, y] += (float)(z * duration);
}
}
}