Results 1 to 10 of 109

Thread: Automatic Forester

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #11
    Guild Expert Ramah's Avatar
    Join Date
    Mar 2009
    Location
    Nottinghamshire
    Posts
    1,414
    Blog Entries
    4

    Post

    Ok... here would be how I did it if I was working out how to place trees and trying to keep in with how I think you are doing it with your 16 square grid.
    I'm assuming your placement routine starts in the top left corner, goes along the x-axis, then down one row on the Y-axis and returns to X0.

    The first thing I would do is have the program examine each of the brushes in its list looking for the widest one. I would then divide this by 4 to get the size of your grid - giving you your sixteen sections which the tree would occupy. As long as all the tree brushes are reasonably close in size then it doesn't matter that some would be smaller and not fit exactly to the edges of the grid.

    If you resize the trees with your slider this calculation would need doing again obviously.

    I'd then send the subroutine crawling through my array, starting at X0, Y0 (or X1 Y1 if Java doesn't use zero-based arrays or whatever). You know where to place the trees in relation to the .png alpha image (no idea how you do that by the way) so as soon as you reach a point in the matrix where a tree is allowed relative to the png mask you do your random check and figure out if a tree is placed and which tree is used etc. Your subroutine would then flag certain positions in your array as unavailable or illegal. If your array is boolean then I guess it would mark them as false.
    Your subroutine would then repeat until you got to the next space which you are allowed to grow a tree on looking at both the .png mask AND the positioning of the last tree. You then do your random check again etc...

    Here's an image to help demonstrate what I mean...

    Click image for larger version. 

Name:	Tree_placement_example.jpg 
Views:	98 
Size:	655.8 KB 
ID:	20144

    So, when tree 1 is placed I would mark off all the places where I have the red X's as ungrowable. So.. X+1, X+2, X+3, X-1 Y+1, Y+1, X+1 Y+1 in the array would be marked as False.
    If a tree is placed in those positions it is too close to the original and looks odd.

    If you do no random checks on the positions where the tree is placed (only for which tree brush is used) then this would be the maximum density forest. There would be a tree in every available position that your .png mask allows.
    To lower the density you would either
    a) do a random chance check for each LEGAL space, lowering the odds each time the density is lowered.
    b) Increase the number of positions marked as ILLEGAL whenever a tree is placed. So each tree is forced to grow further away from the others the lower the density is.
    c) A combination of both of the above.

    I hope this helps. It makes perfect sense to me but I'm not the one programming it and you would obviously know more about whether this is doable for you or not.

    EDIT: I forgot to say... the red X's on the image above are ONLY relative to the first tree placed. If that image was correct there would be other red X's placed relative to the positions of the other two trees.
    Last edited by Ramah; 01-08-2010 at 02:30 PM.
    Royal: I'm very sorry for your loss, your mother was a terribly attractive woman.


    My Cartographer's Guild maps: Finished Maps


    More maps viewable at my DeviantArt page: Ramah-Palmer DeviantArt

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •