...
 
Commits (3)
......@@ -44,22 +44,64 @@
#include "AssimpPlugin.hh"
#include <Type-Light/ObjectTypes/Light/Light.hh>
#include <Type-Light/ObjectTypes/Light/LightObject.hh>
#include <ObjectTypes/Light/LightNode.hh>
#include <OpenMesh/Core/Geometry/VectorT.hh>
#include <Type-Light/ObjectTypes/Light/PluginFunctionsLight.hh>
// Defines for the type handling drop down box
#define TYPEAUTODETECT 0
#define TYPEASK 1
#define TYPEPOLY 2
#define TYPETRIANGLE 3
#include <ObjectTypes/Camera/Camera.hh>
#include "AssimpPluginCommon.hh"
#include "widgets/AssimpOptionsWidget.hh"
#include "widgets/AssimpLoadOptionsWidget.hh"
#include "widgets/AssimpSaveOptionsWidget.hh"
using namespace OpenMesh;
namespace
{
//helper function to convert aiVector to OpenMeshVector
template<typename T, typename R>
static T toOMVec(R _vec)
{
T res;
for(size_t i = 0 ; i < res.size() ; ++i )
res[i] = _vec[i];
return res;
}
}
// static variable to conveniently iterate over all texture types of assimp
std::vector<aiTextureType> allTextureTypes = {aiTextureType_UNKNOWN ,
aiTextureType_AMBIENT ,
aiTextureType_DIFFUSE ,
aiTextureType_DISPLACEMENT ,
aiTextureType_EMISSIVE ,
aiTextureType_HEIGHT ,
aiTextureType_LIGHTMAP ,
aiTextureType_NONE ,
aiTextureType_NORMALS ,
aiTextureType_OPACITY ,
aiTextureType_REFLECTION ,
aiTextureType_SHININESS ,
aiTextureType_SPECULAR };
AssimpPlugin::AssimpPlugin()
:
loadOptions_(nullptr),
saveOptions_(nullptr),
type_(DATA_TRIANGLE_MESH),
options_(),
type_(DATA_UNKNOWN),
cancel_(false)
{
processSteps = aiProcess_FindDegenerates | aiProcess_JoinIdenticalVertices | 0;
}
//--------------------------------------------------------------------------
void AssimpPlugin::initializePlugin() {
QString info =
......@@ -92,68 +134,55 @@ void AssimpPlugin::initializePlugin() {
emit addAboutInfo(info,"File-Assimp Plugin");
connect(this, SIGNAL(showConfirmationDialog(const QString&, const QString&)), this, SLOT(slotShowConfirmationDialog(const QString&, const QString&)), Qt::BlockingQueuedConnection);
connect(this, SIGNAL(showConfirmationDialog(const QString&, const QString&)), this, SLOT(slotShowConfirmationDialog(const QString&, const QString&)), Qt::BlockingQueuedConnection);
}
//--------------------------------------------------------------------------
int AssimpPlugin::convertAiSceneToOpenMesh(const aiScene *_scene, QString _objectName) {
int returnId = -1;
std::vector<int> ids;
embeddedTextures_.clear();
loadedImages_.clear();
if (_scene->mNumMeshes == 0)
emit log(LOGWARN, tr("aiScene contains no meshes"));
if(_scene->mNumMaterials > 1)
// TODO: change the confirmation dialog to a selection dialog where the user can select how to deal with multiple materials
if(_scene->mNumMaterials > 1 && OpenFlipper::Options::gui())
{
if(!emit showConfirmationDialog(tr("Multiple MAterials in file"),
if(!emit showConfirmationDialog(tr("Multiple Materials in file"),
tr("The File you are trying to load contains %1 materials. "
"Assimp creates a separate Mesh for each material, which may cause performance issues.\n\n "
"Do you want to continue loading the file?").arg(_scene->mNumMaterials)))
return returnId;
}
//load textures first if requested,
//as they are referenced by the materials
if(options_.loadTexturesOption_)
loadTexturesFromScene(_scene);
// we always want to load meshes
loadMeshesFromScene(_scene, ids, _objectName);
returnId = ids[0];
#ifdef ENABLE_CAMERA_SUPPORT
if(options_.loadCamerasOption_)
loadCamerasFromScene(_scene);
#endif
#ifdef ENABLE_LIGHT_SUPPORT
if(options_.loadLightsOption_)
loadLightsFromScene(_scene);
#endif
#ifdef ENABLE_SKELETON_SUPPORT
if(options_.loadAnimationsOption_)
loadAnimationsFromScene(_scene);
#endif
for (unsigned int i = 0; i < _scene->mNumMeshes && !cancel_; ++i) {
int objectId = -1;
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 )) {
emit log(LOGERR, tr("Could not create new object!"));
return -1;
}
if (i == 0)
returnId = objectId;
object->setName(_objectName);
PolyMeshObject* polyMeshObj = dynamic_cast< PolyMeshObject* > (object);
TriMeshObject* triMeshObj = dynamic_cast< TriMeshObject* > (object);
if (polyMeshObj) {
convertAiMeshToPolyMesh(polyMeshObj->mesh(), _scene->mMeshes[i]);
emit updatedObject(polyMeshObj->id(), UPDATE_ALL);
ids.push_back(object->id());
} else if (triMeshObj) {
convertAiMeshToTriMesh(triMeshObj->mesh(), _scene->mMeshes[i]);
emit updatedObject(triMeshObj->id(), UPDATE_ALL);
ids.push_back(object->id());
}
emit openedFile( object->id() );
}
//group OpenFlipper objects, if the file contains multiple meshes
if (_scene->mNumMeshes > 1) {
bool dataControlExists = false;
pluginExists( "datacontrol", dataControlExists );
......@@ -166,6 +195,8 @@ int AssimpPlugin::convertAiSceneToOpenMesh(const aiScene *_scene, QString _objec
return returnId;
}
//--------------------------------------------------------------------------
bool AssimpPlugin::convertOpenMeshToAiScene(aiScene *_scene, BaseObjectData *_object) {
_scene->mMeshes = new aiMesh*[1];
_scene->mMeshes[0] = new aiMesh();
......@@ -193,6 +224,8 @@ bool AssimpPlugin::convertOpenMeshToAiScene(aiScene *_scene, BaseObjectData *_ob
}
}
//--------------------------------------------------------------------------
void AssimpPlugin::convertAiMeshToPolyMesh(PolyMesh *_polyMesh, aiMesh *_mesh) {
mapVertices(_polyMesh, _mesh);
......@@ -201,12 +234,11 @@ void AssimpPlugin::convertAiMeshToPolyMesh(PolyMesh *_polyMesh, aiMesh *_mesh) {
aiFace& face = _mesh->mFaces[i];
for (unsigned int j = 0; j < face.mNumIndices; ++j) {
vhandles.push_back(vertexHandles_[face.mIndices[j]]);
if (_mesh->HasNormals()) {
if (_mesh->HasNormals() && options_.loadNormalsOption_) {
aiVector3D& aiNormal = _mesh->mNormals[face.mIndices[j]];
_polyMesh->set_normal(vhandles.back(), ACG::Vec3d(aiNormal.x, aiNormal.y, aiNormal.z));
}
}
_polyMesh->add_face(vhandles);
vhandles.clear();
}
......@@ -217,6 +249,8 @@ void AssimpPlugin::convertAiMeshToPolyMesh(PolyMesh *_polyMesh, aiMesh *_mesh) {
_polyMesh->update_face_normals();
}
//--------------------------------------------------------------------------
void AssimpPlugin::convertAiMeshToTriMesh(TriMesh *_triMesh, aiMesh *_mesh) {
mapVertices(_triMesh, _mesh);
......@@ -225,7 +259,7 @@ void AssimpPlugin::convertAiMeshToTriMesh(TriMesh *_triMesh, aiMesh *_mesh) {
aiFace& face = _mesh->mFaces[i];
for (unsigned int j = 0; j < face.mNumIndices; ++j) {
vhandles.push_back(vertexHandles_[face.mIndices[j]]);
if (_mesh->HasNormals()) {
if (_mesh->HasNormals() && options_.loadNormalsOption_) {
aiVector3D& aiNormal = _mesh->mNormals[face.mIndices[j]];
_triMesh->set_normal(vhandles.back(), ACG::Vec3d(aiNormal.x, aiNormal.y, aiNormal.z));
}
......@@ -241,6 +275,8 @@ void AssimpPlugin::convertAiMeshToTriMesh(TriMesh *_triMesh, aiMesh *_mesh) {
_triMesh->update_face_normals();
}
//--------------------------------------------------------------------------
bool AssimpPlugin::convertPolyMeshToAiMesh(PolyMesh *_polyMesh, aiMesh *_mesh) {
_mesh->mPrimitiveTypes = aiPrimitiveType_POLYGON;
_mesh->mNumVertices = _polyMesh->n_vertices();
......@@ -278,6 +314,8 @@ bool AssimpPlugin::convertPolyMeshToAiMesh(PolyMesh *_polyMesh, aiMesh *_mesh) {
return true;
}
//--------------------------------------------------------------------------
bool AssimpPlugin::convertTriMeshToAiMesh(TriMesh *_triMesh, aiMesh *_mesh) {
_mesh->mPrimitiveTypes = aiPrimitiveType_TRIANGLE;
_mesh->mNumVertices = _triMesh->n_vertices();
......@@ -310,326 +348,295 @@ bool AssimpPlugin::convertTriMeshToAiMesh(TriMesh *_triMesh, aiMesh *_mesh) {
return true;
}
void AssimpPlugin::mapVertices(PolyMesh *_polyMesh, aiMesh *_mesh) {
vertexHandles_.clear();
//--------------------------------------------------------------------------
void AssimpPlugin::loadAnimationsFromScene(const aiScene* _scene)
{
for(unsigned int i = 0 ; !cancel_ && i < _scene->mNumAnimations ; ++i)
{
//TODO: implement animation loading
}
}
//--------------------------------------------------------------------------
void AssimpPlugin::loadLightsFromScene(const aiScene* _scene)
{
for(unsigned int i = 0 ; !cancel_ && i < _scene->mNumLights ; ++i)
{
//only support point lights for now
//TODO: support more light types
if(_scene->mLights[i]->mType == aiLightSource_POINT)
{
int id;
BaseObjectData* object;
emit addEmptyObject(DATA_LIGHT, id);
if(!PluginFunctions::getObject(id, object))
{
emit log(LOGERR, "could not add new light object");
return;
}
LightObject* light = PluginFunctions::lightObject(object);
if(light)
{
light->setName(_scene->mLights[i]->mName.C_Str());
//compute the absolute light position
aiNode* node = _scene->mRootNode->FindNode(_scene->mLights[i]->mName);
//TODO: check if position is always corrent, e.g. if multiple nodes are used,
//and for file formats other than blender files
aiVector3D position = node->mTransformation * _scene->mLights[i]->mPosition;
LightSource* source = PluginFunctions::lightSource(light);
source->position(toOMVec<Vec3d>(position));
source->constantAttenuation(_scene->mLights[i]->mAttenuationConstant);
source->linearAttenuation(_scene->mLights[i]->mAttenuationLinear);
source->quadraticAttenuation(_scene->mLights[i]->mAttenuationQuadratic);
source->ambientColor(color_cast<Vec4f>(toOMVec<Vec3f>(_scene->mLights[i]->mColorAmbient)));
source->diffuseColor(color_cast<Vec4f>(toOMVec<Vec3f>(_scene->mLights[i]->mColorDiffuse)));
source->specularColor(color_cast<Vec4f>(toOMVec<Vec3f>(_scene->mLights[i]->mColorSpecular)));
source->enable();
emit updatedObject(id, UPDATE_ALL);
}
}
else
emit log(LOGWARN, "unsupported light type");
}
}
//--------------------------------------------------------------------------
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));
void AssimpPlugin::loadCamerasFromScene(const aiScene* _scene)
{
for(unsigned int i = 0 ; !cancel_ && i < _scene->mNumCameras ; ++i)
{
int id;
emit addEmptyObject(DATA_CAMERA,id);
CameraObject* cameraObject = PluginFunctions::cameraObject(id);
if(cameraObject)
{
CameraNode* cameraNode = cameraObject->cameraNode();
cameraObject->setName(_scene->mCameras[i]->mName.C_Str());
cameraNode->setNearPlane(_scene->mCameras[i]->mClipPlaneNear);
cameraNode->setFarPlane(_scene->mCameras[i]->mClipPlaneFar);
//todo retrieve matrices
//cameraNode->
}
emit updatedObject(id,UPDATE_ALL);
}
}
void AssimpPlugin::mapVertices(TriMesh *_triMesh, aiMesh *_mesh) {
vertexHandles_.clear();
//--------------------------------------------------------------------------
void AssimpPlugin::loadTexturesFromScene(const aiScene* _scene)
{
//load embedded textures
for(unsigned int j = 0 ;!cancel_ && j < _scene->mNumTextures ; ++j)
{
aiTexture* tex = _scene->mTextures[j];
QImage img;
img = QImage::fromData(reinterpret_cast<uchar *>(tex->pcData),tex->mWidth);
embeddedTextures_.push_back(std::make_pair(QString("EmbeddedTexture_%1").arg(j).toStdString(),img));
//if you encounter cases where mHeight if tex is not 0, copy them via memcopy, or use the following code block.
/*uint sz = tex->mWidth * tex->mHeight;
QByteArray data;
data.resize(sz * 4);
uchar *p = reinterpret_cast<uchar *>(data.data());
for (uint j = 0; j < sz; ++j) {
*p++ = tex->pcData[j].r;
*p++ = tex->pcData[j].g;
*p++ = tex->pcData[j].b;
*p++ = tex->pcData[j].a;
}
img = QImage(reinterpret_cast<const uchar *>(data.constData()), tex->mWidth, tex->mHeight, QImage::Format_RGBA8888);
img.detach();*/
}
}
for (unsigned int i = 0; i < _mesh->mNumVertices; ++i) {
vertexHandles_[i] = _triMesh->add_vertex(ACG::Vec3d(_mesh->mVertices[i].x, _mesh->mVertices[i].y, _mesh->mVertices[i].z));
//--------------------------------------------------------------------------
std::vector<std::pair<std::string,QImage>> AssimpPlugin::loadTexturesFromMaterial(const aiMaterial* _material, aiTextureType _textureType)
{
std::vector<std::pair<std::string, QImage>> result;
aiString path;
for(unsigned int i = 0 ; i < _material->GetTextureCount(_textureType) ; i++ )
{
//retrieve texture path embedded textures start with * followed by the texture index e.g. *0
_material->GetTexture(_textureType, i, &path, nullptr, nullptr, nullptr, nullptr, nullptr);
if(path.length > 0)
{
if(path.C_Str()[0]=='*') // load the embedded texture
{
const char* substr = path.C_Str();
++substr; //skip leading * character
result.push_back(embeddedTextures_[std::atoi(substr)]);
}
else // load the external texture
{
QImage img(QString(path.C_Str()));
if(!img.isNull())
result.push_back(std::make_pair(path.C_Str(),img));
else
emit log(LOGWARN, QString("could not load texture: %1").arg(path.C_Str()));
}
}
path.Clear();
}
return result;
}
//--------------------------------------------------------------------------
void AssimpPlugin::loadMaterial(const aiScene* _scene, MaterialNode* _materialNode, unsigned int _materialIndex)
{
if(_materialIndex >= _scene->mNumMaterials)
{
emit log(LOGERR, "Unable to load material, index is out of bounds.");
return;
}
//load properties from the material
//TODO: load more properties if applicable
aiMaterial* mat = _scene->mMaterials[_materialIndex];
for(unsigned int i = 0; i < mat->mNumProperties ; ++i)
{
aiColor3D color;
float coefficient;
if(mat->Get(AI_MATKEY_COLOR_DIFFUSE,color)==AI_SUCCESS)
_materialNode->set_diffuse_color(color_cast<Vec4f>(toOMVec<Vec3f>(color)));
if(mat->Get(AI_MATKEY_COLOR_AMBIENT, color)==AI_SUCCESS)
_materialNode->set_ambient_color(color_cast<Vec4f>(toOMVec<Vec3f>(color)));
if(mat->Get(AI_MATKEY_COLOR_EMISSIVE, color)==AI_SUCCESS)
_materialNode->set_emission(color_cast<Vec4f>(toOMVec<Vec3f>(color)));
if(mat->Get(AI_MATKEY_COLOR_SPECULAR, color)==AI_SUCCESS)
_materialNode->set_specular_color(color_cast<Vec4f>(toOMVec<Vec3f>(color)));
if(mat->Get(AI_MATKEY_REFLECTIVITY, coefficient) == AI_SUCCESS)
_materialNode->set_reflectance(coefficient);
if(mat->Get(AI_MATKEY_SHININESS, coefficient) == AI_SUCCESS)
_materialNode->set_shininess(coefficient);
}
//load textures from this material if requested
if(options_.loadTexturesOption_)
{
std::vector<std::pair<std::string, QImage>> materialImages;
for(aiTextureType type : allTextureTypes)
{
//gater all textures in a single vector
auto images = loadTexturesFromMaterial(mat,type);
materialImages.insert(materialImages.end(),images.begin(), images.end());
}
//add entry for the material
loadedImages_[_materialIndex] = materialImages;
}
}
//--------------------------------------------------------------------------
void AssimpPlugin::loadMeshesFromScene(const aiScene* _scene, std::vector<int> & _outIds, QString& _objectName)
{
// create a new OpenFlipper object for each mesh in the scene, as long as the user did not cancel loading
for (unsigned int i = 0; i < _scene->mNumMeshes && !cancel_; ++i) {
int objectId = -1;
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 )) {
emit log(LOGERR, tr("Could not create new object!"));
_outIds.push_back(-1);
return;
}
object->setName(_objectName);
PolyMeshObject* polyMeshObj = dynamic_cast< PolyMeshObject* > (object);
TriMeshObject* triMeshObj = dynamic_cast< TriMeshObject* > (object);
if (polyMeshObj) {
convertAiMeshToPolyMesh(polyMeshObj->mesh(), _scene->mMeshes[i]);
loadMaterial(_scene, polyMeshObj->materialNode(),_scene->mMeshes[i]->mMaterialIndex);
} else if (triMeshObj) {
convertAiMeshToTriMesh(triMeshObj->mesh(), _scene->mMeshes[i]);
loadMaterial(_scene, triMeshObj->materialNode(),_scene->mMeshes[i]->mMaterialIndex);
}
//add the textures if requested
if(options_.loadTexturesOption_)
{
for(auto entry : loadedImages_[_scene->mMeshes[i]->mMaterialIndex])
{
emit addTexture (QString(entry.first.c_str()), entry.second, 2, objectId); //only support 2d textures for now TODO: add more
emit switchTexture (QString(entry.first.c_str()), objectId );
//TODO: investigate why new textures are not rendered. probably because texture index property is not set
//emit setTextureMode(QString(entry.first.c_str()),"indexProperty=OriginalTexIndexMapping", objectId );
}
}
_outIds.push_back(object->id());
emit updatedObject(objectId, UPDATE_ALL);
emit openedFile( object->id() );
}
}
//--------------------------------------------------------------------------
DataType AssimpPlugin::supportedType() {
DataType type = DATA_POLY_MESH | DATA_TRIANGLE_MESH | DATA_GROUP;
return type;
}
//--------------------------------------------------------------------------
QString AssimpPlugin::getSaveFilters() {
return QString( tr("Alias/Wavefront ( *.obj );;Collada ( *.dae );;Stereolithography files ( *.stl );;Polygon File Format files ( *.ply )" ) );
}
//--------------------------------------------------------------------------
QString AssimpPlugin::getLoadFilters() {
return QString( tr("Alias/Wavefront ( *.obj );;AutoCAD DXF ( *.dxf );;Collada ( *.dae );;Stereolithography files ( *.stl );;Polygon File Format files ( *.ply );;Blender 3D( *.blend );;3ds Max 3DS ( *.3ds );;3ds Max ASE( *.ase );;Industry Foundation Classes ( *.ifc );;XGL ( *.xgl *.zgl );;Lightwave ( *.lwo );;Lightwave Scene ( *.lws );;Modo ( *.lxo );;DirectX X ( *.x );;AC3D ( *.ac );;Milkshape 3D ( *.ms3d );;TrueSpace ( *.cob *.scn )") );
return QString( tr("Alias/Wavefront ( *.obj );;AutoCAD DXF ( *.dxf );;Collada ( *.dae );;Stereolithography files ( *.stl );;Polygon File Format files ( *.ply );;Blender 3D( *.blend );;3ds Max 3DS ( *.3ds );;3ds Max ASE( *.ase );;Industry Foundation Classes ( *.ifc );;XGL ( *.xgl *.zgl );;Lightwave ( *.lwo );;Lightwave Scene ( *.lws );;Modo ( *.lxo );;DirectX X ( *.x );;AC3D ( *.ac );;Milkshape 3D ( *.ms3d );;TrueSpace ( *.cob *.scn );;Filmbox ( *.fbx )") );
}
//--------------------------------------------------------------------------
QWidget *AssimpPlugin::saveOptionsWidget(QString) {
if (saveOptions_ == nullptr){
//generate widget
saveOptions_ = new QWidget();
QVBoxLayout* layout = new QVBoxLayout();
layout->setAlignment(Qt::AlignTop);
saveFaceColor_ = new QCheckBox("Save Face Colors");
saveNormals_ = new QCheckBox("Save Normals");
saveTexCoords_ = new QCheckBox("Save Texture Coordinates");
saveTextures_ = new QCheckBox("Save Textures");
QList<QWidget*> generalOptions = { saveFaceColor_, saveNormals_, saveTexCoords_, saveTextures_};
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);
save_assimp_process_calcTangentSpace = new QCheckBox("assimp_process_calcTangentSpace ");
save_assimp_process_joinIdenticalVertices = new QCheckBox("assimp_process_joinIdenticalVertices ");
save_assimp_process_makeLeftHanded = new QCheckBox("assimp_process_makeLeftHanded ");
save_assimp_process_triangulate = new QCheckBox("assimp_process_triangulate ");
save_assimp_process_removeComponent = new QCheckBox("assimp_process_removeComponent ");
save_assimp_process_genNormals = new QCheckBox("assimp_process_genNormals ");
save_assimp_process_genSmoothNormals = new QCheckBox("assimp_process_genSmoothNormals ");
save_assimp_process_splitLargeMeshes = new QCheckBox("assimp_process_splitLargeMeshes ");
save_assimp_process_preTransformVertices = new QCheckBox("assimp_process_preTransformVertices ");
save_assimp_process_limitBoneWeights = new QCheckBox("assimp_process_limitBoneWeights ");
save_assimp_process_validateDataStructure = new QCheckBox("assimp_process_validateDataStructure ");
save_assimp_process_improveCacheLocality = new QCheckBox("assimp_process_improveCacheLocality ");
save_assimp_process_removeRedundantMaterials = new QCheckBox("assimp_process_removeRedundantMaterials");
save_assimp_process_fixInfacingNormals = new QCheckBox("assimp_process_fixInfacingNormals ");
save_assimp_process_sortByPType = new QCheckBox("assimp_process_sortByPType ");
save_assimp_process_findDegenerates = new QCheckBox("assimp_process_findDegenerates ");
save_assimp_process_findInvalidData = new QCheckBox("assimp_process_findInvalidData ");
save_assimp_process_genUVCoords = new QCheckBox("assimp_process_genUVCoords ");
save_assimp_process_transformUVCoords = new QCheckBox("assimp_process_transformUVCoords ");
save_assimp_process_findInstances = new QCheckBox("assimp_process_findInstances ");
save_assimp_process_optimizeMeshes = new QCheckBox("assimp_process_optimizeMeshes ");
save_assimp_process_optimizeGraph = new QCheckBox("assimp_process_optimizeGraph ");
save_assimp_process_flipUVs = new QCheckBox("assimp_process_flipUVs ");
save_assimp_process_flipWindingOrder = new QCheckBox("assimp_process_flipWindingOrder ");
save_assimp_process_splitByBoneCount = new QCheckBox("assimp_process_splitByBoneCount ");
save_assimp_process_debone = new QCheckBox("assimp_process_debone ");
QList<QWidget*> advancedOptions= {save_assimp_process_calcTangentSpace ,
save_assimp_process_joinIdenticalVertices ,
save_assimp_process_makeLeftHanded ,
save_assimp_process_triangulate ,
save_assimp_process_removeComponent ,
save_assimp_process_genNormals ,
save_assimp_process_genSmoothNormals ,
save_assimp_process_splitLargeMeshes ,
save_assimp_process_preTransformVertices ,
save_assimp_process_limitBoneWeights ,
save_assimp_process_validateDataStructure ,
save_assimp_process_improveCacheLocality ,
save_assimp_process_removeRedundantMaterials,
save_assimp_process_fixInfacingNormals ,
save_assimp_process_sortByPType ,
save_assimp_process_findDegenerates ,
save_assimp_process_findInvalidData ,
save_assimp_process_genUVCoords ,
save_assimp_process_transformUVCoords ,
save_assimp_process_findInstances ,
save_assimp_process_optimizeMeshes ,
save_assimp_process_optimizeGraph ,
save_assimp_process_flipUVs ,
save_assimp_process_flipWindingOrder ,
save_assimp_process_splitByBoneCount ,
save_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);
}
saveDefaultButton_ = new QPushButton("Make Default");
layout->addWidget(tree);
layout->addWidget(saveDefaultButton_);
saveOptions_->setLayout(layout);
connect(saveDefaultButton_, SIGNAL(clicked()), this, SLOT(slotSaveDefault()));
saveFaceColor_->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() );
save_assimp_process_calcTangentSpace ->setChecked(OpenFlipperSettings().value( "Assimp/Save/process/calcTangentSpace" , false).toBool());
save_assimp_process_joinIdenticalVertices ->setChecked(OpenFlipperSettings().value( "Assimp/Save/process/joinIdenticalVertices" , true ).toBool());
save_assimp_process_makeLeftHanded ->setChecked(OpenFlipperSettings().value( "Assimp/Save/process/makeLeftHanded" , false).toBool());
save_assimp_process_triangulate ->setChecked(OpenFlipperSettings().value( "Assimp/Save/process/triangulate" , false).toBool());
save_assimp_process_removeComponent ->setChecked(OpenFlipperSettings().value( "Assimp/Save/process/removeComponent" , false).toBool());
save_assimp_process_genNormals ->setChecked(OpenFlipperSettings().value( "Assimp/Save/process/genNormals" , false).toBool());
save_assimp_process_genSmoothNormals ->setChecked(OpenFlipperSettings().value( "Assimp/Save/process/genSmoothNormals" , false).toBool());
save_assimp_process_splitLargeMeshes ->setChecked(OpenFlipperSettings().value( "Assimp/Save/process/splitLargeMeshes" , false).toBool());
save_assimp_process_preTransformVertices ->setChecked(OpenFlipperSettings().value( "Assimp/Save/process/preTransformVertices" , false).toBool());
save_assimp_process_limitBoneWeights ->setChecked(OpenFlipperSettings().value( "Assimp/Save/process/limitBoneWeights" , false).toBool());
save_assimp_process_validateDataStructure ->setChecked(OpenFlipperSettings().value( "Assimp/Save/process/validateDataStructure" , false).toBool());
save_assimp_process_improveCacheLocality ->setChecked(OpenFlipperSettings().value( "Assimp/Save/process/improveCacheLocality" , false).toBool());
save_assimp_process_removeRedundantMaterials ->setChecked(OpenFlipperSettings().value( "Assimp/Save/process/removeRedundantMaterials", false).toBool());
save_assimp_process_fixInfacingNormals ->setChecked(OpenFlipperSettings().value( "Assimp/Save/process/fixInfacingNormals" , false).toBool());
save_assimp_process_sortByPType ->setChecked(OpenFlipperSettings().value( "Assimp/Save/process/sortByPType" , false).toBool());
save_assimp_process_findDegenerates ->setChecked(OpenFlipperSettings().value( "Assimp/Save/process/findDegenerates" , true ).toBool());
save_assimp_process_findInvalidData ->setChecked(OpenFlipperSettings().value( "Assimp/Save/process/findInvalidData" , false).toBool());
save_assimp_process_genUVCoords ->setChecked(OpenFlipperSettings().value( "Assimp/Save/process/genUVCoords" , false).toBool());
save_assimp_process_transformUVCoords ->setChecked(OpenFlipperSettings().value( "Assimp/Save/process/transformUVCoords" , false).toBool());
save_assimp_process_findInstances ->setChecked(OpenFlipperSettings().value( "Assimp/Save/process/findInstances" , false).toBool());
save_assimp_process_optimizeMeshes ->setChecked(OpenFlipperSettings().value( "Assimp/Save/process/optimizeMeshes" , false).toBool());
save_assimp_process_optimizeGraph ->setChecked(OpenFlipperSettings().value( "Assimp/Save/process/optimizeGraph" , false).toBool());
save_assimp_process_flipUVs ->setChecked(OpenFlipperSettings().value( "Assimp/Save/process/flipUVs" , false).toBool());
save_assimp_process_flipWindingOrder ->setChecked(OpenFlipperSettings().value( "Assimp/Save/process/flipWindingOrder" , false).toBool());
save_assimp_process_splitByBoneCount ->setChecked(OpenFlipperSettings().value( "Assimp/Save/process/splitByBoneCount" , false).toBool());
save_assimp_process_debone ->setChecked(OpenFlipperSettings().value( "Assimp/Save/process/debone" , false).toBool());
saveOptions_ = new AssimpSaveOptionsWidget(options_);
}
return saveOptions_;
}
//--------------------------------------------------------------------------
QWidget *AssimpPlugin::loadOptionsWidget(QString) {
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 Vertex Colors");
loadNormals_ = new QCheckBox("Load Vertex Normals");
loadTexCoords_ = new QCheckBox("Load Vertex Texture Coordinates");
loadTextures_ = new QCheckBox("Load Textures");
//loading textures is not yet supported
loadTextures_->setDisabled(true);
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);
load_assimp_process_calcTangentSpace = new QCheckBox("assimp_process_calcTangentSpace ");
load_assimp_process_joinIdenticalVertices = new QCheckBox("assimp_process_joinIdenticalVertices ");
load_assimp_process_makeLeftHanded = new QCheckBox("assimp_process_makeLeftHanded ");
load_assimp_process_triangulate = new QCheckBox("assimp_process_triangulate ");
load_assimp_process_removeComponent = new QCheckBox("assimp_process_removeComponent ");
load_assimp_process_genNormals = new QCheckBox("assimp_process_genNormals ");
load_assimp_process_genSmoothNormals = new QCheckBox("assimp_process_genSmoothNormals ");
load_assimp_process_splitLargeMeshes = new QCheckBox("assimp_process_splitLargeMeshes ");
load_assimp_process_preTransformVertices = new QCheckBox("assimp_process_preTransformVertices ");
load_assimp_process_limitBoneWeights = new QCheckBox("assimp_process_limitBoneWeights ");
load_assimp_process_validateDataStructure = new QCheckBox("assimp_process_validateDataStructure ");
load_assimp_process_improveCacheLocality = new QCheckBox("assimp_process_improveCacheLocality ");
load_assimp_process_removeRedundantMaterials = new QCheckBox("assimp_process_removeRedundantMaterials");
load_assimp_process_fixInfacingNormals = new QCheckBox("assimp_process_fixInfacingNormals ");
load_assimp_process_sortByPType = new QCheckBox("assimp_process_sortByPType ");
load_assimp_process_findDegenerates = new QCheckBox("assimp_process_findDegenerates ");
load_assimp_process_findInvalidData = new QCheckBox("assimp_process_findInvalidData ");
load_assimp_process_genUVCoords = new QCheckBox("assimp_process_genUVCoords ");
load_assimp_process_transformUVCoords = new QCheckBox("assimp_process_transformUVCoords ");
load_assimp_process_findInstances = new QCheckBox("assimp_process_findInstances ");
load_assimp_process_optimizeMeshes = new QCheckBox("assimp_process_optimizeMeshes ");
load_assimp_process_optimizeGraph = new QCheckBox("assimp_process_optimizeGraph ");
load_assimp_process_flipUVs = new QCheckBox("assimp_process_flipUVs ");
load_assimp_process_flipWindingOrder = new QCheckBox("assimp_process_flipWindingOrder ");
load_assimp_process_splitByBoneCount = new QCheckBox("assimp_process_splitByBoneCount ");
load_assimp_process_debone = new QCheckBox("assimp_process_debone ");
loadOptions= {{load_assimp_process_calcTangentSpace , aiProcess_CalcTangentSpace },
{load_assimp_process_joinIdenticalVertices , aiProcess_JoinIdenticalVertices },
{load_assimp_process_makeLeftHanded , aiProcess_MakeLeftHanded },
{load_assimp_process_triangulate , aiProcess_Triangulate },
{load_assimp_process_removeComponent , aiProcess_RemoveComponent },
{load_assimp_process_genNormals , aiProcess_GenNormals },
{load_assimp_process_genSmoothNormals , aiProcess_GenSmoothNormals },
{load_assimp_process_splitLargeMeshes , aiProcess_SplitLargeMeshes },
{load_assimp_process_preTransformVertices , aiProcess_PreTransformVertices },
{load_assimp_process_limitBoneWeights , aiProcess_LimitBoneWeights },
{load_assimp_process_validateDataStructure , aiProcess_ValidateDataStructure },
{load_assimp_process_improveCacheLocality , aiProcess_ImproveCacheLocality },
{load_assimp_process_removeRedundantMaterials, aiProcess_RemoveRedundantMaterials},
{load_assimp_process_fixInfacingNormals , aiProcess_FixInfacingNormals },
{load_assimp_process_sortByPType , aiProcess_SortByPType },
{load_assimp_process_findDegenerates , aiProcess_FindDegenerates },
{load_assimp_process_findInvalidData , aiProcess_FindInvalidData },
{load_assimp_process_genUVCoords , aiProcess_GenUVCoords },
{load_assimp_process_transformUVCoords , aiProcess_TransformUVCoords },
{load_assimp_process_findInstances , aiProcess_FindInstances },
{load_assimp_process_optimizeMeshes , aiProcess_OptimizeMeshes },
{load_assimp_process_optimizeGraph , aiProcess_OptimizeGraph },
{load_assimp_process_flipUVs , aiProcess_FlipUVs },
{load_assimp_process_flipWindingOrder , aiProcess_FlipWindingOrder },
{load_assimp_process_splitByBoneCount , aiProcess_SplitByBoneCount },
{load_assimp_process_debone , aiProcess_Debone }};
for(auto it = loadOptions.begin() ; it != loadOptions.end(); ++it)
{
QTreeWidgetItem* treeWidget = new QTreeWidgetItem();
advanced->addChild(treeWidget);
tree->setItemWidget(treeWidget,0,it->first);
}
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() );
load_assimp_process_calcTangentSpace ->setChecked(OpenFlipperSettings().value( "Assimp/Load/process/calcTangentSpace" , false).toBool());
load_assimp_process_joinIdenticalVertices ->setChecked(OpenFlipperSettings().value( "Assimp/Load/process/joinIdenticalVertices" , true ).toBool());
load_assimp_process_makeLeftHanded ->setChecked(OpenFlipperSettings().value( "Assimp/Load/process/makeLeftHanded" , false).toBool());
load_assimp_process_triangulate ->setChecked(OpenFlipperSettings().value( "Assimp/Load/process/triangulate" , false).toBool());
load_assimp_process_removeComponent ->setChecked(OpenFlipperSettings().value( "Assimp/Load/process/removeComponent" , false).toBool());
load_assimp_process_genNormals ->setChecked(OpenFlipperSettings().value( "Assimp/Load/process/genNormals" , false).toBool());
load_assimp_process_genSmoothNormals ->setChecked(OpenFlipperSettings().value( "Assimp/Load/process/genSmoothNormals" , false).toBool());
load_assimp_process_splitLargeMeshes ->setChecked(OpenFlipperSettings().value( "Assimp/Load/process/splitLargeMeshes" , false).toBool());
load_assimp_process_preTransformVertices ->setChecked(OpenFlipperSettings().value( "Assimp/Load/process/preTransformVertices" , false).toBool());
load_assimp_process_limitBoneWeights ->setChecked(OpenFlipperSettings().value( "Assimp/Load/process/limitBoneWeights" , false).toBool());
load_assimp_process_validateDataStructure ->setChecked(OpenFlipperSettings().value( "Assimp/Load/process/validateDataStructure" , false).toBool());
load_assimp_process_improveCacheLocality ->setChecked(OpenFlipperSettings().value( "Assimp/Load/process/improveCacheLocality" , false).toBool());
load_assimp_process_removeRedundantMaterials ->setChecked(OpenFlipperSettings().value( "Assimp/Load/process/removeRedundantMaterials", false).toBool());
load_assimp_process_fixInfacingNormals ->setChecked(OpenFlipperSettings().value( "Assimp/Load/process/fixInfacingNormals" , false).toBool());
load_assimp_process_sortByPType ->setChecked(OpenFlipperSettings().value( "Assimp/Load/process/sortByPType" , false).toBool());
load_assimp_process_findDegenerates ->setChecked(OpenFlipperSettings().value( "Assimp/Load/process/findDegenerates" , true ).toBool());
load_assimp_process_findInvalidData ->setChecked(OpenFlipperSettings().value( "Assimp/Load/process/findInvalidData" , false).toBool());
load_assimp_process_genUVCoords ->setChecked(OpenFlipperSettings().value( "Assimp/Load/process/genUVCoords" , false).toBool());
load_assimp_process_transformUVCoords ->setChecked(OpenFlipperSettings().value( "Assimp/Load/process/transformUVCoords" , false).toBool());
load_assimp_process_findInstances ->setChecked(OpenFlipperSettings().value( "Assimp/Load/process/findInstances" , false).toBool());
load_assimp_process_optimizeMeshes ->setChecked(OpenFlipperSettings().value( "Assimp/Load/process/optimizeMeshes" , false).toBool());
load_assimp_process_optimizeGraph ->setChecked(OpenFlipperSettings().value( "Assimp/Load/process/optimizeGraph" , false).toBool());
load_assimp_process_flipUVs ->setChecked(OpenFlipperSettings().value( "Assimp/Load/process/flipUVs" , false).toBool());
load_assimp_process_flipWindingOrder ->setChecked(OpenFlipperSettings().value( "Assimp/Load/process/flipWindingOrder" , false).toBool());
load_assimp_process_splitByBoneCount ->setChecked(OpenFlipperSettings().value( "Assimp/Load/process/splitByBoneCount" , false).toBool());
load_assimp_process_debone ->setChecked(OpenFlipperSettings().value( "Assimp/Load/process/debone" , false).toBool());
loadOptions_ = new AssimpLoadOptionsWidget(options_);
}
return loadOptions_;
}
//--------------------------------------------------------------------------
int AssimpPlugin::loadObject(QString _filename) {
Assimp::Importer importer;
cancel_ = false;
const aiScene* scene = NULL;
scene = importer.ReadFile(_filename.toStdString(), processSteps(loadOptions));
if(OpenFlipper::Options::gui() && loadOptions_ != nullptr)
processSteps = loadOptions_->processSteps();
scene = importer.ReadFile(_filename.toStdString(), processSteps);
if (!scene) {
emit log(LOGERR, tr(importer.GetErrorString()));
......@@ -638,7 +645,7 @@ int AssimpPlugin::loadObject(QString _filename) {
if(OpenFlipper::Options::gui() && loadOptions_ != nullptr)
{
switch(triMeshHandling_->currentIndex())
switch(options_.triMeshHandling_)
{
case TYPEAUTODETECT :
type_ = DATA_UNKNOWN;
......@@ -670,12 +677,16 @@ int AssimpPlugin::loadObject(QString _filename) {
return convertAiSceneToOpenMesh(scene, f.fileName());
}
//--------------------------------------------------------------------------
int AssimpPlugin::loadObject(QString _filename, DataType _type) {
if (_type != DATA_GROUP) //if equal => autodetect data
type_ = _type;
return loadObject(_filename);
}
//--------------------------------------------------------------------------
bool AssimpPlugin::saveObject(int _id, QString _filename) {
BaseObjectData* object;
PluginFunctions::getObject(_id,object);
......@@ -705,87 +716,7 @@ 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/Load/process/calcTangentSpace" , load_assimp_process_calcTangentSpace ->isChecked() );
OpenFlipperSettings().setValue( "Assimp/Load/process/joinIdenticalVertices" , load_assimp_process_joinIdenticalVertices ->isChecked() );
OpenFlipperSettings().setValue( "Assimp/Load/process/makeLeftHanded" , load_assimp_process_makeLeftHanded ->isChecked() );
OpenFlipperSettings().setValue( "Assimp/Load/process/triangulate" , load_assimp_process_triangulate ->isChecked() );
OpenFlipperSettings().setValue( "Assimp/Load/process/removeComponent" , load_assimp_process_removeComponent ->isChecked() );
OpenFlipperSettings().setValue( "Assimp/Load/process/genNormals" , load_assimp_process_genNormals ->isChecked() );
OpenFlipperSettings().setValue( "Assimp/Load/process/genSmoothNormals" , load_assimp_process_genSmoothNormals ->isChecked() );
OpenFlipperSettings().setValue( "Assimp/Load/process/splitLargeMeshes" , load_assimp_process_splitLargeMeshes ->isChecked() );
OpenFlipperSettings().setValue( "Assimp/Load/process/preTransformVertices" , load_assimp_process_preTransformVertices ->isChecked() );
OpenFlipperSettings().setValue( "Assimp/Load/process/limitBoneWeights" , load_assimp_process_limitBoneWeights ->isChecked() );
OpenFlipperSettings().setValue( "Assimp/Load/process/validateDataStructure" , load_assimp_process_validateDataStructure ->isChecked() );
OpenFlipperSettings().setValue( "Assimp/Load/process/improveCacheLocality" , load_assimp_process_improveCacheLocality ->isChecked() );
OpenFlipperSettings().setValue( "Assimp/Load/process/removeRedundantMaterials", load_assimp_process_removeRedundantMaterials->isChecked() );
OpenFlipperSettings().setValue( "Assimp/Load/process/fixInfacingNormals" , load_assimp_process_fixInfacingNormals ->isChecked() );
OpenFlipperSettings().setValue( "Assimp/Load/process/sortByPType" , load_assimp_process_sortByPType ->isChecked() );
OpenFlipperSettings().setValue( "Assimp/Load/process/findDegenerates" , load_assimp_process_findDegenerates ->isChecked() );
OpenFlipperSettings().setValue( "Assimp/Load/process/findInvalidData" , load_assimp_process_findInvalidData ->isChecked() );
OpenFlipperSettings().setValue( "Assimp/Load/process/genUVCoords" , load_assimp_process_genUVCoords ->isChecked() );
OpenFlipperSettings().setValue( "Assimp/Load/process/transformUVCoords" , load_assimp_process_transformUVCoords ->isChecked() );
OpenFlipperSettings().setValue( "Assimp/Load/process/findInstances" , load_assimp_process_findInstances ->isChecked() );
OpenFlipperSettings().setValue( "Assimp/Load/process/optimizeMeshes" , load_assimp_process_optimizeMeshes ->isChecked() );
OpenFlipperSettings().setValue( "Assimp/Load/process/optimizeGraph" , load_assimp_process_optimizeGraph ->isChecked() );
OpenFlipperSettings().setValue( "Assimp/Load/process/flipUVs" , load_assimp_process_flipUVs ->isChecked() );
OpenFlipperSettings().setValue( "Assimp/Load/process/flipWindingOrder" , load_assimp_process_flipWindingOrder ->isChecked() );
OpenFlipperSettings().setValue( "Assimp/Load/process/splitByBoneCount" , load_assimp_process_splitByBoneCount ->isChecked() );
OpenFlipperSettings().setValue( "Assimp/Load/process/debone" , load_assimp_process_debone ->isChecked() );
OpenFlipperSettings().setValue( "Core/File/UseLoadDefaults", true );
}
void AssimpPlugin::slotSaveDefault() {
OpenFlipperSettings().setValue( "Assimp/Save/FaceColor", saveFaceColor_->isChecked() );
OpenFlipperSettings().setValue( "Assimp/Save/Normals", saveNormals_ ->isChecked() );
OpenFlipperSettings().setValue( "Assimp/Save/TexCoords", saveTexCoords_->isChecked() );
OpenFlipperSettings().setValue( "Assimp/Save/Textures", saveTextures_ ->isChecked() );
OpenFlipperSettings().setValue( "Assimp/Save/process/calcTangentSpace" , save_assimp_process_calcTangentSpace ->isChecked() );
OpenFlipperSettings().setValue( "Assimp/Save/process/joinIdenticalVertices" , save_assimp_process_joinIdenticalVertices ->isChecked() );
OpenFlipperSettings().setValue( "Assimp/Save/process/makeLeftHanded" , save_assimp_process_makeLeftHanded ->isChecked() );
OpenFlipperSettings().setValue( "Assimp/Save/process/triangulate" , save_assimp_process_triangulate ->isChecked() );
OpenFlipperSettings().setValue( "Assimp/Save/process/removeComponent" , save_assimp_process_removeComponent ->isChecked() );
OpenFlipperSettings().setValue( "Assimp/Save/process/genNormals" , save_assimp_process_genNormals ->isChecked() );
OpenFlipperSettings().setValue( "Assimp/Save/process/genSmoothNormals" , save_assimp_process_genSmoothNormals ->isChecked() );
OpenFlipperSettings().setValue( "Assimp/Save/process/splitLargeMeshes" , save_assimp_process_splitLargeMeshes ->isChecked() );
OpenFlipperSettings().setValue( "Assimp/Save/process/preTransformVertices" , save_assimp_process_preTransformVertices ->isChecked() );
OpenFlipperSettings().setValue( "Assimp/Save/process/limitBoneWeights" , save_assimp_process_limitBoneWeights ->isChecked() );
OpenFlipperSettings().setValue( "Assimp/Save/process/validateDataStructure" , save_assimp_process_validateDataStructure ->isChecked() );
OpenFlipperSettings().setValue( "Assimp/Save/process/improveCacheLocality" , save_assimp_process_improveCacheLocality ->isChecked() );
OpenFlipperSettings().setValue( "Assimp/Save/process/removeRedundantMaterials", save_assimp_process_removeRedundantMaterials->isChecked() );
OpenFlipperSettings().setValue( "Assimp/Save/process/fixInfacingNormals" , save_assimp_process_fixInfacingNormals ->isChecked() );
OpenFlipperSettings().setValue( "Assimp/Save/process/sortByPType" , save_assimp_process_sortByPType ->isChecked() );
OpenFlipperSettings().setValue( "Assimp/Save/process/findDegenerates" , save_assimp_process_findDegenerates ->isChecked() );
OpenFlipperSettings().setValue( "Assimp/Save/process/findInvalidData" , save_assimp_process_findInvalidData ->isChecked() );
OpenFlipperSettings().setValue( "Assimp/Save/process/genUVCoords" , save_assimp_process_genUVCoords ->isChecked() );
OpenFlipperSettings().setValue( "Assimp/Save/process/transformUVCoords" , save_assimp_process_transformUVCoords ->isChecked() );
OpenFlipperSettings().setValue( "Assimp/Save/process/findInstances" , save_assimp_process_findInstances ->isChecked() );
OpenFlipperSettings().setValue( "Assimp/Save/process/optimizeMeshes" , save_assimp_process_optimizeMeshes ->isChecked() );
OpenFlipperSettings().setValue( "Assimp/Save/process/optimizeGraph" , save_assimp_process_optimizeGraph ->isChecked() );
OpenFlipperSettings().setValue( "Assimp/Save/process/flipUVs" , save_assimp_process_flipUVs ->isChecked() );
OpenFlipperSettings().setValue( "Assimp/Save/process/flipWindingOrder" , save_assimp_process_flipWindingOrder ->isChecked() );
OpenFlipperSettings().setValue( "Assimp/Save/process/splitByBoneCount" , save_assimp_process_splitByBoneCount ->isChecked() );
OpenFlipperSettings().setValue( "Assimp/Save/process/debone" , save_assimp_process_debone ->isChecked() );
}
unsigned int AssimpPlugin::processSteps( const std::unordered_map<QCheckBox*, unsigned int>& _options)
{
unsigned int result = 0;
for(auto entry : _options)
{
if(entry.first != nullptr)
result |= entry.first->isChecked()? entry.second : 0;
}
return result;
}
//--------------------------------------------------------------------------
bool AssimpPlugin::slotShowConfirmationDialog(const QString& _title, const QString& _message)
{
......@@ -801,12 +732,10 @@ bool AssimpPlugin::slotShowConfirmationDialog(const QString& _title, const QStri
return true;
}
//--------------------------------------------------------------------------
void AssimpPlugin::canceledJob(QString _jobId)
{
if(_jobId == "Loading File" || _jobId == "Loading Files")
cancel_ = true;
}
#if QT_VERSION < 0x050000
Q_EXPORT_PLUGIN2( assimpplugin , AssimpPlugin )
#endif
......@@ -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_;
//QWidget *loadOptions_, *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_;
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. *
* *
\*==================================================