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
191c0cbc
Commit
191c0cbc
authored
Jan 02, 2017
by
Anakin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
scale and move to center,
performance is not very good. Takes very long to load
parent
fc7941a8
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
13 additions
and
4 deletions
+13
-4
QtMeshViewer/Header/GeometryEngine.h
QtMeshViewer/Header/GeometryEngine.h
+1
-0
QtMeshViewer/Resources/vshader.glsl
QtMeshViewer/Resources/vshader.glsl
+2
-1
QtMeshViewer/Source/GeometryEngine.cpp
QtMeshViewer/Source/GeometryEngine.cpp
+9
-2
QtMeshViewer/Source/OglViewerWidget.cpp
QtMeshViewer/Source/OglViewerWidget.cpp
+1
-1
No files found.
QtMeshViewer/Header/GeometryEngine.h
View file @
191c0cbc
...
...
@@ -27,6 +27,7 @@ private:
QOpenGLBuffer
m_indexBuf
;
QVector
<
QOpenGLTexture
*>
m_textures
;
QVector
<
DrawInformation
>
m_drawList
;
BoundingBox
m_boundings
;
void
loadTexture
(
const
char
*
filePath
);
void
clearData
();
...
...
QtMeshViewer/Resources/vshader.glsl
View file @
191c0cbc
...
...
@@ -5,6 +5,7 @@ precision mediump float;
#endif
uniform
mat4
vp_matrix
;
uniform
mat4
norm_matrix
;
uniform
mat4
m_matrix
;
attribute
vec4
a_position
;
...
...
@@ -15,7 +16,7 @@ varying vec2 v_texcoord;
void
main
()
{
// Calculate vertex position in screen space
gl_Position
=
vp_matrix
*
m_matrix
*
a_position
;
gl_Position
=
vp_matrix
*
norm_matrix
*
m_matrix
*
a_position
;
// Pass texture coordinate to fragment shader
// Value will be automatically interpolated to fragments inside polygon faces
...
...
QtMeshViewer/Source/GeometryEngine.cpp
View file @
191c0cbc
#include "..\Header\GeometryEngine.h"
#include "..\Header\MshFile.h"
#include <cmath>
/////////////////////////////////////////////////////////////////////////
...
...
@@ -45,6 +46,7 @@ void GeometryEngine::loadFile(const char* filePath)
MshFile
file
(
filePath
);
models
=
file
.
getModels
();
textureNames
=
file
.
getTextureNames
();
m_boundings
=
file
.
getBoundingBox
();
// collect data
unsigned
int
indexOffset
(
0
);
...
...
@@ -76,8 +78,6 @@ void GeometryEngine::loadFile(const char* filePath)
}
}
//TODO: cleanup old stuff
// Transfer vertex data to VBO 0
m_arrayBuf
.
bind
();
m_arrayBuf
.
allocate
(
vertexData
.
data
(),
vertexData
.
size
()
*
sizeof
(
VertexData
));
...
...
@@ -159,6 +159,13 @@ void GeometryEngine::drawGeometry(QOpenGLShaderProgram *program)
m_arrayBuf
.
bind
();
m_indexBuf
.
bind
();
// Allways normalize by this
QMatrix4x4
normMatrix
;
float
maxExtent
=
std
::
max
(
std
::
max
(
m_boundings
.
extents
[
0
],
m_boundings
.
extents
[
1
]),
m_boundings
.
extents
[
2
]);
normMatrix
.
scale
(
1
/
maxExtent
);
normMatrix
.
translate
(
-
m_boundings
.
center
[
0
],
-
m_boundings
.
center
[
1
],
-
m_boundings
.
center
[
2
]);
program
->
setUniformValue
(
"norm_matrix"
,
normMatrix
);
// Allways use texture unit 0
program
->
setUniformValue
(
"texture"
,
0
);
...
...
QtMeshViewer/Source/OglViewerWidget.cpp
View file @
191c0cbc
...
...
@@ -6,7 +6,7 @@
#include <math.h>
#include <iostream>
#define DEFAULT_Z_DISTANCE -
5
.0
#define DEFAULT_Z_DISTANCE -
4
.0
/////////////////////////////////////////////////////////////////////////
...
...
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