Some cleanups.
parent
7f227f8250
commit
fe6be58b35
|
@ -58,7 +58,15 @@ IF(VIEWER_BUILD)
|
||||||
LINK_DIRECTORIES(${Assimp_BINARY_DIR})
|
LINK_DIRECTORIES(${Assimp_BINARY_DIR})
|
||||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -pedantic -Wall")
|
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -pedantic -Wall")
|
||||||
|
|
||||||
SET(assimp_qt_viewer_SRCS main.cpp loggerview.cpp glview.cpp mainwindow.cpp)
|
SET(assimp_qt_viewer_SRCS
|
||||||
|
main.cpp
|
||||||
|
loggerview.hpp
|
||||||
|
loggerview.cpp
|
||||||
|
glview.hpp
|
||||||
|
glview.cpp
|
||||||
|
mainwindow.hpp
|
||||||
|
mainwindow.cpp
|
||||||
|
)
|
||||||
|
|
||||||
IF(ASSIMP_QT4_VIEWER)
|
IF(ASSIMP_QT4_VIEWER)
|
||||||
MESSAGE("assimp_qt_viewer use Qt4")
|
MESSAGE("assimp_qt_viewer use Qt4")
|
||||||
|
|
|
@ -1,9 +1,45 @@
|
||||||
/// \file glview.cpp
|
/*
|
||||||
/// \brief OpenGL visualisation. Implementation file.
|
---------------------------------------------------------------------------
|
||||||
/// \author smal.root@gmail.com
|
Open Asset Import Library (assimp)
|
||||||
/// \date 2016
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2018, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the following
|
||||||
|
conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* 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.
|
||||||
|
|
||||||
|
* Neither the name of the assimp team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the assimp team.
|
||||||
|
|
||||||
|
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
|
||||||
|
OWNER 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 "glview.hpp"
|
#include "glview.hpp"
|
||||||
|
|
||||||
// Header files, Qt.
|
// Header files, Qt.
|
||||||
|
@ -42,11 +78,10 @@ CGLView::SHelper_Mesh::SHelper_Mesh(const size_t pQuantity_Point, const size_t p
|
||||||
Index_Triangle = pQuantity_Triangle ? new GLuint[pQuantity_Triangle * 3] : nullptr;
|
Index_Triangle = pQuantity_Triangle ? new GLuint[pQuantity_Triangle * 3] : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
CGLView::SHelper_Mesh::~SHelper_Mesh()
|
CGLView::SHelper_Mesh::~SHelper_Mesh() {
|
||||||
{
|
delete [] Index_Point;
|
||||||
if(Index_Point != nullptr) delete [] Index_Point;
|
delete [] Index_Line;
|
||||||
if(Index_Line != nullptr) delete [] Index_Line;
|
delete [] Index_Triangle;
|
||||||
if(Index_Triangle != nullptr) delete [] Index_Triangle;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**********************************/
|
/**********************************/
|
||||||
|
@ -215,22 +250,20 @@ void CGLView::Matrix_NodeToRoot(const aiNode* pNode, aiMatrix4x4& pOutMatrix)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGLView::ImportTextures(const QString& pScenePath)
|
void CGLView::ImportTextures(const QString& scenePath) {
|
||||||
{
|
|
||||||
auto LoadTexture = [&](const QString& pFileName) -> bool ///TODO: IME texture mode, operation.
|
auto LoadTexture = [&](const QString& pFileName) -> bool ///TODO: IME texture mode, operation.
|
||||||
{
|
{
|
||||||
GLuint id_ogl_texture;// OpenGL texture ID.
|
GLuint id_ogl_texture;// OpenGL texture ID.
|
||||||
|
|
||||||
if(!pFileName.startsWith(AI_EMBEDDED_TEXNAME_PREFIX))
|
if(!pFileName.startsWith(AI_EMBEDDED_TEXNAME_PREFIX))
|
||||||
{
|
{
|
||||||
QString basepath = pScenePath.left(pScenePath.lastIndexOf('/') + 1);// path with '/' at the end.
|
QString basepath = scenePath.left(scenePath.lastIndexOf('/') + 1);// path with '/' at the end.
|
||||||
QString fileloc = (basepath + pFileName);
|
QString fileloc = (basepath + pFileName);
|
||||||
|
|
||||||
fileloc.replace('\\', "/");
|
fileloc.replace('\\', "/");
|
||||||
int x, y, n;
|
int x, y, n;
|
||||||
unsigned char *data = stbi_load(fileloc.toLocal8Bit(), &x, &y, &n, STBI_rgb_alpha );
|
unsigned char *data = stbi_load(fileloc.toLocal8Bit(), &x, &y, &n, STBI_rgb_alpha );
|
||||||
if(nullptr==data)
|
if ( nullptr == data ) {
|
||||||
{
|
|
||||||
LogError(QString("Couldn't load Image: %1").arg(fileloc));
|
LogError(QString("Couldn't load Image: %1").arg(fileloc));
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -649,6 +682,7 @@ void CGLView::initializeGL()
|
||||||
glEnable(GL_DEPTH_TEST);
|
glEnable(GL_DEPTH_TEST);
|
||||||
glEnable(GL_NORMALIZE);
|
glEnable(GL_NORMALIZE);
|
||||||
glEnable(GL_TEXTURE_2D);
|
glEnable(GL_TEXTURE_2D);
|
||||||
|
//glEnable( GL_MULTISAMPLE );
|
||||||
|
|
||||||
glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT);
|
glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT);
|
||||||
glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
|
glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
|
||||||
|
|
|
@ -1,7 +1,45 @@
|
||||||
/// \file glview.hpp
|
/*
|
||||||
/// \brief OpenGL visualisation.
|
---------------------------------------------------------------------------
|
||||||
/// \author smal.root@gmail.com
|
Open Asset Import Library (assimp)
|
||||||
/// \date 2016
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2018, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the following
|
||||||
|
conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* 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.
|
||||||
|
|
||||||
|
* Neither the name of the assimp team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the assimp team.
|
||||||
|
|
||||||
|
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
|
||||||
|
OWNER 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
|
#pragma once
|
||||||
|
|
||||||
|
|
|
@ -1,19 +1,64 @@
|
||||||
/// \file loggerview.cpp
|
/*
|
||||||
/// \brief Stream for Assimp logging subsystem.
|
---------------------------------------------------------------------------
|
||||||
/// \author smal.root@gmail.com
|
Open Asset Import Library (assimp)
|
||||||
/// \date 2016
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2018, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the following
|
||||||
|
conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* 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.
|
||||||
|
|
||||||
|
* Neither the name of the assimp team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the assimp team.
|
||||||
|
|
||||||
|
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
|
||||||
|
OWNER 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 "loggerview.hpp"
|
#include "loggerview.hpp"
|
||||||
|
|
||||||
// Header files, Qt.
|
// Header files, Qt.
|
||||||
#include <QTime>
|
#include <QTime>
|
||||||
|
#include <QTextBrowser>
|
||||||
|
|
||||||
CLoggerView::CLoggerView(QTextBrowser* pOutputWidget)
|
CLoggerView::CLoggerView(QTextBrowser* pOutputWidget)
|
||||||
: mOutputWidget(pOutputWidget)
|
: mOutputWidget(pOutputWidget) {
|
||||||
{
|
// empty
|
||||||
}
|
}
|
||||||
|
|
||||||
void CLoggerView::write(const char *pMessage)
|
CLoggerView::~CLoggerView() {
|
||||||
{
|
mOutputWidget = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CLoggerView::write(const char *pMessage) {
|
||||||
|
if (nullptr == mOutputWidget) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
mOutputWidget->insertPlainText(QString("[%1] %2").arg(QTime::currentTime().toString()).arg(pMessage));
|
mOutputWidget->insertPlainText(QString("[%1] %2").arg(QTime::currentTime().toString()).arg(pMessage));
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,33 +1,67 @@
|
||||||
/// \file loggerview.hpp
|
/*
|
||||||
/// \brief Stream for Assimp logging subsystem.
|
---------------------------------------------------------------------------
|
||||||
/// \author smal.root@gmail.com
|
Open Asset Import Library (assimp)
|
||||||
/// \date 2016
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2018, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the following
|
||||||
|
conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* 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.
|
||||||
|
|
||||||
|
* Neither the name of the assimp team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the assimp team.
|
||||||
|
|
||||||
|
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
|
||||||
|
OWNER 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
|
#pragma once
|
||||||
|
|
||||||
// Header files, Qt.
|
|
||||||
#include <QTextBrowser>
|
|
||||||
|
|
||||||
// Header files, Assimp.
|
// Header files, Assimp.
|
||||||
#include <assimp/DefaultLogger.hpp>
|
#include <assimp/DefaultLogger.hpp>
|
||||||
|
|
||||||
/// \class CLoggerView
|
class QTextBrowser;
|
||||||
/// GUI-stream for Assimp logging subsytem. Get data for logging and write it to output widget.
|
|
||||||
class CLoggerView final : public Assimp::LogStream
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
|
|
||||||
QTextBrowser* mOutputWidget;///< Widget for displaying messages.
|
|
||||||
|
|
||||||
|
/// @class CLoggerView
|
||||||
|
/// @brief GUI-stream for Assimp logging sub-sytem. Get data for logging and write it to output widget.
|
||||||
|
class CLoggerView final : public ::Assimp::LogStream {
|
||||||
public:
|
public:
|
||||||
|
/// @brief The class constructor.
|
||||||
|
/// @param [in] pOutputWidget - pointer to output widget.
|
||||||
|
explicit CLoggerView( QTextBrowser* pOutputWidget );
|
||||||
|
|
||||||
/// \fn explicit CLoggerView(QTextBrowser* pOutputWidget)
|
/// @brief The class destructor.
|
||||||
/// Constructor.
|
virtual ~CLoggerView();
|
||||||
/// \param [in] pOutputWidget - pointer to output widget.
|
|
||||||
explicit CLoggerView(QTextBrowser* pOutputWidget);
|
|
||||||
|
|
||||||
/// \fn virtual void write(const char *pMessage)
|
|
||||||
/// Write message to output widget. Used by Assimp.
|
/// Write message to output widget. Used by Assimp.
|
||||||
/// \param [in] pMessage - message for displaying.
|
/// \param [in] pMessage - message for displaying.
|
||||||
virtual void write(const char *pMessage);
|
virtual void write(const char *pMessage);
|
||||||
|
|
||||||
|
private:
|
||||||
|
QTextBrowser * mOutputWidget; ///< Widget for displaying messages.
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,7 +1,46 @@
|
||||||
/// \file main.cpp
|
/*
|
||||||
/// \brief Start-up file which contain function "main".
|
---------------------------------------------------------------------------
|
||||||
/// \author smal.root@gmail.com
|
Open Asset Import Library (assimp)
|
||||||
/// \date 2016
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2018, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the following
|
||||||
|
conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* 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.
|
||||||
|
|
||||||
|
* Neither the name of the assimp team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the assimp team.
|
||||||
|
|
||||||
|
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
|
||||||
|
OWNER 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.
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
// Thanks to acorn89 for support.
|
// Thanks to acorn89 for support.
|
||||||
|
|
||||||
// Header files, project.
|
// Header files, project.
|
||||||
|
@ -11,9 +50,9 @@
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
QApplication a(argc, argv);
|
QApplication app(argc, argv);
|
||||||
MainWindow w;
|
MainWindow win;
|
||||||
w.show();
|
win.show();
|
||||||
|
|
||||||
return a.exec();
|
return app.exec();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,45 @@
|
||||||
/// \file mainwindow.hpp
|
/*
|
||||||
/// \brief Main window and algorhytms.
|
---------------------------------------------------------------------------
|
||||||
/// \author smal.root@gmail.com
|
Open Asset Import Library (assimp)
|
||||||
/// \date 2016
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2018, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the following
|
||||||
|
conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* 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.
|
||||||
|
|
||||||
|
* Neither the name of the assimp team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the assimp team.
|
||||||
|
|
||||||
|
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
|
||||||
|
OWNER 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 "mainwindow.hpp"
|
#include "mainwindow.hpp"
|
||||||
#include "ui_mainwindow.h"
|
#include "ui_mainwindow.h"
|
||||||
|
@ -14,6 +52,8 @@
|
||||||
#define __unused __attribute__((unused))
|
#define __unused __attribute__((unused))
|
||||||
#endif // __unused
|
#endif // __unused
|
||||||
|
|
||||||
|
using namespace Assimp;
|
||||||
|
|
||||||
/**********************************/
|
/**********************************/
|
||||||
/************ Functions ***********/
|
/************ Functions ***********/
|
||||||
/**********************************/
|
/**********************************/
|
||||||
|
@ -241,7 +281,6 @@ MainWindow::MainWindow(QWidget *parent)
|
||||||
: QMainWindow(parent), ui(new Ui::MainWindow),
|
: QMainWindow(parent), ui(new Ui::MainWindow),
|
||||||
mScene(nullptr)
|
mScene(nullptr)
|
||||||
{
|
{
|
||||||
using namespace Assimp;
|
|
||||||
|
|
||||||
// other variables
|
// other variables
|
||||||
mMouse_Transformation.Position_Pressed_Valid = false;
|
mMouse_Transformation.Position_Pressed_Valid = false;
|
||||||
|
|
|
@ -1,7 +1,45 @@
|
||||||
/// \file mainwindow.hpp
|
/*
|
||||||
/// \brief Main window and algorhytms.
|
---------------------------------------------------------------------------
|
||||||
/// \author smal.root@gmail.com
|
Open Asset Import Library (assimp)
|
||||||
/// \date 2016
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2018, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the following
|
||||||
|
conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* 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.
|
||||||
|
|
||||||
|
* Neither the name of the assimp team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the assimp team.
|
||||||
|
|
||||||
|
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
|
||||||
|
OWNER 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
|
#pragma once
|
||||||
|
|
||||||
|
@ -20,125 +58,64 @@
|
||||||
#include <assimp/Importer.hpp>
|
#include <assimp/Importer.hpp>
|
||||||
#include <assimp/scene.h>
|
#include <assimp/scene.h>
|
||||||
|
|
||||||
namespace Ui { class MainWindow; }
|
namespace Ui {
|
||||||
|
class MainWindow;
|
||||||
|
}
|
||||||
|
|
||||||
/// \class MainWindow
|
/// \class MainWindow
|
||||||
/// Main window and algorhytms.
|
/// Main window and algorithms.
|
||||||
class MainWindow : public QMainWindow
|
class MainWindow : public QMainWindow {
|
||||||
{
|
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
/**********************************/
|
struct SMouse_Transformation;
|
||||||
/************ Variables ***********/
|
|
||||||
/**********************************/
|
|
||||||
|
|
||||||
private:
|
public:
|
||||||
|
/// @brief The class constructor.
|
||||||
|
/// \param [in] pParent - pointer to parent widget.
|
||||||
|
explicit MainWindow( QWidget* pParent = 0 );
|
||||||
|
|
||||||
Ui::MainWindow *ui;
|
/// @brief The class destructor.
|
||||||
|
~MainWindow();
|
||||||
|
|
||||||
CGLView* mGLView;///< Pointer to OpenGL render.
|
|
||||||
CLoggerView* mLoggerView;///< Pointer to logging object.
|
|
||||||
Assimp::Importer mImporter;///< Assimp importer.
|
|
||||||
const aiScene* mScene;///< Pointer to loaded scene (\ref aiScene).
|
|
||||||
|
|
||||||
/// \struct SMouse_Transformation
|
|
||||||
/// Holds data about transformation of the scene/camera when mouse us used.
|
|
||||||
struct SMouse_Transformation
|
|
||||||
{
|
|
||||||
bool Position_Pressed_Valid;///< Mouse button pressed on GLView.
|
|
||||||
QPoint Position_Pressed_LMB;///< Position where was pressed left mouse button.
|
|
||||||
QPoint Position_Pressed_RMB;///< Position where was pressed right mouse button.
|
|
||||||
aiMatrix4x4 Rotation_AroundCamera;///< Rotation matrix which set rotation angles of the scene around camera.
|
|
||||||
aiMatrix4x4 Rotation_Scene;///< Rotation matrix which set rotation angles of the scene around own center.
|
|
||||||
} mMouse_Transformation;
|
|
||||||
|
|
||||||
/**********************************/
|
|
||||||
/************ Functions ***********/
|
|
||||||
/**********************************/
|
|
||||||
|
|
||||||
/********************************************************************/
|
|
||||||
/********************* Import/Export functions **********************/
|
|
||||||
/********************************************************************/
|
|
||||||
|
|
||||||
/// \fn void ImportFile(const QString& pFileName)
|
|
||||||
/// Import scene from file.
|
/// Import scene from file.
|
||||||
/// \param [in] pFileName - path and name of the file.
|
/// \param [in] pFileName - path and name of the file.
|
||||||
void ImportFile(const QString& pFileName);
|
void ImportFile(const QString& pFileName);
|
||||||
|
|
||||||
|
|
||||||
/// \fn void ResetSceneInfos()
|
|
||||||
/// Reset informations about the scene
|
/// Reset informations about the scene
|
||||||
void ResetSceneInfos();
|
void ResetSceneInfos();
|
||||||
|
|
||||||
/********************************************************************/
|
|
||||||
/************************ Logging functions *************************/
|
|
||||||
/********************************************************************/
|
|
||||||
|
|
||||||
/// \fn void LogInfo(const QString& pMessage)
|
|
||||||
/// Add message with severity "Warning" to log.
|
/// Add message with severity "Warning" to log.
|
||||||
void LogInfo(const QString& pMessage);
|
void LogInfo(const QString& pMessage);
|
||||||
|
|
||||||
/// \fn void LogError(const QString& pMessage)
|
|
||||||
/// Add message with severity "Error" to log.
|
/// Add message with severity "Error" to log.
|
||||||
void LogError(const QString& pMessage);
|
void LogError(const QString& pMessage);
|
||||||
|
|
||||||
/********************************************************************/
|
|
||||||
/*********************** Override functions ************************/
|
|
||||||
/********************************************************************/
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
/// \fn void mousePressEvent(QMouseEvent* pEvent) override
|
|
||||||
/// Override function which handles mouse event "button pressed".
|
/// Override function which handles mouse event "button pressed".
|
||||||
/// \param [in] pEvent - pointer to event data.
|
/// \param [in] pEvent - pointer to event data.
|
||||||
void mousePressEvent(QMouseEvent* pEvent) override;
|
void mousePressEvent(QMouseEvent* pEvent) override;
|
||||||
|
|
||||||
/// \fn void mouseReleaseEvent(QMouseEvent *pEvent) override
|
|
||||||
/// Override function which handles mouse event "button released".
|
/// Override function which handles mouse event "button released".
|
||||||
/// \param [in] pEvent - pointer to event data.
|
/// \param [in] pEvent - pointer to event data.
|
||||||
void mouseReleaseEvent(QMouseEvent *pEvent) override;
|
void mouseReleaseEvent(QMouseEvent *pEvent) override;
|
||||||
|
|
||||||
/// \fn void mouseMoveEvent(QMouseEvent* pEvent) override
|
|
||||||
/// Override function which handles mouse event "move".
|
/// Override function which handles mouse event "move".
|
||||||
/// \param [in] pEvent - pointer to event data.
|
/// \param [in] pEvent - pointer to event data.
|
||||||
void mouseMoveEvent(QMouseEvent* pEvent) override;
|
void mouseMoveEvent(QMouseEvent* pEvent) override;
|
||||||
|
|
||||||
/// \fn void keyPressEvent(QKeyEvent* pEvent) override
|
|
||||||
/// Override function which handles key event "key pressed".
|
/// Override function which handles key event "key pressed".
|
||||||
/// \param [in] pEvent - pointer to event data.
|
/// \param [in] pEvent - pointer to event data.
|
||||||
void keyPressEvent(QKeyEvent* pEvent) override;
|
void keyPressEvent(QKeyEvent* pEvent) override;
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
/********************************************************************/
|
|
||||||
/********************** Constructor/Destructor **********************/
|
|
||||||
/********************************************************************/
|
|
||||||
|
|
||||||
/// \fn explicit MainWindow(QWidget* pParent = 0)
|
|
||||||
/// \param [in] pParent - pointer to parent widget.
|
|
||||||
explicit MainWindow(QWidget* pParent = 0);
|
|
||||||
|
|
||||||
/// \fn ~MainWindow()
|
|
||||||
/// Destructor.
|
|
||||||
~MainWindow();
|
|
||||||
|
|
||||||
/********************************************************************/
|
|
||||||
/****************************** Slots *******************************/
|
|
||||||
/********************************************************************/
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
/// \fn void Paint_Finished(const int pPaintTime)
|
|
||||||
/// Show paint/render time and distance between camera and center of the scene.
|
/// Show paint/render time and distance between camera and center of the scene.
|
||||||
/// \param [in] pPaintTime_ms - paint time in milliseconds.
|
/// \param [in] pPaintTime_ms - paint time in milliseconds.
|
||||||
void Paint_Finished(const size_t pPaintTime_ms, const GLfloat pDistance);
|
void Paint_Finished(const size_t pPaintTime_ms, const GLfloat pDistance);
|
||||||
|
|
||||||
/// \fn void SceneObject_Camera(const QString& pName)
|
|
||||||
/// Add camera name to list.
|
/// Add camera name to list.
|
||||||
/// \param [in] pName - name of the camera.
|
/// \param [in] pName - name of the camera.
|
||||||
void SceneObject_Camera(const QString& pName);
|
void SceneObject_Camera(const QString& pName);
|
||||||
|
|
||||||
/// \fn void SceneObject_LightSource(const QString& pName)
|
|
||||||
/// Add lighting source name to list.
|
/// Add lighting source name to list.
|
||||||
/// \param [in] pName - name of the light source,
|
/// \param [in] pName - name of the light source,
|
||||||
void SceneObject_LightSource(const QString& pName);
|
void SceneObject_LightSource(const QString& pName);
|
||||||
|
@ -151,4 +128,21 @@ private slots:
|
||||||
void on_cbxBBox_clicked(bool checked);
|
void on_cbxBBox_clicked(bool checked);
|
||||||
void on_cbxTextures_clicked(bool checked);
|
void on_cbxTextures_clicked(bool checked);
|
||||||
void on_cbxDrawAxes_clicked(bool checked);
|
void on_cbxDrawAxes_clicked(bool checked);
|
||||||
|
|
||||||
|
private:
|
||||||
|
Ui::MainWindow *ui;
|
||||||
|
CGLView *mGLView;///< Pointer to OpenGL render.
|
||||||
|
CLoggerView *mLoggerView;///< Pointer to logging object.
|
||||||
|
Assimp::Importer mImporter;///< Assimp importer.
|
||||||
|
const aiScene* mScene;///< Pointer to loaded scene (\ref aiScene).
|
||||||
|
|
||||||
|
/// \struct SMouse_Transformation
|
||||||
|
/// Holds data about transformation of the scene/camera when mouse us used.
|
||||||
|
struct SMouse_Transformation {
|
||||||
|
bool Position_Pressed_Valid;///< Mouse button pressed on GLView.
|
||||||
|
QPoint Position_Pressed_LMB;///< Position where was pressed left mouse button.
|
||||||
|
QPoint Position_Pressed_RMB;///< Position where was pressed right mouse button.
|
||||||
|
aiMatrix4x4 Rotation_AroundCamera;///< Rotation matrix which set rotation angles of the scene around camera.
|
||||||
|
aiMatrix4x4 Rotation_Scene;///< Rotation matrix which set rotation angles of the scene around own center.
|
||||||
|
} mMouse_Transformation;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue