How to generate forests in javaUnderstanding “randomness”Gradient Circles for Map GeneratorIs Java “pass-by-reference” or “pass-by-value”?How do I efficiently iterate over each entry in a Java Map?What is the difference between public, protected, package-private and private in Java?How do I call one constructor from another in Java?How do I read / convert an InputStream into a String in Java?When to use LinkedList over ArrayList in Java?How do I generate random integers within a specific range in Java?How do I determine whether an array contains a particular value in Java?How do I convert a String to an int in Java?Creating a memory leak with Java

Where did the “Vikings wear helmets with horn” stereotype come from and why?

Is a post-climate apocolypse city in which many or most insects have disappeared realistic?

Glitch in AC sine wave interfering with phase cut dimming

Why are huge challot displayed on the wedding couple / Bar Mitzvah's table?

What is the most important source of natural gas? coal, oil or other?

What problems does SciDraw still solve?

How do you deal with an abrupt change in personality for a protagonist?

How to prevent bad sectors?

Can a Beholder use rays in melee range?

What's the connection between "kicking a pigeon" and "how a bill becomes a law"?

How to properly maintain eye contact with people that have distinct facial features?

Different PCB color ( is it different material? )

What are the benefits of cryosleep?

A Mathematical Discussion: Fill in the Blank

Split polygon using another polygon in QGIS

Apparent Ring of Craters on the Moon

What does the behaviour of water on the skin of an aircraft in flight tell us?

Ticket sales for Queen at the Live Aid

What is the best linguistic term for describing the kw > p / gw > b change, and its usual companion s > h

How feasible is the Delta-Glider?

File globbing pattern, !(*example), behaves differently in bash script than it does in bash shell

Compact Mechanical Energy Source

Terminology about G- simplicial complexes

What are these (utility?) boxes at the side of the house?



How to generate forests in java


Understanding “randomness”Gradient Circles for Map GeneratorIs Java “pass-by-reference” or “pass-by-value”?How do I efficiently iterate over each entry in a Java Map?What is the difference between public, protected, package-private and private in Java?How do I call one constructor from another in Java?How do I read / convert an InputStream into a String in Java?When to use LinkedList over ArrayList in Java?How do I generate random integers within a specific range in Java?How do I determine whether an array contains a particular value in Java?How do I convert a String to an int in Java?Creating a memory leak with Java






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








4















I am createing a game where a landscape is generated all of the generations work perfectly, a week ago i have created a basic 'forest' generation system wich just is a for loop that takes a chunk, and places random amounts of trees in random locations. But that does not give the result i would like to a achieve.




Code




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);






Result




Image with the result of the basic above seen generation code



If you know any way i could generate more realistic forests please let me know it would help me out a lot.



Thanks in advance










share|improve this question




























    4















    I am createing a game where a landscape is generated all of the generations work perfectly, a week ago i have created a basic 'forest' generation system wich just is a for loop that takes a chunk, and places random amounts of trees in random locations. But that does not give the result i would like to a achieve.




    Code




    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);






    Result




    Image with the result of the basic above seen generation code



    If you know any way i could generate more realistic forests please let me know it would help me out a lot.



    Thanks in advance










    share|improve this question
























      4












      4








      4


      1






      I am createing a game where a landscape is generated all of the generations work perfectly, a week ago i have created a basic 'forest' generation system wich just is a for loop that takes a chunk, and places random amounts of trees in random locations. But that does not give the result i would like to a achieve.




      Code




      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);






      Result




      Image with the result of the basic above seen generation code



      If you know any way i could generate more realistic forests please let me know it would help me out a lot.



      Thanks in advance










      share|improve this question














      I am createing a game where a landscape is generated all of the generations work perfectly, a week ago i have created a basic 'forest' generation system wich just is a for loop that takes a chunk, and places random amounts of trees in random locations. But that does not give the result i would like to a achieve.




      Code




      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);






      Result




      Image with the result of the basic above seen generation code



      If you know any way i could generate more realistic forests please let me know it would help me out a lot.



      Thanks in advance







      java opengl lwjgl landscape






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 24 at 8:44









      Random CoderRandom Coder

      704




      704






















          2 Answers
          2






          active

          oldest

          votes


















          2














          First of all take a look at my:



          • simple C++ Island generator

          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:



          • Understanding “randomness”

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



          So what you should do is get few random locations that would be covering your region shape uniformly. And then generate trees with density dependent on minimal distance to these points. The smaller distance the dense trees placement.



          placemet






          share|improve this answer
































            0














            What are you looking for is a low-discrepancy-sequence to generate random numbers. The generated numbers are not truely random, but rather uniformly distributed. This distinguishes them from random number generators, which do not automatically produce uniformly distributed numbers.



            One example of such a sequence would be the Halton Sequence, and Apache Commons also has an implementation which you can use.



            double[] nextVector = generator.nextVector();


            In your case, using two dimensions, the resulting array also has two entries. What you still need to do is to translate the points into your local coordinates by adding the the central point of the square where you want to place the forest to each generated vector. Also, to increase the gap between points, you should consider scaling the vectors.






            share|improve this answer























              Your Answer






              StackExchange.ifUsing("editor", function ()
              StackExchange.using("externalEditor", function ()
              StackExchange.using("snippets", function ()
              StackExchange.snippets.init();
              );
              );
              , "code-snippets");

              StackExchange.ready(function()
              var channelOptions =
              tags: "".split(" "),
              id: "1"
              ;
              initTagRenderer("".split(" "), "".split(" "), channelOptions);

              StackExchange.using("externalEditor", function()
              // Have to fire editor after snippets, if snippets enabled
              if (StackExchange.settings.snippets.snippetsEnabled)
              StackExchange.using("snippets", function()
              createEditor();
              );

              else
              createEditor();

              );

              function createEditor()
              StackExchange.prepareEditor(
              heartbeatType: 'answer',
              autoActivateHeartbeat: false,
              convertImagesToLinks: true,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: 10,
              bindNavPrevention: true,
              postfix: "",
              imageUploader:
              brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
              contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
              allowUrls: true
              ,
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              );



              );













              draft saved

              draft discarded


















              StackExchange.ready(
              function ()
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55322029%2fhow-to-generate-forests-in-java%23new-answer', 'question_page');

              );

              Post as a guest















              Required, but never shown

























              2 Answers
              2






              active

              oldest

              votes








              2 Answers
              2






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              2














              First of all take a look at my:



              • simple C++ Island generator

              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:



              • Understanding “randomness”

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



              So what you should do is get few random locations that would be covering your region shape uniformly. And then generate trees with density dependent on minimal distance to these points. The smaller distance the dense trees placement.



              placemet






              share|improve this answer





























                2














                First of all take a look at my:



                • simple C++ Island generator

                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:



                • Understanding “randomness”

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



                So what you should do is get few random locations that would be covering your region shape uniformly. And then generate trees with density dependent on minimal distance to these points. The smaller distance the dense trees placement.



                placemet






                share|improve this answer



























                  2












                  2








                  2







                  First of all take a look at my:



                  • simple C++ Island generator

                  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:



                  • Understanding “randomness”

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



                  So what you should do is get few random locations that would be covering your region shape uniformly. And then generate trees with density dependent on minimal distance to these points. The smaller distance the dense trees placement.



                  placemet






                  share|improve this answer















                  First of all take a look at my:



                  • simple C++ Island generator

                  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:



                  • Understanding “randomness”

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



                  So what you should do is get few random locations that would be covering your region shape uniformly. And then generate trees with density dependent on minimal distance to these points. The smaller distance the dense trees placement.



                  placemet







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Mar 25 at 8:06

























                  answered Mar 24 at 9:51









                  SpektreSpektre

                  31.1k652223




                  31.1k652223























                      0














                      What are you looking for is a low-discrepancy-sequence to generate random numbers. The generated numbers are not truely random, but rather uniformly distributed. This distinguishes them from random number generators, which do not automatically produce uniformly distributed numbers.



                      One example of such a sequence would be the Halton Sequence, and Apache Commons also has an implementation which you can use.



                      double[] nextVector = generator.nextVector();


                      In your case, using two dimensions, the resulting array also has two entries. What you still need to do is to translate the points into your local coordinates by adding the the central point of the square where you want to place the forest to each generated vector. Also, to increase the gap between points, you should consider scaling the vectors.






                      share|improve this answer



























                        0














                        What are you looking for is a low-discrepancy-sequence to generate random numbers. The generated numbers are not truely random, but rather uniformly distributed. This distinguishes them from random number generators, which do not automatically produce uniformly distributed numbers.



                        One example of such a sequence would be the Halton Sequence, and Apache Commons also has an implementation which you can use.



                        double[] nextVector = generator.nextVector();


                        In your case, using two dimensions, the resulting array also has two entries. What you still need to do is to translate the points into your local coordinates by adding the the central point of the square where you want to place the forest to each generated vector. Also, to increase the gap between points, you should consider scaling the vectors.






                        share|improve this answer

























                          0












                          0








                          0







                          What are you looking for is a low-discrepancy-sequence to generate random numbers. The generated numbers are not truely random, but rather uniformly distributed. This distinguishes them from random number generators, which do not automatically produce uniformly distributed numbers.



                          One example of such a sequence would be the Halton Sequence, and Apache Commons also has an implementation which you can use.



                          double[] nextVector = generator.nextVector();


                          In your case, using two dimensions, the resulting array also has two entries. What you still need to do is to translate the points into your local coordinates by adding the the central point of the square where you want to place the forest to each generated vector. Also, to increase the gap between points, you should consider scaling the vectors.






                          share|improve this answer













                          What are you looking for is a low-discrepancy-sequence to generate random numbers. The generated numbers are not truely random, but rather uniformly distributed. This distinguishes them from random number generators, which do not automatically produce uniformly distributed numbers.



                          One example of such a sequence would be the Halton Sequence, and Apache Commons also has an implementation which you can use.



                          double[] nextVector = generator.nextVector();


                          In your case, using two dimensions, the resulting array also has two entries. What you still need to do is to translate the points into your local coordinates by adding the the central point of the square where you want to place the forest to each generated vector. Also, to increase the gap between points, you should consider scaling the vectors.







                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Mar 24 at 9:59









                          GlainsGlains

                          1,318920




                          1,318920



























                              draft saved

                              draft discarded
















































                              Thanks for contributing an answer to Stack Overflow!


                              • Please be sure to answer the question. Provide details and share your research!

                              But avoid


                              • Asking for help, clarification, or responding to other answers.

                              • Making statements based on opinion; back them up with references or personal experience.

                              To learn more, see our tips on writing great answers.




                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function ()
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55322029%2fhow-to-generate-forests-in-java%23new-answer', 'question_page');

                              );

                              Post as a guest















                              Required, but never shown





















































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown

































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown







                              Popular posts from this blog

                              Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

                              SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

                              은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현