Commit 8d2b8492 authored by Martin Schultz's avatar Martin Schultz

added load options to Assimp Plugin

parent 8662a68a
......@@ -44,6 +44,13 @@
#include "AssimpPlugin.hh"
#include <ACG/QtWidgets/QtFlapBox.hh>
// Defines for the type handling drop down box
#define TYPEAUTODETECT 0
#define TYPEASK 1
#define TYPEPOLY 2
#define TYPETRIANGLE 3
AssimpPlugin::AssimpPlugin()
:
......@@ -56,11 +63,11 @@ AssimpPlugin::AssimpPlugin()
void AssimpPlugin::initializePlugin() {
QString info =
" Copyright (c) 2006-2012 assimp team<br>"
" All rights reserved.<br>"
" Copyright (c) 2006-2012 assimp team<br> "
" All rights reserved.<br> "
" Redistribution and use in source and binary forms, with or without modification, are "
" permitted provided that the following conditions are met: <br> "
" <br> "
" <br> "
" Redistributions of source code must retain the above copyright notice, this list of "
" conditions and the following disclaimer.<br> "
" <br> "
......@@ -71,7 +78,7 @@ void AssimpPlugin::initializePlugin() {
" Neither the name of the assimp team nor the names of its contributors may be used to "
" endorse or promote products derived from this software without specific prior written "
" permission.<br> "
" <br> "
" <br> "
" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND ANY "
" EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF"
" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL "
......@@ -80,7 +87,7 @@ void AssimpPlugin::initializePlugin() {
" PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS"
" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, "
" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF"
" THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. "
" THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. "
" <br> ";
emit addAboutInfo(info,"File-Assimp Plugin");
......@@ -323,8 +330,145 @@ QWidget *AssimpPlugin::saveOptionsWidget(QString) {
}
QWidget *AssimpPlugin::loadOptionsWidget(QString) {
if (!loadOptions_) {
loadOptions_ = new QWidget();
if (loadOptions_ == 0){
//generate widget
loadOptions_ = new QWidget();
QVBoxLayout* layout = new QVBoxLayout();
layout->setAlignment(Qt::AlignTop);
// generic configuration
triMeshHandling_ = new QComboBox();
triMeshHandling_->addItem( tr("Detect correct mesh type") );
triMeshHandling_->addItem( tr("Ask") );
triMeshHandling_->addItem( tr("Open as PolyMesh") );
triMeshHandling_->addItem( tr("Open as TriangleMesh") );
loadFaceColor_ = new QCheckBox("Load Face Colors");
loadNormals_ = new QCheckBox("Load Normals");
loadTexCoords_ = new QCheckBox("Load Texture Coordinates");
loadTextures_ = new QCheckBox("Load Textures");
QList<QWidget*> generalOptions = {triMeshHandling_, loadFaceColor_, loadNormals_, loadTexCoords_, loadTextures_};
QTreeWidget* tree = new QTreeWidget();
tree->setHeaderLabel("Configuration:");
QTreeWidgetItem* advanced = new QTreeWidgetItem();
advanced->setText(0,"Advanced");
QTreeWidgetItem* general = new QTreeWidgetItem();
general->setText(0,"General");
tree->invisibleRootItem()->addChild(general);
tree->invisibleRootItem()->addChild(advanced);
assimp_process_calcTangentSpace = new QCheckBox("assimp_process_calcTangentSpace ");
assimp_process_joinIdenticalVertices = new QCheckBox("assimp_process_joinIdenticalVertices ");
assimp_process_makeLeftHanded = new QCheckBox("assimp_process_makeLeftHanded ");
assimp_process_triangulate = new QCheckBox("assimp_process_triangulate ");
assimp_process_removeComponent = new QCheckBox("assimp_process_removeComponent ");
assimp_process_genNormals = new QCheckBox("assimp_process_genNormals ");
assimp_process_genSmoothNormals = new QCheckBox("assimp_process_genSmoothNormals ");
assimp_process_splitLargeMeshes = new QCheckBox("assimp_process_splitLargeMeshes ");
assimp_process_preTransformVertices = new QCheckBox("assimp_process_preTransformVertices ");
assimp_process_limitBoneWeights = new QCheckBox("assimp_process_limitBoneWeights ");
assimp_process_validateDataStructure = new QCheckBox("assimp_process_validateDataStructure ");
assimp_process_improveCacheLocality = new QCheckBox("assimp_process_improveCacheLocality ");
assimp_process_removeRedundantMaterials = new QCheckBox("assimp_process_removeRedundantMaterials");
assimp_process_fixInfacingNormals = new QCheckBox("assimp_process_fixInfacingNormals ");
assimp_process_sortByPType = new QCheckBox("assimp_process_sortByPType ");
assimp_process_findDegenerates = new QCheckBox("assimp_process_findDegenerates ");
assimp_process_findInvalidData = new QCheckBox("assimp_process_findInvalidData ");
assimp_process_genUVCoords = new QCheckBox("assimp_process_genUVCoords ");
assimp_process_transformUVCoords = new QCheckBox("assimp_process_transformUVCoords ");
assimp_process_findInstances = new QCheckBox("assimp_process_findInstances ");
assimp_process_optimizeMeshes = new QCheckBox("assimp_process_optimizeMeshes ");
assimp_process_optimizeGraph = new QCheckBox("assimp_process_optimizeGraph ");
assimp_process_flipUVs = new QCheckBox("assimp_process_flipUVs ");
assimp_process_flipWindingOrder = new QCheckBox("assimp_process_flipWindingOrder ");
assimp_process_splitByBoneCount = new QCheckBox("assimp_process_splitByBoneCount ");
assimp_process_debone = new QCheckBox("assimp_process_debone ");
QList<QWidget*> advancedOptions= {assimp_process_calcTangentSpace ,
assimp_process_joinIdenticalVertices ,
assimp_process_makeLeftHanded ,
assimp_process_triangulate ,
assimp_process_removeComponent ,
assimp_process_genNormals ,
assimp_process_genSmoothNormals ,
assimp_process_splitLargeMeshes ,
assimp_process_preTransformVertices ,
assimp_process_limitBoneWeights ,
assimp_process_validateDataStructure ,
assimp_process_improveCacheLocality ,
assimp_process_removeRedundantMaterials,
assimp_process_fixInfacingNormals ,
assimp_process_sortByPType ,
assimp_process_findDegenerates ,
assimp_process_findInvalidData ,
assimp_process_genUVCoords ,
assimp_process_transformUVCoords ,
assimp_process_findInstances ,
assimp_process_optimizeMeshes ,
assimp_process_optimizeGraph ,
assimp_process_flipUVs ,
assimp_process_flipWindingOrder ,
assimp_process_splitByBoneCount ,
assimp_process_debone };
for(QList<QWidget*>::iterator it = advancedOptions.begin() ; it != advancedOptions.end(); ++it)
{
QTreeWidgetItem* treeWidget = new QTreeWidgetItem();
advanced->addChild(treeWidget);
tree->setItemWidget(treeWidget,0,*it);
}
for(QList<QWidget*>::iterator it = generalOptions.begin() ; it != generalOptions.end(); ++it)
{
QTreeWidgetItem* treeWidget = new QTreeWidgetItem();
general->addChild(treeWidget);
tree->setItemWidget(treeWidget,0,*it);
}
loadDefaultButton_ = new QPushButton("Make Default");
layout->addWidget(tree);
layout->addWidget(loadDefaultButton_);
loadOptions_->setLayout(layout);
connect(loadDefaultButton_, SIGNAL(clicked()), this, SLOT(slotLoadDefault()));
triMeshHandling_->setCurrentIndex(OpenFlipperSettings().value("Assimp/Load/TriMeshHandling",TYPEAUTODETECT).toInt() );
loadFaceColor_->setChecked( OpenFlipperSettings().value("Assimp/Load/FaceColor",true).toBool() );
loadNormals_->setChecked ( OpenFlipperSettings().value("Assimp/Load/Normals" ,true).toBool() );
loadTexCoords_->setChecked( OpenFlipperSettings().value("Assimp/Load/TexCoords",true).toBool() );
loadTextures_->setChecked ( OpenFlipperSettings().value("Assimp/Load/Textures" ,true).toBool() );
assimp_process_calcTangentSpace ->setChecked(OpenFlipperSettings().value( "Assimp/process/calcTangentSpace" , false).toBool());
assimp_process_joinIdenticalVertices ->setChecked(OpenFlipperSettings().value( "Assimp/process/joinIdenticalVertices" , true ).toBool());
assimp_process_makeLeftHanded ->setChecked(OpenFlipperSettings().value( "Assimp/process/makeLeftHanded" , false).toBool());
assimp_process_triangulate ->setChecked(OpenFlipperSettings().value( "Assimp/process/triangulate" , false).toBool());
assimp_process_removeComponent ->setChecked(OpenFlipperSettings().value( "Assimp/process/removeComponent" , false).toBool());
assimp_process_genNormals ->setChecked(OpenFlipperSettings().value( "Assimp/process/genNormals" , false).toBool());
assimp_process_genSmoothNormals ->setChecked(OpenFlipperSettings().value( "Assimp/process/genSmoothNormals" , false).toBool());
assimp_process_splitLargeMeshes ->setChecked(OpenFlipperSettings().value( "Assimp/process/splitLargeMeshes" , false).toBool());
assimp_process_preTransformVertices ->setChecked(OpenFlipperSettings().value( "Assimp/process/preTransformVertices" , false).toBool());
assimp_process_limitBoneWeights ->setChecked(OpenFlipperSettings().value( "Assimp/process/limitBoneWeights" , false).toBool());
assimp_process_validateDataStructure ->setChecked(OpenFlipperSettings().value( "Assimp/process/validateDataStructure" , false).toBool());
assimp_process_improveCacheLocality ->setChecked(OpenFlipperSettings().value( "Assimp/process/improveCacheLocality" , false).toBool());
assimp_process_removeRedundantMaterials ->setChecked(OpenFlipperSettings().value( "Assimp/process/removeRedundantMaterials", false).toBool());
assimp_process_fixInfacingNormals ->setChecked(OpenFlipperSettings().value( "Assimp/process/fixInfacingNormals" , false).toBool());
assimp_process_sortByPType ->setChecked(OpenFlipperSettings().value( "Assimp/process/sortByPType" , false).toBool());
assimp_process_findDegenerates ->setChecked(OpenFlipperSettings().value( "Assimp/process/findDegenerates" , true ).toBool());
assimp_process_findInvalidData ->setChecked(OpenFlipperSettings().value( "Assimp/process/findInvalidData" , false).toBool());
assimp_process_genUVCoords ->setChecked(OpenFlipperSettings().value( "Assimp/process/genUVCoords" , false).toBool());
assimp_process_transformUVCoords ->setChecked(OpenFlipperSettings().value( "Assimp/process/transformUVCoords" , false).toBool());
assimp_process_findInstances ->setChecked(OpenFlipperSettings().value( "Assimp/process/findInstances" , false).toBool());
assimp_process_optimizeMeshes ->setChecked(OpenFlipperSettings().value( "Assimp/process/optimizeMeshes" , false).toBool());
assimp_process_optimizeGraph ->setChecked(OpenFlipperSettings().value( "Assimp/process/optimizeGraph" , false).toBool());
assimp_process_flipUVs ->setChecked(OpenFlipperSettings().value( "Assimp/process/flipUVs" , false).toBool());
assimp_process_flipWindingOrder ->setChecked(OpenFlipperSettings().value( "Assimp/process/flipWindingOrder" , false).toBool());
assimp_process_splitByBoneCount ->setChecked(OpenFlipperSettings().value( "Assimp/process/splitByBoneCount" , false).toBool());
assimp_process_debone ->setChecked(OpenFlipperSettings().value( "Assimp/process/debone" , false).toBool());
}
return loadOptions_;
......@@ -383,6 +527,44 @@ bool AssimpPlugin::saveObject(int _id, QString _filename) {
return ok;
}
void AssimpPlugin::slotLoadDefault() {
OpenFlipperSettings().setValue( "Assimp/Load/FaceColor", loadFaceColor_->isChecked() );
OpenFlipperSettings().setValue( "Assimp/Load/Normals", loadNormals_->isChecked() );
OpenFlipperSettings().setValue( "Assimp/Load/TexCoords", loadTexCoords_->isChecked() );
OpenFlipperSettings().setValue( "Assimp/Load/Textures", loadTextures_->isChecked() );
OpenFlipperSettings().setValue( "Assimp/Load/TriMeshHandling", triMeshHandling_->currentIndex() );
OpenFlipperSettings().setValue( "Assimp/process/calcTangentSpace" , assimp_process_calcTangentSpace ->isChecked() );
OpenFlipperSettings().setValue( "Assimp/process/joinIdenticalVertices" , assimp_process_joinIdenticalVertices ->isChecked() );
OpenFlipperSettings().setValue( "Assimp/process/makeLeftHanded" , assimp_process_makeLeftHanded ->isChecked() );
OpenFlipperSettings().setValue( "Assimp/process/triangulate" , assimp_process_triangulate ->isChecked() );
OpenFlipperSettings().setValue( "Assimp/process/removeComponent" , assimp_process_removeComponent ->isChecked() );
OpenFlipperSettings().setValue( "Assimp/process/genNormals" , assimp_process_genNormals ->isChecked() );
OpenFlipperSettings().setValue( "Assimp/process/genSmoothNormals" , assimp_process_genSmoothNormals ->isChecked() );
OpenFlipperSettings().setValue( "Assimp/process/splitLargeMeshes" , assimp_process_splitLargeMeshes ->isChecked() );
OpenFlipperSettings().setValue( "Assimp/process/preTransformVertices" , assimp_process_preTransformVertices ->isChecked() );
OpenFlipperSettings().setValue( "Assimp/process/limitBoneWeights" , assimp_process_limitBoneWeights ->isChecked() );
OpenFlipperSettings().setValue( "Assimp/process/validateDataStructure" , assimp_process_validateDataStructure ->isChecked() );
OpenFlipperSettings().setValue( "Assimp/process/improveCacheLocality" , assimp_process_improveCacheLocality ->isChecked() );
OpenFlipperSettings().setValue( "Assimp/process/removeRedundantMaterials", assimp_process_removeRedundantMaterials->isChecked() );
OpenFlipperSettings().setValue( "Assimp/process/fixInfacingNormals" , assimp_process_fixInfacingNormals ->isChecked() );
OpenFlipperSettings().setValue( "Assimp/process/sortByPType" , assimp_process_sortByPType ->isChecked() );
OpenFlipperSettings().setValue( "Assimp/process/findDegenerates" , assimp_process_findDegenerates ->isChecked() );
OpenFlipperSettings().setValue( "Assimp/process/findInvalidData" , assimp_process_findInvalidData ->isChecked() );
OpenFlipperSettings().setValue( "Assimp/process/genUVCoords" , assimp_process_genUVCoords ->isChecked() );
OpenFlipperSettings().setValue( "Assimp/process/transformUVCoords" , assimp_process_transformUVCoords ->isChecked() );
OpenFlipperSettings().setValue( "Assimp/process/findInstances" , assimp_process_findInstances ->isChecked() );
OpenFlipperSettings().setValue( "Assimp/process/optimizeMeshes" , assimp_process_optimizeMeshes ->isChecked() );
OpenFlipperSettings().setValue( "Assimp/process/optimizeGraph" , assimp_process_optimizeGraph ->isChecked() );
OpenFlipperSettings().setValue( "Assimp/process/flipUVs" , assimp_process_flipUVs ->isChecked() );
OpenFlipperSettings().setValue( "Assimp/process/flipWindingOrder" , assimp_process_flipWindingOrder ->isChecked() );
OpenFlipperSettings().setValue( "Assimp/process/splitByBoneCount" , assimp_process_splitByBoneCount ->isChecked() );
OpenFlipperSettings().setValue( "Assimp/process/debone" , assimp_process_debone ->isChecked() );
OpenFlipperSettings().setValue( "Core/File/UseLoadDefaults", true );
}
#if QT_VERSION < 0x050000
Q_EXPORT_PLUGIN2( assimpplugin , AssimpPlugin )
#endif
......@@ -133,6 +133,8 @@ private slots:
void noguiSupported( ) {}
void initializePlugin();
void slotLoadDefault();
private:
......@@ -164,6 +166,42 @@ private:
//Option Widgets
QWidget* loadOptions_;
QWidget* saveOptions_;
QComboBox* triMeshHandling_;
QCheckBox* loadVertexColor_;
QCheckBox* loadFaceColor_;
QCheckBox* loadAlpha_;
QCheckBox* loadNormals_;
QCheckBox* loadTexCoords_;
QCheckBox* loadTextures_;
QPushButton* loadDefaultButton_;
QCheckBox* assimp_process_calcTangentSpace ;
QCheckBox* assimp_process_joinIdenticalVertices ;
QCheckBox* assimp_process_makeLeftHanded ;
QCheckBox* assimp_process_triangulate ;
QCheckBox* assimp_process_removeComponent ;
QCheckBox* assimp_process_genNormals ;
QCheckBox* assimp_process_genSmoothNormals ;
QCheckBox* assimp_process_splitLargeMeshes ;
QCheckBox* assimp_process_preTransformVertices ;
QCheckBox* assimp_process_limitBoneWeights ;
QCheckBox* assimp_process_validateDataStructure ;
QCheckBox* assimp_process_improveCacheLocality ;
QCheckBox* assimp_process_removeRedundantMaterials;
QCheckBox* assimp_process_fixInfacingNormals ;
QCheckBox* assimp_process_sortByPType ;
QCheckBox* assimp_process_findDegenerates ;
QCheckBox* assimp_process_findInvalidData ;
QCheckBox* assimp_process_genUVCoords ;
QCheckBox* assimp_process_transformUVCoords ;
QCheckBox* assimp_process_findInstances ;
QCheckBox* assimp_process_optimizeMeshes ;
QCheckBox* assimp_process_optimizeGraph ;
QCheckBox* assimp_process_flipUVs ;
QCheckBox* assimp_process_flipWindingOrder ;
QCheckBox* assimp_process_splitByBoneCount ;
QCheckBox* assimp_process_debone ;
DataType type_;
......
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