Skip to content

Meshconvert

Chuck Walbourn edited this page Jun 9, 2023 · 23 revisions

meshconvert.exe

This DirectXMesh sample is an implementation of the meshconvert command-line utility from the DirectX SDK using DirectXMesh rather than D3DX. This tool imports geometry and prepares it for runtime use including generating normals and tangent frames, performing vertex-cache optimization, and writing it to a file format suited for runtime use.

The original tool imported from legacy X files. This version imports from WaveFront Object (OBJ) or VBO files.

Syntax

Meshconvert.exe uses the following command syntax:

meshconvert [options] <file-name(s)>

The file-name parameter indicates the file(s) to convert.

The command-line parsing uses Windows-style - or / for options. It also has some POSIX-like behavior: it supports --version and --help command-line options, and the use of -- disables further options parsing to support filenames that begin with - or / characters.

Optional Switches Description

File options

-r: Input file names can contain wildcard characters (? or *). If this switch is used, subdirectories are also searched.

-flist filename: Uses the provided filename as a text file containing a list of input files (one per line). Ignores lines that begin with # (used for comments). Does not support providing additional command-line arguments or the use of filename wildcards.

-o filename: specifies output filename which is otherwise generated from the input file name. Use of this switch supports only one input file.

-l: Forces the output path & filename to all lower-case. Windows file system is case-insensitive by default, but some programs like git are case-sensitive.

-y: overwrite existing output file if any. By default, the tool will abort if the output file already exists.

Normal/Tangent options

-n: generate normals weighted by angle
-na: generate normals weighted by area
-ne: generate normals weighted equally

-t: generate tangents.
-tb: generate tangents and bi-tangents (aka bi-normals).

-fn format: Sets the format for writing vertex normals/tangents/bi-normals for SDKMESH output: float3 (the default), float16_4, or r11g11b10 (x2 biased). This switch is not supported by CMO or VBO.

-cw: faces are clockwise (defaults to counter-clockwise) for generating normal

Face-winding options

-flip: reverses the winding of faces

Texture coordinate options

-flipu: inverts the u texture coordinate
-flipv: inverts the v texture coordinate (Direct3D vs. OpenGL image orientation)

Vertex/index options

-flipz: negates the z component (RH vs. LH view systems)

-ib32: Forces the use of 32-bit indices for SDKMESH output. By default it will attempt to write 16-bit indices if possible. This switch is not supported by CMO or VBO.

-fuv format: Sets the format for writing vertex texture coordinates for SDKMESH output: float2 (the default) or float16_2. This switch is not supported by CMO or VBO.

-fc format: Sets the format for writing vertex color for SDKMESH output: bgra (the default), rgba, float4, float16_4, rgba_10 or r11g11b10. This switch is not supported by CMO or VBO.

Optimization options

-op: vertex cache optimize the mesh (implies -c) using the Hoppe algorithm.
-oplru: vertex cache optimize the mesh (implies -c) using the Forsyth algorithm.

-c: mesh cleaning including vertex duplication for attribute sets.

-ta: when generating adjacency use topological adjacency (the default)
-ga: when generating adjacency use geometric adjacency (uses epsilon of 1e-5f)

Output format options

-sdkmesh: output an SDKMESH file (the default)
-sdkmesh2: output an SDKMESH file with PBR materials
-cmo: output a Visual Studio CMO file (requires normals, tangents and texture coordinates)
-vbo: output a VBO file (requires normals and texture coordinates)
-wf: output a WaveFront Object OBJ file

-nodds: prevents extension renaming in exported materials. By default, texture filenames are converted from an existing image extension to .dds assuming they are going to be processed by 'texconv'. This flag prevents the renaming and leaves the original extension.

Miscellaneous options

-nologo: suppress copyright message.

Example

meshconvert cup.obj -n -op

This loads the geometry in a Wavefront OBJ file 'cup.obj', generates normals (using weight by angle), performs vertex-cache optimization, and then writes the result to cup.sdkmesh.

For Use

  • Universal Windows Platform apps
  • Windows desktop apps
  • Windows 11
  • Windows 10
  • Windows 8.1
  • Windows 7 Service Pack 1
  • Xbox One
  • Xbox Series X|S
  • Windows Subsystem for Linux

For Development

  • Visual Studio 2022
  • Visual Studio 2019 (16.11)
  • clang/LLVM v12 - v16
  • GCC 9.4, 11.3
  • MinGW 12.2, 13.2
  • CMake 3.20

Related Projects

DirectX Tool Kit for DirectX 11

DirectX Tool Kit for DirectX 12

DirectXTex

DirectXMath

Tools

Test Suite

Content Exporter

DxCapsViewer

See also

DirectX Landing Page

Clone this wiki locally