Automatic decal placement script/program for environment)

Post Reply
Wahlamt
Posts: 7933
Joined: Mon Sep 13, 2010 3:15 pm
Team: MLG Compton
Location: Sweden
Contact:

Automatic decal placement script/program for environment)

Post by Wahlamt »

Hey guys!

So I've been a while back I got kind of annoyed with the placing of decals over large areas, like doing a whole environment in grass. It's especially 2 things that are annoying when decalling the environment. 1. It takes a lot of time. 2. It often overlays each other so you will end up with x times more decals than what's needed to cover the area, so I went ahead and tested my web/programming skills.

This script/program comes in three options! 2 of them are "simple" and 1 is advanced. The simple ones are the same, but 1 is online where you enter the code and then the webpage returns the code you entered, the other one does the same thing, except it's an .exe file that you can download and use offline. Instead of returning it in a webpage, it creates a .txt document that has all the same code in it as the webpage would.

Following will be a guide on how to use each script!

The Simple online script
This script can be found at http://mxsimtools.storkenmxs.com/ and then go to the simple one, or directly go to http://mxsimtools.storkenmxs.com/basicdecalplacing.php.

1. When you enter the site, it will look like this:
Image

2. Fill out the fields.

Not sure what each of them are for? Here's an explanation.

Terrain size in pixels: Assuming you want to cover the whole track, this option is supposed to the same as the length of 1 side of the map. If you go into editor mode, and hold the mouse in the bottom right corner, where the map ends, you will get 2 coordinates. Either they will most likely be 1025x1025 or 2049x2049. That is the value you want to enter, in my examples, I use 2049.

Decal size in pixels: This is how big the decal is supposed to be ingame. Typical ontrack decals are around 30, but the environment usually doesn't have to be the same quality, so a little higher, maybe 50, will often be good to use.

Random decal rotation: If this is yes, it will output decals in random rotation, if no is selection, they will be at rotation 0.

Spacing distance: This is the distance between each decal. Note that the decals coordinates it at the center of the decal. A good value to aim at is about half of the value that your "Decals size in pixels" is. This will place one decal at start, then the next one is "Spacing distance: value" away from the first one. The next one will be as far away from the 2nd as the 2nd one was away from the first one and so on. This goes for both x and y axis.

Decal path from your track folder: Assuming you are in your personal folder, you first want to type your tracks folder name. Let's say mine is "cooltrack". Then you want to enter eventual subfolders, for my example, I'll have the subfolder "decal". At last in my folder "decal", there is the decal "sand.png". In this example, my entered text would look like: cooltrack/decal/sand.png

Now it's just to submit!

This is what it could look like once filled out:
Image

The output will look something like this after you've clicked submit:
Image

3. Selecting the output.
When you've hit submit, you are supposed to get a large output, easiest way to select this is my selecting the first or first few characters in the output like this:
Image

After that's done, scroll down to the bottom (using the scroll-bar at the side of the page or the button labeled "end" to get to the end of the page. It will most likely be a few thousand lines of output so regular scrolling will take time). Once you've reached the bottom, hold shift an click right after the last character of you output, where the blue line is in this image:
Image

4. Once it's all selected, either right click and choose "copy" or press "ctrl + c".

5. Open up the decal file for your track
If you place the copied code on top of the decal file, the decals will appear at the bottom on your track.
If you place the copied code on the bottom of the decal file, the decals will appear at the top on your track.

Most likely you want to have them on the bottom, covering the tilemap and to fill out the environment. Then make sure to have a blank line on the top of your decal file, like this (where the blue lines are at):
Image

Now paste the code you copied on that blank line on top, either by right click and choose "paste" or press "ctrl + v".

You should now end up at a line quite a bit down the document like this (the blue curve is where the newly pasted code ends and the old one starts);
Image

Save up, and start your track, it should now have a nice layer on the bottom with your decals you chose.




The Advanced online script
For the options that are same as the simple script, check those descriptions.

This script can be found at http://mxsimtools.storkenmxs.com/ and then go to the simple one, or directly go to http://mxsimtools.storkenmxs.com/advanceddecalplacing.php.

1. When you enter the site it will look like this:
Image

Fill out the fields!

Start point Y-axis: Where in the Y axis you want the decals to start covering.

