closes https://github.com/assimp/assimp/issues/2019: fix the qt-viewer without export.
parent
aa09001333
commit
e5fa1798f6
|
@ -272,12 +272,13 @@ struct Node
|
||||||
/** Node instances at this node */
|
/** Node instances at this node */
|
||||||
std::vector<NodeInstance> mNodeInstances;
|
std::vector<NodeInstance> mNodeInstances;
|
||||||
|
|
||||||
/** Rootnodes: Name of primary camera, if any */
|
/** Root-nodes: Name of primary camera, if any */
|
||||||
std::string mPrimaryCamera;
|
std::string mPrimaryCamera;
|
||||||
|
|
||||||
//! Constructor. Begin with a zero parent
|
//! Constructor. Begin with a zero parent
|
||||||
Node() {
|
Node()
|
||||||
mParent = NULL;
|
: mParent( nullptr ){
|
||||||
|
// empty
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Destructor: delete all children subsequently
|
//! Destructor: delete all children subsequently
|
||||||
|
|
|
@ -201,6 +201,7 @@ void ColladaLoader::InternReadFile( const std::string& pFile, aiScene* pScene, I
|
||||||
0, -1, 0, 0,
|
0, -1, 0, 0,
|
||||||
0, 0, 0, 1);
|
0, 0, 0, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// store all meshes
|
// store all meshes
|
||||||
StoreSceneMeshes( pScene);
|
StoreSceneMeshes( pScene);
|
||||||
|
|
||||||
|
@ -740,10 +741,6 @@ aiMesh* ColladaLoader::CreateMesh( const ColladaParser& pParser, const Collada::
|
||||||
// create bones if given
|
// create bones if given
|
||||||
if( pSrcController && pSrcController->mType == Collada::Skin)
|
if( pSrcController && pSrcController->mType == Collada::Skin)
|
||||||
{
|
{
|
||||||
// refuse if the vertex count does not match
|
|
||||||
// if( pSrcController->mWeightCounts.size() != dstMesh->mNumVertices)
|
|
||||||
// throw DeadlyImportError( "Joint Controller vertex count does not match mesh vertex count");
|
|
||||||
|
|
||||||
// resolve references - joint names
|
// resolve references - joint names
|
||||||
const Collada::Accessor& jointNamesAcc = pParser.ResolveLibraryReference( pParser.mAccessorLibrary, pSrcController->mJointNameSource);
|
const Collada::Accessor& jointNamesAcc = pParser.ResolveLibraryReference( pParser.mAccessorLibrary, pSrcController->mJointNameSource);
|
||||||
const Collada::Data& jointNames = pParser.ResolveLibraryReference( pParser.mDataLibrary, jointNamesAcc.mSource);
|
const Collada::Data& jointNames = pParser.ResolveLibraryReference( pParser.mDataLibrary, jointNamesAcc.mSource);
|
||||||
|
@ -971,7 +968,8 @@ void ColladaLoader::StoreAnimations( aiScene* pScene, const ColladaParser& pPars
|
||||||
for( size_t b = a+1; b < mAnims.size(); ++b)
|
for( size_t b = a+1; b < mAnims.size(); ++b)
|
||||||
{
|
{
|
||||||
aiAnimation* other = mAnims[b];
|
aiAnimation* other = mAnims[b];
|
||||||
if( other->mNumChannels == 1 && other->mDuration == templateAnim->mDuration && other->mTicksPerSecond == templateAnim->mTicksPerSecond )
|
if( other->mNumChannels == 1 && other->mDuration == templateAnim->mDuration &&
|
||||||
|
other->mTicksPerSecond == templateAnim->mTicksPerSecond )
|
||||||
collectedAnimIndices.push_back( b);
|
collectedAnimIndices.push_back( b);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -68,7 +68,7 @@ using namespace Assimp::Formatter;
|
||||||
// Constructor to be privately used by Importer
|
// Constructor to be privately used by Importer
|
||||||
ColladaParser::ColladaParser( IOSystem* pIOHandler, const std::string& pFile)
|
ColladaParser::ColladaParser( IOSystem* pIOHandler, const std::string& pFile)
|
||||||
: mFileName( pFile )
|
: mFileName( pFile )
|
||||||
, mReader( NULL )
|
, mReader( nullptr )
|
||||||
, mDataLibrary()
|
, mDataLibrary()
|
||||||
, mAccessorLibrary()
|
, mAccessorLibrary()
|
||||||
, mMeshLibrary()
|
, mMeshLibrary()
|
||||||
|
@ -79,20 +79,20 @@ ColladaParser::ColladaParser( IOSystem* pIOHandler, const std::string& pFile)
|
||||||
, mLightLibrary()
|
, mLightLibrary()
|
||||||
, mCameraLibrary()
|
, mCameraLibrary()
|
||||||
, mControllerLibrary()
|
, mControllerLibrary()
|
||||||
, mRootNode( NULL )
|
, mRootNode( nullptr )
|
||||||
, mAnims()
|
, mAnims()
|
||||||
, mUnitSize( 1.0f )
|
, mUnitSize( 1.0f )
|
||||||
, mUpDirection( UP_Y )
|
, mUpDirection( UP_Y )
|
||||||
, mFormat(FV_1_5_n ) // We assume the newest file format by default
|
, mFormat(FV_1_5_n ) // We assume the newest file format by default
|
||||||
{
|
{
|
||||||
// validate io-handler instance
|
// validate io-handler instance
|
||||||
if ( NULL == pIOHandler ) {
|
if (nullptr == pIOHandler ) {
|
||||||
throw DeadlyImportError("IOSystem is NULL." );
|
throw DeadlyImportError("IOSystem is NULL." );
|
||||||
}
|
}
|
||||||
|
|
||||||
// open the file
|
// open the file
|
||||||
std::unique_ptr<IOStream> file( pIOHandler->Open(pFile ) );
|
std::unique_ptr<IOStream> file( pIOHandler->Open(pFile ) );
|
||||||
if (file.get() == NULL) {
|
if (file.get() == nullptr) {
|
||||||
throw DeadlyImportError( "Failed to open file " + pFile + "." );
|
throw DeadlyImportError( "Failed to open file " + pFile + "." );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -363,9 +363,9 @@ void ColladaParser::ReadAnimationClipLibrary()
|
||||||
|
|
||||||
void ColladaParser::PostProcessControllers()
|
void ColladaParser::PostProcessControllers()
|
||||||
{
|
{
|
||||||
for (ControllerLibrary::iterator it = mControllerLibrary.begin(); it != mControllerLibrary.end(); ++it)
|
std::string meshId;
|
||||||
{
|
for (ControllerLibrary::iterator it = mControllerLibrary.begin(); it != mControllerLibrary.end(); ++it) {
|
||||||
std::string meshId = it->second.mMeshId;
|
meshId = it->second.mMeshId;
|
||||||
ControllerLibrary::iterator findItr = mControllerLibrary.find(meshId);
|
ControllerLibrary::iterator findItr = mControllerLibrary.find(meshId);
|
||||||
while(findItr != mControllerLibrary.end()) {
|
while(findItr != mControllerLibrary.end()) {
|
||||||
meshId = findItr->second.mMeshId;
|
meshId = findItr->second.mMeshId;
|
||||||
|
|
|
@ -1261,9 +1261,10 @@ void CGLView::Camera_Set(const size_t pCameraNumber)
|
||||||
gluLookAt(hcam.Position.x, hcam.Position.y, hcam.Position.z, hcam.Target.x, hcam.Target.y, hcam.Target.z, up.x, up.y, up.z);
|
gluLookAt(hcam.Position.x, hcam.Position.y, hcam.Position.z, hcam.Target.x, hcam.Target.y, hcam.Target.z, up.x, up.y, up.z);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGLView::Camera_RotateScene(const GLfloat pAngle_X, const GLfloat pAngle_Y, const GLfloat pAngle_Z, const aiMatrix4x4* pMatrix_Rotation_Initial)
|
void CGLView::Camera_RotateScene(const GLfloat pAngle_X, const GLfloat pAngle_Y, const GLfloat pAngle_Z, const aiMatrix4x4* pMatrix_Rotation_Initial) {
|
||||||
{
|
auto deg2rad = [](const GLfloat pDegree) -> GLfloat {
|
||||||
auto deg2rad = [](const GLfloat pDegree) -> GLfloat { return pDegree * M_PI / 180.0; };
|
return pDegree * AI_MATH_PI / 180.0;
|
||||||
|
};
|
||||||
|
|
||||||
aiMatrix4x4 mat_rot;
|
aiMatrix4x4 mat_rot;
|
||||||
|
|
||||||
|
@ -1276,7 +1277,7 @@ auto deg2rad = [](const GLfloat pDegree) -> GLfloat { return pDegree * M_PI / 18
|
||||||
|
|
||||||
void CGLView::Camera_Rotate(const GLfloat pAngle_X, const GLfloat pAngle_Y, const GLfloat pAngle_Z, const aiMatrix4x4* pMatrix_Rotation_Initial)
|
void CGLView::Camera_Rotate(const GLfloat pAngle_X, const GLfloat pAngle_Y, const GLfloat pAngle_Z, const aiMatrix4x4* pMatrix_Rotation_Initial)
|
||||||
{
|
{
|
||||||
auto deg2rad = [](const GLfloat pDegree) -> GLfloat { return pDegree * M_PI / 180.0; };
|
auto deg2rad = [](const GLfloat pDegree) -> GLfloat { return pDegree * AI_MATH_PI / 180.0; };
|
||||||
|
|
||||||
aiMatrix4x4 mat_rot;
|
aiMatrix4x4 mat_rot;
|
||||||
|
|
||||||
|
|
|
@ -133,8 +133,7 @@ void MainWindow::LogError(const QString& pMessage)
|
||||||
void MainWindow::mousePressEvent(QMouseEvent* pEvent)
|
void MainWindow::mousePressEvent(QMouseEvent* pEvent)
|
||||||
{
|
{
|
||||||
const QPoint ms_pt = pEvent->pos();
|
const QPoint ms_pt = pEvent->pos();
|
||||||
|
aiVector3D temp_v3;
|
||||||
__unused aiVector3D temp_v3;
|
|
||||||
|
|
||||||
// Check if GLView is pointed.
|
// Check if GLView is pointed.
|
||||||
if(childAt(ms_pt) == mGLView)
|
if(childAt(ms_pt) == mGLView)
|
||||||
|
@ -305,24 +304,26 @@ void MainWindow::SceneObject_LightSource(const QString& pName)
|
||||||
ui->lstLight->selectAll();
|
ui->lstLight->selectAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_butOpenFile_clicked()
|
void MainWindow::on_butOpenFile_clicked() {
|
||||||
{
|
|
||||||
aiString filter_temp;
|
aiString filter_temp;
|
||||||
QString filename, filter;
|
|
||||||
|
|
||||||
mImporter.GetExtensionList( filter_temp );
|
mImporter.GetExtensionList( filter_temp );
|
||||||
|
|
||||||
|
QString filename, filter;
|
||||||
filter = filter_temp.C_Str();
|
filter = filter_temp.C_Str();
|
||||||
filter.replace(';', ' ');
|
filter.replace(';', ' ');
|
||||||
filter.append(" ;; All (*.*)");
|
filter.append(" ;; All (*.*)");
|
||||||
filename = QFileDialog::getOpenFileName(this, "Choose the file", "", filter);
|
filename = QFileDialog::getOpenFileName(this, "Choose the file", "", filter);
|
||||||
|
|
||||||
if(!filename.isEmpty()) ImportFile(filename);
|
if (!filename.isEmpty()) {
|
||||||
|
ImportFile( filename );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_butExport_clicked()
|
void MainWindow::on_butExport_clicked()
|
||||||
{
|
{
|
||||||
using namespace Assimp;
|
using namespace Assimp;
|
||||||
|
|
||||||
|
#ifndef ASSIMP_BUILD_NO_EXPORT
|
||||||
QString filename, filter, format_id;
|
QString filename, filter, format_id;
|
||||||
Exporter exporter;
|
Exporter exporter;
|
||||||
QTime time_begin;
|
QTime time_begin;
|
||||||
|
@ -373,6 +374,7 @@ QMap<QString, const aiExportFormatDesc*> exportersMap;
|
||||||
LogError(errorMessage);
|
LogError(errorMessage);
|
||||||
QMessageBox::critical(this, "Export error", errorMessage);
|
QMessageBox::critical(this, "Export error", errorMessage);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_cbxLighting_clicked(bool pChecked)
|
void MainWindow::on_cbxLighting_clicked(bool pChecked)
|
||||||
|
@ -382,11 +384,7 @@ void MainWindow::on_cbxLighting_clicked(bool pChecked)
|
||||||
else
|
else
|
||||||
mGLView->Lighting_Disable();
|
mGLView->Lighting_Disable();
|
||||||
|
|
||||||
#if ASSIMP_QT4_VIEWER
|
|
||||||
mGLView->updateGL();
|
|
||||||
#else
|
|
||||||
mGLView->update();
|
mGLView->update();
|
||||||
#endif // ASSIMP_QT4_VIEWER
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_lstLight_itemSelectionChanged()
|
void MainWindow::on_lstLight_itemSelectionChanged()
|
||||||
|
@ -438,9 +436,5 @@ void MainWindow::on_cbxDrawAxes_clicked(bool checked)
|
||||||
void MainWindow::on_cbxTextures_clicked(bool checked)
|
void MainWindow::on_cbxTextures_clicked(bool checked)
|
||||||
{
|
{
|
||||||
mGLView->Enable_Textures(checked);
|
mGLView->Enable_Textures(checked);
|
||||||
#if ASSIMP_QT4_VIEWER
|
|
||||||
mGLView->updateGL();
|
|
||||||
#else
|
|
||||||
mGLView->update();
|
mGLView->update();
|
||||||
#endif // ASSIMP_QT4_VIEWER
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
// Header files, Qt.
|
// Header files, Qt.
|
||||||
#if ASSIMP_QT4_VIEWER
|
#if defined ASSIMP_QT4_VIEWER
|
||||||
# include <QMainWindow>
|
# include <QMainWindow>
|
||||||
#else
|
#else
|
||||||
# include <QtWidgets>
|
# include <QtWidgets>
|
||||||
|
|
Loading…
Reference in New Issue