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
c28a12cd
Commit
c28a12cd
authored
Jan 03, 2017
by
Anakin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
finally fixed rotation bug,
some performance,
parent
0fefc616
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
28 additions
and
14 deletions
+28
-14
QtMeshViewer/Header/MshFile.h
QtMeshViewer/Header/MshFile.h
+1
-0
QtMeshViewer/Source/GeometryEngine.cpp
QtMeshViewer/Source/GeometryEngine.cpp
+4
-5
QtMeshViewer/Source/MshFile.cpp
QtMeshViewer/Source/MshFile.cpp
+21
-9
QtMeshViewer/main.cpp
QtMeshViewer/main.cpp
+2
-0
Release/Msh/rotTest.msh
Release/Msh/rotTest.msh
+0
-0
No files found.
QtMeshViewer/Header/MshFile.h
View file @
c28a12cd
...
...
@@ -44,4 +44,5 @@ private:
void
readUV
(
Segment
*
dataDestination
,
std
::
streampos
position
);
QMatrix4x4
getParentMatrix
(
std
::
string
parent
)
const
;
QQuaternion
getParentRotation
(
std
::
string
parent
)
const
;
};
\ No newline at end of file
QtMeshViewer/Source/GeometryEngine.cpp
View file @
c28a12cd
...
...
@@ -10,8 +10,6 @@ GeometryEngine::GeometryEngine()
:
m_indexBuf
(
QOpenGLBuffer
::
IndexBuffer
)
{
initializeOpenGLFunctions
();
loadFile
(
"..
\\
Release
\\
Msh
\\
cubeTex.msh"
);
}
GeometryEngine
::~
GeometryEngine
()
...
...
@@ -63,9 +61,10 @@ void GeometryEngine::loadFile(const char* filePath)
new_info
.
modelMatrix
=
modelIterator
->
m4x4Translation
;
new_info
.
modelMatrix
.
rotate
(
modelIterator
->
quadRotation
);
// add offset to indices
for
(
auto
&
it
:
segmentIterator
->
indices
)
it
+=
vertexOffset
;
// add offset to indices, no need to do it for the first one (maybe it's very big)
if
(
vertexOffset
!=
0
)
for
(
auto
&
it
:
segmentIterator
->
indices
)
it
+=
vertexOffset
;
// save data
vertexData
+=
segmentIterator
->
vertices
;
...
...
QtMeshViewer/Source/MshFile.cpp
View file @
c28a12cd
...
...
@@ -291,14 +291,14 @@ void MshFile::analyseModlChunks(Model * dataDestination, std::list<ChunkHeader*>
for
(
int
i
=
0
;
i
<
3
;
i
++
)
m_file
.
read
(
F2V
(
tmp_trans
[
i
]),
sizeof
(
float
));
// modify the matrix
// modify the matrix
and quaternion
dataDestination
->
m4x4Translation
.
scale
(
tmp_scale
[
0
],
tmp_scale
[
1
],
tmp_scale
[
2
]);
dataDestination
->
m4x4Translation
.
translate
(
tmp_trans
[
0
],
tmp_trans
[
1
],
tmp_trans
[
2
]);
dataDestination
->
quadRotation
.
setVector
(
QVector3D
(
tmp_rotation
[
0
],
tmp_rotation
[
1
],
tmp_rotation
[
2
]));
dataDestination
->
quadRotation
.
setScalar
(
tmp_rotation
[
3
]);
dataDestination
->
m4x4Translation
=
getParentMatrix
(
dataDestination
->
parent
)
*
dataDestination
->
m4x4Translation
;
dataDestination
->
quadRotation
=
getParentRotation
(
dataDestination
->
parent
)
*
dataDestination
->
quadRotation
;
}
// geometry data
...
...
@@ -406,10 +406,7 @@ void MshFile::analyseSegmChunks(Model * dataDestination, std::list<ChunkHeader*>
else
if
(
!
strcmp
(
"STRP"
,
it
->
name
))
{
// don't get null, bone, shadowMesh and hidden mesh indices
if
(
m_currentType
==
null
||
m_currentType
==
bone
||
m_currentType
==
shadowMesh
||
m_currentRenderFlag
==
1
)
if
(
m_currentType
==
null
||
m_currentType
==
bone
||
m_currentType
==
shadowMesh
||
m_currentRenderFlag
==
1
)
continue
;
// jump to the data section and read the size;
...
...
@@ -455,7 +452,7 @@ void MshFile::analyseSegmChunks(Model * dataDestination, std::list<ChunkHeader*>
for
(
unsigned
int
tri
=
0
;
tri
<
tmp_multiPolySize
-
2
;
tri
++
)
// ..calculate the edge indices
for
(
int
triEdge
=
0
;
triEdge
<
3
;
triEdge
++
)
new_segment
->
indices
.
push_back
(
(
GLuint
)
tmp_buffer
[(
tri
+
triEdge
-
((
tri
%
2
)
*
(
triEdge
-
1
)
*
2
))]);
new_segment
->
indices
.
push_back
(
tmp_buffer
[(
tri
+
triEdge
-
((
tri
%
2
)
*
(
triEdge
-
1
)
*
2
))]);
}
}
// if 2 high bits are set
...
...
@@ -475,7 +472,7 @@ void MshFile::analyseSegmChunks(Model * dataDestination, std::list<ChunkHeader*>
for
(
unsigned
int
tri
=
0
;
tri
<
tmp_multiPolySize
-
2
;
tri
++
)
// ..calculate the edge indices
for
(
int
triEdge
=
0
;
triEdge
<
3
;
triEdge
++
)
new_segment
->
indices
.
push_back
(
(
GLuint
)
tmp_buffer
[(
tri
+
triEdge
-
((
tri
%
2
)
*
(
triEdge
-
1
)
*
2
))]);
new_segment
->
indices
.
push_back
(
tmp_buffer
[(
tri
+
triEdge
-
((
tri
%
2
)
*
(
triEdge
-
1
)
*
2
))]);
}
}
}
...
...
@@ -610,7 +607,6 @@ QMatrix4x4 MshFile::getParentMatrix(std::string parent) const
{
if
(
!
strcmp
(
parent
.
c_str
(),
it
->
name
.
c_str
()))
{
//TODO: the other way around??
matrix
=
getParentMatrix
(
it
->
parent
)
*
it
->
m4x4Translation
;
break
;
}
...
...
@@ -618,3 +614,19 @@ QMatrix4x4 MshFile::getParentMatrix(std::string parent) const
return
matrix
;
}
QQuaternion
MshFile
::
getParentRotation
(
std
::
string
parent
)
const
{
QQuaternion
rotation
;
for
(
auto
&
it
:
*
m_models
)
{
if
(
!
strcmp
(
parent
.
c_str
(),
it
->
name
.
c_str
()))
{
rotation
=
getParentRotation
(
it
->
parent
)
*
it
->
quadRotation
;
break
;
}
}
return
rotation
;
}
QtMeshViewer/main.cpp
View file @
c28a12cd
#include "Header\MainWindow.h"
#include <QtWidgets/QApplication>
int
main
(
int
argc
,
char
*
argv
[])
{
QApplication
a
(
argc
,
argv
);
MainWindow
w
;
w
.
show
();
return
a
.
exec
();
}
Release/Msh/rotTest.msh
0 → 100644
View file @
c28a12cd
File added
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