Game Development Community

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
Page «Previous 1 2
#1
09/12/2009 (10:00 am)
you do that in max..

Torque's 3ds max artist documentation:


------------------------------------------------------------------
Subtrees and Level of Detail:

A subtree is a dummy object at the scene root level with the following types of children: at least one detail level marker (an object whose name ends in a number), and at least one branch (a dummy object with children that have geometry somewhere in the sub-hierarchy).

The detail level markers indicate to the exporter what detail is to be drawn at a given distance. The number corresponds to the pixel size in the game engine at which the shape will draw with these meshes.

E.g., if you have markers named 'detail2' and 'detail36', then when the size is 36 or greater the shape would be drawn with the highest detail level. When the size is between 2 and 36 it would be drawn with the lower detail level ending with the number 2, and when the size was less than 2 nothing would draw.

The name of the marker is unimportant (except the number, of course) but it does get exported and can be used to look up a detail level by the programmer. What lies under the "branch" corresponds to the actual shape. The whole subtree can be under one branch or there can be multiple branches. If you have a shape at the root level and want to export it, the following arrangement should suffice:

An object on the root level will normally be interpreted as a mesh (a detail level) or a subtree (unless it's the bounds node or a sequence object).

If the object has geometry, then it will be interpreted as a mesh. If this mesh does not correspond to any mesh on the shape, it will be flagged as an error unless 'Allow Unused Meshes' is turned on in the Error Control sub-panel of the exporter utility. If "unused meshes" are allowed, then the mesh will be ignored.

If an object on the root level has no geometry (if it's a dummy object, for example) it will be interpreted as a subtree. If it has no detail markers or branches, then it will be flagged as an error unless 'Allow Empty Subtrees' is turned on (in the Error Control sub-panel of the exporter utility panel). If empty subtrees are allowed, then the object will be ignored.
------------------------------------------------------------------
Unlinked Meshes and Level of Detail:

In the exporter there is generally only one subtree (although it supports more if desired) and the artist must supply a different set of meshes to be drawn for each detail level.

This is done by naming different detail levels of the same mesh with the same base name but a different trailing number. E.g., 'head64' and 'head32'. The numbers in the detail level should correspond to the number on the 'detail marker' (see section 'Subtrees').

One detail level of the mesh needs to be linked to the shape in the appropriate place; the other detail levels of the mesh should be unlinked. During export, these unlinked meshes are collected and added to the shape at the appropriate location.

In a 3DSMAX scene we only have one set of meshes linked to the shape at a time, so we need some convention for including in the file other meshes that correspond to lower detail levels.

This is done by leaving meshes that belong to other detail levels unlinked. Furthermore, they must be named just like the meshes that are attached to the shape, except they should end in a different detail number (if in the shape you have a mesh named 'head' or 'head64', then the unlinked version of that mesh that will be drawn for detail level 32 must be called head32).

During export, these loose meshes are collected and added to the shape at the appropriate location.
------------------------------------------------------------------
www.garagegames.com/documentation/artist
#2
09/12/2009 (9:23 pm)
Thanks mate,
I have read that I was more curious if there was an external to MAX method of assigning the LODs.
Basically we have a few commercial model sets with some LOD's but they don't conform to this even though we have DTS version.
I have for example:
bridge.dts
bridge_lod.dts

And was looking for how I could use the LOD without having to open the MAX versions of the models and build the LOD in from there.
Looks like I'll need to do that though

Thanks.

#3
09/12/2009 (11:45 pm)
I really don't know David, I have not looked into that scenario...it may be possible.
#4
09/13/2009 (12:03 pm)
You can do this with the TSShapeConstructor.

Take a look at the documentation here:

docs.garagegames.com/torque-3d/official/

under, Artist Section/TSShapeConstructor
#5
09/13/2009 (7:11 pm)
Champion,
Exactly what I was after many thanks mate.
Glad someone knows their way around the doco

Thanks Jaimi
#6
09/13/2009 (10:45 pm)
Ok, Pretty sure I follow the TSShapeConstructor information however still not seeing the results so it must be my unfamiliarity with the system.

Here's what I have:

DatablockExec.cs I have inserted this:
exec("./castle_gate_1.cs");
in the castle_gate_1.cs file located in the datablock dir:
datablock StaticShapeData(CastleGate1)
{
   category = "Misc";
   shapeFile = "art/shapes/dexsoft/castle_gate_1.dts";
};
Then in the directory where my shape files are I have castle_gate_1.cs:
singleton TSShapeConstructor(CastleGateTSSC1)
{
   baseShape = "~/data/shapes/dexsoft/castle_gate_1.dts";
};

function CastleGateTSSC1::onLoad(%this)
{
   //%this.renameNode("Mesh Object", "castlegate");
   %this.setMeshSize("Skin Mesh 0", 1024);
   %this.addMesh("castle_gate_lod1.dts", "Mesh Object", "CastleGate512");
   %this.addMesh("castle_gate_lod2.dts", "Mesh Object", "CastleGate256");
   %this.dumpShape("./dump.txt");
   %this.saveShape("./castlegate_1.dts");
}
#7
09/14/2009 (4:24 am)
I assume you are trying to combine 3 separate DTS files to get 3 detail levels for a single mesh?

If so, a couple of things stand out:

1. The first line in the onLoad method changes the size of the mesh "Skin Mesh 0". That is, a mesh of size 0 of the object "Skin Mesh". But then the addMesh commands specify an entirely different object: "CastleGate" with sizes 512 and 256.

2. The addMesh commands both specify a source mesh of "Mesh Object", but no size is given. Is this right?

What does the output of the dumpShape function look like (ie. the contents of dump.txt)? Do you see any warnings/errors in the console when the shape loads?
#8
09/14/2009 (8:02 am)
You assume correctly!

I have three files:
castle_gate_1, castle_gate_lod1, castle_gate_lod2

each has the Mesh Object (with no numbers) shown as follows in showtool Pro TSDump:
Quote:
Shape Heierachy:
Details:
detail-1, Subtree 0, objectDetail 0, size 32

Subtrees:
Subtree 0
Mesh Object

Skins
Skin Mesh Object with the following details: 32

All three files have the same information except the texture section.
I did change the Skin Mesh to Mesh Object and still no luck.
Strangely enough dumpShape doesn't appear to be outputting anything to a text file or console and there are no errors in the console either.






#9
09/14/2009 (11:36 am)
Could it be because you have the datablock 'name' differing from the singleton 'name'??? What about the bad path in the first argument[no path at all?!] string?? Isn't the engine looking for the mesh 'Group' name?? and not that it's a 'meshObject', since all meshes are 'objects' to the engine??

Just getting back into T3D, Collada and TSShapeConstructor.....thanks; got a lot of catching up to do!

Great Job, Chris!


For example: here's from the documentation...

%this.addMesh("./collision.dts", "ColMesh-1", "Col-1");

...notice how the path argument shows an actual path to the art,
...notice how the Scr object to use has it's skin/object 'name' and not it's 'class'.

Now, your example:...
%this.addMesh("castle_gate_lod1.dts", "Mesh Object", "CastleGate512");

I see a few differences from the provided example in the documentation. OH, this only works in the T3D engine....

Am I far off, Chris?!?
#10
09/14/2009 (8:51 pm)
Quote:each has the Mesh Object (with no numbers) shown as follows in showtool Pro TSDump

OK. That is the first problem. When you use the 'setMeshSize' or 'addMesh' commands, you need to specify the full mesh name. This will be made up of an object name ("Mesh Object" in your case), and a detail size (32 in your case). The detail size is required because the object could have multiple details and you need to tell 'addMesh' which one you want to use.

The last argument to the 'addMesh' command is the name of the destination mesh; again a combination of the object name and detail size.

Based on that, I think your onLoad method should look like this:

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");
  %this.saveShape("./castlegate_1.dts");
}

Quote:Strangely enough dumpShape doesn't appear to be outputting anything to a text file or console and there are no errors in the console either.

The TSShapeConstructor::onLoad method is not being run because there is an error in your shape path. The StaticShapeData datablock has path "art/shapes/dexsoft/castle_gate_1.dts" but the TSShapeConstructor object has path "~/data/shapes/dexsoft/castle_gate_1.dts".
#11
09/14/2009 (8:57 pm)
@Rex:
Quote:Could it be because you have the datablock 'name' differing from the singleton 'name'???

No!. You should never have 2 Torque objects with the same name. The 'link' if you like between the StaticShapeData and TSShapeConstructor is the path to the shape file.

The objects aren't really 'linked' though. What happens is that TSShapeConstructor modifies the loaded DTS file in-memory. When the StaticShapeData object attempts to load the DTS file, the Torque ResourceManager sees that it is already loaded into memory and gives it the modified shape.
#12
09/15/2009 (1:15 am)
Chris,
Many thanks for the advice. I got a step closer but this is doing my head in a little ;-) The paths were stopping the script.

Current 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");
  //%this.saveShape("./castlegate_1.dts");
}

So, now in the console I get is shows that it can't find the meshes:
TSShape::setMeshSize: Could not find mesh 'Mesh Object32'
TSShape::addMesh: Could not find mesh 'Mesh Object32' in shape
TSShape::addMesh: Could not find mesh 'Mesh Object32' in shape

Now this gives a result in dump.txt but it's no different to the basic castle_gate_1.dts

Shape Hierarchy:

   Details:
      Detail-1, Subtree 0, objectDetail 0, size 32

   Subtrees:
      Subtree 0
         Mesh Object

   Skins:
      Skin Mesh Object with following details:  32


   Sequences:
        0: Untitled

   Material list:
   material #0: 'STONE_2'.
   material #1: 'STONE_3'.
   material #2: 'WOOD_5'.


I thought perhaps I'm not using the right names for meshes etc. I'm still getting across the DTS structure so here is the tree view in ShowtoolPro

Details
detail-1 Size: 32

Subshapes
Subshape 0
Mesh Object

Skins
Mesh Object
Skin Mesh 0 Detail: detail-1 Size: 32
#0 STONE_2
#1 STONE_3
#2 WOOD_5



#13
09/15/2009 (4:19 am)
It certainly looks like the skin object is called "Mesh Object" and the only mesh in this object has size = 32. Could you try adding this to the top of the onLoad method as an experiment? It should print out the names of all the meshes in the shape (you can then use this knowledge to correct the parameters in the setMeshSize and addMesh functions.

// 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) @ "'");
}
#14
09/15/2009 (6:37 am)
Thanks, Chris...Threads like this are very helpful, indeed.

