...
 
Commits (3)
......@@ -58,6 +58,7 @@
#include <OpenFlipper/BasePlugin/RPCInterface.hh>
#include <OpenFlipper/BasePlugin/AboutInfoInterface.hh>
#include <OpenFlipper/BasePlugin/ProcessInterface.hh>
#include <OpenFlipper/BasePlugin/TextureInterface.hh>
#include <ObjectTypes/PolyMesh/PolyMesh.hh>
#include <ObjectTypes/TriangleMesh/TriangleMesh.hh>
......@@ -69,8 +70,12 @@
#include<unordered_map>
#include "AssimpPluginCommon.hh"
class AssimpOptionsWidget;
class AssimpPlugin : public QObject, BaseInterface, FileInterface, LoadSaveInterface,
LoggingInterface, ScriptInterface, RPCInterface, AboutInfoInterface, ProcessInterface
LoggingInterface, ScriptInterface, RPCInterface, AboutInfoInterface, ProcessInterface, TextureInterface
{
Q_OBJECT
Q_INTERFACES(FileInterface)
......@@ -81,6 +86,7 @@ class AssimpPlugin : public QObject, BaseInterface, FileInterface, LoadSaveInter
Q_INTERFACES(RPCInterface)
Q_INTERFACES(AboutInfoInterface)
Q_INTERFACES(ProcessInterface)
Q_INTERFACES(TextureInterface)
#if QT_VERSION >= 0x050000
Q_PLUGIN_METADATA(IID "org.OpenFlipper.Plugins.Plugin-Assimp")
......@@ -103,6 +109,13 @@ class AssimpPlugin : public QObject, BaseInterface, FileInterface, LoadSaveInter
//AboutInfoInterface
void addAboutInfo(QString _text, QString _tabName );
//texture interface
void addTexture( QString _name , QImage _image , uint _dimension , int _id );
void switchTexture( QString _textureName , int _id );
void setTextureMode(QString _textureName, QString _mode, int _id );
public:
AssimpPlugin();
......@@ -150,6 +163,7 @@ private slots:
signals:
bool showConfirmationDialog(const QString& _title, const QString & _message);
// void addTexture(TextureNode* _node, const QImage& img);
private:
......@@ -172,29 +186,54 @@ private:
bool convertTriMeshToAiMesh(TriMesh* _triMesh, aiMesh* _mesh);
/// add a vertex from _mesh to _polyMesh and stores the index to handle mapping
void mapVertices(PolyMesh* _polyMesh, aiMesh* _mesh);
//void mapVertices(PolyMesh* _polyMesh, aiMesh* _mesh);
/// add a vertex from _mesh to _trimesh and stores the index to handle mapping
void mapVertices(TriMesh* _triMesh, aiMesh* _mesh);
//void mapVertices(TriMesh* _triMesh, aiMesh* _mesh);
template<typename Mesh>
void mapVertices(Mesh* _triMesh, aiMesh* _mesh);
/// returns which postprocessing steps are enabled for the loader
unsigned int processSteps(const std::unordered_map<QCheckBox*, unsigned int>& _options);
//unsigned int processSteps(const std::unordered_map<QCheckBox*, unsigned int>& _options);
/// loads a material from the given aiScene to a given MaterialNode
void loadMaterial(const aiScene* _scene, MaterialNode* _matNode, unsigned int _materialIndex);
/// loads all embedded textures from a scene
void loadTexturesFromScene(const aiScene* _scene);
/// load all textures of a specific type from a material
/// this also loads textures which are not embedded, but specified by a file path
std::vector<std::pair<std::string,QImage>> loadTexturesFromMaterial(const aiMaterial* _mat, aiTextureType _textureType);
/// loads all lights from a scene
void loadLightsFromScene(const aiScene* _scene);
/// loads all cameras from a scene
void loadCamerasFromScene(const aiScene* _scene);
/// loads all animations from a scene
void loadAnimationsFromScene(const aiScene* _scene);
/// loads all meshes from a scene
void loadMeshesFromScene(const aiScene* _scene, std::vector<int> & _outIds, QString& _objectName);
private:
//Option Widgets
QWidget* loadOptions_;
QWidget* saveOptions_;
QComboBox* triMeshHandling_;
QCheckBox* loadVertexColor_;
QCheckBox* loadFaceColor_;
QCheckBox* loadAlpha_;
QCheckBox* loadNormals_;
QCheckBox* loadTexCoords_;
QCheckBox* loadTextures_;
//QWidget *loadOptions_, *saveOptions_;
AssimpOptionsWidget *loadOptions_, *saveOptions_;
QComboBox *triMeshHandling_;
QCheckBox * loadVertexColor_ , * loadNormals_ , * loadTexCoords_ , * loadTextures_ ,
* loadLights_ , * loadCameras_ , * loadAnimations_ ;
QPushButton* loadDefaultButton_;
LoaderOptions options_;
QCheckBox* load_assimp_process_calcTangentSpace ;
QCheckBox* load_assimp_process_joinIdenticalVertices ;
QCheckBox* load_assimp_process_makeLeftHanded ;
......@@ -223,6 +262,7 @@ private:
QCheckBox* load_assimp_process_debone ;
std::unordered_map<QCheckBox*, unsigned int> loadOptions;
unsigned int processSteps;
QCheckBox* saveVertexColor_;
QCheckBox* saveFaceColor_;
......@@ -266,7 +306,14 @@ private:
/// maps indices of vertices in an aiMesh to OpenMesh VertexHandles
std::map<unsigned int, OpenMesh::VertexHandle> vertexHandles_;
/// cancels loading
bool cancel_;
/// a list of images, that was loaded by material type
std::unordered_map<unsigned int, std::vector<std::pair<std::string, QImage>>> loadedImages_;
std::vector<std::pair<std::string, QImage>> embeddedTextures_;
};
#include "AssimpPluginT.cc"
#endif // ASSIMPPLUGIN_HH
/*===========================================================================*\
* *
* OpenFlipper *
* Copyright (c) 2001-2015, RWTH-Aachen University *
* Department of Computer Graphics and Multimedia *
* All rights reserved. *
* www.openflipper.org *
* *
*---------------------------------------------------------------------------*
* This file is part of OpenFlipper. *
*---------------------------------------------------------------------------*
* *
* Redistribution and use in source and binary forms, with or without *
* modification, are permitted provided that the following conditions *
* are met: *
* *
* 1. Redistributions of source code must retain the above copyright notice, *
* this list of conditions and the following disclaimer. *
* *
* 2. Redistributions in binary form must reproduce the above copyright *
* notice, this list of conditions and the following disclaimer in the *
* documentation and/or other materials provided with the distribution. *
* *
* 3. Neither the name of the copyright holder nor the names of its *
* contributors may be used to endorse or promote products derived from *
* this software without specific prior written permission. *
* *
* 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 THE COPYRIGHT HOLDER *
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
* 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. *
* *
\*===========================================================================*/
#pragma once
// Defines for the type handling drop down box
#define TYPEAUTODETECT 0
#define TYPEASK 1
#define TYPEPOLY 2
#define TYPETRIANGLE 3
struct LoaderOptions
{
unsigned int triMeshHandling_;
bool loadVertexColorOption_ , loadNormalsOption_ , loadTexCoordsOption_ , loadTexturesOption_,
loadLightsOption_ , loadCamerasOption_ , loadAnimationsOption_;
LoaderOptions() : triMeshHandling_ (TYPEAUTODETECT) , loadVertexColorOption_(false) , loadNormalsOption_(false) ,
loadTexCoordsOption_(false) , loadTexturesOption_ (false) , loadLightsOption_ (false) ,
loadCamerasOption_ (false) , loadAnimationsOption_ (false)
{}
};
/*===========================================================================*\
* *
* OpenFlipper *
* Copyright (c) 2001-2015, RWTH-Aachen University *
* Department of Computer Graphics and Multimedia *
* All rights reserved. *
* www.openflipper.org *
* *
*---------------------------------------------------------------------------*
* This file is part of OpenFlipper. *
*---------------------------------------------------------------------------*
* *
* Redistribution and use in source and binary forms, with or without *
* modification, are permitted provided that the following conditions *
* are met: *
* *
* 1. Redistributions of source code must retain the above copyright notice, *
* this list of conditions and the following disclaimer. *
* *
* 2. Redistributions in binary form must reproduce the above copyright *
* notice, this list of conditions and the following disclaimer in the *
* documentation and/or other materials provided with the distribution. *
* *
* 3. Neither the name of the copyright holder nor the names of its *
* contributors may be used to endorse or promote products derived from *
* this software without specific prior written permission. *
* *
* 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 THE COPYRIGHT HOLDER *
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
* 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. *
* *
\*===========================================================================*/
#pragma once
template <typename Mesh>
void AssimpPlugin::mapVertices(Mesh *_polyMesh, aiMesh *_mesh) {
vertexHandles_.clear();
std::cout<<"mesh has "<<_mesh->GetNumColorChannels()<<" color channels"<<std::endl;
bool tc1requested = false;
bool tc2requested = false;
bool tc3requested = false;
//
for (unsigned int i = 0; i < _mesh->mNumVertices; ++i) {
vertexHandles_[i] = _polyMesh->add_vertex(ACG::Vec3d(_mesh->mVertices[i].x, _mesh->mVertices[i].y, _mesh->mVertices[i].z));
//load vertexColors
for(unsigned int j = 0 ; j < _mesh->GetNumColorChannels(); ++j)
{
if(options_.loadVertexColorOption_ && _mesh->HasVertexColors(j))
_polyMesh->set_color(vertexHandles_[i], PolyMesh::Color(_mesh->mColors[j][i].r, _mesh->mColors[j][i].g, _mesh->mColors[j][i].b, _mesh->mColors[j][i].a));
}
//load texCoords
for(unsigned int j = 0 ; j < _mesh->GetNumUVChannels(); ++j)
{
if(options_.loadTexCoordsOption_ && _mesh->HasTextureCoords(j))
{
if(_mesh->mNumUVComponents[j] == 1)
{
if(!tc1requested)
{
_polyMesh->request_vertex_texcoords1D();
tc1requested = true;
}
_polyMesh->set_texcoord1D(vertexHandles_[i], PolyMesh::TexCoord1D(_mesh->mTextureCoords[j][i].x));
}
if(_mesh->mNumUVComponents[j] == 2)
{
if(!tc2requested)
{
_polyMesh->request_vertex_texcoords2D();
tc2requested = true;
}
_polyMesh->set_texcoord2D(vertexHandles_[i], PolyMesh::TexCoord2D(_mesh->mTextureCoords[j][i].x, _mesh->mTextureCoords[j][i].y));
}
if(_mesh->mNumUVComponents[j] == 3)
{
if(!tc3requested)
{
_polyMesh->request_vertex_texcoords3D();
tc3requested = true;
}
_polyMesh->set_texcoord3D(vertexHandles_[i], PolyMesh::TexCoord3D(_mesh->mTextureCoords[j][i].x, _mesh->mTextureCoords[j][i].y, _mesh->mTextureCoords[j][i].z));
}
}
}
}
}
include(plugin)
openflipper_plugin(DEPS ASSIMP
TYPES POLYMESH TRIANGLEMESH)
openflipper_plugin(DIRS widgets
DEPS ASSIMP
TYPES POLYMESH TRIANGLEMESH
OPT_TYPES LIGHT CAMERA SKELETON)
/*===========================================================================*\
* *
* OpenFlipper *
* Copyright (c) 2001-2015, RWTH-Aachen University *
* Department of Computer Graphics and Multimedia *
* All rights reserved. *
* www.openflipper.org *
* *
*---------------------------------------------------------------------------*
* This file is part of OpenFlipper. *
*---------------------------------------------------------------------------*
* *
* Redistribution and use in source and binary forms, with or without *
* modification, are permitted provided that the following conditions *
* are met: *
* *
* 1. Redistributions of source code must retain the above copyright notice, *
* this list of conditions and the following disclaimer. *
* *
* 2. Redistributions in binary form must reproduce the above copyright *
* notice, this list of conditions and the following disclaimer in the *
* documentation and/or other materials provided with the distribution. *
* *
* 3. Neither the name of the copyright holder nor the names of its *
* contributors may be used to endorse or promote products derived from *
* this software without specific prior written permission. *
* *
* 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 THE COPYRIGHT HOLDER *
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
* 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. *
* *
\*===========================================================================*/
#include "AssimpLoadOptionsWidget.hh"
#include <assimp/postprocess.h>
#include <OpenFlipper/common/GlobalOptions.hh>
#include "../AssimpPluginCommon.hh"
AssimpLoadOptionsWidget::AssimpLoadOptionsWidget(LoaderOptions & loader, QWidget * parent )
: AssimpOptionsWidget ("Load", loader, parent)
{
// 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") );
loadVertexColor_ = new QCheckBox("Load Vertex Colors");
loadNormals_ = new QCheckBox("Load Vertex Normals");
loadTexCoords_ = new QCheckBox("Load Vertex Texture Coordinates");
loadTextures_ = new QCheckBox("Load Textures");
loadLights_ = new QCheckBox("Load Lights");
loadCameras_ = new QCheckBox("Load Cameras");
loadAnimations_ = new QCheckBox("Load Animations");
#ifndef ENABLE_LIGHT_SUPPORT
loadLights_->setEnabled(false);
#endif
#ifndef ENABLE_CAMERA_SUPPORT
loadCameras_->setEnabled(false);
#endif
#ifndef ENABLE_SKELETON_SUPPORT
loadAnimations_->setEnabled(false);
#endif
connect(loadVertexColor_, &QCheckBox::toggled, [&](bool _toggled){loader.loadVertexColorOption_ = _toggled ;});
connect(loadNormals_ , &QCheckBox::toggled, [&](bool _toggled){loader.loadNormalsOption_ = _toggled ;});
connect(loadTexCoords_ , &QCheckBox::toggled, [&](bool _toggled){loader.loadTexCoordsOption_ = _toggled ;});
connect(loadTextures_ , &QCheckBox::toggled, [&](bool _toggled){loader.loadTexturesOption_ = _toggled ;});
connect(loadLights_ , &QCheckBox::toggled, [&](bool _toggled){loader.loadLightsOption_ = _toggled ;});
connect(loadCameras_ , &QCheckBox::toggled, [&](bool _toggled){loader.loadCamerasOption_ = _toggled ;});
connect(loadAnimations_ , &QCheckBox::toggled, [&](bool _toggled){loader.loadAnimationsOption_ = _toggled ;});
connect(triMeshHandling_ , static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), [&loader](unsigned int _index){loader.triMeshHandling_ = _index;});
QList<QWidget*> generalOptions = {triMeshHandling_, loadVertexColor_, loadNormals_, loadTexCoords_,
loadTextures_, loadLights_, loadCameras_, loadAnimations_};
QTreeWidgetItem* general = new QTreeWidgetItem();
general->setText(0,"General");
tree->invisibleRootItem()->insertChild(0,general);
for(QList<QWidget*>::iterator it = generalOptions.begin() ; it != generalOptions.end(); ++it)
{
QTreeWidgetItem* treeWidget = new QTreeWidgetItem();
general->addChild(treeWidget);
tree->setItemWidget(treeWidget,0,*it);
}
connect(makeDefaultButton_, SIGNAL(clicked()), this, SLOT(slotMakeDefault()));
triMeshHandling_->setCurrentIndex(OpenFlipperSettings().value("Assimp/Load/TriMeshHandling",TYPEAUTODETECT).toInt() );
loadVertexColor_->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() );
}
void AssimpLoadOptionsWidget::slotMakeDefault()
{
OpenFlipperSettings().setValue( "Assimp/Load/FaceColor", loadVertexColor_->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( "Core/File/UseLoadDefaults", true );
}
/*===========================================================================*\
* *
* OpenFlipper *
* Copyright (c) 2001-2015, RWTH-Aachen University *
* Department of Computer Graphics and Multimedia *
* All rights reserved. *
* www.openflipper.org *
* *
*---------------------------------------------------------------------------*
* This file is part of OpenFlipper. *
*---------------------------------------------------------------------------*
* *
* Redistribution and use in source and binary forms, with or without *
* modification, are permitted provided that the following conditions *
* are met: *
* *
* 1. Redistributions of source code must retain the above copyright notice, *
* this list of conditions and the following disclaimer. *
* *
* 2. Redistributions in binary form must reproduce the above copyright *
* notice, this list of conditions and the following disclaimer in the *
* documentation and/or other materials provided with the distribution. *
* *
* 3. Neither the name of the copyright holder nor the names of its *
* contributors may be used to endorse or promote products derived from *
* this software without specific prior written permission. *
* *
* 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 THE COPYRIGHT HOLDER *
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
* 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. *
* *
\*===========================================================================*/
#pragma once
#include "AssimpOptionsWidget.hh"
#include <QtWidgets>
#include <unordered_map>
struct LoaderOptions;
class AssimpLoadOptionsWidget : public AssimpOptionsWidget
{
Q_OBJECT
public:
AssimpLoadOptionsWidget(LoaderOptions& loader, QWidget * parent = 0);
QComboBox *triMeshHandling_;
QCheckBox * loadVertexColor_ , * loadNormals_ , * loadTexCoords_ , * loadTextures_ ,
* loadLights_ , * loadCameras_ , * loadAnimations_ ;
private slots:
void slotMakeDefault();
};
/*===========================================================================*\
* *
* OpenFlipper *
* Copyright (c) 2001-2015, RWTH-Aachen University *
* Department of Computer Graphics and Multimedia *
* All rights reserved. *
* www.openflipper.org *
* *
*---------------------------------------------------------------------------*
* This file is part of OpenFlipper. *
*---------------------------------------------------------------------------*
* *
* Redistribution and use in source and binary forms, with or without *
* modification, are permitted provided that the following conditions *
* are met: *
* *
* 1. Redistributions of source code must retain the above copyright notice, *
* this list of conditions and the following disclaimer. *
* *
* 2. Redistributions in binary form must reproduce the above copyright *
* notice, this list of conditions and the following disclaimer in the *
* documentation and/or other materials provided with the distribution. *
* *
* 3. Neither the name of the copyright holder nor the names of its *
* contributors may be used to endorse or promote products derived from *
* this software without specific prior written permission. *
* *
* 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 THE COPYRIGHT HOLDER *
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
* 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. *
* *
\*===========================================================================*/
#pragma once
#include "ui_AssimpOptionsWidget.hh"
#include <QtWidgets>
#include <unordered_map>
struct LoaderOptions;
class AssimpOptionsWidget : public QWidget, public Ui::AssimpOptionsWidget
{
Q_OBJECT
public:
AssimpOptionsWidget(const QString & _settingPrefix, LoaderOptions& loader, QWidget * parent = 0);
QString settingPrefix;
QCheckBox* option_assimp_process_calcTangentSpace ;
QCheckBox* option_assimp_process_joinIdenticalVertices ;
QCheckBox* option_assimp_process_makeLeftHanded ;
QCheckBox* option_assimp_process_triangulate ;
QCheckBox* option_assimp_process_removeComponent ;
QCheckBox* option_assimp_process_genNormals ;
QCheckBox* option_assimp_process_genSmoothNormals ;
QCheckBox* option_assimp_process_splitLargeMeshes ;
QCheckBox* option_assimp_process_preTransformVertices ;
QCheckBox* option_assimp_process_limitBoneWeights ;
QCheckBox* option_assimp_process_validateDataStructure ;
QCheckBox* option_assimp_process_improveCacheLocality ;
QCheckBox* option_assimp_process_removeRedundantMaterials;
QCheckBox* option_assimp_process_fixInfacingNormals ;
QCheckBox* option_assimp_process_sortByPType ;
QCheckBox* option_assimp_process_findDegenerates ;
QCheckBox* option_assimp_process_findInvalidData ;
QCheckBox* option_assimp_process_genUVCoords ;
QCheckBox* option_assimp_process_transformUVCoords ;
QCheckBox* option_assimp_process_findInstances ;
QCheckBox* option_assimp_process_optimizeMeshes ;
QCheckBox* option_assimp_process_optimizeGraph ;
QCheckBox* option_assimp_process_flipUVs ;
QCheckBox* option_assimp_process_flipWindingOrder ;
QCheckBox* option_assimp_process_splitByBoneCount ;
QCheckBox* option_assimp_process_debone ;
std::unordered_map<QCheckBox*, unsigned int> loadOptions;
unsigned int processSteps();
private slots:
void slotMakeDefault();
void slotSaveDefault();
};
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>AssimpOptionsWidget</class>
<widget class="QWidget" name="AssimpOptionsWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>485</width>
<height>338</height>
</rect>
</property>
<property name="windowTitle">
<string>Property Visualization</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_7">
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QTreeWidget" name="tree">
<column>
<property name="text">
<string>Configuration:</string>
</property>
</column>
</widget>
</item>
<item>
<widget class="QPushButton" name="makeDefaultButton_">
<property name="text">
<string>Make Default</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
/*===========================================================================*\
* *
* OpenFlipper *
* Copyright (c) 2001-2015, RWTH-Aachen University *
* Department of Computer Graphics and Multimedia *
* All rights reserved. *
* www.openflipper.org *
* *
*---------------------------------------------------------------------------*
* This file is part of OpenFlipper. *
*---------------------------------------------------------------------------*
* *
* Redistribution and use in source and binary forms, with or without *
* modification, are permitted provided that the following conditions *
* are met: *
* *
* 1. Redistributions of source code must retain the above copyright notice, *
* this list of conditions and the following disclaimer. *
* *
* 2. Redistributions in binary form must reproduce the above copyright *
* notice, this list of conditions and the following disclaimer in the *
* documentation and/or other materials provided with the distribution. *
* *
* 3. Neither the name of the copyright holder nor the names of its *
* contributors may be used to endorse or promote products derived from *
* this software without specific prior written permission. *
* *
* 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 THE COPYRIGHT HOLDER *
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
* 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. *
* *
\*===========================================================================*/
#include "AssimpSaveOptionsWidget.hh"
#include <assimp/postprocess.h>
#include <OpenFlipper/common/GlobalOptions.hh>
#include "../AssimpPluginCommon.hh"
AssimpSaveOptionsWidget::AssimpSaveOptionsWidget(LoaderOptions & loader, QWidget * parent )
: AssimpOptionsWidget ("Save", loader, parent)
{
// generic configuration
saveVertexColor_ = new QCheckBox("Save Vertex Colors");
saveNormals_ = new QCheckBox("Save Vertex Normals");
saveTexCoords_ = new QCheckBox("Save Vertex Texture Coordinates");
saveTextures_ = new QCheckBox("Save Textures");
saveLights_ = new QCheckBox("Save Lights");
saveCameras_ = new QCheckBox("Save Cameras");
saveAnimations_ = new QCheckBox("Save Animations");
#ifndef ENABLE_LIGHT_SUPPORT
saveLights_->setEnabled(false);
#endif
#ifndef ENABLE_CAMERA_SUPPORT
saveCameras_->setEnabled(false);
#endif
#ifndef ENABLE_SKELETON_SUPPORT
saveAnimations_->setEnabled(false);
#endif
connect(saveVertexColor_, &QCheckBox::toggled, [&](bool _toggled){loader.loadVertexColorOption_ = _toggled ;});
connect(saveNormals_ , &QCheckBox::toggled, [&](bool _toggled){loader.loadNormalsOption_ = _toggled ;});
connect(saveTexCoords_ , &QCheckBox::toggled, [&](bool _toggled){loader.loadTexCoordsOption_ = _toggled ;});
connect(saveTextures_ , &QCheckBox::toggled, [&](bool _toggled){loader.loadTexturesOption_ = _toggled ;});
connect(saveLights_ , &QCheckBox::toggled, [&](bool _toggled){loader.loadLightsOption_ = _toggled ;});
connect(saveCameras_ , &QCheckBox::toggled, [&](bool _toggled){loader.loadCamerasOption_ = _toggled ;});
connect(saveAnimations_ , &QCheckBox::toggled, [&](bool _toggled){loader.loadAnimationsOption_ = _toggled ;});
QList<QWidget*> generalOptions = {saveVertexColor_, saveNormals_, saveTexCoords_,
saveTextures_ , saveLights_ , saveCameras_ , saveAnimations_};
QTreeWidgetItem* general = new QTreeWidgetItem();
general->setText(0,"General");
tree->invisibleRootItem()->insertChild(0,general);
for(QList<QWidget*>::iterator it = generalOptions.begin() ; it != generalOptions.end(); ++it)
{
QTreeWidgetItem* treeWidget = new QTreeWidgetItem();
general->addChild(treeWidget);
tree->setItemWidget(treeWidget,0,*it);
}
connect(makeDefaultButton_, SIGNAL(clicked()), this, SLOT(slotMakeDefault()));
saveVertexColor_->setChecked( OpenFlipperSettings().value("Assimp/Save/FaceColor",true).toBool() );
saveNormals_->setChecked ( OpenFlipperSettings().value("Assimp/Save/Normals" ,true).toBool() );
saveTexCoords_->setChecked ( OpenFlipperSettings().value("Assimp/Save/TexCoords",true).toBool() );
saveTextures_->setChecked ( OpenFlipperSettings().value("Assimp/Save/Textures" ,true).toBool() );
}
void AssimpSaveOptionsWidget::slotMakeDefault()
{
OpenFlipperSettings().setValue( "Assimp/Save/FaceColor", saveVertexColor_->isChecked() );
OpenFlipperSettings().setValue( "Assimp/Save/Normals", saveNormals_->isChecked() );
OpenFlipperSettings().setValue( "Assimp/Save/TexCoords", saveTexCoords_->isChecked() );
OpenFlipperSettings().setValue( "Assimp/Save/Textures", saveTextures_->isChecked() );
OpenFlipperSettings().setValue( "Core/File/UseLoadDefaults", true );
}
/*===========================================================================*\
* *
* OpenFlipper *
* Copyright (c) 2001-2015, RWTH-Aachen University *
* Department of Computer Graphics and Multimedia *
* All rights reserved. *
* www.openflipper.org *
* *
*---------------------------------------------------------------------------*
* This file is part of OpenFlipper. *
*---------------------------------------------------------------------------*
* *
* Redistribution and use in source and binary forms, with or without *
* modification, are permitted provided that the following conditions *
* are met: *
* *
* 1. Redistributions of source code must retain the above copyright notice, *
* this list of conditions and the following disclaimer. *
* *
* 2. Redistributions in binary form must reproduce the above copyright *
* notice, this list of conditions and the following disclaimer in the *
* documentation and/or other materials provided with the distribution. *
* *
* 3. Neither the name of the copyright holder nor the names of its *
* contributors may be used to endorse or promote products derived from *
* this software without specific prior written permission. *
* *
* 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 THE COPYRIGHT HOLDER *
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
* 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. *
* *
\*===========================================================================*/
#pragma once
#include "AssimpOptionsWidget.hh"
#include <QtWidgets>
#include <unordered_map>
struct LoaderOptions;
class AssimpSaveOptionsWidget : public AssimpOptionsWidget
{
Q_OBJECT
public:
AssimpSaveOptionsWidget(LoaderOptions& loader, QWidget * parent = 0);
QCheckBox * saveVertexColor_ , * saveNormals_ , * saveTexCoords_ , * saveTextures_ ,
* saveLights_ , * saveCameras_ , * saveAnimations_ ;
private slots:
void slotMakeDefault();
};