Javaで森林を生成する方法

ランダムコーダー:

私はちょうどチャンクを取るforループですウィッヒ基本的な「森の世代のシステムを作成した一週間前、完璧に動作し、かつランダムな場所に木のランダムな量を置く風景がすべての世代で生成されたゲームをcreateingています。しかし、それは私が達成したい結果を与えるものではありません。

コード

for(int t = 0; t <= randomForTrees.nextInt(maxTreesPerChunk); t++){

    // generates random locations for the X, Z positions\\
    // the Y position is the height on the terrain gain with the X, Z coordinates \\
    float TreeX = random.nextInt((int) (Settings.TERRAIN_VERTEX_COUNT + Settings.TERRAIN_SIZE)) + terrain.getX();
    float TreeZ = random.nextInt((int) (Settings.TERRAIN_VERTEX_COUNT + Settings.TERRAIN_SIZE)) + terrain.getZ();
    float TreeY = terrain.getTerrainHeightAtSpot(TreeX, TreeZ);

    // creates a tree entity with the previous generated positions \\
    Entity tree = new Entity(TreeStaticModel, new Vector3f(TreeX, TreeY, TreeZ), 0, random.nextInt(360), 0, 1);

    // checks if the tree is on land \\
    if(!(tree.getPosition().y <= -17)){
        trees.add(tree);
    }

}

結果

基本上で見生成コードの結果と画像

あなたは私がより現実的な森林を生成することができますどのような方法を知っていれば、私はそれは多くのことを私を助けるお知らせください。

前もって感謝します

範囲:

まず第一に、私を見てみましょう:

as you can see you can compute Biomes from elevation, slope, etc... more sophisticated generators create a Voronoi map dividing your map into Biomes regions assigning randomly (with some rules) biome types based on neighbors already assigned...

Back to your question you should place your trees more dense around some position instead of uniformly cover large area with sparse trees... So you need slightly different kind of randomness distribution (like gauss). See the legendary:

on how to get a different distribution from uniform one...

それでは、あなたがすべきことは一様に、お住まいの地域の形状をカバーすることになるいくつかのランダムな位置を取得することです。そして、これらの点に最小限の距離に依存密度で木を生成します。小さい距離密な木の配置。

placemet

おすすめ

転載: http://43.154.161.224:23101/article/api/json?id=181035&siteId=1