Commit 2790e9f3 authored by Martin Schultz's avatar Martin Schultz

added widgets folder to cmakelists

modified assimpPlugin to split loading of components to different
functions
parent 7db6f547
...@@ -58,6 +58,7 @@ ...@@ -58,6 +58,7 @@
#include <OpenFlipper/BasePlugin/RPCInterface.hh> #include <OpenFlipper/BasePlugin/RPCInterface.hh>
#include <OpenFlipper/BasePlugin/AboutInfoInterface.hh> #include <OpenFlipper/BasePlugin/AboutInfoInterface.hh>
#include <OpenFlipper/BasePlugin/ProcessInterface.hh> #include <OpenFlipper/BasePlugin/ProcessInterface.hh>
#include <OpenFlipper/BasePlugin/TextureInterface.hh>
#include <ObjectTypes/PolyMesh/PolyMesh.hh> #include <ObjectTypes/PolyMesh/PolyMesh.hh>
#include <ObjectTypes/TriangleMesh/TriangleMesh.hh> #include <ObjectTypes/TriangleMesh/TriangleMesh.hh>
...@@ -69,8 +70,12 @@ ...@@ -69,8 +70,12 @@
#include<unordered_map> #include<unordered_map>
#include "AssimpPluginCommon.hh"
class AssimpOptionsWidget;
class AssimpPlugin : public QObject, BaseInterface, FileInterface, LoadSaveInterface, class AssimpPlugin : public QObject, BaseInterface, FileInterface, LoadSaveInterface,
LoggingInterface, ScriptInterface, RPCInterface, AboutInfoInterface, ProcessInterface LoggingInterface, ScriptInterface, RPCInterface, AboutInfoInterface, ProcessInterface, TextureInterface
{ {
Q_OBJECT Q_OBJECT
Q_INTERFACES(FileInterface) Q_INTERFACES(FileInterface)
...@@ -81,6 +86,7 @@ class AssimpPlugin : public QObject, BaseInterface, FileInterface, LoadSaveInter ...@@ -81,6 +86,7 @@ class AssimpPlugin : public QObject, BaseInterface, FileInterface, LoadSaveInter
Q_INTERFACES(RPCInterface) Q_INTERFACES(RPCInterface)
Q_INTERFACES(AboutInfoInterface) Q_INTERFACES(AboutInfoInterface)
Q_INTERFACES(ProcessInterface) Q_INTERFACES(ProcessInterface)
Q_INTERFACES(TextureInterface)
#if QT_VERSION >= 0x050000 #if QT_VERSION >= 0x050000
Q_PLUGIN_METADATA(IID "org.OpenFlipper.Plugins.Plugin-Assimp") Q_PLUGIN_METADATA(IID "org.OpenFlipper.Plugins.Plugin-Assimp")
...@@ -103,6 +109,13 @@ class AssimpPlugin : public QObject, BaseInterface, FileInterface, LoadSaveInter ...@@ -103,6 +109,13 @@ class AssimpPlugin : public QObject, BaseInterface, FileInterface, LoadSaveInter
//AboutInfoInterface //AboutInfoInterface
void addAboutInfo(QString _text, QString _tabName ); 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: public:
AssimpPlugin(); AssimpPlugin();
...@@ -150,6 +163,7 @@ private slots: ...@@ -150,6 +163,7 @@ private slots:
signals: signals:
bool showConfirmationDialog(const QString& _title, const QString & _message); bool showConfirmationDialog(const QString& _title, const QString & _message);
// void addTexture(TextureNode* _node, const QImage& img);
private: private:
...@@ -172,29 +186,54 @@ private: ...@@ -172,29 +186,54 @@ private:
bool convertTriMeshToAiMesh(TriMesh* _triMesh, aiMesh* _mesh); bool convertTriMeshToAiMesh(TriMesh* _triMesh, aiMesh* _mesh);
/// add a vertex from _mesh to _polyMesh and stores the index to handle mapping /// 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 /// 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 /// 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: private:
//Option Widgets //Option Widgets
QWidget* loadOptions_; //QWidget *loadOptions_, *saveOptions_;
QWidget* saveOptions_; AssimpOptionsWidget *loadOptions_, *saveOptions_;
QComboBox *triMeshHandling_;
QCheckBox * loadVertexColor_ , * loadNormals_ , * loadTexCoords_ , * loadTextures_ ,
* loadLights_ , * loadCameras_ , * loadAnimations_ ;
QComboBox* triMeshHandling_;
QCheckBox* loadVertexColor_;
QCheckBox* loadFaceColor_;
QCheckBox* loadAlpha_;
QCheckBox* loadNormals_;
QCheckBox* loadTexCoords_;
QCheckBox* loadTextures_;
QPushButton* loadDefaultButton_; QPushButton* loadDefaultButton_;
LoaderOptions options_;
QCheckBox* load_assimp_process_calcTangentSpace ; QCheckBox* load_assimp_process_calcTangentSpace ;
QCheckBox* load_assimp_process_joinIdenticalVertices ; QCheckBox* load_assimp_process_joinIdenticalVertices ;
QCheckBox* load_assimp_process_makeLeftHanded ; QCheckBox* load_assimp_process_makeLeftHanded ;
...@@ -223,6 +262,7 @@ private: ...@@ -223,6 +262,7 @@ private:
QCheckBox* load_assimp_process_debone ; QCheckBox* load_assimp_process_debone ;
std::unordered_map<QCheckBox*, unsigned int> loadOptions; std::unordered_map<QCheckBox*, unsigned int> loadOptions;
unsigned int processSteps;
QCheckBox* saveVertexColor_; QCheckBox* saveVertexColor_;
QCheckBox* saveFaceColor_; QCheckBox* saveFaceColor_;
...@@ -266,7 +306,14 @@ private: ...@@ -266,7 +306,14 @@ private:
/// maps indices of vertices in an aiMesh to OpenMesh VertexHandles /// maps indices of vertices in an aiMesh to OpenMesh VertexHandles
std::map<unsigned int, OpenMesh::VertexHandle> vertexHandles_; std::map<unsigned int, OpenMesh::VertexHandle> vertexHandles_;
/// cancels loading
bool cancel_; 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 #endif // ASSIMPPLUGIN_HH
include(plugin) include(plugin)
openflipper_plugin(DEPS ASSIMP openflipper_plugin(DIRS widgets
TYPES POLYMESH TRIANGLEMESH) DEPS ASSIMP
TYPES POLYMESH TRIANGLEMESH
OPT_TYPES LIGHT CAMERA SKELETON)
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