Page 1 of 2

Model Tool Updates

Posted: Thu Sep 27, 2007 11:38 pm
by JeffM
Ok so with all the research I did to help people understand draw info, I went ahead and updated model tool to generate draw info meshes if you want it to. Complete with support for LOD.

A windows build of model tool 1.8.4 can be found at;
http://beta.bzflag.bz/builds/tools/mode ... _1.8.4.zip

Optic Delusion has been kind enough to provide an intel mac build
http://beta.bzflag.bz/builds/tools/mode ... _1.8.4.zip

Linux and OSX users can build modeltool from the sources in the current development trunk of the bzflag source code ( see http://my.bzflag.org/w/BZFlag_SVN for info on how to get the code ). Model tool is fully cross platform, it is NOT windows only.

To generate a draw info mesh, modeltool needs more info then just a single obj file, so what you have to do is pass it a "diconf" file. This is just a text file with it's extension changed to diconf. In this file you refrence one or more obj files to import and tell model tool how to use it.

I've attached a sample config file as well as a bzw file generated by the tool ( the tank spinning ).

Please let me know if you have any questions, or find any bugs. This is new code, and has only been briefly tested by me.

This update supports static geometry ( as normal mesh faces ), invisible bounding geometry ( as normal mesh faces ), LOD meshes ( as triangle lists or polygons ), and animation commands for the LOD geometry. It does not support triangle strips or fans, or any of the other extended draw info commands. It also requires an OBJ file for each LOD level, it will not generate them for you.

Update Notes:

1.8.0 : First draw info release.
1.8.1 : Bug fixes and material updates for draw info after initial testing.
1.8.2 : Support global shift and scale in all input models, and for draw info bounds computation.
1.8.3 : Change default behavor to NOT compute Draw Info bounds and sphere, so BZ can compute them.
1.8.4 : Options to output comments in the BZW file with index IDs.

Posted: Fri Sep 28, 2007 5:37 pm
by JeffM
Optic Delusion has been kind enough to provide an Intel mac build and I have uploaded it to

http://beta.bzflag.bz/builds/tools/mode ... _intel.zip

I also moved the windows build to the same directory so it can be found at

http://beta.bzflag.bz/builds/tools/modeltool_1.8.zip

Posted: Fri Sep 28, 2007 5:47 pm
by anomaly
Here are the diconfig and obj file I tried to convert to drawInfo.
command line:
$ modeltool bztank.diconf
diconf file bztank.diconf converted to BZW as bztank.bzw
$ ls
bztank.diconf
bztank.mtl
bztank.obj

didn't output the .bzw

Posted: Fri Sep 28, 2007 7:43 pm
by anomaly
I'm having intermittent success with it. I managed to get output from another obj file after repeated attempts. The diconf was :

anim "angvel 40"
lod 0 "objectfile.obj"

It seems that the anim command isn't getting to the drawInfo output, but is needed to make the app work? Without anim command I could not get output.

When it works its great! Thanks.

Posted: Fri Sep 28, 2007 7:49 pm
by JeffM
you actually found a real bug. the parser for the diconf files wasn't handling unix line endings right. I have updated the windows binary with the fix ( the source is in svn ). I'll see if I can new mac builds as well.

Posted: Fri Sep 28, 2007 7:57 pm
by anomaly
Thanks! :D I'll update and recompile.

Posted: Fri Sep 28, 2007 8:17 pm
by anomaly
maybe one more, line 442 in modeltool.cxx, shouldn't that be

Code: Select all

 if (!meshes.valid()) 
it's

Code: Select all

 if ( meshes.valid()) 
on my copy.

That was confusing the hell outa me, kept saying "no valid meshes...", but the .bzw was there. :?

Posted: Fri Sep 28, 2007 8:26 pm
by JeffM
yes that has also been fixed in a recent code update.

Posted: Fri Sep 28, 2007 8:47 pm
by anomaly
Line: 896
section += mesh.faces[0].material;

not
section += mesh.faces[0].material.size();

OK I'll stop

honestly though, its a heluva good job! We've been wanting this for awhile.

Posted: Fri Sep 28, 2007 9:22 pm
by JeffM
fixed.

Posted: Fri Sep 28, 2007 11:15 pm
by JeffM
model tool has been updated to 1.8.1 to address some of the issues found in testing.

Posted: Wed Oct 24, 2007 3:13 pm
by optic delusion
This is working well, but we have some problems.

Inevitably after exporting with angvel, we need to make some changes to the object to make it fit into the map. I might move the object around with a group, or even change the vertices. This has a tendency to invalidate the extents and sphere numbers. We need a way to generate new extents including shift in the group, without making a new obj-to bzw export. We need an actual formula.

I would also like to see a conf option to #number each v/n/t and corner, to help in later editing.

Posted: Wed Oct 24, 2007 5:23 pm
by JeffM
technically you have the "formula" since you have the code, but it's prety simple

find the largest and smallest value for X Y and Z ( each independently )

For each one, subtract the min from the max, and divide it by 2
add that value to the min. That is the center point in that axis, and the value is the distance to the bounds in that axis

When you have all all 3 axes, you have the full center point just do the square root of the X distance squared, + the Y distance squared + the Z distance squared, and that is your sphere radius.

If the mesh object is in a group, then the sphere you define is relative to the group, so you should not have to modify the bounds or the sphere based on where the group is ( if it does not work like this, I call that a bug, since you may have more then one instance of the group )

I see that that bounding code in model tool doesn't take the global shift and scale into account. I've fixed that bug in the current code for 2.1. The shift and scale are now applied when the model is read in.

Posted: Wed Oct 24, 2007 5:33 pm
by JeffM
Note, a windows build with the recent fixes has been posted as 1.8.4 ( see the first message in this thread ).

little tutorial

Posted: Wed Oct 24, 2007 7:18 pm
by optic delusion
The mac build in the above download has been updated as well, to 1.8.4

There's nothing about modeltool on the wiki, if some one adds that, you'd be doing mappers a gigantic favor. In the meantime, I'll give my little "how to"

1. Jeff provides builds of modeltool, get the correct one for your system, and a copy of example.diconf. Place them in a new folder.
2. Into the same folder place your .obj file. The ENTIRE object should be texture mapped.
3. Edit the diconf so it references your .obj file.
3a. The line "lod 0" is the only one you really need to start experimenting with drawinfo. put your filename there. For now leave "bounding" and "static" with double-slash // C++ style comment markers.
3b. You can add angvel if you want motion, 40 is a good number.
4. Open your terminal and cd to the folder you created.
5. run this command ./modeltool example.diconf
6. A .bzw will be created, named after the .diconf. Load it into bzfs.

Posted: Tue Oct 30, 2007 2:09 pm
by optic delusion
This is becoming much easier now. You don't need to know the mysteries of how to make drawinfo map objects, it's all done for you. Once modeltool is set up with a diconf, I just make an .obj, run it through modeltool, then place it in my bzw. It works pretty much like any other object, especially if i wrap it in a define and place with a group.
Jeff, it it could wrap the generated bzw object in a define for me, that would save a lot of copy-paste operations, there would be no need to open the modeltool'd bzw at all, thanks to the include function.

I haven't delved into LOD much, yet. Is the diconf command "lod 0.2 "lowerResFile.obj"" repeatable for multiple LODs?
Tedius's di-machine script has it's uses. It is doing tristrips, quadstrips and trifans, as well as very sloppy automatic vertex decimation for LOD. He just skips every other corner in further LODs. (As opposed to modeltool's correct method, where a second obj must be generated by the mapper, and fed into modeltool.) The easier but sloppy method appears to be sufficient for complex meshes, at first blush, as long as I use a LengthPerPixel greater than .5

Posted: Tue Oct 30, 2007 4:58 pm
by JeffM
add -g GROUP_NAME and it'll put it in a define.

Posted: Tue Oct 30, 2007 7:55 pm
by Tedius
Optic Delusion wrote:very sloppy automatic vertex decimation for LOD. He just skips every other corner in further LODs. (As opposed to modeltool's correct method,
I don't mean to hijack the thread, but I want to clear up the misconception about my baby. dI-machine does not include any decimation, sloppy or otherwise. I wouldn't attempt to create something that even the best 3D modeling software can't do right. It only includes instructions in the output for where to copy and paste other LODs. Similar to modeltool, it is up to the mapper to make multiple lower resolution models.

Now back to your regularly scheduled Modeltool Topic.

Posted: Mon Jan 21, 2008 2:53 am
by Abominable
I don't mean to break disscusion, but all I really use is notepad and codes.
Is this userfriendly and easy to use, or is it going to take time to adapt?

Posted: Mon Jan 21, 2008 3:02 am
by optic delusion
Modeltool takes files in .obj-format, and converts them into .bzw format.
I suppose it's possible to create obj format files in text editors, but that is extremely difficult.
You are going to need some kind of 3D editor, that can export to obj format.

Using modeltool is very easy, once you know how it works.
http://mybzflag.net/?p=296#comments

Posted: Mon Jan 21, 2008 3:55 am
by Abominable
Where can I get it?
Both of the links above are dead.

Posted: Mon Jan 21, 2008 4:01 am
by optic delusion
Are you looking at the top post in this thread? they seem live to me.

Posted: Mon Jan 21, 2008 4:03 am
by Abominable
Hmm.
Now they're working.
That was odd :P
Thanks!

Posted: Sat Feb 16, 2008 1:49 am
by Anthony
i think this is a bug i try to open it it runs for a seccond then closes

Posted: Sat Feb 16, 2008 5:39 am
by blast
This is not a utility with a GUI. You run it from the command line and pass parameters to it.