Some cleanups.
parent
7f227f8250
commit
fe6be58b35
|
@ -58,7 +58,15 @@ IF(VIEWER_BUILD)
|
|||
LINK_DIRECTORIES(${Assimp_BINARY_DIR})
|
||||
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)
|
||||
MESSAGE("assimp_qt_viewer use Qt4")
|
||||
|
|
|
@ -1,9 +1,45 @@
|
|||
/// \file glview.cpp
|
||||
/// \brief OpenGL visualisation. Implementation file.
|
||||
/// \author smal.root@gmail.com
|
||||
/// \date 2016
|
||||
/*
|
||||
---------------------------------------------------------------------------
|
||||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
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"
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
CGLView::SHelper_Mesh::~SHelper_Mesh()
|
||||
{
|
||||
if(Index_Point != nullptr) delete [] Index_Point;
|
||||
if(Index_Line != nullptr) delete [] Index_Line;
|
||||
if(Index_Triangle != nullptr) delete [] Index_Triangle;
|
||||
CGLView::SHelper_Mesh::~SHelper_Mesh() {
|
||||
delete [] Index_Point;
|
||||
delete [] Index_Line;
|
||||
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.
|
||||
{
|
||||
GLuint id_ogl_texture;// OpenGL texture ID.
|
||||
|
||||
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);
|
||||
|
||||
fileloc.replace('\\', "/");
|
||||
int x, y, n;
|
||||
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));
|
||||
|
||||
return false;
|
||||
|
@ -649,6 +682,7 @@ void CGLView::initializeGL()
|
|||
glEnable(GL_DEPTH_TEST);
|
||||
glEnable(GL_NORMALIZE);
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
//glEnable( GL_MULTISAMPLE );
|
||||
|
||||
glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT);
|
||||
glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
|
||||
|
|
|
@ -1,7 +1,45 @@
|
|||
/// \file glview.hpp
|
||||
/// \brief OpenGL visualisation.
|
||||
/// \author smal.root@gmail.com
|
||||
/// \date 2016
|
||||
/*
|
||||
---------------------------------------------------------------------------
|
||||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
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
|
||||
|
||||
|
|
|
@ -1,19 +1,64 @@
|
|||
/// \file loggerview.cpp
|
||||
/// \brief Stream for Assimp logging subsystem.
|
||||
/// \author smal.root@gmail.com
|
||||
/// \date 2016
|
||||
/*
|
||||
---------------------------------------------------------------------------
|
||||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
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"
|
||||
|
||||
// Header files, Qt.
|
||||
#include <QTime>
|
||||
#include <QTextBrowser>
|
||||
|
||||
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));
|
||||
}
|
||||
|
|
|
@ -1,33 +1,67 @@
|
|||
/// \file loggerview.hpp
|
||||
/// \brief Stream for Assimp logging subsystem.
|
||||
/// \author smal.root@gmail.com
|
||||
/// \date 2016
|
||||
/*
|
||||
---------------------------------------------------------------------------
|
||||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
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
|
||||
|
||||
// Header files, Qt.
|
||||
#include <QTextBrowser>
|
||||
|
||||
// Header files, Assimp.
|
||||
#include <assimp/DefaultLogger.hpp>
|
||||
|
||||
/// \class CLoggerView
|
||||
/// 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 QTextBrowser;
|
||||
|
||||
/// @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:
|
||||
/// @brief The class constructor.
|
||||
/// @param [in] pOutputWidget - pointer to output widget.
|
||||
explicit CLoggerView( QTextBrowser* pOutputWidget );
|
||||
|
||||
/// \fn explicit CLoggerView(QTextBrowser* pOutputWidget)
|
||||
/// Constructor.
|
||||
/// \param [in] pOutputWidget - pointer to output widget.
|
||||
explicit CLoggerView(QTextBrowser* pOutputWidget);
|
||||
/// @brief The class destructor.
|
||||
virtual ~CLoggerView();
|
||||
|
||||
/// \fn virtual void write(const char *pMessage)
|
||||
/// Write message to output widget. Used by Assimp.
|
||||
/// \param [in] pMessage - message for displaying.
|
||||
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
|
||||
/// \date 2016
|
||||
/*
|
||||
---------------------------------------------------------------------------
|
||||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
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.
|
||||
|
||||
// Header files, project.
|
||||
|
@ -11,9 +50,9 @@
|
|||
#include <QApplication>
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
QApplication a(argc, argv);
|
||||
MainWindow w;
|
||||
w.show();
|
||||
QApplication app(argc, argv);
|
||||
MainWindow win;
|
||||
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
|
||||
/// \date 2016
|
||||
/*
|
||||
---------------------------------------------------------------------------
|
||||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
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 "ui_mainwindow.h"
|
||||
|
@ -14,6 +52,8 @@
|
|||
#define __unused __attribute__((unused))
|
||||
#endif // __unused
|
||||
|
||||
using namespace Assimp;
|
||||
|
||||
/**********************************/
|
||||
/************ Functions ***********/
|
||||
/**********************************/
|
||||
|
@ -241,7 +281,6 @@ MainWindow::MainWindow(QWidget *parent)
|
|||
: QMainWindow(parent), ui(new Ui::MainWindow),
|
||||
mScene(nullptr)
|
||||
{
|
||||
using namespace Assimp;
|
||||
|
||||
// other variables
|
||||
mMouse_Transformation.Position_Pressed_Valid = false;
|
||||
|
|
|
@ -1,7 +1,45 @@
|
|||
/// \file mainwindow.hpp
|
||||
/// \brief Main window and algorhytms.
|
||||
/// \author smal.root@gmail.com
|
||||
/// \date 2016
|
||||
/*
|
||||
---------------------------------------------------------------------------
|
||||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
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
|
||||
|
||||
|
@ -20,125 +58,64 @@
|
|||
#include <assimp/Importer.hpp>
|
||||
#include <assimp/scene.h>
|
||||
|
||||
namespace Ui { class MainWindow; }
|
||||
namespace Ui {
|
||||
class MainWindow;
|
||||
}
|
||||
|
||||
/// \class MainWindow
|
||||
/// Main window and algorhytms.
|
||||
class MainWindow : public QMainWindow
|
||||
{
|
||||
/// Main window and algorithms.
|
||||
class MainWindow : public QMainWindow {
|
||||
Q_OBJECT
|
||||
|
||||
/**********************************/
|
||||
/************ Variables ***********/
|
||||
/**********************************/
|
||||
struct SMouse_Transformation;
|
||||
|
||||
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.
|
||||
/// \param [in] pFileName - path and name of the file.
|
||||
void ImportFile(const QString& pFileName);
|
||||
|
||||
|
||||
/// \fn void ResetSceneInfos()
|
||||
/// Reset informations about the scene
|
||||
void ResetSceneInfos();
|
||||
|
||||
/********************************************************************/
|
||||
/************************ Logging functions *************************/
|
||||
/********************************************************************/
|
||||
|
||||
/// \fn void LogInfo(const QString& pMessage)
|
||||
/// Add message with severity "Warning" to log.
|
||||
void LogInfo(const QString& pMessage);
|
||||
|
||||
/// \fn void LogError(const QString& pMessage)
|
||||
/// Add message with severity "Error" to log.
|
||||
void LogError(const QString& pMessage);
|
||||
|
||||
/********************************************************************/
|
||||
/*********************** Override functions ************************/
|
||||
/********************************************************************/
|
||||
|
||||
protected:
|
||||
|
||||
/// \fn void mousePressEvent(QMouseEvent* pEvent) override
|
||||
/// Override function which handles mouse event "button pressed".
|
||||
/// \param [in] pEvent - pointer to event data.
|
||||
void mousePressEvent(QMouseEvent* pEvent) override;
|
||||
|
||||
/// \fn void mouseReleaseEvent(QMouseEvent *pEvent) override
|
||||
/// Override function which handles mouse event "button released".
|
||||
/// \param [in] pEvent - pointer to event data.
|
||||
void mouseReleaseEvent(QMouseEvent *pEvent) override;
|
||||
|
||||
/// \fn void mouseMoveEvent(QMouseEvent* pEvent) override
|
||||
/// Override function which handles mouse event "move".
|
||||
/// \param [in] pEvent - pointer to event data.
|
||||
void mouseMoveEvent(QMouseEvent* pEvent) override;
|
||||
|
||||
/// \fn void keyPressEvent(QKeyEvent* pEvent) override
|
||||
/// Override function which handles key event "key pressed".
|
||||
/// \param [in] pEvent - pointer to event data.
|
||||
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:
|
||||
|
||||
/// \fn void Paint_Finished(const int pPaintTime)
|
||||
/// Show paint/render time and distance between camera and center of the scene.
|
||||
/// \param [in] pPaintTime_ms - paint time in milliseconds.
|
||||
void Paint_Finished(const size_t pPaintTime_ms, const GLfloat pDistance);
|
||||
|
||||
/// \fn void SceneObject_Camera(const QString& pName)
|
||||
/// Add camera name to list.
|
||||
/// \param [in] pName - name of the camera.
|
||||
void SceneObject_Camera(const QString& pName);
|
||||
|
||||
/// \fn void SceneObject_LightSource(const QString& pName)
|
||||
/// Add lighting source name to list.
|
||||
/// \param [in] pName - name of the light source,
|
||||
void SceneObject_LightSource(const QString& pName);
|
||||
|
@ -151,4 +128,21 @@ private slots:
|
|||
void on_cbxBBox_clicked(bool checked);
|
||||
void on_cbxTextures_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