本文整理汇总了C++中assimp::Exporter::GetExportFormatCount方法的典型用法代码示例。如果您正苦于以下问题:C++ Exporter::GetExportFormatCount方法的具体用法?C++ Exporter::GetExportFormatCount怎么用?C++ Exporter::GetExportFormatCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类assimp::Exporter
的用法示例。
在下文中一共展示了Exporter::GetExportFormatCount方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getSupportedFormats
std::string AssimpModelExport::getSupportedFormats()
{
std::string all = "All (";
std::string individual = "";
Assimp::Exporter exporter;
for (size_t i = 0; i < exporter.GetExportFormatCount(); ++i)
{
const aiExportFormatDesc* desc = exporter.GetExportFormatDescription(i);
all += "*." + std::string(desc->fileExtension) + " ";
individual += ";;" + std::string(desc->description) + " (*." +
std::string(desc->fileExtension) + ")";
}
all += ")";
return all + individual;
}
示例2: getExportFormatID
std::string AssimpModelExport::getExportFormatID(
const std::string &fileExtension)
{
std::string ret;
Assimp::Exporter exporter;
for (size_t i = 0; i < exporter.GetExportFormatCount(); ++i)
{
const aiExportFormatDesc* desc = exporter.GetExportFormatDescription(i);
if (fileExtension == desc->fileExtension)
{
ret = desc->id;
break;
}
}
return ret;
}
示例3: main
// ------------------------------------------------------------------------------
// Application entry point
int main (int argc, char* argv[])
{
if (argc <= 1) {
printf("assimp: No command specified. Use \'assimp help\' for a detailed command list\n");
return 0;
}
// assimp version
// Display version information
if (! strcmp(argv[1], "version")) {
const unsigned int flags = aiGetCompileFlags();
printf(AICMD_MSG_ABOUT,
aiGetVersionMajor(),
aiGetVersionMinor(),
(flags & ASSIMP_CFLAGS_DEBUG ? "-debug " : ""),
(flags & ASSIMP_CFLAGS_NOBOOST ? "-noboost " : ""),
(flags & ASSIMP_CFLAGS_SHARED ? "-shared " : ""),
(flags & ASSIMP_CFLAGS_SINGLETHREADED ? "-st " : ""),
(flags & ASSIMP_CFLAGS_STLPORT ? "-stlport " : ""),
aiGetVersionRevision());
return 0;
}
// assimp help
// Display some basic help (--help and -h work as well
// because people could try them intuitively)
if (!strcmp(argv[1], "help") || !strcmp(argv[1], "--help") || !strcmp(argv[1], "-h")) {
printf("%s",AICMD_MSG_HELP);
return 0;
}
// assimp cmpdump
// Compare two mini model dumps (regression suite)
if (! strcmp(argv[1], "cmpdump")) {
return Assimp_CompareDump (&argv[2],argc-2);
}
// construct global importer and exporter instances
Assimp::Importer imp;
imp.SetPropertyBool("GLOB_MEASURE_TIME",true);
globalImporter = &imp;
#ifndef ASSIMP_BUILD_NO_EXPORT
//
Assimp::Exporter exp;
globalExporter = &exp;
#endif
// assimp listext
// List all file extensions supported by Assimp
if (! strcmp(argv[1], "listext")) {
aiString s;
imp.GetExtensionList(s);
printf("%s\n",s.data);
return 0;
}
#ifndef ASSIMP_BUILD_NO_EXPORT
// assimp listexport
// List all export file formats supported by Assimp (not the file extensions, just the format identifiers!)
if (! strcmp(argv[1], "listexport")) {
aiString s;
for(size_t i = 0, end = exp.GetExportFormatCount(); i < end; ++i) {
const aiExportFormatDesc* const e = exp.GetExportFormatDescription(i);
s.Append( e->id );
if (i!=end-1) {
s.Append("\n");
}
}
printf("%s\n",s.data);
return 0;
}
// assimp exportinfo
// stat an export format
if (! strcmp(argv[1], "exportinfo")) {
aiString s;
if (argc<3) {
printf("Expected file format id\n");
return -11;
}
for(size_t i = 0, end = exp.GetExportFormatCount(); i < end; ++i) {
const aiExportFormatDesc* const e = exp.GetExportFormatDescription(i);
if (!strcmp(e->id,argv[2])) {
printf("%s\n%s\n%s\n",e->id,e->fileExtension,e->description);
return 0;
}
}
printf("Unknown file format id: \'%s\'\n",argv[2]);
return -12;
//.........这里部分代码省略.........
示例4: exportCad
/*!
* \brief Export a cad model (vertices and faces) with the assimp library
* \author Sascha Kaden
* \param[in] format
* \param[in] filePath
* \param[in] list of vertices
* \param[in] list of faces
* \date 2017-02-19
*/
bool exportCad(ExportFormat format, const std::string &filePath, const std::vector<Vector3> &vertices,
const std::vector<Vector3i> &faces) {
if (filePath.empty()) {
Logging::warning("Empty output file path", "CadProcessing");
return false;
}
Assimp::Exporter exporter;
size_t maxFormatCount = exporter.GetExportFormatCount();
size_t formatCount;
switch (format) {
case ExportFormat::COLLADA:
formatCount = 0;
break;
case ExportFormat::X_FILES:
formatCount = 1;
break;
case ExportFormat::STEP:
formatCount = 2;
break;
case ExportFormat::OBJ:
formatCount = 3;
break;
case ExportFormat::STEREOLITHOGRAPHY:
formatCount = 4;
break;
case ExportFormat::STEREOLITHOGRAPHY_BINARY:
formatCount = 5;
break;
case ExportFormat::STANFORD_POLYGON_LIBRARY:
formatCount = 6;
break;
case ExportFormat::STANFORD_POLYGON_LIBRARY_BINARY:
formatCount = 7;
break;
case ExportFormat::AUTODESK_3DS:
formatCount = 8;
break;
case ExportFormat::GL_TRANSMISSION_FORMAT:
formatCount = 9;
break;
case ExportFormat::GL_TRANSMISSION_FORMAT_BINARY:
formatCount = 10;
break;
case ExportFormat::ASSIMP_BINARY:
formatCount = 11;
break;
case ExportFormat::ASSXML_DOCUMENT:
formatCount = 12;
break;
case ExportFormat::EXTENSIBLE_3D:
formatCount = 13;
break;
}
if (formatCount > maxFormatCount) {
Logging::warning("Selected format is not supported", "CadProcessing");
return false;
}
aiScene scene = generateScene(vertices, faces);
const aiExportFormatDesc *formatDesc = exporter.GetExportFormatDescription(formatCount);
exporter.Export(&scene, formatDesc->id, filePath + "." + formatDesc->fileExtension, aiProcess_Triangulate);
return true;
}
示例5: write
void OBJWriter::write(const std::shared_ptr<gameplay::Model>& model,
const std::string& baseName,
const std::map<loader::TextureLayoutProxy::TextureKey, std::shared_ptr<gameplay::Material>>& mtlMap1,
const std::map<loader::TextureLayoutProxy::TextureKey, std::shared_ptr<gameplay::Material>>& mtlMap2,
const glm::vec3& ambientColor) const
{
Expects(model != nullptr);
auto fullPath = m_basePath / baseName;
Assimp::Exporter exporter;
std::string formatIdentifier;
for(size_t i = 0; i < exporter.GetExportFormatCount(); ++i)
{
auto descr = exporter.GetExportFormatDescription(i);
BOOST_ASSERT(descr != nullptr);
std::string exporterExtension = std::string(".") + descr->fileExtension;
if(exporterExtension == fullPath.extension().string())
{
formatIdentifier = descr->id;
break;
}
}
if(formatIdentifier.empty())
{
BOOST_LOG_TRIVIAL(error) << "Failed to find an exporter for the supplied file extension";
BOOST_LOG_TRIVIAL(info) << "Here's the list of registered exporters";
for(size_t i = 0; i < exporter.GetExportFormatCount(); ++i)
{
auto descr = exporter.GetExportFormatDescription(i);
BOOST_ASSERT(descr != nullptr);
BOOST_LOG_TRIVIAL(info) << descr->description << ", extension `" << descr->fileExtension << "`, id `" << descr->id << "`";
}
BOOST_THROW_EXCEPTION(std::runtime_error("Failed to find an exporter for the supplied file extension"));
}
std::unique_ptr<aiScene> scene = std::make_unique<aiScene>();
BOOST_ASSERT(scene->mRootNode == nullptr);
scene->mRootNode = new aiNode();
{
size_t totalPartCount = 0;
for( const auto& mesh : model->getMeshes() )
{
totalPartCount += mesh->getPartCount();
}
scene->mNumMaterials = totalPartCount;
scene->mMaterials = new aiMaterial*[totalPartCount];
std::fill_n(scene->mMaterials, totalPartCount, nullptr);
scene->mNumMeshes = totalPartCount;
scene->mMeshes = new aiMesh*[totalPartCount];
std::fill_n(scene->mMeshes, totalPartCount, nullptr);
scene->mRootNode->mNumMeshes = totalPartCount;
scene->mRootNode->mMeshes = new unsigned int[totalPartCount];
for( size_t i = 0; i < totalPartCount; ++i )
scene->mRootNode->mMeshes[i] = i;
}
for( size_t mi = 0, globalPartIndex = 0; mi < model->getMeshes().size(); ++mi )
{
BOOST_ASSERT(mi < scene->mNumMeshes);
const auto& mesh = model->getMeshes()[mi];
for( size_t pi = 0; pi < mesh->getPartCount(); ++pi , ++globalPartIndex )
{
BOOST_ASSERT(globalPartIndex < scene->mNumMaterials);
const std::shared_ptr<gameplay::MeshPart>& part = mesh->getPart(pi);
scene->mMeshes[globalPartIndex] = new aiMesh();
aiMesh* outMesh = scene->mMeshes[globalPartIndex];
allocateElementMemory(mesh, outMesh);
copyVertexData(mesh, outMesh);
BOOST_ASSERT(part->getPrimitiveType() == gameplay::Mesh::PrimitiveType::TRIANGLES && part->getIndexCount() % 3 == 0);
outMesh->mMaterialIndex = globalPartIndex;
scene->mMaterials[globalPartIndex] = new aiMaterial();
scene->mMaterials[globalPartIndex]->AddProperty(new aiColor4D(ambientColor.r, ambientColor.g, ambientColor.b, 1), 1, AI_MATKEY_COLOR_AMBIENT);
{
// try to find the texture for our material
using Entry = decltype(*mtlMap1.begin());
auto finder = [&part](const Entry& entry)
{
return entry.second == part->getMaterial();
};
auto texIt = std::find_if(mtlMap1.begin(), mtlMap1.end(), finder);
bool found = false;
//.........这里部分代码省略.........