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
b2df84eb
Commit
b2df84eb
authored
Jan 23, 2017
by
Anakin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
read tx1d tx2d tx3d texture names and print to info window
parent
2ed9e475
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
89 additions
and
29 deletions
+89
-29
QtMeshViewer/Header/FileInterface.h
QtMeshViewer/Header/FileInterface.h
+7
-3
QtMeshViewer/Source/GeometryEngine.cpp
QtMeshViewer/Source/GeometryEngine.cpp
+5
-5
QtMeshViewer/Source/MainWindow.cpp
QtMeshViewer/Source/MainWindow.cpp
+24
-4
QtMeshViewer/Source/MshFile.cpp
QtMeshViewer/Source/MshFile.cpp
+46
-9
QtMeshViewer/main.cpp
QtMeshViewer/main.cpp
+1
-0
README.md
README.md
+6
-8
No files found.
QtMeshViewer/Header/FileInterface.h
View file @
b2df84eb
...
...
@@ -42,8 +42,12 @@ struct Model {
struct
Material
{
QString
name
;
QString
textureName
;
QOpenGLTexture
*
texture
=
Q_NULLPTR
;
QString
tx0d
;
QString
tx1d
;
QString
tx2d
;
QString
tx3d
;
QOpenGLTexture
*
texture0
=
Q_NULLPTR
;
QOpenGLTexture
*
texture1
=
Q_NULLPTR
;
QVector4D
specularColor
=
{
1.0
,
1.0
,
1.0
,
1.0
};
QVector4D
diffuseColor
=
{
1.0
,
0.0
,
0.0
,
1.0
};
QVector4D
ambientColor
=
{
1.0
,
1.0
,
1.0
,
1.0
};
...
...
@@ -132,7 +136,7 @@ public:
// f.ex. texture coordinate (1.1, 1.2) is same as (0.1, 0.2)
new_texture
->
setWrapMode
(
QOpenGLTexture
::
Repeat
);
defMaterial
->
texture
=
new_texture
;
defMaterial
->
texture
0
=
new_texture
;
defMaterial
->
name
=
"Default Material"
;
return
defMaterial
;
...
...
QtMeshViewer/Source/GeometryEngine.cpp
View file @
b2df84eb
...
...
@@ -21,7 +21,7 @@ GeometryEngine::GeometryEngine(QObject *parent)
GeometryEngine
::~
GeometryEngine
()
{
clearData
();
delete
m_defaultMaterial
->
texture
;
delete
m_defaultMaterial
->
texture
0
;
delete
m_defaultMaterial
;
}
...
...
@@ -39,7 +39,7 @@ void GeometryEngine::clearData()
if
(
m_materials
!=
Q_NULLPTR
)
{
for
(
auto
it
:
*
m_materials
)
delete
it
.
texture
;
delete
it
.
texture
0
;
m_materials
->
clear
();
delete
m_materials
;
}
...
...
@@ -182,9 +182,9 @@ void GeometryEngine::drawGeometry(QOpenGLShaderProgram *program, bool wireframe)
QVector3D
specularColor
;
// bind the correct texture
if
(
it
.
textureIndex
<
m_materials
->
size
()
&&
m_materials
->
at
(
it
.
textureIndex
).
texture
!=
Q_NULLPTR
)
if
(
it
.
textureIndex
<
m_materials
->
size
()
&&
m_materials
->
at
(
it
.
textureIndex
).
texture
0
!=
Q_NULLPTR
)
{
m_materials
->
at
(
it
.
textureIndex
).
texture
->
bind
();
m_materials
->
at
(
it
.
textureIndex
).
texture
0
->
bind
();
tmp_transparent
=
m_materials
->
at
(
it
.
textureIndex
).
transparent
;
tmp_specular
=
m_materials
->
at
(
it
.
textureIndex
).
flags
[
7
];
shininess
=
m_materials
->
at
(
it
.
textureIndex
).
shininess
;
...
...
@@ -192,7 +192,7 @@ void GeometryEngine::drawGeometry(QOpenGLShaderProgram *program, bool wireframe)
}
else
{
m_defaultMaterial
->
texture
->
bind
();
m_defaultMaterial
->
texture
0
->
bind
();
tmp_transparent
=
m_defaultMaterial
->
transparent
;
}
// Set model matrix
...
...
QtMeshViewer/Source/MainWindow.cpp
View file @
b2df84eb
...
...
@@ -210,17 +210,37 @@ void MainWindow::setFileInfo(QString name, QVector<Material>* materials, int ver
m_fileInfo
+=
QByteArray
::
number
(
triangle
);
m_fileInfo
+=
"<detail>"
;
//TODO: mark not opened textures
//TODO: add more information
for
(
auto
&
it
:
*
materials
)
{
m_fileInfo
+=
it
.
name
;
m_fileInfo
+=
"
\n
"
;
m_fileInfo
+=
"TX0D:
\t\t
"
;
if
(
it
.
t
exture
==
NULL
)
if
(
it
.
t
x0d
.
isEmpty
()
)
m_fileInfo
+=
"-"
;
m_fileInfo
+=
it
.
textureName
;
else
m_fileInfo
+=
it
.
tx0d
;
m_fileInfo
+=
"
\n
"
;
m_fileInfo
+=
"TX1D:
\t\t
"
;
if
(
it
.
tx1d
.
isEmpty
())
m_fileInfo
+=
"-"
;
else
m_fileInfo
+=
it
.
tx1d
;
m_fileInfo
+=
"
\n
"
;
m_fileInfo
+=
"TX2D:
\t\t
"
;
if
(
it
.
tx2d
.
isEmpty
())
m_fileInfo
+=
"-"
;
else
m_fileInfo
+=
it
.
tx2d
;
m_fileInfo
+=
"
\n
"
;
m_fileInfo
+=
"TX3D:
\t\t
"
;
if
(
it
.
tx3d
.
isEmpty
())
m_fileInfo
+=
"-"
;
else
m_fileInfo
+=
it
.
tx3d
;
m_fileInfo
+=
"
\n
"
;
m_fileInfo
+=
"Flags:
\t\t
"
;
...
...
QtMeshViewer/Source/MshFile.cpp
View file @
b2df84eb
...
...
@@ -249,7 +249,6 @@ void MshFile::analyseMatdChunks(std::list<ChunkHeader*>& chunkList)
m_file
.
read
(
F2V
(
m_materials
->
back
().
shininess
),
sizeof
(
float
));
}
// TODO: evaluate specular, gloss,.. and save values
// attributes
else
if
(
!
strcmp
(
"ATRB"
,
it
->
name
))
{
...
...
@@ -281,7 +280,7 @@ void MshFile::analyseMatdChunks(std::list<ChunkHeader*>& chunkList)
}
// texture
zero
// texture
0
else
if
(
!
strcmp
(
"TX0D"
,
it
->
name
))
{
// get the texture name
...
...
@@ -289,12 +288,50 @@ void MshFile::analyseMatdChunks(std::list<ChunkHeader*>& chunkList)
char
*
buffer
=
new
char
[
it
->
size
+
1
];
*
buffer
=
{
0
};
m_file
.
read
(
buffer
,
it
->
size
);
m_materials
->
back
().
t
extureName
=
buffer
;
m_materials
->
back
().
t
x0d
=
buffer
;
delete
[]
buffer
;
// load the texture if the name is not empty
if
(
!
m_materials
->
back
().
textureName
.
isEmpty
())
loadTexture
(
m_materials
->
back
().
texture
,
m_filepath
+
"/"
+
m_materials
->
back
().
textureName
);
if
(
!
m_materials
->
back
().
tx0d
.
isEmpty
())
loadTexture
(
m_materials
->
back
().
texture0
,
m_filepath
+
"/"
+
m_materials
->
back
().
tx0d
);
}
// texture 1
else
if
(
!
strcmp
(
"TX1D"
,
it
->
name
))
{
// get the texture name
m_file
.
seekg
(
it
->
position
);
char
*
buffer
=
new
char
[
it
->
size
+
1
];
*
buffer
=
{
0
};
m_file
.
read
(
buffer
,
it
->
size
);
m_materials
->
back
().
tx1d
=
buffer
;
delete
[]
buffer
;
// TODO: load texture to slot 1, need to change loadTexutre function
}
// texture 2
else
if
(
!
strcmp
(
"TX2D"
,
it
->
name
))
{
// get the texture name
m_file
.
seekg
(
it
->
position
);
char
*
buffer
=
new
char
[
it
->
size
+
1
];
*
buffer
=
{
0
};
m_file
.
read
(
buffer
,
it
->
size
);
m_materials
->
back
().
tx2d
=
buffer
;
delete
[]
buffer
;
}
// texture 3
else
if
(
!
strcmp
(
"TX3D"
,
it
->
name
))
{
// get the texture name
m_file
.
seekg
(
it
->
position
);
char
*
buffer
=
new
char
[
it
->
size
+
1
];
*
buffer
=
{
0
};
m_file
.
read
(
buffer
,
it
->
size
);
m_materials
->
back
().
tx3d
=
buffer
;
delete
[]
buffer
;
}
}
}
...
...
@@ -586,12 +623,12 @@ void MshFile::analyseClthChunks(Model * dataDestination, std::list<ChunkHeader*>
m_materials
->
push_back
(
Material
());
m_materials
->
back
().
name
=
"Cloth Material"
;
m_materials
->
back
().
t
extureName
=
QString
(
buffer
);
m_materials
->
back
().
t
x0d
=
QString
(
buffer
);
m_materials
->
back
().
shininess
=
10
;
if
(
!
m_materials
->
back
().
t
extureName
.
isEmpty
())
loadTexture
(
m_materials
->
back
().
texture
,
m_filepath
+
"/"
+
m_materials
->
back
().
textureName
);
if
(
!
m_materials
->
back
().
t
x0d
.
isEmpty
())
loadTexture
(
m_materials
->
back
().
texture
0
,
m_filepath
+
"/"
+
m_materials
->
back
().
tx0d
);
new_segment
->
textureIndex
=
m_materials
->
size
()
-
1
;
...
...
@@ -687,7 +724,7 @@ void MshFile::loadTexture(QOpenGLTexture *& destination, QString filepath)
img
=
QImage
(
1
,
1
,
QImage
::
Format_RGB32
);
img
.
fill
(
QColor
(
m_materials
->
back
().
diffuseColor
[
0
]
*
255
,
m_materials
->
back
().
diffuseColor
[
1
]
*
255
,
m_materials
->
back
().
diffuseColor
[
2
]
*
255
));
m_materials
->
back
().
t
extureName
+=
" *"
;
m_materials
->
back
().
t
x0d
+=
" *"
;
}
// Load image to OglTexture
...
...
QtMeshViewer/main.cpp
View file @
b2df84eb
#include "Header\MainWindow.h"
#include <QtWidgets/QApplication>
// TODO: add glow/emissive
int
main
(
int
argc
,
char
*
argv
[])
{
...
...
README.md
View file @
b2df84eb
...
...
@@ -13,11 +13,9 @@ Feel free to use my code the way you like. But remember i used some public libra
licence, too.
### To Do
-
optional display bones, shadow, collision,...
-
integrate into a software:
-> list all msh under a directory,
-> display shadows,
-> display colisions,
-> lights,
-> handle render flags,
-
normal map,
-
list all msh in a directory
-
glow/emissive
-
optional display bones, shadow, collision
-
change pose
-
animation
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