-
Notifications
You must be signed in to change notification settings - Fork 10
DTL.Shape.PerlinIsland (形状クラス)
sitRyo edited this page Jan 15, 2020
·
6 revisions
namespace DTL.Shape {
public class PerlinIsland : RectBaseFractal<PerlinIsland>
}
PerlinIsland
とは "Matrixの描画範囲にパーリンノイズを使用して地形を生成する" 機能を持つクラスである。
DTL.Base.RectBasePerlin<TDerived> → DTL.Shape.PerlinIsland
// (1)
PerlinIsland()
// (2)
PerlinIsland(uint startX, uint startY, uint width, uint height)
// (3)
PerlinIsland(double frequency)
// (4)
PerlinIsland(double frequency, uint octaves)
// (5)
PerlinIsland(double frequency, uint octaves, int maxHeight)
// (6)
PerlinIsland(double frequency, uint octaves, int maxHeight, int minHeight)
// (7)
PerlinIsland(DTL.Base.Coordinate2DimensionalAndLength2DimensionalmatrixRange matrixRange, double frequency)
// (8)
PerlinIsland(DTL.Base.Coordinate2DimensionalAndLength2DimensionalmatrixRange matrixRange, double frequency, uint octaves, int maxHeight)
// (9)
PerlinIsland(DTL.Base.Coordinate2DimensionalAndLength2DimensionalmatrixRange matrixRange, double frequency, uint octaves, int maxHeight)
// (10)
PerlinIsland(DTL.Base.Coordinate2DimensionalAndLength2DimensionalmatrixRange matrixRange, double frequency, uint octaves, int maxHeight, int minHeight)
// (11)
PerlinIsland(uint startX, uint startY, uint width, uint height, double frequency)
// (12)
PerlinIsland(uint startX, uint startY, uint width, uint height, double frequency, uint octaves)
// (13)
PerlinIsland(uint startX, uint startY, uint width, uint height, double frequency, uint octaves, int maxHeight)
// (14)
PerlinIsland(uint startX, uint startY, uint width, uint height, double frequency, uint octaves, int maxHeight, int minHeight)
|説明| |(1) 初期値なしのインスタンスを生成する。| |(2) 描画範囲を指定したインスタンスを生成する。| |(3), (6), (9) 最小値を指定したインスタンスを生成する。| |(4), (7), (10) 最小値と高度を指定したインスタンスを生成する。| |(5), (8), (11) 最小値と高度, 高度の変動値を指定したインスタンスを生成する。|
Name | Accessibility | Descriptions | Version |
---|---|---|---|
uint startX | public get, protected set | 描画の開始点X | v0.1.0 |
uint startY | public get, protected set | 描画の開始点Y | v0.1.0 |
uint width | public get, protected set | 描画横幅W | v0.1.0 |
uint height | public get, protected set | 描画縦幅H | v0.1.0 |
double frequency | public get, protected set | 周波数 | v0.1.0 |
uint octaves | public get, protected set | オクターブ | v0.1.0 |
int minHeight | public get, protected set | 高さの最小値 | v0.1.0 |
int maxHeight | public get, protected set | 高さの最高値 | v0.1.0 |
Name | Descriptions | Version |
---|---|---|
GetPointX | 描画始点座標Xを取得 | v0.1.0 |
GetPointY | 描画始点座標Yを取得 | v0.1.0 |
GetWidth | 描画横幅Wを取得 | v0.1.0 |
GetHeight | 描画縦幅Hを取得 | v0.1.0 |
GetPoint | 描画始点座標を取得 | v0.1.0 |
GetValue | frequencyを取得 | v0.1.0 |
GetFrequency | frequencyを取得 | v0.1.0 |
GetOctaves | octavesを取得 | v0.1.0 |
GetMinHeight | minHeightを取得 | v0.1.0 |
GetMaxHeight | maxHeightを取得 | v0.1.0 |
Name | Descriptions | Version |
---|---|---|
SetPointX | 描画始点座標Xを指定 | v0.1.0 |
SetPointY | 描画始点座標Yを指定 | v0.1.0 |
SetWidth | 描画横幅Wを指定 | v0.1.0 |
SetHeight | 描画縦幅Hを指定 | v0.1.0 |
SetPoint | 描画始点座標(X,Y)を指定 | v0.1.0 |
SetRange | 描画範囲(X,Y,W,H)を指定 | v0.1.0 |
SetValue | frequencyを指定 | v0.1.0 |
SetFrequency | frequencyを指定 | v0.1.0 |
SetOctaves | octavesを指定 | v0.1.0 |
SetMinHeight | minHeightを指定 | v0.1.0 |
SetMaxHeight | maxHeightを指定 | v0.1.0 |
名前 | 説明 | 対応バージョン |
---|---|---|
ClearPointX | 描画始点座標Xを消去 | v0.1.0 |
ClearPointY | 描画始点座標Yを消去 | v0.1.0 |
ClearWidth | 描画横幅Wを消去 | v0.1.0 |
ClearHeight | 描画縦幅Hを消去 | v0.1.0 |
ClearPoint | 描画始点座標(X,Y)を消去 | v0.1.0 |
ClearRange | 描画範囲(X,Y,W,H)を消去 | v0.1.0 |
ClearValue | frequencyを消去 | v0.1.0 |
Clear | ClearRangeとClearValueを実行 | v0.1.0 |
ClearFrequency | frequencyを消去 | v0.1.0 |
ClearOctaves | octavesを消去 | v0.1.0 |
ClearMinHeight | minHeightを消去 | v0.1.0 |
ClearMaxHeight | maxHeightを消去 | v0.1.0 |
Name | Descriptions | Version |
---|---|---|
Draw(int[,]) | Matrixに描画する | v0.1.0 |
Create(int[,]) | Matrixに描画してMatrixを返す | v0.1.0 |
DrawNormalize(float[,]) | [0, 1]に正規化した値をMatrixに描画する | v0.1.0 |
using DTL.Range;
using DTL.Shape;
using UnityEngine;
using System.Collections.Generic;
using DTL.Console;
public class GeneratePerlinIsland : MonoBehaviour {
public const int height = 200;
public const int width = 200;
private PerlinIsland perlinIsland;
public List<GameObject> cubes = new List<GameObject>();
private void Start () {
var matrix = new int[height, width];
perlinIsland = new PerlinIsland(6.0, 8, 150);
perlinIsland.Draw(matrix);
new OutputConsole().Draw(matrix);
Generate(height, width, matrix, 150);
}
private void Generate(int height, int width, int[,] matrix, int maxHeight) {
int[] limited = new int[cubes.Count];
SetLimit(limited, maxHeight);
for (int row = 0; row < height; ++row) {
for (int col = 0; col < width; ++col) {
var cubeHeight = GetMapHeight(matrix[row, col], limited);
CubeInstantiate(row, cubeHeight, col);
}
}
}
private void CubeInstantiate(int x, int y, int z) {
Instantiate(cubes[y], new Vector3(x, y, z), Quaternion.identity);
}
private int GetMapHeight(int arrayValue, int[] limit) {
var length = limit.Length;
var value = length-1;
for (int i = 0; i < length; ++i) {
if (arrayValue < limit[i]) {
value = i-1;
return value;
}
}
return value;
}
private int[] SetLimit(int[] limit, int maxHeight) {
var length = limit.Length;
var heightUnit = (int) maxHeight / length;
var count = 0;
for (int i = 0; i < length; ++i) {
limit[i] = count;
count += heightUnit;
}
return limit;
}
}
using System;
using DTL.Shape;
using DTL.Random;
using UnityEngine;
using System.Collections.Generic;
using DTL.Util;
public class GeneratePerlinIslandTerrain : MonoBehaviour {
public int depth = 50;
public int height = 200;
public int width = 200;
public double frequency = 6.0;
public uint octaves = 8;
public int maxHeight = 150;
private Terrain terrain;
private PerlinIsland perlinIsland;
public List<Texture2D> texture2D = new List<Texture2D>();
void Start() {
perlinIsland = new PerlinIsland(frequency, octaves, maxHeight);
this.terrain = GetComponent<Terrain>();
TerrainUtil terrainUtil = new TerrainUtil(terrain, texture2D, perlinIsland, height, width, depth);
terrainUtil.Draw();
}
}
Copyright (c) 2017-2019 Kasugaccho. Copyright (c) 2018-2019 As Project.
Distributed under the Boost Software License, Version 1.0.(See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)