Quote:The 'link' if you like between the StaticShapeData and TSShapeConstructor is the path to the shape file.

...sounds good, and logical. Here are the two 'paths' I see in the above Datablocks:

"~/data/shapes/dexsoft/castle_gate_1.dts" = TSShapeConstructor path to art

"art/shapes/dexsoft/castle_gate_1.dts" = StaticShape path to art

They appear to not be the same asset location, is this causing glitches??? The Static Shape path, just seems wrong, doesn't start with /, ~, or .; is this correct?
#15
09/15/2009 (7:42 am)
Righto...
I may be wrong but I'm wondering if there is something amiss in the model
I get this after adding the code Chris.
getMeshCount: Could not find object 'Mesh Object'
#16
09/16/2009 (7:53 pm)
Can you provide the DTS shapes to evaluate??

Yes, I would tend to agree, with the assessment on the art. That mesh name is not working....the mesh has to have a name....

I also think the path to the art is incorrect in the StaticShape data block....?? How is your Project Tree setup? the folder hierarchy??

. = start of path from where script is executed
~ = start of path from MOD folder
/ = start of path from Root main.cs folder


....Is 'art' a name of a MOD in your project?!?
#17
09/16/2009 (8:16 pm)
Certainly.
The licence obligates me to point out you need to trash them after fiddling since they're only licenced to our team but appreciate any assistance you can offer:



the tree is artshapesdexsoft
All the files reside in there.

Current script uses ./ inside the .cs file which also resides in there
#18
09/16/2009 (8:19 pm)
Sure....I don't keep art I've helped with for any reason beyond educational. I'll take a lookie-loo right away...just got home from a short day.

Ya...sure 'seems' as though the mesh geometry is named "Mesh Object", wonder if the whiteSpace between Mesh & Object is causing problems...also think you need to fix the path to the art in the Static Shape data block.

Where is the StaticShape script being executed from? the same Dexsoft folder?

...if all scripts and art are in same folder....keep the path the same in both datablocks...I think that is our key, the static shape datablock's path and where the script is located.
#19
09/16/2009 (8:28 pm)
Thanks Rex.
I'll have a look at the path and give it another go.
If the space causes an issue I guess I have to resign myself to taking the models back into Max (I have .obj, .3ds versions as well in the pack)
#20
09/16/2009 (8:30 pm)
Start with the pathing....don't reexport art until the last resort! Let's get this solved...!!
Page «Previous 1 2