Commit 7b2c2202 authored by Isaak Lim's avatar Isaak Lim

- added .blend and .3ds load filters (tested loading files of those formats)

- fixed loading and converting a scene with multiple meshes

refs #1274

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free-Staging@16907 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 97986824
......@@ -119,41 +119,62 @@ void AssimpPlugin::initializePlugin() {
}
int AssimpPlugin::convertAiSceneToOpenMesh(const aiScene *_scene, QString _objectName) {
int returnId = -1;
std::vector<int> ids;
if (_scene->mNumMeshes == 0)
emit log(LOGWARN, tr("aiScene contains no meshes"));
for (unsigned int i = 0; i < _scene->mNumMeshes; ++i) {
int objectId = -1;
emit addEmptyObject(type_, objectId);
BaseObject* object(0);
if(!PluginFunctions::getObject( objectId, object )) {
emit log(LOGERR, tr("Could not create new object!"));
return -1;
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) {
for (unsigned int i = 0; i < _scene->mNumMeshes; ++i)
convertPolyMeshToAiMesh(polyMeshObj->mesh(), _scene->mMeshes[i]);
convertPolyMeshToAiMesh(polyMeshObj->mesh(), _scene->mMeshes[i]);
polyMeshObj->update();
polyMeshObj->show();
ids.push_back(object->id());
} else if (triMeshObj) {
for (unsigned int i = 0; i < _scene->mNumMeshes; ++i)
convertAiMeshToTriMesh(triMeshObj->mesh(), _scene->mMeshes[i]);
convertAiMeshToTriMesh(triMeshObj->mesh(), _scene->mMeshes[i]);
triMeshObj->update();
triMeshObj->show();
ids.push_back(object->id());
}
emit openedFile( object->id() );
}
if (_scene->mNumMeshes > 1) {
bool dataControlExists = false;
pluginExists( "datacontrol", dataControlExists );
if ( dataControlExists ){
returnId = RPC::callFunctionValue<int>("datacontrol","groupObjects", ids, _objectName);
}
}
// Update viewport
PluginFunctions::viewAll();
// Update viewport
PluginFunctions::viewAll();
return objectId;
return returnId;
}
bool AssimpPlugin::convertOpenMeshToAiScene(aiScene *_scene, BaseObjectData *_object) {
......@@ -327,7 +348,7 @@ QString AssimpPlugin::getSaveFilters() {
}
QString AssimpPlugin::getLoadFilters() {
return QString( tr("Alias/Wavefront ( *.obj );;AutoCAD DXF ( *.dxf );;Collada ( *.dae );;Stereolithography files ( *.stl );;Polygon File Format files ( *.ply )") );
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 )") );
}
QWidget *AssimpPlugin::saveOptionsWidget(QString) {
......
......@@ -55,6 +55,7 @@
#include <OpenFlipper/BasePlugin/LoggingInterface.hh>
#include <OpenFlipper/BasePlugin/ScriptInterface.hh>
#include <OpenFlipper/BasePlugin/TypeInterface.hh>
#include <OpenFlipper/BasePlugin/RPCInterface.hh>
#include <ObjectTypes/PolyMesh/PolyMesh.hh>
#include <ObjectTypes/TriangleMesh/TriangleMesh.hh>
......@@ -66,7 +67,7 @@
class AssimpPlugin : public QObject, BaseInterface, FileInterface, LoadSaveInterface,
LoggingInterface, ScriptInterface
LoggingInterface, ScriptInterface, RPCInterface
{
Q_OBJECT
Q_INTERFACES(FileInterface)
......@@ -74,6 +75,7 @@ class AssimpPlugin : public QObject, BaseInterface, FileInterface, LoadSaveInter
Q_INTERFACES(LoggingInterface)
Q_INTERFACES(BaseInterface)
Q_INTERFACES(ScriptInterface)
Q_INTERFACES(RPCInterface)
signals:
void openedFile( int _id );
......@@ -86,6 +88,8 @@ class AssimpPlugin : public QObject, BaseInterface, FileInterface, LoadSaveInter
void deleteObject( int _id );
//RPCInterface
void pluginExists( QString _pluginName , bool& _exists );
public:
AssimpPlugin();
......
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