Procedural Terrain Painter - Chance/Density option.
by Andy Wright · 07/27/2013 (7:07 am) · 15 comments
This resource is not my code, it is Jack Davidson's. He wrote it to work along side Konrad Kiss's procedural terrain painter, it allows you to chose the chance of it painting a tile within your height and angle parameters. Konrad's resource has been included in the current GIT build, however jack's changes were not, and were also broken due to some file name changes. I have fixed these and added a new field to the procedural terrain painter gui to allow you to chose the chance of it painting a tile.
When choosing your chance amount, it is a bit unintuitive as its not a percentage, but you have to think of it as " 1 in X " tiles are painted, so if you leave it as 1, then 1 in 1 tiles will be covered with the new texture (100%) where as if you input 5, then 1 in 5 tiles will be painted (20%)
Do not enter a value under 1 or use decimals of any amount, it will crash If someone knows how to lock the gui so that it will round to the nearest integer, please feel free to fix that...



The files are available here
the .Gui with added field for chance
TerrainEditor.cpp
TerrainEditor.h
When choosing your chance amount, it is a bit unintuitive as its not a percentage, but you have to think of it as " 1 in X " tiles are painted, so if you leave it as 1, then 1 in 1 tiles will be covered with the new texture (100%) where as if you input 5, then 1 in 5 tiles will be painted (20%)
Do not enter a value under 1 or use decimals of any amount, it will crash If someone knows how to lock the gui so that it will round to the nearest integer, please feel free to fix that...



The files are available here
the .Gui with added field for chance
TerrainEditor.cpp
TerrainEditor.h
About the author
#2
07/27/2013 (7:16 am)
Yeah, the procedural painter is in there, but always felt quite limited before Jack made the chance option, cant live without it now. When upgrading to MIT I noticed that Konrad's was included, but Jack's additions wernt, and they also got broken because of some file name changes etc. This is Jack's additions fixed to work with whats in the MIT3 build
#3
07/27/2013 (7:19 am)
Ah fair enough! Sounds good.
#4
07/27/2013 (8:12 am)
Thanks Andy (and Jack). This is bloody brilliant!
#5
07/27/2013 (4:52 pm)
Beautiful!
#7
07/28/2013 (2:50 pm)
Thanks, but please remember its not my code and i dont claim it to be, all ive done is fixed the file links as they changed and added the gui option
#8
07/31/2013 (3:23 pm)
This is really good stuff, thanks.
#9
07/31/2013 (3:46 pm)
Did you make a pull request, or want to make one?
#10
08/01/2013 (9:26 am)
Well, it has a major bug at the moment, where if the user puts a number in for chance that is under 1 it crashes. If there is some way on a gui to change the value of chance to 1 if a value entered is under 1, then someone could fix that, or through the source
#11
Found a fix for the hard crash when putting in a value lower than 1 into the chance field.
in terrainEditor.cpp at like 2897/2898 you will find
Directly under this add the following
Quite chuffed at myself for that lol.
What it does is if the chance value is under 1, instead of causing a crash to desktop, it now reverts the chance to 1, painting the while terrain. A hack fix i guess, but if you have undo enabled, its all good. Might add a note at the bottom of the gui window under the chance field to notify the user about this.
08/03/2013 (10:00 am)
well bugger me, i remembered something from college nearly 12 years ago, made it all worth it lol...Found a fix for the hard crash when putting in a value lower than 1 into the chance field.
in terrainEditor.cpp at like 2897/2898 you will find
if (gi.mMaterial == mat)
continue;Directly under this add the following
if (Chance < 1){
(Chance = 1);
}
else if (Chance > 1){
(Chance = Chance);
}Quite chuffed at myself for that lol.
What it does is if the chance value is under 1, instead of causing a crash to desktop, it now reverts the chance to 1, painting the while terrain. A hack fix i guess, but if you have undo enabled, its all good. Might add a note at the bottom of the gui window under the chance field to notify the user about this.
#12
In any case, I've been working with Anroid phones. got a game and an app out now.
for that bug:
That should round everything up. Won't work with 0 though.
just put it in where you said, under:
I hope it works. Like I said, I can't actually test it right now.
08/28/2013 (4:14 pm)
Thanks for doing that! I wanted to update the code, but currently I don't have any system good enough to work with T3D... My computer won't stay on for more than a few minutes now.In any case, I've been working with Anroid phones. got a game and an app out now.
for that bug:
Chance = ceil(Chance);
That should round everything up. Won't work with 0 though.
just put it in where you said, under:
if (gi.mMaterial == mat)
continue;I hope it works. Like I said, I can't actually test it right now.
#13
08/28/2013 (4:20 pm)
Hey Jack, no worries. I have similar issues with T3D on my laptop, it cant cool itself fast enough when running t3d lol and after 10-15 minutes it just powers off to stop it damaging itself :| tho works fine if i just have my deskfan blowing under it while its lifted ontop of 4 empty cig packets... lol
#14
I'm gona modify the code a bit, then try to merge the changes with the development branch.
12/13/2013 (8:58 am)
Ok, I built up a new computer!I'm gona modify the code a bit, then try to merge the changes with the development branch.
#15
05/04/2014 (10:34 pm)
Alright, good news! i just published a pull request to the development branch of T3D. Hopefully we'll be seeing this in the next version of T3D. Fixed a bunch of problems too. Its a percentage now, rather than something arbitrary. decimals are fine now, and no crashes from entering weird values. 
Torque Owner Lukas Joergensen
WinterLeaf Entertainment
In context: I though this was already added in MIT 3.0? Except for the chance option.