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
#22
I have not seen any single tutorial. Search TDN and the forums.
01/06/2007 (8:09 am)
Oops! I suppose that would help. Launch the dialog with "Ctrl-F12". Thanks for catching that. I've updated the post.I have not seen any single tutorial. Search TDN and the forums.
#23
01/06/2007 (1:44 pm)
Thanks Dude! :0)
#24
DeathTwister here and I have just a few questains /smirks.... hahaha
OK, I have made my chu/atlas file and my TQT file easy enough for me, but then I got to the blend part and then I found trouble. It seems I am having a bit of a go with the light map. I brought it in as a .jpg from L3DT should be no biggie and then made a TQT file from that, I was suposed to right?
But when I go to blend them all, for some reason and the light map file is in the same place as the texture TQT file, but I cannot see my light map to bring in anywhere and I know where I put it /smiles....... So I have no idea why I have not been able to bring it in yet.
Other then that, the Chu and first texture TQT went in fine. I am not sure what I am doing wrong on the light map one though, is it me? or a bug? Probobly me, that is why I am asking what I am doing wrong /wry grins.......that turns sheepish hahahahahahaha So having trouble with the blend part ATM if I can get some help, I have about 60 Large arse terrains to bring in, Wooo Hooo.
DT
01/07/2007 (4:05 am)
Hay all,DeathTwister here and I have just a few questains /smirks.... hahaha
OK, I have made my chu/atlas file and my TQT file easy enough for me, but then I got to the blend part and then I found trouble. It seems I am having a bit of a go with the light map. I brought it in as a .jpg from L3DT should be no biggie and then made a TQT file from that, I was suposed to right?
But when I go to blend them all, for some reason and the light map file is in the same place as the texture TQT file, but I cannot see my light map to bring in anywhere and I know where I put it /smiles....... So I have no idea why I have not been able to bring it in yet.
Other then that, the Chu and first texture TQT went in fine. I am not sure what I am doing wrong on the light map one though, is it me? or a bug? Probobly me, that is why I am asking what I am doing wrong /wry grins.......that turns sheepish hahahahahahaha So having trouble with the blend part ATM if I can get some help, I have about 60 Large arse terrains to bring in, Wooo Hooo.
DT
#25
In my experience you don't need to create a TQT file. For any tiled map (other than heightmaps), including lightmap, textures, and opacity, use the TxFromTiles pane to go directly to an atlas file. You will have one atlas file for each tiled map plus the atlas file generated using the "Import Chu" pane. Once you have all of these atlas files use the Blender pane to create a blended terrain or the Unique pane to create a unique terrain.
Also see the response to Bobby Leighton above. Hope this helps.
01/07/2007 (7:27 am)
DeathTwister, In my experience you don't need to create a TQT file. For any tiled map (other than heightmaps), including lightmap, textures, and opacity, use the TxFromTiles pane to go directly to an atlas file. You will have one atlas file for each tiled map plus the atlas file generated using the "Import Chu" pane. Once you have all of these atlas files use the Blender pane to create a blended terrain or the Unique pane to create a unique terrain.
Also see the response to Bobby Leighton above. Hope this helps.
#26
AltasResourceTOC::immediateLoad - got an empty stub!
Anyone had the same problem before?
03/15/2007 (12:06 pm)
When make the unique altas, always got the error message:AltasResourceTOC
Anyone had the same problem before?
#27
The atlas file consists of several sections. Each section has a stub which is the header that contains the necessary information and is followed by the chunk that contains the data. If the stub is empty then something that the engine expects isn't there.
03/15/2007 (3:40 pm)
Steven, I'm not sure why you would get that error however you may not be supplying all of the data that is needed or you may be using the wrong data. For example if you need to be sure to use the geometry atlas as the input for unique terrain and not some other atlas file. The geometry atlas files have "_geo.atlas" at the end while the final atlas files are just ".atlas". The engine will take either but you'll get an error if you specify the wrong one. The same would be true of the texture atlas file.The atlas file consists of several sections. Each section has a stub which is the header that contains the necessary information and is followed by the chunk that contains the data. If the stub is empty then something that the engine expects isn't there.
#28
I've solved this problem by using atlasGenerateTextureTOCFromLargeJPEG to convert the texture instead of the atlasGenerateTextureTOCFromTiles function for making unique altas. Still not very clear about the usage of atlasGenerateTextureTOCFromTiles function.
03/16/2007 (8:03 pm)
Dennis, thanks for your quick reply!I've solved this problem by using atlasGenerateTextureTOCFromLargeJPEG to convert the texture instead of the atlasGenerateTextureTOCFromTiles function for making unique altas. Still not very clear about the usage of atlasGenerateTextureTOCFromTiles function.
#29
03/16/2007 (8:35 pm)
Steven, I am happy to hear that you have solved your problem! There seems to be several ways to generate the final atlas. Thanks for the input.
#30
03/26/2007 (10:25 pm)
Crashes in latest version of TGEA :(
#31
03/27/2007 (3:19 pm)
I haven't had any problems. What does the log show?
#32
http://img367.imageshack.us/img367/3182/tgeaerrorfc3.png
Information about ntdll.dll can be found here:
http://msdn2.microsoft.com/en-us/library/ms723894.aspx
I can send you the log file, if you can provide a means of sending it to you..
03/27/2007 (5:56 pm)
I don't see anything obvious in the log, but the error is pretty serious, and I can't get a stack trace of it - it appears the crash is happening in a system DLL (ntdll.dll), so I'm guessing that it's actually a change in Vista that is the problem.http://img367.imageshack.us/img367/3182/tgeaerrorfc3.png
Information about ntdll.dll can be found here:
http://msdn2.microsoft.com/en-us/library/ms723894.aspx
I can send you the log file, if you can provide a means of sending it to you..
#33
Most likely this is an Atlas / Windows problem and not due to the dialog. I'm not using Vista so I haven't paid much attention to any problems but I vaguely remember seeing some issues associated with it. However, if you find out it is a dialog problem let me know.
03/27/2007 (6:51 pm)
I'd recommend clicking break and then look at the stack trace window at the bottom (bottom right on my VSE). Since you say it is breaking in ntdll.dll there will not be any debug info available and those parts of the stack trace will be grayed out. Double click on the first entry down from the top that isn't greyed out, if there are any, and look for bad pointers, etc in the code. The error isn't necessarily where the exception occurred. Keep in mind that Atlas is multi threaded so the error could occur in a thread you are not currently actively debugging. Of course it might automatically switch you to that thread when the error occurs, I don't know. You can switch the thread you are debugging by right clicking on the thread in the thread window (right side, bottom most likely) and selecting "Switch to thread".Most likely this is an Atlas / Windows problem and not due to the dialog. I'm not using Vista so I haven't paid much attention to any problems but I vaguely remember seeing some issues associated with it. However, if you find out it is a dialog problem let me know.
#34
08/22/2007 (5:29 pm)
New version posted. Correct path used in file browse when locating input and output files. Added ability to store your preferred paths and reload them when the dialog starts. Added button to load default paths.
#35
exec("~ui/nx/Nxinit.cs");
Once i figgured it out everything was good
exec("~/ui/NX/NXInit.cs");
10/13/2007 (10:39 pm)
only problem I had installing was this partexec("~ui/nx/Nxinit.cs");
Once i figgured it out everything was good
exec("~/ui/NX/NXInit.cs");
#36
I like the tool, very nice.
Whenever I try to import a map from L3DT it won't create the final .atlas file. I get this from the console shown below:
atlasGenerateUniqueTerrain - getting ready to generate a terrain with a unique schema...
o Opening 'starter.fps/data/terrains/korkeza.geometry.atlas' for geometry...
AtlasFile::load - loading Atlas resource 19a175c with starter.fps/data/terrains/korkeza.geometry.atlas
o Opening 'starter.fps/data/terrains/korkeza.texture.atlas' for texture data...
AtlasFile::load - loading Atlas resource 1a1b160 with starter.fps/data/terrains/korkeza.texture.atlas
o Locating geometry TOC...
o Locating texture TOC...
o Copying & registering geometry TOC...
o Copying & registering texture TOC...
o Registering config TOC...
o Creating atlas file 'starter.fps/data/terrains/korkeza.atlas'...
AtlasDeferredFile::ensureStreamWritable - switching file into writable mode... This may cause a crash if you have other copies of Torque accessing it!
o Preparing for Atlas IO...
o Generating texture schema configuration chunk...
o Copying geometry chunks...
AtlasDeferredFile::ensureStreamWritable - switching file into writable mode... This may cause a crash if you have other copies of Torque accessing it!
- Copied 21 chunks via copyChunksToTOC, stream len approx. 21256858 bytes
o Copying texture chunks...
Fatal: (c:\torque\tgea_1_0_3\engine\platform\platformmemory.cpp @ 1122) Not an allocated block!
Error, a DecalManager (197aec4) isn't properly out of the bins!
I've tried running scripts on my own to import maps, I've tried multiple maps with multiple different settings. The other parts worked, and they worked with the tool as well. Just the last part fails.
Any thoughts?
Thanks,
X~
01/21/2008 (5:23 pm)
Hello All,I like the tool, very nice.
Whenever I try to import a map from L3DT it won't create the final .atlas file. I get this from the console shown below:
atlasGenerateUniqueTerrain - getting ready to generate a terrain with a unique schema...
o Opening 'starter.fps/data/terrains/korkeza.geometry.atlas' for geometry...
AtlasFile::load - loading Atlas resource 19a175c with starter.fps/data/terrains/korkeza.geometry.atlas
o Opening 'starter.fps/data/terrains/korkeza.texture.atlas' for texture data...
AtlasFile::load - loading Atlas resource 1a1b160 with starter.fps/data/terrains/korkeza.texture.atlas
o Locating geometry TOC...
o Locating texture TOC...
o Copying & registering geometry TOC...
o Copying & registering texture TOC...
o Registering config TOC...
o Creating atlas file 'starter.fps/data/terrains/korkeza.atlas'...
AtlasDeferredFile::ensureStreamWritable - switching file into writable mode... This may cause a crash if you have other copies of Torque accessing it!
o Preparing for Atlas IO...
o Generating texture schema configuration chunk...
o Copying geometry chunks...
AtlasDeferredFile::ensureStreamWritable - switching file into writable mode... This may cause a crash if you have other copies of Torque accessing it!
- Copied 21 chunks via copyChunksToTOC, stream len approx. 21256858 bytes
o Copying texture chunks...
Fatal: (c:\torque\tgea_1_0_3\engine\platform\platformmemory.cpp @ 1122) Not an allocated block!
Error, a DecalManager (197aec4) isn't properly out of the bins!
I've tried running scripts on my own to import maps, I've tried multiple maps with multiple different settings. The other parts worked, and they worked with the tool as well. Just the last part fails.
Any thoughts?
Thanks,
X~
#37
01/22/2008 (3:18 pm)
No, sorry I'm not sure what to tell you about that error.
#38
03/03/2008 (1:24 am)
I get a "attempted to get invalid gfx device" if exec("~/ui/NX/NXinit.cs") is in canvas.cs :(
#39
03/03/2008 (4:13 pm)
George, here is how I have it in canvas.cs. Is yours similar? I'm using the dialog currently with no issues.// Common GUI's
exec("~/ui/ConsoleDlg.gui");
// exec("~/ui/ColorPickerDlg.gui");
exec("~/ui/MessageBoxOkDlg.gui");
exec("~/ui/MessageBoxYesNoDlg.gui");
exec("~/ui/MessageBoxOKCancelDlg.gui");
exec("~/ui/MessagePopupDlg.gui");
exec("~/ui/HelpDlg.gui");
exec("~/ui/RecordingsDlg.gui");
exec("~/ui/NetGraphGui.gui");
exec("~/ui/LoadFileDlg.gui");
exec("~/ui/SaveFileDlg.gui");
//
// NX extensions
//
exec("~/ui/nx/NXInit.cs"); 
Torque Owner Dennis in 3D