Commit 78e57c54 authored by Martin Schultz's avatar Martin Schultz

minor cleanup of Assimp Plugin

Assimp loader respects polymesh trimesh selection now
parent 17be8d95
......@@ -96,13 +96,21 @@ void AssimpPlugin::initializePlugin() {
int AssimpPlugin::convertAiSceneToOpenMesh(const aiScene *_scene, QString _objectName) {
int returnId = -1;
std::vector<int> ids;
std::cout<<"found " << _scene->mNumMeshes << " meshes "<<std::endl;
if (_scene->mNumMeshes == 0)
emit log(LOGWARN, tr("aiScene contains no meshes"));
for (unsigned int i = 0; i < _scene->mNumMeshes; ++i) {
int objectId = -1;
emit addEmptyObject(type_, objectId);
if(type_ == DATA_UNKNOWN)
{
if(_scene->mMeshes[i]->mPrimitiveTypes & aiPrimitiveType_POLYGON)
emit addEmptyObject(DATA_POLY_MESH, objectId);
else
emit addEmptyObject(DATA_TRIANGLE_MESH, objectId);
}
else
emit addEmptyObject(type_, objectId);
BaseObject* object(0);
if(!PluginFunctions::getObject( objectId, object )) {
......@@ -604,33 +612,45 @@ QWidget *AssimpPlugin::loadOptionsWidget(QString) {
int AssimpPlugin::loadObject(QString _filename) {
Assimp::Importer importer;
const aiScene* scene = NULL;
scene = importer.ReadFile(_filename.toStdString(), processSteps(loadOptions));
if (!scene) {
emit log(LOGERR, tr(importer.GetErrorString()));
return -1;
}
if(OpenFlipper::Options::gui() && loadOptions_ != nullptr)
{
switch(triMeshHandling_->currentIndex())
{
case TYPEAUTODETECT :
type_ = DATA_UNKNOWN;
break;
case TYPEPOLY :
type_ = DATA_POLY_MESH;
break;
case TYPETRIANGLE :
type_ = DATA_TRIANGLE_MESH;
break;
case TYPEASK :
QMessageBox msgBox;
QPushButton *detectButton = msgBox.addButton(tr("Auto-Detect"), QMessageBox::ActionRole);
QPushButton *triButton = msgBox.addButton(tr("Open as triangle mesh"), QMessageBox::ActionRole);
QPushButton *polyButton = msgBox.addButton(tr("Open as poly mesh"), QMessageBox::ActionRole);
msgBox.setWindowTitle( tr("Mesh types in file") );
msgBox.setText( tr("You are about to open a file containing one or more mesh types. \n\n Which mesh type should be used?") );
msgBox.setDefaultButton( detectButton );
msgBox.exec();
if (msgBox.clickedButton() == triButton)
type_ = DATA_TRIANGLE_MESH;
else if (msgBox.clickedButton() == polyButton)
type_ = DATA_POLY_MESH;
break;
}
}
const aiScene* scene = NULL;
if (type_ == DATA_TRIANGLE_MESH)
scene = importer.ReadFile(_filename.toStdString(), processSteps(loadOptions));// aiProcess_JoinIdenticalVertices | aiProcess_Triangulate | aiProcess_FindDegenerates);
else
scene = importer.ReadFile(_filename.toStdString(), processSteps(loadOptions));// aiProcess_JoinIdenticalVertices | aiProcess_FindDegenerates);
std::cout<<"processSteps: "<< processSteps(loadOptions)<<std::endl;
if (!scene) {
emit log(LOGERR, tr(importer.GetErrorString()));
return -1;
}
QFileInfo f(_filename);
return convertAiSceneToOpenMesh(scene, f.fileName());
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment