Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
OpenGL
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
C-Fu
OpenGL
Commits
0735ef99
Commit
0735ef99
authored
Dec 31, 2016
by
Anakin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cosmetic to MainWindow,
drop does not work for widget, fixed offset problem, add esc key
parent
dca6e61c
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
86 additions
and
15 deletions
+86
-15
QtMeshViewer/Header/GeometryEngine.h
QtMeshViewer/Header/GeometryEngine.h
+1
-1
QtMeshViewer/Header/MainWindow.h
QtMeshViewer/Header/MainWindow.h
+6
-0
QtMeshViewer/Header/OglViewerWidget.h
QtMeshViewer/Header/OglViewerWidget.h
+4
-0
QtMeshViewer/Source/GeometryEngine.cpp
QtMeshViewer/Source/GeometryEngine.cpp
+7
-5
QtMeshViewer/Source/MainWindow.cpp
QtMeshViewer/Source/MainWindow.cpp
+43
-4
QtMeshViewer/Source/OglViewerWidget.cpp
QtMeshViewer/Source/OglViewerWidget.cpp
+19
-2
README.md
README.md
+6
-3
No files found.
QtMeshViewer/Header/GeometryEngine.h
View file @
0735ef99
...
...
@@ -25,10 +25,10 @@ private:
QVector
<
QOpenGLTexture
*>
m_textures
;
QVector
<
DrawInformation
>
m_drawList
;
void
loadFile
(
const
char
*
filePath
);
void
loadTexture
(
const
char
*
filePath
);
public:
void
loadFile
(
const
char
*
filePath
);
void
drawGeometry
(
QOpenGLShaderProgram
*
program
);
};
QtMeshViewer/Header/MainWindow.h
View file @
0735ef99
...
...
@@ -13,4 +13,10 @@ public:
private:
Ui
::
MainWindowClass
*
ui
;
private
slots
:
void
openFile
();
void
aboutFile
();
void
aboutTool
();
};
QtMeshViewer/Header/OglViewerWidget.h
View file @
0735ef99
...
...
@@ -40,6 +40,7 @@ protected:
void
mouseReleaseEvent
(
QMouseEvent
*
e
)
Q_DECL_OVERRIDE
;
void
mouseMoveEvent
(
QMouseEvent
*
e
)
Q_DECL_OVERRIDE
;
void
wheelEvent
(
QWheelEvent
*
e
)
Q_DECL_OVERRIDE
;
void
dropEvent
(
QDropEvent
*
event
)
Q_DECL_OVERRIDE
;
void
keyPressEvent
(
QKeyEvent
*
e
)
Q_DECL_OVERRIDE
;
void
initializeGL
()
Q_DECL_OVERRIDE
;
...
...
@@ -49,6 +50,9 @@ protected:
private:
void
initShaders
();
public:
void
openFile
(
const
char
*
filePath
);
};
QtMeshViewer/Source/GeometryEngine.cpp
View file @
0735ef99
...
...
@@ -15,7 +15,7 @@ GeometryEngine::GeometryEngine()
m_indexBuf
.
create
();
// Initializes cube geometry and transfers it to VBOs
loadFile
(
"..
\\
Release
\\
Msh
\\
triClothMan
.msh"
);
loadFile
(
"..
\\
Release
\\
Msh
\\
ic_helmet
.msh"
);
}
GeometryEngine
::~
GeometryEngine
()
...
...
@@ -50,21 +50,22 @@ void GeometryEngine::loadFile(const char* filePath)
textureNames
=
file
.
getTextureNames
();
// collect data
unsigned
int
offsetCount
(
0
);
unsigned
int
indexOffset
(
0
);
unsigned
int
vertexOffset
(
0
);
for
(
auto
&
modelIterator
:
*
models
)
{
for
(
auto
&
segmentIterator
:
modelIterator
->
segmList
)
{
// get draw information
DrawInformation
new_info
;
new_info
.
offset
=
offsetCoun
t
;
new_info
.
offset
=
indexOffse
t
;
new_info
.
size
=
segmentIterator
->
indices
.
size
();
new_info
.
textureIndex
=
segmentIterator
->
textureIndex
;
new_info
.
modelMatrix
=
modelIterator
->
m4x4Translation
;
// add offset to indices
for
(
auto
&
it
:
segmentIterator
->
indices
)
it
+=
new_info
.
o
ffset
;
it
+=
vertexO
ffset
;
// save data
vertexData
+=
segmentIterator
->
vertices
;
...
...
@@ -72,7 +73,8 @@ void GeometryEngine::loadFile(const char* filePath)
m_drawList
.
push_back
(
new_info
);
// update offset
offsetCount
+=
new_info
.
size
;
indexOffset
+=
new_info
.
size
;
vertexOffset
+=
segmentIterator
->
vertices
.
size
();
}
}
...
...
QtMeshViewer/Source/MainWindow.cpp
View file @
0735ef99
#include "..\Header\MainWindow.h"
#include "..\Header\OglViewerWidget.h"
#include <QSurfaceFormat>
#include <QMessageBox>
#include <QFileDialog>
#define WINDOW_NAME "Mesh Viewer"
MainWindow
::
MainWindow
(
QWidget
*
parent
)
:
QMainWindow
(
parent
)
...
...
@@ -8,19 +12,54 @@ MainWindow::MainWindow(QWidget *parent)
{
ui
->
setupUi
(
this
);
setWindowTitle
(
WINDOW_NAME
);
setWindowIcon
(
QIcon
(
":/images/icon.ico"
));
ui
->
statusBar
->
showMessage
(
"pre-alpha"
);
ui
->
mainToolBar
->
addAction
(
"Open File"
,
this
,
&
MainWindow
::
openFile
);
ui
->
mainToolBar
->
addAction
(
"About File"
,
this
,
&
MainWindow
::
aboutFile
);
ui
->
mainToolBar
->
addAction
(
"Help"
,
this
,
&
MainWindow
::
aboutTool
);
QSurfaceFormat
format
;
format
.
setDepthBufferSize
(
24
);
QSurfaceFormat
::
setDefaultFormat
(
format
);
setCentralWidget
(
new
OglViewerWidget
(
this
));
setWindowIcon
(
QIcon
(
":/images/icon.ico"
));
setWindowTitle
(
"Mesh Viewer"
);
ui
->
statusBar
->
showMessage
(
"pre-alpha"
);
}
MainWindow
::~
MainWindow
()
{
delete
ui
;
}
void
MainWindow
::
openFile
()
{
QString
fileName
=
QFileDialog
::
getOpenFileName
(
this
,
"Open File"
,
"../Release/Msh"
,
"Mesh (*.msh)"
);
dynamic_cast
<
OglViewerWidget
*>
(
centralWidget
())
->
openFile
(
fileName
.
toStdString
().
c_str
());
}
void
MainWindow
::
aboutFile
()
{
QMessageBox
*
dialog
=
new
QMessageBox
(
QMessageBox
::
Information
,
WINDOW_NAME
,
"When i find some time, i'll add some information about
\n
the file in the detailed text"
,
QMessageBox
::
StandardButton
::
Close
,
this
,
Qt
::
Dialog
|
Qt
::
MSWindowsFixedSizeDialogHint
);
dialog
->
setDetailedText
(
"This is the cool detailed text
\n
"
);
dialog
->
exec
();
}
void
MainWindow
::
aboutTool
()
{
QMessageBox
*
dialog
=
new
QMessageBox
(
QMessageBox
::
Question
,
WINDOW_NAME
,
"This is the Pre-Alpha version of my Mesh Viewer
\n
Check the detailed information"
,
QMessageBox
::
StandardButton
::
Close
,
this
,
Qt
::
Dialog
|
Qt
::
MSWindowsFixedSizeDialogHint
);
dialog
->
setDetailedText
(
"left mouse - rotate
\n
right mouse - move
\n
scroll - zoom
\n
space - reset view
\n
esc - close"
);
dialog
->
exec
();
}
\ No newline at end of file
QtMeshViewer/Source/OglViewerWidget.cpp
View file @
0735ef99
#include "..\Header\OglViewerWidget.h"
#include <QMouseEvent>
#include <QDropEvent>
#include <QMimeData>
#include <math.h>
#include <iostream>
...
...
@@ -16,6 +18,7 @@ OglViewerWidget::OglViewerWidget(QWidget *parent) :
{
setFocus
();
m_translation
.
setZ
(
DEFAULT_Z_DISTANCE
);
setAcceptDrops
(
true
);
}
OglViewerWidget
::~
OglViewerWidget
()
...
...
@@ -89,6 +92,11 @@ void OglViewerWidget::wheelEvent(QWheelEvent *e)
update
();
}
void
OglViewerWidget
::
dropEvent
(
QDropEvent
*
e
)
{
std
::
cout
<<
e
->
mimeData
()
->
text
().
toStdString
()
<<
std
::
endl
;
}
void
OglViewerWidget
::
keyPressEvent
(
QKeyEvent
*
e
)
{
if
(
e
->
key
()
==
Qt
::
Key_Space
)
...
...
@@ -96,6 +104,10 @@ void OglViewerWidget::keyPressEvent(QKeyEvent *e)
m_rotation
=
QQuaternion
();
m_translation
=
{
0.0
,
0.0
,
DEFAULT_Z_DISTANCE
};
}
else
if
(
e
->
key
()
==
Qt
::
Key_Escape
)
{
parentWidget
()
->
close
();
}
update
();
}
...
...
@@ -103,7 +115,7 @@ void OglViewerWidget::initializeGL()
{
initializeOpenGLFunctions
();
glClearColor
(
0
,
0
,
0
,
1
);
glClearColor
(
0
.5000
f
,
0.8000
f
,
1.0000
f
,
0.0000
f
);
initShaders
();
...
...
@@ -174,4 +186,9 @@ void OglViewerWidget::initShaders()
/////////////////////////////////////////////////////////////////////////
// public functions
\ No newline at end of file
// public functions
void
OglViewerWidget
::
openFile
(
const
char
*
filePath
)
{
m_dataEngine
->
loadFile
(
filePath
);
}
\ No newline at end of file
README.md
View file @
0735ef99
...
...
@@ -13,11 +13,14 @@ Feel free to use my code the way you like. But remember i used some public libra
licence, too.
### To Do
-
rotation problem
-
cloth not working correctly
-
center and normalize
-
open file while runtime does not work
-
drag and drop does not work
-
tga with alpha cannot be opened
-
multi polygons not correctly triangulated
-
5+ polygons => corrupted file
-
optional display bones, shadow, collision,...
-
integrate into a software:
-> gui open file ( + drag and drop),
-> list all msh under a directory,
-> display shadows,
-> display colisions,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment