Merge branch 'master' into issue_2024
commit
43ddd93fae
|
@ -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
|
||||||
|
|
|
@ -181,26 +181,27 @@ void ColladaLoader::InternReadFile( const std::string& pFile, aiScene* pScene, I
|
||||||
// ... then fill the materials with the now adjusted settings
|
// ... then fill the materials with the now adjusted settings
|
||||||
FillMaterials(parser, pScene);
|
FillMaterials(parser, pScene);
|
||||||
|
|
||||||
// Apply unitsize scale calculation
|
// Apply unitsize scale calculation
|
||||||
pScene->mRootNode->mTransformation *= aiMatrix4x4(parser.mUnitSize, 0, 0, 0,
|
pScene->mRootNode->mTransformation *= aiMatrix4x4(parser.mUnitSize, 0, 0, 0,
|
||||||
0, parser.mUnitSize, 0, 0,
|
0, parser.mUnitSize, 0, 0,
|
||||||
0, 0, parser.mUnitSize, 0,
|
0, 0, parser.mUnitSize, 0,
|
||||||
0, 0, 0, 1);
|
0, 0, 0, 1);
|
||||||
if( !ignoreUpDirection ) {
|
if( !ignoreUpDirection ) {
|
||||||
// Convert to Y_UP, if different orientation
|
// Convert to Y_UP, if different orientation
|
||||||
if( parser.mUpDirection == ColladaParser::UP_X)
|
if( parser.mUpDirection == ColladaParser::UP_X)
|
||||||
pScene->mRootNode->mTransformation *= aiMatrix4x4(
|
pScene->mRootNode->mTransformation *= aiMatrix4x4(
|
||||||
0, -1, 0, 0,
|
0, -1, 0, 0,
|
||||||
1, 0, 0, 0,
|
1, 0, 0, 0,
|
||||||
0, 0, 1, 0,
|
0, 0, 1, 0,
|
||||||
0, 0, 0, 1);
|
0, 0, 0, 1);
|
||||||
else if( parser.mUpDirection == ColladaParser::UP_Z)
|
else if( parser.mUpDirection == ColladaParser::UP_Z)
|
||||||
pScene->mRootNode->mTransformation *= aiMatrix4x4(
|
pScene->mRootNode->mTransformation *= aiMatrix4x4(
|
||||||
1, 0, 0, 0,
|
1, 0, 0, 0,
|
||||||
0, 0, 1, 0,
|
0, 0, 1, 0,
|
||||||
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,17 +363,17 @@ 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;
|
||||||
findItr = mControllerLibrary.find(meshId);
|
findItr = mControllerLibrary.find(meshId);
|
||||||
}
|
}
|
||||||
|
|
||||||
it->second.mMeshId = meshId;
|
it->second.mMeshId = meshId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -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;
|
||||||
|
|
||||||
|
@ -1289,7 +1290,7 @@ auto deg2rad = [](const GLfloat pDegree) -> GLfloat { return pDegree * M_PI / 18
|
||||||
|
|
||||||
void CGLView::Camera_Translate(const GLfloat pTranslate_X, const GLfloat pTranslate_Y, const GLfloat pTranslate_Z)
|
void CGLView::Camera_Translate(const GLfloat pTranslate_X, const GLfloat pTranslate_Y, const GLfloat pTranslate_Z)
|
||||||
{
|
{
|
||||||
aiVector3D vect_tr(pTranslate_X, pTranslate_Y, pTranslate_Z);
|
aiVector3D vect_tr(pTranslate_X, pTranslate_Y, pTranslate_Z);
|
||||||
|
|
||||||
vect_tr *= mHelper_Camera.Rotation_AroundCamera;
|
vect_tr *= mHelper_Camera.Rotation_AroundCamera;
|
||||||
mHelper_Camera.Translation_ToScene += vect_tr;
|
mHelper_Camera.Translation_ToScene += vect_tr;
|
||||||
|
|
|
@ -132,9 +132,8 @@ 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,30 +304,32 @@ 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;
|
mImporter.GetExtensionList( filter_temp );
|
||||||
QString filename, filter;
|
|
||||||
|
|
||||||
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;
|
||||||
|
|
||||||
QString filename, filter, format_id;
|
#ifndef ASSIMP_BUILD_NO_EXPORT
|
||||||
Exporter exporter;
|
QString filename, filter, format_id;
|
||||||
QTime time_begin;
|
Exporter exporter;
|
||||||
aiReturn rv;
|
QTime time_begin;
|
||||||
QStringList exportersList;
|
aiReturn rv;
|
||||||
QMap<QString, const aiExportFormatDesc*> exportersMap;
|
QStringList exportersList;
|
||||||
|
QMap<QString, const aiExportFormatDesc*> exportersMap;
|
||||||
|
|
||||||
|
|
||||||
if(mScene == nullptr)
|
if(mScene == nullptr)
|
||||||
|
@ -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