Model Tool Updates

Discussion, updates, modifications, etc for the various map editors...
User avatar
JeffM
Staff Sergeant
Staff Sergeant
Posts: 5196
Joined: Fri Dec 13, 2002 4:11 am

Model Tool Updates

Post 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.
Attachments
example.diconf.zip
sample config file with notes.
(887 Bytes) Downloaded 496 times
tank.bzw
a sample mesh that uses draw info.
(23.54 KiB) Downloaded 464 times
Last edited by JeffM on Wed Oct 24, 2007 11:22 pm, edited 5 times in total.
ImageJeffM
User avatar
JeffM
Staff Sergeant
Staff Sergeant
Posts: 5196
Joined: Fri Dec 13, 2002 4:11 am

Post 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
ImageJeffM
anomaly
Private First Class
Private First Class
Posts: 220
Joined: Tue Jul 26, 2005 10:32 pm
Location: Gainesville Florida

Post 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
Attachments
bztank.diconf.txt
the diconf file
(1.59 KiB) Downloaded 484 times
bztank.obj.txt
The obj file
(232.17 KiB) Downloaded 390 times
bztank.mtl.txt
The mtl file, just in case
(231 Bytes) Downloaded 401 times
anomaly
Private First Class
Private First Class
Posts: 220
Joined: Tue Jul 26, 2005 10:32 pm
Location: Gainesville Florida

Post 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.
User avatar
JeffM
Staff Sergeant
Staff Sergeant
Posts: 5196
Joined: Fri Dec 13, 2002 4:11 am

Post 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.
ImageJeffM
anomaly
Private First Class
Private First Class
Posts: 220
Joined: Tue Jul 26, 2005 10:32 pm
Location: Gainesville Florida

Post by anomaly »

Thanks! :D I'll update and recompile.
anomaly
Private First Class
Private First Class
Posts: 220
Joined: Tue Jul 26, 2005 10:32 pm
Location: Gainesville Florida

Post 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. :?
User avatar
JeffM
Staff Sergeant
Staff Sergeant
Posts: 5196
Joined: Fri Dec 13, 2002 4:11 am

Post by JeffM »

yes that has also been fixed in a recent code update.
ImageJeffM
anomaly
Private First Class
Private First Class
Posts: 220
Joined: Tue Jul 26, 2005 10:32 pm
Location: Gainesville Florida

Post 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.
User avatar
JeffM
Staff Sergeant
Staff Sergeant
Posts: 5196
Joined: Fri Dec 13, 2002 4:11 am

Post by JeffM »

fixed.
ImageJeffM
User avatar
JeffM
Staff Sergeant
Staff Sergeant
Posts: 5196
Joined: Fri Dec 13, 2002 4:11 am

Post by JeffM »

model tool has been updated to 1.8.1 to address some of the issues found in testing.
ImageJeffM
User avatar
optic delusion
Special Forces
Special Forces
Posts: 1052
Joined: Sat Sep 25, 2004 2:29 pm
Location: Planet MoFo
Contact:

Post 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.
Take a look at my Defender game mode concept.

Thinking is not an automatic process. A man can choose to think or to let his mind stagnate, or he can choose actively to turn against his intelligence, to evade his knowledge, to subvert his reason. If he refuses to think, he courts disaster: he cannot with impunity reject his means of perceiving reality.
User avatar
JeffM
Staff Sergeant
Staff Sergeant
Posts: 5196
Joined: Fri Dec 13, 2002 4:11 am

Post 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.
ImageJeffM
User avatar
JeffM
Staff Sergeant
Staff Sergeant
Posts: 5196
Joined: Fri Dec 13, 2002 4:11 am

Post by JeffM »

Note, a windows build with the recent fixes has been posted as 1.8.4 ( see the first message in this thread ).
Last edited by JeffM on Wed Oct 24, 2007 11:23 pm, edited 1 time in total.
ImageJeffM
User avatar
optic delusion
Special Forces
Special Forces
Posts: 1052
Joined: Sat Sep 25, 2004 2:29 pm
Location: Planet MoFo
Contact:

little tutorial

Post 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.
Take a look at my Defender game mode concept.

Thinking is not an automatic process. A man can choose to think or to let his mind stagnate, or he can choose actively to turn against his intelligence, to evade his knowledge, to subvert his reason. If he refuses to think, he courts disaster: he cannot with impunity reject his means of perceiving reality.
User avatar
optic delusion
Special Forces
Special Forces
Posts: 1052
Joined: Sat Sep 25, 2004 2:29 pm
Location: Planet MoFo
Contact:

Post 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
Take a look at my Defender game mode concept.

Thinking is not an automatic process. A man can choose to think or to let his mind stagnate, or he can choose actively to turn against his intelligence, to evade his knowledge, to subvert his reason. If he refuses to think, he courts disaster: he cannot with impunity reject his means of perceiving reality.
User avatar
JeffM
Staff Sergeant
Staff Sergeant
Posts: 5196
Joined: Fri Dec 13, 2002 4:11 am

Post by JeffM »

add -g GROUP_NAME and it'll put it in a define.
ImageJeffM
User avatar
Tedius
Sergeant First Class
Sergeant First Class
Posts: 142
Joined: Tue Sep 19, 2006 6:10 pm
Contact:

Post 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.
this signature intentionally left blank
User avatar
Abominable
Private First Class
Private First Class
Posts: 141
Joined: Mon Oct 22, 2007 12:31 am

Post 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?
Image
Image
User avatar
optic delusion
Special Forces
Special Forces
Posts: 1052
Joined: Sat Sep 25, 2004 2:29 pm
Location: Planet MoFo
Contact:

Post 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
Take a look at my Defender game mode concept.

Thinking is not an automatic process. A man can choose to think or to let his mind stagnate, or he can choose actively to turn against his intelligence, to evade his knowledge, to subvert his reason. If he refuses to think, he courts disaster: he cannot with impunity reject his means of perceiving reality.
User avatar
Abominable
Private First Class
Private First Class
Posts: 141
Joined: Mon Oct 22, 2007 12:31 am

Post by Abominable »

Where can I get it?
Both of the links above are dead.
Image
Image
User avatar
optic delusion
Special Forces
Special Forces
Posts: 1052
Joined: Sat Sep 25, 2004 2:29 pm
Location: Planet MoFo
Contact:

Post by optic delusion »

Are you looking at the top post in this thread? they seem live to me.
Take a look at my Defender game mode concept.

Thinking is not an automatic process. A man can choose to think or to let his mind stagnate, or he can choose actively to turn against his intelligence, to evade his knowledge, to subvert his reason. If he refuses to think, he courts disaster: he cannot with impunity reject his means of perceiving reality.
User avatar
Abominable
Private First Class
Private First Class
Posts: 141
Joined: Mon Oct 22, 2007 12:31 am

Post by Abominable »

Hmm.
Now they're working.
That was odd :P
Thanks!
Image
Image
Anthony
Private First Class
Private First Class
Posts: 222
Joined: Fri Jan 11, 2008 4:01 pm

Post by Anthony »

i think this is a bug i try to open it it runs for a seccond then closes
User avatar
blast
General
General
Posts: 4931
Joined: Fri Mar 21, 2003 3:49 pm
Location: playing.cxx
Contact:

Post by blast »

This is not a utility with a GUI. You run it from the command line and pass parameters to it.
"In addition to knowing the secrets of the Universe, I can assure you that I am also quite potty trained." -Koenma (Yu Yu Hakusho)

Image
Post Reply