celestia/src/tools/cmod
Hleb Valoshka bd7f9ebc9b Use libepoxy instead of GLEW
Unlike GLEW libepoxy supports OpenGL ES and better handles cases with
functions provided by different extensions, e.g. the same functions
provided by vendor/EXT/ARB/core.
2020-03-26 11:24:56 +03:00
..
3dstocmod Fix PVS Studio reported errors (Closes: #425) 2019-10-04 20:49:34 +03:00
cmodfix Remove deprecated C++ features 2019-11-30 22:45:25 +03:00
cmodsphere Fix two MSVC C4305 warnings 2019-05-20 10:48:04 +03:00
cmodview Use libepoxy instead of GLEW 2020-03-26 11:24:56 +03:00
common Remove deprecated C++ features 2019-11-30 22:45:25 +03:00
itokawa [cmake] Enable cmod tools building 2019-04-08 12:07:43 +03:00
CMakeLists.txt [cmake] refactor build_cmod_tool macro to allow WIN32 targets 2019-04-12 17:09:58 +03:00
cmod.pro Reorganise cmod tools directory and add qmake project files. 2012-05-03 19:49:05 +00:00
cmodtangent.cpp fix whitespaces and indents 2018-09-22 23:41:57 +03:00
cmodtools-readme.txt Tool to optimize a mesh in Microsofts X file format and convert it to cmod. 2004-02-22 07:00:08 +00:00
cmodtools.mak Fixed specular power conversion in 3dstocmod tool. 2006-09-27 16:26:41 +00:00
readme.txt - Changed 3dstocmod utility to write out names from 3ds file as comments in cmod file. 2004-07-21 07:22:24 +00:00
xtocmod.cpp Automatically convert to c++11 using clan-tidy 2018-09-22 23:42:02 +03:00

readme.txt

3DSCONV:

The 3dsconv utility converts a 3D Studio mesh to an ASCII format CMOD model.
The command line usage is very simple:

3dsconv <input 3ds file>

The cmod file is written to standard output, so you must use output redirection
to send it to a file.  The standard usage is something like this:

3dsconv in.3ds > out.cmod

The cmod files produced by 3dsconv are unoptimized and will benefit from
further processing with the cmodfix tool.



CMODFIX:

Cmodfix is a command line utility for performing some basic manipulations of
cmod 3D model files.  Various switches specify what operations are to be
performed on the cmod file.  The operations are always applied in a fixed
order, so the order of the switches is irrelevant.

cmodfix [options] [input cmod file [output cmod file]]
   --binary (or -b)      : output a binary .cmod file
   --ascii (or -a)       : output an ASCII .cmod file
   --uniquify (or -u)    : eliminate duplicate vertices
   --tangents (or -t)    : generate tangents
   --normals (or -n)     : generate normals
   --smooth (or -s) <angle> : smoothing angle for normal generation
   --weld (or -w)        : join identical vertices before normal generation
   --merge (or -m)       : merge submeshes to improve rendering performance
   --optimize (or -o)    : optimize by converting triangle lists to strips


The order in which the operations are applied is as follows:

   1. Weld vertices
   2. Generate normals
   3. Generate tangents
   4. Merge meshes
   5. Uniquify (eliminate duplicate vertices)
   6. Optimize triangle lists to strips
   7. Write output mesh


Weld vertices
This operation is relevant only when generating new normals or tangents for
a model.  It causes vertices with identical positions to be treated as
identical for normal/tangent generation even if they have other attributes
that differ.  It's most commonly used to eliminate ugly creases from models
that have cylindrically wrapping texture coordinates.  Although it may slightly
increase the time required to modify a cmod file, it's usually desirable to
enable vertex welding.

Generate normals
Compute new normals for a model by averaging face normals.  Faces are only
averaged when the angle between their normals is less than the smoothing angle.
The default smoothing angle of 60 degrees is reasonable for many models.  To
force faces to always be averaged, use a smoothing angle of 180 degrees.  This
will make the object appear curved and smooth everywhere.  A smoothing angle
of zero degrees results in an object that appears faceted, with a hard edge
between every pair of faces.

Generate tangents
Tangents are required in order to apply bump maps or other per-pixel lighting
effects to a cmod.  The tangent vectors are generated from the vertex
normals and texture coordinates--both must be present in order to create
tangents.

Merge meshes
This operation will pool compatible submeshes into a single large mesh.
Reducing the number of meshes can improve rendering performance, but it usually
only helps when there are a lot of very small meshes in the original cmod
file.

Uniquify vertices
Uniquify collapses identical vertices into a single vertex, reducing the size
of the cmod file and making it render faster (though the improvement won't
always be noticeable.)  It's almost always a good idea to uniquify model
vertices, and especially so when the input mesh is derived from unindexed
data such as the output of 3dstocmod.

Optimize triangle lists to strips
This option is only available when cmodfix has be built with NVIDIA's
NvTriStrip library (http://developer.nvidia.com/object/nvtristrip_library.html)
It converts triangle lists in a cmod file into much more efficient triangle
lists.  Converting lists to strips often has a profound impact on rendering
performance.  Calculating optimal triangle lists can be a slow process for
large models: it could take a minute to process a one million triangle model.

Output
CMOD files can be stored in either an ASCII or binary format.  The binary
format is more compact and loads more quickly but is not human readable.
The ASCII format is useful if for some reason you need to hand-modify the
model.  Otherwise, the binary format is prefered.


TYPICAL EXAMPLES:

Generate normals with a 45 degree smoothing angle:
cmodfix -u -w -n -s 45 in.cmod out.cmod

Convert a binary cmod file to ASCII:
cmodfix -a in.cmod out.cmod

Generate tangents:
cmodfix -u -w -n -t in.cmod out.cmod

Optimize a mesh:
cmodfix -u -o in.cmod out.cmod


BUGS:

The NvTriStrip library only handles 16-bit vertex indices, so submeshes with
more than 65536 vertices will be skipped when optimizing.

Binary file output does not work with redirection on Windows machines.  To
write a binary file on Windows, you must specify the output file name.
For example, instead of this:
   cmodfix -b in.cmod > out.cmod
Write this:
   cmodfix -b in.cmod out.cmod



LICENSE:

The 3dstocmod and cmodfix programs are free software.  You can redistribute
and modify them under the terms of the GNU General Public License, the full
text of which is in the COPYING file.  The source code for the programs is
available for free from the Celestia project on SourceForge:
http://www.sourceforge.net/projects/celestia/

cmodfix may be optionally compiled with NVIDIA's NvTriStrip library, available
in source form from NVIDIA's developer web site:
http://developer.nvidia.com/object/nvtristrip_library.html
NvTriStrip is /not/ covered by the same license as the cmodtools.



CREDITS:

The cmod tools were developed by Chris Laurel as part of the Celestia project.
Send bug reports and suggesestion to claurel@shatters.net.