Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
C-Fu
OpenGL
Commits
10718f22
Commit
10718f22
authored
Jan 23, 2017
by
Anakin
Browse files
load tx1d texture
parent
b2df84eb
Changes
3
Hide whitespace changes
Inline
Side-by-side
QtMeshViewer/Header/MshFile.h
View file @
10718f22
...
...
@@ -43,7 +43,7 @@ private:
void
readVertex
(
Segment
*
dataDestination
,
std
::
streampos
position
);
void
readUV
(
Segment
*
dataDestination
,
std
::
streampos
position
);
void
loadTexture
(
QOpenGLTexture
*&
destination
,
QString
filepath
);
void
loadTexture
(
QOpenGLTexture
*&
destination
,
QString
filepath
,
QString
&
filename
);
QMatrix4x4
getParentMatrix
(
std
::
string
parent
)
const
;
QQuaternion
getParentRotation
(
std
::
string
parent
)
const
;
...
...
QtMeshViewer/Source/GeometryEngine.cpp
View file @
10718f22
...
...
@@ -39,7 +39,13 @@ void GeometryEngine::clearData()
if
(
m_materials
!=
Q_NULLPTR
)
{
for
(
auto
it
:
*
m_materials
)
delete
it
.
texture0
;
{
if
(
it
.
texture0
!=
Q_NULLPTR
)
delete
it
.
texture0
;
if
(
it
.
texture1
!=
Q_NULLPTR
)
delete
it
.
texture1
;
}
m_materials
->
clear
();
delete
m_materials
;
}
...
...
QtMeshViewer/Source/MshFile.cpp
View file @
10718f22
...
...
@@ -293,7 +293,7 @@ void MshFile::analyseMatdChunks(std::list<ChunkHeader*>& chunkList)
// load the texture if the name is not empty
if
(
!
m_materials
->
back
().
tx0d
.
isEmpty
())
loadTexture
(
m_materials
->
back
().
texture0
,
m_filepath
+
"/"
+
m_materials
->
back
().
tx0d
);
loadTexture
(
m_materials
->
back
().
texture0
,
m_filepath
,
m_materials
->
back
().
tx0d
);
}
// texture 1
...
...
@@ -307,7 +307,9 @@ void MshFile::analyseMatdChunks(std::list<ChunkHeader*>& chunkList)
m_materials
->
back
().
tx1d
=
buffer
;
delete
[]
buffer
;
// TODO: load texture to slot 1, need to change loadTexutre function
if
(
!
m_materials
->
back
().
tx1d
.
isEmpty
())
loadTexture
(
m_materials
->
back
().
texture1
,
m_filepath
,
m_materials
->
back
().
tx1d
);
}
// texture 2
...
...
@@ -628,7 +630,7 @@ void MshFile::analyseClthChunks(Model * dataDestination, std::list<ChunkHeader*>
m_materials
->
back
().
shininess
=
10
;
if
(
!
m_materials
->
back
().
tx0d
.
isEmpty
())
loadTexture
(
m_materials
->
back
().
texture0
,
m_filepath
+
"/"
+
m_materials
->
back
().
tx0d
);
loadTexture
(
m_materials
->
back
().
texture0
,
m_filepath
,
m_materials
->
back
().
tx0d
);
new_segment
->
textureIndex
=
m_materials
->
size
()
-
1
;
...
...
@@ -713,18 +715,18 @@ void MshFile::readUV(Segment * dataDestination, std::streampos position)
m_file
.
read
(
F2V
(
dataDestination
->
vertices
[
i
].
texCoord
[
j
]),
sizeof
(
float
));
}
void
MshFile
::
loadTexture
(
QOpenGLTexture
*&
destination
,
QString
filepath
)
void
MshFile
::
loadTexture
(
QOpenGLTexture
*&
destination
,
QString
filepath
,
QString
&
filename
)
{
bool
loadSuccess
(
false
);
QImage
img
=
loadTga
(
filepath
,
loadSuccess
);
QImage
img
=
loadTga
(
filepath
+
"/"
+
filename
,
loadSuccess
);
if
(
!
loadSuccess
)
{
emit
sendMessage
(
"WARNING: texture not found or corrupted: "
+
m_materials
->
back
().
name
,
1
);
emit
sendMessage
(
"WARNING: texture not found or corrupted: "
+
file
name
,
1
);
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
().
tx0d
+=
" *"
;
filename
+=
" *"
;
}
// Load image to OglTexture
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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