microsoft / DirectXMesh

DirectXMesh geometry processing library
https://walbourn.github.io/directxmesh/
MIT License
787 stars 151 forks source link

Concatenate Mesh #6

Closed walbourn closed 3 years ago

walbourn commented 9 years ago

A function to combine multiple meshes into a single mesh.

HRESULT D3DXConcatenateMeshes(
  _In_   LPD3DXMESH *ppMeshes,
  _In_   UINT NumMeshes,
  _In_   DWORD Options,
  _In_   const D3DXMATRIX *pGeomXForms,
  _In_   const D3DXMATRIX *pTextureXForms,
  _In_   const D3DVERTEXELEMENT9 *pDecl,
  _In_   LPDIRECT3DDEVICE9 pD3DDevice,
  _Out_  LPD3DXMESH *ppMeshOut
);

The original D3DX function would create a 'union' of the input layouts as needed to generate the final vertex buffer if a specific one was not provided.

The DirectXMesh version would likely only operate on the indices and an array of XMFLOAT3 positions, and provide a remap array for each of the original input mesh indices to the new indices for dealing with other vertex data.

walbourn commented 3 years ago

For DirectXMesh, the concat is basically very a simple remap generator.

The documentation should recommend doing Clean, AttributeSort, and CompactVB before concat.

The transformation behavior is potentially something that would be added to the Mesh utility instead. It uses the matrix for positions, inverse transpose for normals, and texture xforms for the uvs.