Have 3 DTSfiles - Different LODs - how to combine?
by David McDonald · in Artist Corner · 09/12/2009 (7:18 am) · 39 replies
I have a seris of models in DTS format, buildings mostly. And they include LOD version in DTS format.
For all I can find it seems I have to include the LOD versions from within my model program (3ds max) is this correct or is there a script/config etc that I can detail the LOD dts filenames that should be used as I move further away.
I cannot find references in the docs for this.
Cheers
For all I can find it seems I have to include the LOD versions from within my model program (3ds max) is this correct or is there a script/config etc that I can detail the LOD dts filenames that should be used as I move further away.
I cannot find references in the docs for this.
Cheers
About the author
After many years in the professional business end of the IT industry I am working with a small group of friends to enter the indie game development market.
#22
It seems to have changed a bit since my Alpha and Beta1 versions.
I now think it may be your constructor path that is bad. With new versions of T3D, the folder structure has changed. Is there a 'data' folder in your T3D project?? I 'think' that the newer versions of T3D no longer use that pathing.
I have in a 'newer' T3D tree, "art/shapes/blah", no "DATA/..." like in your TSShapeConstructor pathing. I was all assbackwards there, mea culpa. Wrong datablock...lol, with 'bad' pathing; and that would make sense; all the addMesh code is in that block of code.
Totally weird pathing in T3D....I guess.
09/16/2009 (8:55 pm)
Yes, it has been quite some time since I looked at at 'T3D' Project Tree...It seems to have changed a bit since my Alpha and Beta1 versions.
I now think it may be your constructor path that is bad. With new versions of T3D, the folder structure has changed. Is there a 'data' folder in your T3D project?? I 'think' that the newer versions of T3D no longer use that pathing.
I have in a 'newer' T3D tree, "art/shapes/blah", no "DATA/..." like in your TSShapeConstructor pathing. I was all assbackwards there, mea culpa. Wrong datablock...lol, with 'bad' pathing; and that would make sense; all the addMesh code is in that block of code.
Totally weird pathing in T3D....I guess.
#23
\game\art\shapes\....
\game\art\datablocks\.....
etc.
I removed the DATA dir from the path as per above
09/16/2009 (8:59 pm)
Yeah the actual tree is:\game\art\shapes\....
\game\art\datablocks\.....
etc.
I removed the DATA dir from the path as per above
#24
# {
# baseShape = "./castle_gate_1.dts";
# };
#
# function CastleGateTSSC1::onLoad(%this)
# {
#
# // print the names of all meshes in the shape
# %objCount = %this.getObjectCount();
# for (%i = 0; %i < %objCount; %i++)
# {
# %objName = %this.getObjectName(%i);
# %meshCount = %this.getMeshCount(%objName);
# for (%j = 0; %j < %meshCount; %j++)
# echo("'" @ %this.getMeshName(%objName, %j) @ "'");
# }
# %this.setMeshSize("Mesh Object", 1024);
# %this.addMesh("castle_gate_lod1.dts", "Mesh Object", "CastleGate512");
# %this.addMesh("castle_gate_lod2.dts", "Mesh Object", "CastleGate256");
# %this.dumpShape("./dump.txt");
# }
what happens if you remove the 'pathing' from the string in addMesh,as above?
09/16/2009 (9:03 pm)
# singleton TSShapeConstructor(CastleGateTSSC1) # {
# baseShape = "./castle_gate_1.dts";
# };
#
# function CastleGateTSSC1::onLoad(%this)
# {
#
# // print the names of all meshes in the shape
# %objCount = %this.getObjectCount();
# for (%i = 0; %i < %objCount; %i++)
# {
# %objName = %this.getObjectName(%i);
# %meshCount = %this.getMeshCount(%objName);
# for (%j = 0; %j < %meshCount; %j++)
# echo("'" @ %this.getMeshName(%objName, %j) @ "'");
# }
# %this.setMeshSize("Mesh Object", 1024);
# %this.addMesh("castle_gate_lod1.dts", "Mesh Object", "CastleGate512");
# %this.addMesh("castle_gate_lod2.dts", "Mesh Object", "CastleGate256");
# %this.dumpShape("./dump.txt");
# }
what happens if you remove the 'pathing' from the string in addMesh,as above?
#25
Appears dropping the ./ off the paths doesn't help.
09/16/2009 (9:09 pm)
ok now we get:Exporting server prefs... getMeshCount: Could not find object 'Mesh Object' TSShape::setMeshSize: Could not find mesh 'Mesh Object' Resource<TSShape>::create - Could not open 'castle_gate_lod1.dts' Failed to create resource: [castle_gate_lod1.dts] addMesh failed: Could not load source shape: 'castle_gate_lod1.dts' Resource<TSShape>::create - Could not open 'castle_gate_lod2.dts' Failed to create resource: [castle_gate_lod2.dts] addMesh failed: Could not load source shape: 'castle_gate_lod2.dts'
Appears dropping the ./ off the paths doesn't help.
#26
I did try with the underscore previously and same errors of not finding the mesh appeared but I'll have a go with the collada files and using the cached DTS files after conversion.
watch this space :-)
09/16/2009 (9:26 pm)
I'm going to try a slightly different approach. I have Collada versions of the files as well and reading those I can see the names of the mesh as Mesh_Object.I did try with the underscore previously and same errors of not finding the mesh appeared but I'll have a go with the collada files and using the cached DTS files after conversion.
watch this space :-)
#27
I'm getting a response now from the meshname interrogation
Mesh_Object2
However the addmesh commands are crashingthe app when I start it now so have commented them out and will check the mesh names ofthe LOD models to see if that's the hassle.
09/16/2009 (9:40 pm)
ok small success.I'm getting a response now from the meshname interrogation
Mesh_Object2
However the addmesh commands are crashingthe app when I start it now so have commented them out and will check the mesh names ofthe LOD models to see if that's the hassle.
#28
1. Used the DAE files and renamed the cached.dts version to the above names.
2. I recieved the console report that the scene was not Toruw so it added a dummy node and detail level2 (Indicating a problem up front if the manufacturer of the model didn't structure the nodes right before exporting DTS versions)
3. Ran the system up and got the dump.txt to report the changed mesh size however if I have the addmessh commands uncommented then the game crashes before anything comes up.
4. Tried repeating the process with the LOD versions with no success.
5. Checked the LOD DAE files and all three DAE files use Mesh_Object
Final script which crashes:
If I comment out the addmesh lines then the system runs up and I get a dump.txt showing the Mesh_Object resized to detail 1024
Uncomment the AddMesh lines and the system crashes before anything comes up. (I am assuming at the point the datablock loads this object up and therefore when this script is executed).
Last ditch suggestions anyone?
I'm expecting remodel time is rapidly approaching....
And Rex, Chris, et al, many thanks for helping with this one.
09/17/2009 (12:03 am)
OK, I'm beaten ;-(1. Used the DAE files and renamed the cached.dts version to the above names.
2. I recieved the console report that the scene was not Toruw so it added a dummy node and detail level2 (Indicating a problem up front if the manufacturer of the model didn't structure the nodes right before exporting DTS versions)
3. Ran the system up and got the dump.txt to report the changed mesh size however if I have the addmessh commands uncommented then the game crashes before anything comes up.
4. Tried repeating the process with the LOD versions with no success.
5. Checked the LOD DAE files and all three DAE files use Mesh_Object
Final script which crashes:
singleton TSShapeConstructor(CastleGateTSSC1)
{
baseShape = "./castle_gate_1.dts";
};
function CastleGateTSSC1::onLoad(%this)
{
echo("Counting meshes");
// print the names of all meshes in the shape
%objCount = %this.getObjectCount();
for (%i = 0; %i < %objCount; %i++)
{
%objName = %this.getObjectName(%i);
%meshCount = %this.getMeshCount(%objName);
for (%j = 0; %j < %meshCount; %j++)
echo("'" @ %this.getMeshName(%objName, %j) @ "'");
}
%this.setMeshSize("Mesh_Object", 1024);
%this.addMesh("./castle_gate_LOD1.dts", "Mesh_Object", "CastleGate512");
%this.addMesh("./castle_gate_LOD2.dts", "Mesh_Object", "CastleGate256");
%this.dumpShape("./dump.txt");
}If I comment out the addmesh lines then the system runs up and I get a dump.txt showing the Mesh_Object resized to detail 1024
Uncomment the AddMesh lines and the system crashes before anything comes up. (I am assuming at the point the datablock loads this object up and therefore when this script is executed).
Last ditch suggestions anyone?
I'm expecting remodel time is rapidly approaching....
And Rex, Chris, et al, many thanks for helping with this one.
#29
Still crashes. Windows error doesn't shed any light.
09/17/2009 (12:07 am)
And just for kicks in case the AddMesh wants the same mesh name used I tried this:....
%this.setMeshSize("Mesh_Object", 1024);
%this.addMesh("./castle_gate_LOD1.dts", "Mesh_Object", "Mesh_Object512");
%this.addMesh("./castle_gate_LOD2.dts", "Mesh_Object", "Mesh_Object256");
%this.dumpShape("./dump.txt");
}Still crashes. Windows error doesn't shed any light.
#30
Aside from that though, it seems like there is something odd going on with these models. 'getObjectName' returns "Mesh Object", but then this name does not work when trying to find a mesh.
Could you send me the 3 DTS files? I will have a poke into the code to see what is going wrong.
09/17/2009 (10:01 pm)
@David - This was with beta5, right? There was a bug in the addMesh command with earlier versions that would crash if you added a skinned mesh, but I've tested that this was working in beta5 in the past.Aside from that though, it seems like there is something odd going on with these models. 'getObjectName' returns "Mesh Object", but then this name does not work when trying to find a mesh.
Could you send me the 3 DTS files? I will have a poke into the code to see what is going wrong.
#32
There were 2 separate issues here; the first I consider an error in the DTS export. The DTS format stores strings used by the shape in an array which indexed by the various shape elements. So for example, a node might have nameIndex=3, which means the node's name is at string index 3.
Torque takes advantage of this feature to speed up looking for a particular node or object by name. Say we're searching for the "Mesh Object" object. Torque looks through the string array for the index of the "Mesh Object" string. If found, Torque looks through all the objects for one with a matching nameIndex.
The problem with your DTS files is that the strings in the array are not unique. There are two instances of "Mesh Object"; one used by a node and one used by an object. So when Torque goes looking for the "Mesh Object" object, it finds the index of the node string (since that just happens to be first) and then it can't find an object with matching nameIndex! Doh!
One could argue that Torque should handle this, but I really think it is a bug in the export of the DTS files. It can be 'hacked' around by manually editing the DTS file and changing one of the "Mesh Object" strings. If you do this, make sure to keep the length of the string the same. Changing one of them to "MeshObjNode" for example would be ok, but "Mesh Object2" would not work (because of the way the DTS format stores strings).
Quite separately, there is a bug in beta5 that causes a crash when adding a mesh using TSShapeConstructor (this is the one you see when you tried to use Collada). I have fixed this in trunk and it will be available in the upcoming release.
09/19/2009 (10:51 pm)
@David:There were 2 separate issues here; the first I consider an error in the DTS export. The DTS format stores strings used by the shape in an array which indexed by the various shape elements. So for example, a node might have nameIndex=3, which means the node's name is at string index 3.
Torque takes advantage of this feature to speed up looking for a particular node or object by name. Say we're searching for the "Mesh Object" object. Torque looks through the string array for the index of the "Mesh Object" string. If found, Torque looks through all the objects for one with a matching nameIndex.
The problem with your DTS files is that the strings in the array are not unique. There are two instances of "Mesh Object"; one used by a node and one used by an object. So when Torque goes looking for the "Mesh Object" object, it finds the index of the node string (since that just happens to be first) and then it can't find an object with matching nameIndex! Doh!
One could argue that Torque should handle this, but I really think it is a bug in the export of the DTS files. It can be 'hacked' around by manually editing the DTS file and changing one of the "Mesh Object" strings. If you do this, make sure to keep the length of the string the same. Changing one of them to "MeshObjNode" for example would be ok, but "Mesh Object2" would not work (because of the way the DTS format stores strings).
Quite separately, there is a bug in beta5 that causes a crash when adding a mesh using TSShapeConstructor (this is the one you see when you tried to use Collada). I have fixed this in trunk and it will be available in the upcoming release.
#33
With the crash-bugfix in trunk, I get a single object with 3 LODs as expected. The dump.txt output is:
09/19/2009 (11:26 pm)
For reference, I changed the first instance of the "Mesh Object" string in each DTS file to "MeshObjNode", and used the following TSShapeConstructor script:singleton TSShapeConstructor(CastleGateTSSC1)
{
baseShape = "./castle_gate_1.dts";
};
function CastleGateTSSC1::onLoad(%this)
{
%this.setMeshSize("Mesh Object32", 1024);
%this.addMesh("./castle_gate_LOD1.dts", "Mesh Object32", "Mesh Object512");
%this.addMesh("./castle_gate_LOD2.dts", "Mesh Object32", "Mesh Object256");
%this.dumpShape("./dump.txt");
}With the crash-bugfix in trunk, I get a single object with 3 LODs as expected. The dump.txt output is:
Shape Hierarchy:
Details:
detail1024, Subtree 0, objectDetail 0, size 1024
detail512, Subtree 0, objectDetail 1, size 512
detail256, Subtree 0, objectDetail 2, size 256
Subtrees:
Subtree 0
MeshObjNode
Skins:
Skin Mesh Object with following details: 1024 512 256
Sequences:
0: Untitled
Material list:
material #0: 'STONE_2'.
material #1: 'STONE_3'.
material #2: 'WOOD_5'.
material #3: 'stone_2'.
material #4: 'stone_3'.
material #5: 'wood_5'.
material #6: 'LOD_castle_gate'.
#34
Glad it wasn't just me then!
Rather than hack away at the DTS files though I think I'll just work on the original files in Max and export the LODs correctly.
This does have the added advantage that any other modifications we need to make won't fall foul of improperly exported DTS files as well..
Great work and thanks for the investigation
DM
09/20/2009 (1:35 am)
Excellent work thanks Chris.Glad it wasn't just me then!
Rather than hack away at the DTS files though I think I'll just work on the original files in Max and export the LODs correctly.
This does have the added advantage that any other modifications we need to make won't fall foul of improperly exported DTS files as well..
Great work and thanks for the investigation
DM
#35
09/20/2009 (12:40 pm)
What program will open DTS files so that I can manually edit them, please?
#36
Any text or hex editor. When I say manually edit, I mean it! :-)
09/20/2009 (8:14 pm)
Quote:What program will open DTS files so that I can manually edit them, please?
Any text or hex editor. When I say manually edit, I mean it! :-)
#37
09/20/2009 (10:35 pm)
When I open a DTS in HxD hex editor, the hex codes come up fine, but the ascii is all garbled. Any idea what I might be doing wrong?
#38
Changing anything else in a DTS file by hand is not recommended!
09/20/2009 (11:24 pm)
Unlike collada (which is just XML), DTS is a binary file format. The only section that is easily readable is the list of strings near the end of the file. In the very specific case of editing one of these strings, any text or hex editor is suitable.Changing anything else in a DTS file by hand is not recommended!
#39
09/21/2009 (12:18 am)
Ok, I see that now. I think I'll take your advice and stay away from this, however. Thanks for the info.
David McDonald
Bad Uncle Games
Numerous errors about not being able to open the file whane I tried alternatives.
Errors dissapeared when I reverted to the original:
datablock StaticShapeData(CastleGate1Data) { category = "Misc"; shapeFile = "art/shapes/dexsoft/castle_gate_1.dts"; };The system pre-pends C:TorqueTorque 3D 2009 Beta 5My ProjectsAlbagame to whatever path I put in the shapefile section
When I tried other alternatives (such as /game/art/shapes/dexsoft/castle_gate_1.dts) it complained about failing to open:
C:TorqueTorque 3D 2009 Beta 5My ProjectsAlbagamegameartshapesdexsoftcastle_gate_1.dts
So the datablock path seems ok as I don't get any complaints and it creates the object under misc when I put the original path as per above.
Once that is done I still get the cannot open mesh errors.
Current scripts:
datablock StaticShapeData(CastleGate1Data) { category = "Misc"; shapeFile = "art/shapes/dexsoft/castle_gate_1.dts"; };In the dexsoft dir
singleton TSShapeConstructor(CastleGateTSSC1) { baseShape = "./castle_gate_1.dts"; }; function CastleGateTSSC1::onLoad(%this) { // print the names of all meshes in the shape %objCount = %this.getObjectCount(); for (%i = 0; %i < %objCount; %i++) { %objName = %this.getObjectName(%i); %meshCount = %this.getMeshCount(%objName); for (%j = 0; %j < %meshCount; %j++) echo("'" @ %this.getMeshName(%objName, %j) @ "'"); } %this.setMeshSize("Mesh Object", 1024); %this.addMesh("./castle_gate_lod1.dts", "Mesh Object", "CastleGate512"); %this.addMesh("./castle_gate_lod2.dts", "Mesh Object", "CastleGate256"); %this.dumpShape("./dump.txt"); }