Atlas2 Terrain Creation Dialog V2.2
by Dennis Trevillyan · 12/14/2006 (3:02 pm) · 39 comments
Download Code File
The atlas2 terrain dialog consists of script files and an updated version of atlasInstance2.cpp.
Installation of the script files: Create a new directory "NX" in "example/common/ui". Unzip atlas2nx.zip and copy the files into this new directory. Open "examples/common/client/canvas.cs" in an editor and add exec("~/ui/NX/NXinit.cs"); just after the "Common GUI's" exec statements.
C Code Update: The script code passes a variable number of arguments to atlasGenerateBlenderTerrain() depending on the number of textures used. Currently atlas blender can only use up to four textures although this may change. The modified code includes a simple routine to count the number of real textures and set argc accordingly. The following code is in atlasConsoleGenerator.cpp. Add the bolded code lines as shown below.
Instructions:
The dialog consists of five panes: Geometry, TQT, Textures, Blender, Unique and Paths. During calculations progress and error messages are shown in the winconsole window (the dos window that opens when you start TGEA). The functions performed on each pane is explained below:
Geometry: A two step process is used to create the geometry atlas file. First the raw input file is converted to .chu and second the .chu is converted to .atlas. The atlas functions used for these conversions are generateChunkFileFromRaw16 and importOldAtlasChu. Necessary information is provided in several text edit boxes. Buttons with the ellipses "..." will open a file browsing drop down to assist in locating files. Output filenames will be automatically created based on the input files. Output filenames can be changed. The default is to append "_geo" as part of the geometry atlas file created using this pane. Specify heightmap size, square size, error metric and tree depth in the text boxes at the bottom of the pane for CHU creation. These parameters are not required to convert the CHU to Atlas.
TQT: Used for Atlas1 terrains. No changes to the original version.
TxFromTiles: Generates texture atlas files using atlasGenerateTextureTOCFromTiles. This pane has the following applications: Unique: import texture tiles to atlas. Blender: import lightmap and opacity maps to atlas. Both jpeg and png formats are accepted and must be specified using the checkboxes.
Blender Textures: Clicking the "Texture" button opens a pane to import terrain textures used to create Blender terrains. Select jpeg or png and then click add and then browse to find the desired file. Textures are passed to Atlas2 in the order shown in the dialog.
Blender Terrain Creation: Clicking the "Blender" button opens a pane to create Blender terrains. Any atlas files created during the current session will be present in the correct location. Browse for any missing files using the ellipses "..." button. Textures must be defined before generating the blender atlas file using the "Texture" pane.
Unique Terrain Creation: Clicking the "Unique" button opens a pane to create Unique terrains. When used during a single session the geometry atlas and texture jpeg will already be shown in the proper places. Create the texture atlas using "TxFromTiles".
Paths: This pane shows the directories that the dialog will use to load the various files on the panes discussed above. Use the ellipses buttons to browse for the desired directory and select "Load". Once all directories are saved use the "Save" button to save the changes. Saved changes will be loaded each time the dialog is started. To return to the defaults use the "Default" button.
To launch the dialog hit "Ctrl-F12".
V2.2 Changes: Fix file dialog to start in proper directories, add capability to save modified directories and load defaults.
The atlas2 terrain dialog consists of script files and an updated version of atlasInstance2.cpp.
Installation of the script files: Create a new directory "NX" in "example/common/ui". Unzip atlas2nx.zip and copy the files into this new directory. Open "examples/common/client/canvas.cs" in an editor and add exec("~/ui/NX/NXinit.cs"); just after the "Common GUI's" exec statements.
C Code Update: The script code passes a variable number of arguments to atlasGenerateBlenderTerrain() depending on the number of textures used. Currently atlas blender can only use up to four textures although this may change. The modified code includes a simple routine to count the number of real textures and set argc accordingly. The following code is in atlasConsoleGenerator.cpp. Add the bolded code lines as shown below.
[b]S32 verifyArgc(S32 argc, const char **argv);[/b]
ConsoleFunction(atlasGenerateBlenderTerrain, bool, 5, 20, "(outFile, inGeometryFile, inOpacityFile, inLightmapFile, virtualTexSize, sourceImage0, sourceImage1, sourceImage2, ..., sourceImageN)")
{
.
.
.
acc->setEntry("virtualTexSize", argv[5]);
Con::printf(" - Virtual texture size is %d", virtTexSize);
// How many source images are specified?
[b]argc = verifyArgc(argc, argv); //verify real texture count and set argc accordingly[/b]
S32 numSrcImages = argc - 6;
Con::printf(" - Found %d source images specified.", numSrcImages);
acc->setEntry("sourceImageCount", avar("%d", numSrcImages));
.
.
.
}
[b]
S32 verifyArgc(S32 argc, const char *argv[])
{
S32 nCount = 0;
for(int i=6 ; i<argc ; i++)
if(strlen(argv[i]) != 0) nCount++;
return nCount+6;
}
[/b]Instructions:
The dialog consists of five panes: Geometry, TQT, Textures, Blender, Unique and Paths. During calculations progress and error messages are shown in the winconsole window (the dos window that opens when you start TGEA). The functions performed on each pane is explained below:
Geometry: A two step process is used to create the geometry atlas file. First the raw input file is converted to .chu and second the .chu is converted to .atlas. The atlas functions used for these conversions are generateChunkFileFromRaw16 and importOldAtlasChu. Necessary information is provided in several text edit boxes. Buttons with the ellipses "..." will open a file browsing drop down to assist in locating files. Output filenames will be automatically created based on the input files. Output filenames can be changed. The default is to append "_geo" as part of the geometry atlas file created using this pane. Specify heightmap size, square size, error metric and tree depth in the text boxes at the bottom of the pane for CHU creation. These parameters are not required to convert the CHU to Atlas.
TQT: Used for Atlas1 terrains. No changes to the original version.
TxFromTiles: Generates texture atlas files using atlasGenerateTextureTOCFromTiles. This pane has the following applications: Unique: import texture tiles to atlas. Blender: import lightmap and opacity maps to atlas. Both jpeg and png formats are accepted and must be specified using the checkboxes.
Blender Textures: Clicking the "Texture" button opens a pane to import terrain textures used to create Blender terrains. Select jpeg or png and then click add and then browse to find the desired file. Textures are passed to Atlas2 in the order shown in the dialog.
Blender Terrain Creation: Clicking the "Blender" button opens a pane to create Blender terrains. Any atlas files created during the current session will be present in the correct location. Browse for any missing files using the ellipses "..." button. Textures must be defined before generating the blender atlas file using the "Texture" pane.
Unique Terrain Creation: Clicking the "Unique" button opens a pane to create Unique terrains. When used during a single session the geometry atlas and texture jpeg will already be shown in the proper places. Create the texture atlas using "TxFromTiles".
Paths: This pane shows the directories that the dialog will use to load the various files on the panes discussed above. Use the ellipses buttons to browse for the desired directory and select "Load". Once all directories are saved use the "Save" button to save the changes. Saved changes will be loaded each time the dialog is started. To return to the defaults use the "Default" button.
To launch the dialog hit "Ctrl-F12".
V2.2 Changes: Fix file dialog to start in proper directories, add capability to save modified directories and load defaults.
About the author
#2
Regards,
Dreamer
12/14/2006 (11:06 pm)
Oh wow man this is just awesome, you've just saved me hours of work.Regards,
Dreamer
#3
People have been asking me for an update recently and I have posted a link to this on the original resource page.
Thanks for posting the resource....
12/15/2006 (3:05 pm)
Heh, seems my laziness has paid off ;pPeople have been asking me for an update recently and I have posted a link to this on the original resource page.
Thanks for posting the resource....
#4
12/17/2006 (6:14 am)
Once again you da man Neo. We thanks as always
#5
12/17/2006 (2:03 pm)
Hey everyone, thanks for the posts. Without Neo's original work this Atlas2 extension would have never happened. Thanks Neo! I think that there are some improvements that could be made so someone should take the ball and run to the next level. Anyone?
#6
I hate the trial and error process pushed on us by the missing tool set in Torque. Your ressource definitely help make it more user friendly.
12/17/2006 (10:55 pm)
Great ressource, it make generating terrain a much more straight forward process.I hate the trial and error process pushed on us by the missing tool set in Torque. Your ressource definitely help make it more user friendly.
#7
There is no "example/common/client/ui" directory. There is "example/common/ui" though. Which one?
12/18/2006 (11:56 am)
Confused about your installation instructions....Quote:
Installation of the script files: Create a new directory "NX" in "example/common/client/ui". Unzip atlas2nx.zip and copy the files into this new directory. Open "examples/common/client/canvas.cs" in an editor and add exec("~ui/nx/Nxinit.cs"); just after the "Common GUI's" exec statements.
There is no "example/common/client/ui" directory. There is "example/common/ui" though. Which one?
#8
12/18/2006 (2:23 pm)
Oops! My bad. It is "example/common/ui". Thank you for identifying that error.
#9
1) Have it save full built configurations to a config file. After having Atlas crash on me 5-6 times I went back to just pasting in command line options in the console - was far easier than typing in stuff again.
2) The way you handle size input is confusing. My terrain raw file is 1025 and I use 1025 as a parameter to atlasOldGenerateChunkFileFromRaw16, but your system asks me for 1024. I get it, but it's confusing sorta.
3) Get it to remember the last directory shown. Having to rechoose the diretory from a huge list of them available is a pain.
Unfortunately though the tool is a nice one, the underlying Atlas code for generating terrain geometry is still buggy and a real crap shoot to use. Anything in this tool that helps me either guess/get the parameters right, or help me remember what I tried last time that made it crash (so I won't try it again) would be nice.
12/18/2006 (2:53 pm)
So if you want feature requests, here's mine :^)1) Have it save full built configurations to a config file. After having Atlas crash on me 5-6 times I went back to just pasting in command line options in the console - was far easier than typing in stuff again.
2) The way you handle size input is confusing. My terrain raw file is 1025 and I use 1025 as a parameter to atlasOldGenerateChunkFileFromRaw16, but your system asks me for 1024. I get it, but it's confusing sorta.
3) Get it to remember the last directory shown. Having to rechoose the diretory from a huge list of them available is a pain.
Unfortunately though the tool is a nice one, the underlying Atlas code for generating terrain geometry is still buggy and a real crap shoot to use. Anything in this tool that helps me either guess/get the parameters right, or help me remember what I tried last time that made it crash (so I won't try it again) would be nice.
#10
The third thing that you mention is a biggie to me too. It has to do with the way Torque handles relative file paths. At least I think so (that's my story and I'm sticking to it!).
I have some free time while I'm running some large L3DT runs (128k x 128k) so I'll look into the config file and path names.
12/18/2006 (3:41 pm)
Tim, thanks for the input. I like your idea about a config file. That hadn't occurred to me and I'll give it some thought. I know what you mean about the heightmap size. I wrote the code to ask for the size of the heightmap, not the size+1 of the raw file. Just one of those things you need to remember I suppose. The third thing that you mention is a biggie to me too. It has to do with the way Torque handles relative file paths. At least I think so (that's my story and I'm sticking to it!).
I have some free time while I'm running some large L3DT runs (128k x 128k) so I'll look into the config file and path names.
#11
I have a RAW file of 2048x2048 (exported as 2049x2049 from L3DT)
Square size = 4
Height Range = 1203
Error Metric = 1 (I can only assume that mean a 1 meter size per mesh, I want that precision)
Tree Depth = ?? << My problem
Texture, high res 4 per pixel, exported from L3DT as 8192x8192, using 1024x1024 png tiles.
Leaf Size = 8 (is that right ? if 8 then the name is a bit confusing)
Anyway my main problem is what should the Tree Depth be ? 8 like leaf size ?
I am totally confused and no turtorial or ressource or post or TDN info give me satisfactory answers.
Thanks for helping.
12/19/2006 (3:01 am)
Can somebody help me understand something here. (note I am using Dennis GUI)I have a RAW file of 2048x2048 (exported as 2049x2049 from L3DT)
Square size = 4
Height Range = 1203
Error Metric = 1 (I can only assume that mean a 1 meter size per mesh, I want that precision)
Tree Depth = ?? << My problem
Texture, high res 4 per pixel, exported from L3DT as 8192x8192, using 1024x1024 png tiles.
Leaf Size = 8 (is that right ? if 8 then the name is a bit confusing)
Anyway my main problem is what should the Tree Depth be ? 8 like leaf size ?
I am totally confused and no turtorial or ressource or post or TDN info give me satisfactory answers.
Thanks for helping.
#12
The "square size" is the mesh size. In L3DT you can get this using operations->Heightmap->resample.
Leaf Size is the number of tiles that make up a texture. Your heightmap is 2048 so the textures will be 4x2048=8192. Assuming you keep the default tile size of 512 then you have a leaf size of 8192/512 or 16. You can verify this in the TX directory. Each file will have a suffix like x0y0 through x16y16. See the connection?
In the dialog I used the terminology presented in the TDN information on Atlas2. Don't give up. The learning curve on Atlas is intimidating but it isn't that hard once you get past these oddities.
There is much more on the forums. Hope that helps some.
12/19/2006 (10:32 am)
Do a search in the forums for atlas2, error metric, and/or tree depth. There are several good posts that will help you to understand what these parameters are. Keep in mind that there is no specific error metric or tree depth in a general sense. You need to pick these to give you the best terrain and texture detail through experimentation. It also depends on if you are running a blender or unique terrain.The "square size" is the mesh size. In L3DT you can get this using operations->Heightmap->resample.
Leaf Size is the number of tiles that make up a texture. Your heightmap is 2048 so the textures will be 4x2048=8192. Assuming you keep the default tile size of 512 then you have a leaf size of 8192/512 or 16. You can verify this in the TX directory. Each file will have a suffix like x0y0 through x16y16. See the connection?
In the dialog I used the terminology presented in the TDN information on Atlas2. Don't give up. The learning curve on Atlas is intimidating but it isn't that hard once you get past these oddities.
There is much more on the forums. Hope that helps some.
#13
Thanks for the answer. Problem is that I have read all L3DT forum, turorial and TDN as well as numerous posts in GG forums. They all assume everybody know what treedepth and error metric mean or I am dumb (that's a good possibility ;) )
For the leaf size, you can't realy go wrong as the importer scream when a file is missing, but "Leaf Size" should be realy named "Leaf count", leaf size is used in numerous example as the pixel size of a tile, that got me confused for a while.
For error metric, I am still confused. What I understand is, if I use a heighfield of 1 pixel for 4m (square size 4) and an error metric of 1 then it generate a mesh per HF pixel.
Example :
EM = 1, SS = 4 >> 1 mesh per 4m.
EM = 10, SS = 4 >> 1 mesh per 40m.
EM = 0.25, SS = 4 >> 1 mesh per 1m.
Tree Depth : I understand that's the number of level of LOD generated and it has nothing to do with Leaf Size as I was assuming. Difference between doing TQT or directly generating atlas from Tile got me confused here.
So anyone can confirm this ?
12/19/2006 (12:06 pm)
@DennisThanks for the answer. Problem is that I have read all L3DT forum, turorial and TDN as well as numerous posts in GG forums. They all assume everybody know what treedepth and error metric mean or I am dumb (that's a good possibility ;) )
For the leaf size, you can't realy go wrong as the importer scream when a file is missing, but "Leaf Size" should be realy named "Leaf count", leaf size is used in numerous example as the pixel size of a tile, that got me confused for a while.
For error metric, I am still confused. What I understand is, if I use a heighfield of 1 pixel for 4m (square size 4) and an error metric of 1 then it generate a mesh per HF pixel.
Example :
EM = 1, SS = 4 >> 1 mesh per 4m.
EM = 10, SS = 4 >> 1 mesh per 40m.
EM = 0.25, SS = 4 >> 1 mesh per 1m.
Tree Depth : I understand that's the number of level of LOD generated and it has nothing to do with Leaf Size as I was assuming. Difference between doing TQT or directly generating atlas from Tile got me confused here.
So anyone can confirm this ?
#14
12/19/2006 (5:35 pm)
Claude-Alain, that is very interesting but I don't know the answer. I would recommend starting a thread on one of the TSE forums. More people will see them there than here. Thanks for your recommendations on labels for the controls. I'll consider these if I post an update.
#15
------------------------------------------------------------------
S32 verifyArgc(S32 argc, const char *argv[])
{
S32 nCount = 0; for(int i=6 ; i
if(strlen(argv[i]) != 0) nCount++;
return nCount+6;
}
------------------------------------------------------------------
12/31/2006 (10:07 pm)
I am not sure where to put the following code------------------------------------------------------------------
S32 verifyArgc(S32 argc, const char *argv[])
{
S32 nCount = 0; for(int i=6 ; i
return nCount+6;
}
------------------------------------------------------------------
#16
01/01/2007 (3:21 pm)
Cappaucino, the code you reference is a new function. You can add it to the end of atlasConsoleGenerator.cpp. For simplicity I added the function prototype at the beginning of the same file.
#17
Which tool do I use?
Could you outline a method for this here that i could use as a guide?
thank you:)
01/02/2007 (10:27 am)
I'm really having trouble with the converting a TQT to .Atlas?Which tool do I use?
Could you outline a method for this here that i could use as a guide?
thank you:)
#18
In general do this:
1. Use the "import chu" pane to import your geometry from raw into chu. Settings are explained in the forums. Now convert the chu into atlas.
2. The remaining maps to convert are graphics (either jpg or png) and may be tiled or one piece. These include lightmaps and opacity maps for blended terrains and the texture map for unique terrains. Convert these to atlas using the "TxfromTile" pane.
3. Build the final atlas file using either the Blended or Unique pane. Note that for the blended terrain you also need to specify the textures that will be shown on the terrain using the "Textures" pane (this one is not used for Unique).
Hope that helps.
01/03/2007 (4:01 pm)
Bobby, as I understand it you don't need to use the TQT conversion unless you are doing an Atlas 1 terrain. In my ramblings through the forums it appears that TSE will not even load Atlas 1 any longer. For Atlas 2 you have two options: blended terrain and unique terrain. Blended terrains use a heightmap, lightmap, opacity map, and up to four textures. Unique terrain gives you more flexibility in texturing because you use a heightmap and a large texture map. This is all explained in TDN and the forum although you'll need to look for it (ie: it isn't all in one place).In general do this:
1. Use the "import chu" pane to import your geometry from raw into chu. Settings are explained in the forums. Now convert the chu into atlas.
2. The remaining maps to convert are graphics (either jpg or png) and may be tiled or one piece. These include lightmaps and opacity maps for blended terrains and the texture map for unique terrains. Convert these to atlas using the "TxfromTile" pane.
3. Build the final atlas file using either the Blended or Unique pane. Note that for the blended terrain you also need to specify the textures that will be shown on the terrain using the "Textures" pane (this one is not used for Unique).
Hope that helps.
#19
01/04/2007 (3:12 pm)
That really does help, I thought i had to convert the TQT to Atlas, going strait to Atlas makes much more sense thank you. Now that I know where to put things I will start getting a flow down:)
#20
01/06/2007 (5:27 am)
I have a question, after you modify the files how do bring up the application to import the terrain? 
Torque 3D Owner iHugMedia
I'm trying it out now, I've always had trouble with atlas2.