Start point X-axis: Where in the X axis you want the decals to start covering.

End point Y-axis: Where on the Y axis you want the decals to stop covering.

End point X-axis: Where on the X axis you want the decals to stop covering.

Number of different decals: Some more advanced users like to use different decals for the environment, to change things up and not have the environment in one tone.

Decal path from your track folderX: This is exactly the same as the other one, except these are for the extra decals.

Note: It's a random function that randomly chooses which decal that is going to be in the output. If you choose that you want to have 4 decals, but only enter 3 of them, you will end up with a few blank lines. If you enter 4 different but select that you only want to have 3 different, the last decal won't be in the output code.

An input can look like this:
Image

As you can see with the new output, it starts at the coordinates we entered and it prints out the different decals we entered as well.
Image

Applying the code is the same as for the basic one!



The Basic Program

This program can be downloaded at: http://storkenmxs.com/files/DecalPlacing_1-00.rar

1. When you launch the program, it will look like this:
Image

2. Just enter the values as you do with the simple online script! This is what an input can look like:

NOTE: The last line "Tryck ned valfri tangent för att fortsätta..." means "Press any key to continue" (it's Swedish... My laptop language is Swedish...). After you click enter after you've put in your folder path, the program will automatically proceed to make a file with the output in it.
Image

The .exe file should now have created a output file (in the same directory that the .exe file is in) that looks something like this one:
Image

If you open that file it will look something like this:
Image

Select all by pressing "ctrl + a" then copy everything and paste it into your decals file for your tracks, as you do in "The Simple online script".


If you find any bugs, please make a comment or pm me, or if you have any other feedback!

If you use this or find it useful, leave a comment and let me know! :)

Hope you all can use this and that it works as it's intended to! :)
Racers52
Posts: 3216
Joined: Sun Feb 03, 2013 8:10 pm
Location: Texas
Contact:

Re: Automatic decal placement script/program for environment

Post by Racers52 »

Wow! Thanks man!
Halvorson
Posts: 477
Joined: Tue Oct 16, 2012 11:58 pm
Location: Montana

Re: Automatic decal placement script/program for environment

Post by Halvorson »

Awesome thanks man!
SMR 510RR
Posts: 2526
Joined: Sun Apr 08, 2012 6:36 am
Team: Privateer

Re: Automatic decal placement script/program for environment

Post by SMR 510RR »

Seems cool. Since everything is in feet and you don't specify what the scale for the track is, I think there may be an error in your methods. I would like to see this use feet for all the inputs, simply input terrain.png resolution and terrain.hf scale multiplier to extract the size of the track in feet.

Maybe I am wrong in how it works.
Wahlamt
Posts: 7933
Joined: Mon Sep 13, 2010 3:15 pm
Team: MLG Compton
Location: Sweden
Contact:

Re: Automatic decal placement script/program for environment

Post by Wahlamt »

SMR 510RR wrote:Seems cool. Since everything is in feet and you don't specify what the scale for the track is, I think there may be an error in your methods. I would like to see this use feet for all the inputs, simply input terrain.png resolution and terrain.hf scale multiplier to extract the size of the track in feet.

Maybe I am wrong in how it works.
Hey, thanks for the feedback!

You are right about the feet thing. I just "assumed" that people will run 1.0 ft/px, but that obviously isn't the case. I'd be better of changing pixels to feet. And if the decals size is '20', it means that it is 20ft ingame, not equivalent to 20px ingame? The terrain.png resolution times terrain.hf scale would be a pretty simple fix though. Great that you pointed it out, I'll look into it as soon as I have time, probably next week, or in the beginning of June. If you remember, send me a reminder!

Thanks again for the feedback!
SMR 510RR
Posts: 2526
Joined: Sun Apr 08, 2012 6:36 am
Team: Privateer

Re: Automatic decal placement script/program for environment

Post by SMR 510RR »

Yea the decals size are in feet, seems like an easy change to make you got the hard part done. Also from my testing the actual terrain size is ((terrain.png width-1)*track scale) so its actually 2048 not 2049 for example. Tracks from real height data are probably not going to have a scale of 1 since you end up with a sort of random size of terrain depending on what you got and if you want to scale it up or down slightly then you can adjust it.

Other suggestions:
Randomize decal size between user entered numbers or a percentage +/- from the entered size (like I could say it should be 20' +/-10% to give some more variation or I want it to be random between 18-22' for example).

