Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GetExportFormatDescription gets two same string, how to control different format #2481

Open
kimkulling opened this issue May 22, 2019 · 3 comments
Labels
API Bugs related to the public API Bug Global flag to mark a deviation from expected behaviour

Comments

@kimkulling
Copy link
Member

I hope to control assimp export format.
I use GetExportFormatDescription(index) from 0 to last one and get follow result:
0: dae 1: x 2: stp 3: obj 4: obj 5: stl 6: stl 7: ply 8: ply 9: 3ds 10: gltf 11: glb 12: gltf2 13: assbin 14: assxml 15: x3d 16: 3mf
There are two obj (3,4) and two ply(7,8).
I think that two obj or ply format, maybe one ascii and another one bin.
But how does it control or choose?

aiReturn Assimp::Exporter::Export ( const aiScene * pScene,
  const std::string & pFormatId,
  const std::string & pPath,
  unsigned int pPreprocessing = 0u )

my code as follow:

Assimp::Exporter exporter;
auto numExporters = exporter.GetExportFormatCount();
int index = -1;
for (auto i = 0; i < numExporters; i++) {
  const aiExportFormatDesc format = exporter.GetExportFormatDescription(i);
  TRACE("%d: %s\n", i, format->fileExtension);
  if  (ext.compare(format->fileExtension) == 0)
    index = i;
  }
  if (index == -1)
  {
    AfxMessageBox(L"No support format");
  }
  const aiExportFormatDesc format = exporter.GetExportFormatDescription(index);
  aiReturn ret = exporter.Export(scene, format->id, out);
}

@kimkulling kimkulling added Bug Global flag to mark a deviation from expected behaviour API Bugs related to the public API labels May 22, 2019
@RichardTea
Copy link
Contributor

RichardTea commented Jun 4, 2019

The field aiExportFormatDesc.id is supposed to be used to identify the exporter, not the extension.

  • See "cexport.h"

This already works just fine - eg to export as Collada, you have to ask for "collada", not "dae".

I see these exporters at the moment:

Id: 'assbin'   Assimp Binary - *.assbin
Id: 'assxml'   Assxml Document - *.assxml
Id: '3ds'      Autodesk 3DS (legacy) - *.3ds
Id: 'fbxa'     Autodesk FBX (ascii) - *.fbx
Id: 'fbx'      Autodesk FBX (binary) - *.fbx
Id: 'collada'  COLLADA - Digital Asset Exchange Schema - *.dae
Id: 'x3d'      Extensible 3D - *.x3d
Id: 'gltf'     GL Transmission Format - *.gltf
Id: 'glb'      GL Transmission Format (binary) - *.glb
Id: 'gltf2'    GL Transmission Format v. 2 - *.gltf
Id: 'glb2'     GL Transmission Format v. 2 (binary) - *.glb
Id: 'ply'      Stanford Polygon Library - *.ply
Id: 'plyb'     Stanford Polygon Library (binary) - *.ply
Id: 'stp'      Step Files - *.stp
Id: 'stl'      Stereolithography - *.stl
Id: 'stlb'     Stereolithography (binary) - *.stl
Id: '3mf'      The 3MF-File-Format - *.3mf
Id: 'obj'      Wavefront OBJ format - *.obj
Id: 'objnomtl' Wavefront OBJ format without material file - *.obj
Id: 'x'        X Files - *.x

All those IDs appear to be unique

@RichardTea
Copy link
Contributor

I'm not certain whether the uniqueness of the format_id is currently enforced though.

@RichardTea
Copy link
Contributor

I think this issue can now be closed, the unit tests added in this commit enforce unique idents.
7e8a3ec#diff-60dd585b361aadf04df9171bb2a8b084

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Bugs related to the public API Bug Global flag to mark a deviation from expected behaviour
Projects
Status: No status
Development

No branches or pull requests

2 participants