Make certain decals land on top. This would be helpful if you have a dead grass decal for example and want to make sure it always is on top of the healthy grass. It would be easy enough to sort it after the fact with notepad ++ but if you feel like adding it that would be cool.
Wahlamt
Posts: 7933
Joined: Mon Sep 13, 2010 3:15 pm
Team: MLG Compton
Location: Sweden
Contact:

Re: Automatic decal placement script/program for environment

Post by Wahlamt »

SMR 510RR wrote:Tracks from real height data are probably not going to have a scale of 1 since you end up with a sort of random size of terrain depending on what you got and if you want to scale it up or down slightly then you can adjust it.
That's right. Never actually made a replica using real height data so I didn't have that in mind. Now when you explained it, it's clear.
SMR 510RR wrote:Other suggestions:
Randomize decal size between user entered numbers or a percentage +/- from the entered size (like I could say it should be 20' +/-10% to give some more variation or I want it to be random between 18-22' for example).
Should that be an option yes/no for all the decals? Like decals 1 through 5 will be a random size when it's printed?
SMR 510RR wrote:Make certain decals land on top. This would be helpful if you have a dead grass decal for example and want to make sure it always is on top of the healthy grass. It would be easy enough to sort it after the fact with notepad ++ but if you feel like adding it that would be cool.
That's a good feature. Not sure how to implement it though. Maybe add it to a string that gets printed last would do it.

You've at least given me some great activities for the summer :D
SMR 510RR
Posts: 2526
Joined: Sun Apr 08, 2012 6:36 am
Team: Privateer

Re: Automatic decal placement script/program for environment

Post by SMR 510RR »

Being able to randomly size each decal individually may be nice but if you do a % based system then I think applying it to all of them would be fine.

I got tons of ideas, no good ones yet but I am working on it.
Wahlamt
Posts: 7933
Joined: Mon Sep 13, 2010 3:15 pm
Team: MLG Compton
Location: Sweden
Contact:

Re: Automatic decal placement script/program for environment

Post by Wahlamt »

SMR 510RR wrote:I got tons of ideas, no good ones yet but I am working on it.
Create an array and add all of the top ones in there, then print the array last?
SMR 510RR
Posts: 2526
Joined: Sun Apr 08, 2012 6:36 am
Team: Privateer

Re: Automatic decal placement script/program for environment

Post by SMR 510RR »

Like I know haha. It probably really doesn't matter, it would take me all of 10 seconds to sort them in Notepad++ afterward. Maybe if it is selected for Decal 2 it can be placed at the end and decal 1 gets put at the beginning? I really don't know much about how any of this works aside from me using it so any suggestions past that would be horrible guesses haha.
Wahlamt
Posts: 7933
Joined: Mon Sep 13, 2010 3:15 pm
Team: MLG Compton
Location: Sweden
Contact:

Re: Automatic decal placement script/program for environment

Post by Wahlamt »

SMR 510RR wrote:Like I know haha. It probably really doesn't matter, it would take me all of 10 seconds to sort them in Notepad++ afterward. Maybe if it is selected for Decal 2 it can be placed at the end and decal 1 gets put at the beginning? I really don't know much about how any of this works aside from me using it so any suggestions past that would be horrible guesses haha.
Haha, it's kind of tricky trying to figure out :p how would you sort that in notepad++, since you will have to sort complete rows?
SMR 510RR
Posts: 2526
Joined: Sun Apr 08, 2012 6:36 am
Team: Privateer

Re: Automatic decal placement script/program for environment

Post by SMR 510RR »

Copy the lines to a separate file, use find to bookmark all the lines I don't want leaving one type of decal, delete bookmarked lines, copy that back to the original file, repeat for all types of decals I want to layer.
Wahlamt
Posts: 7933
Joined: Mon Sep 13, 2010 3:15 pm
Team: MLG Compton
Location: Sweden
Contact:

Re: Automatic decal placement script/program for environment

Post by Wahlamt »

SMR 510RR wrote:Copy the lines to a separate file, use find to bookmark all the lines I don't want leaving one type of decal, delete bookmarked lines, copy that back to the original file, repeat for all types of decals I want to layer.
Oh okay, had no idea!
Post Reply