Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
OpenGL
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Container registry
Model registry
Analyze
Contributor analytics
Repository analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
C-Fu
OpenGL
Commits
c0a84c75
Commit
c0a84c75
authored
8 years ago
by
Anakin
Browse files
Options
Downloads
Patches
Plain Diff
get all materials,
save the texture name for every modl, program crashes at glfwPollEvents(); fix???
parent
03553616
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
MshViewer/Header/Object.h
+2
-1
2 additions, 1 deletion
MshViewer/Header/Object.h
MshViewer/Source/Object.cpp
+70
-10
70 additions, 10 deletions
MshViewer/Source/Object.cpp
MshViewer/Source/OpenGlController.cpp
+1
-2
1 addition, 2 deletions
MshViewer/Source/OpenGlController.cpp
with
73 additions
and
13 deletions
MshViewer/Header/Object.h
+
2
−
1
View file @
c0a84c75
...
...
@@ -54,13 +54,14 @@ private:
std
::
list
<
Modl
*>
lModls
;
std
::
fstream
fsMesh
;
std
::
list
<
std
::
string
>
l
Textures
;
std
::
vector
<
std
::
string
>
v
Textures
;
private:
void
setModlDefault
(
Modl
*
model
);
void
loadChunks
(
std
::
list
<
ChunkHeader
*>
&
destination
,
std
::
streampos
start
,
const
std
::
uint32_t
end
);
void
analyseMsh2Chunks
(
std
::
list
<
ChunkHeader
*>
&
chunkList
);
void
analyseMatdChunks
(
Modl
*
dataDestination
,
std
::
list
<
ChunkHeader
*>
&
chunkList
);
void
analyseModlChunks
(
Modl
*
dataDestination
,
std
::
list
<
ChunkHeader
*>
&
chunkList
);
void
analyseGeomChunks
(
Modl
*
dataDestination
,
std
::
list
<
ChunkHeader
*>
&
chunkList
);
void
analyseSegmChunks
(
Modl
*
dataDestination
,
std
::
list
<
ChunkHeader
*>
&
chunkList
);
...
...
This diff is collapsed.
Click to expand it.
MshViewer/Source/Object.cpp
+
70
−
10
View file @
c0a84c75
...
...
@@ -2,7 +2,6 @@
#include
<iostream>
/////////////////////////////////////////////////////////////////////////
// public constructor/destructor
...
...
@@ -24,7 +23,7 @@ Object::Object(const char* path)
fsMesh
.
read
(
reinterpret_cast
<
char
*>
(
&
tempFileSize
),
sizeof
(
tempFileSize
));
loadChunks
(
tempMainChunks
,
fsMesh
.
tellg
(),
tempFileSize
);
// evaluate sub
chunks (= find MSH2)
// evaluate
HEDR
subchunks (= find MSH2)
for
(
std
::
list
<
ChunkHeader
*>::
iterator
it
=
tempMainChunks
.
begin
();
it
!=
tempMainChunks
.
end
();
it
++
)
{
if
(
!
strcmp
(
"MSH2"
,
(
*
it
)
->
name
))
...
...
@@ -65,7 +64,6 @@ Object::~Object()
}
/////////////////////////////////////////////////////////////////////////
// private functions
...
...
@@ -135,17 +133,51 @@ void Object::analyseMsh2Chunks(std::list<ChunkHeader*>& chunkList)
{
for
(
std
::
list
<
ChunkHeader
*>::
iterator
it
=
chunkList
.
begin
();
it
!=
chunkList
.
end
();
it
++
)
{
Modl
*
tempModl
=
new
Modl
;
setModlDefault
(
tempModl
);
if
(
!
strcmp
(
"MATL"
,
(
*
it
)
->
name
))
{
// get all MATD from MATL list
std
::
list
<
ChunkHeader
*>
tempMatlChunks
;
loadChunks
(
tempMatlChunks
,
(
*
it
)
->
position
,
(
*
it
)
->
size
);
// evaluate MATL subchunks
for
(
std
::
list
<
ChunkHeader
*>::
iterator
it
=
tempMatlChunks
.
begin
();
it
!=
tempMatlChunks
.
end
();
it
++
)
{
// This shouldn't be anything else than MATD
if
(
!
strcmp
(
"MATD"
,
(
*
it
)
->
name
))
{
// get all subchunks from MATD
std
::
list
<
ChunkHeader
*>
tempMatdChunks
;
loadChunks
(
tempMatdChunks
,
(
*
it
)
->
position
,
(
*
it
)
->
size
);
// analyse MATD subchunks
analyseMatdChunks
(
tempModl
,
tempMatdChunks
);
// clean up
while
(
!
tempMatdChunks
.
empty
())
{
ChunkHeader
*
tempCursor
=
tempMatdChunks
.
front
();
tempMatdChunks
.
pop_front
();
delete
tempCursor
;
}
}
}
// clean up
while
(
!
tempMatlChunks
.
empty
())
{
ChunkHeader
*
tempCursor
=
tempMatlChunks
.
front
();
tempMatlChunks
.
pop_front
();
delete
tempCursor
;
}
continue
;
}
if
(
!
strcmp
(
"MODL"
,
(
*
it
)
->
name
))
{
Modl
*
tempModl
=
new
Modl
;
setModlDefault
(
tempModl
);
// get all subchunks
std
::
list
<
ChunkHeader
*>
tempChunks
;
loadChunks
(
tempChunks
,
(
*
it
)
->
position
,
(
*
it
)
->
size
);
...
...
@@ -161,9 +193,27 @@ void Object::analyseMsh2Chunks(std::list<ChunkHeader*>& chunkList)
delete
tempCursor
;
}
// save Model data
lModls
.
push_back
(
tempModl
);
continue
;
}
// save Model data
lModls
.
push_back
(
tempModl
);
}
}
void
Object
::
analyseMatdChunks
(
Modl
*
dataDestination
,
std
::
list
<
ChunkHeader
*>&
chunkList
)
{
for
(
std
::
list
<
ChunkHeader
*>::
iterator
it
=
chunkList
.
begin
();
it
!=
chunkList
.
end
();
it
++
)
{
//TX1D, TX2D, TX3D
if
(
!
strcmp
(
"TX0D"
,
(
*
it
)
->
name
))
{
fsMesh
.
seekg
((
*
it
)
->
position
);
char
*
buffer
=
new
char
[(
*
it
)
->
size
+
1
];
*
buffer
=
{
0
};
fsMesh
.
read
(
buffer
,
(
*
it
)
->
size
);
vTextures
.
push_back
(
buffer
);
delete
buffer
;
continue
;
}
}
...
...
@@ -186,6 +236,7 @@ void Object::analyseModlChunks(Modl* dataDestination, std::list<ChunkHeader*>& c
{
fsMesh
.
seekg
((
*
it
)
->
position
);
char
*
buffer
=
new
char
[(
*
it
)
->
size
];
*
buffer
=
{
0
};
fsMesh
.
read
(
buffer
,
(
*
it
)
->
size
);
dataDestination
->
parent
=
buffer
;
delete
buffer
;
...
...
@@ -196,6 +247,7 @@ void Object::analyseModlChunks(Modl* dataDestination, std::list<ChunkHeader*>& c
{
fsMesh
.
seekg
((
*
it
)
->
position
);
char
*
buffer
=
new
char
[(
*
it
)
->
size
];
*
buffer
=
{
0
};
fsMesh
.
read
(
buffer
,
(
*
it
)
->
size
);
dataDestination
->
name
=
buffer
;
delete
buffer
;
...
...
@@ -328,8 +380,15 @@ void Object::analyseSegmChunks(Modl * dataDestination, std::list<ChunkHeader*>&
if
(
!
strcmp
(
"MATI"
,
(
*
it
)
->
name
))
{
fsMesh
.
seekg
((
*
it
)
->
position
);
// material index index into MATL
// long int - 4 - material index
std
::
uint32_t
tempIndex
;
fsMesh
.
read
(
reinterpret_cast
<
char
*>
(
&
tempIndex
),
sizeof
(
tempIndex
));
if
(
vTextures
.
size
()
<
tempIndex
-
1
)
{
std
::
cout
<<
"warning texture index <"
<<
tempIndex
<<
"> unknown"
<<
std
::
endl
;
dataDestination
->
texture
=
""
;
continue
;
}
dataDestination
->
texture
=
vTextures
[
tempIndex
-
1
];
continue
;
}
...
...
@@ -410,6 +469,7 @@ void Object::analyseClthChunks(Modl * dataDestination, std::list<ChunkHeader*>&
{
fsMesh
.
seekg
((
*
it
)
->
position
);
char
*
buffer
=
new
char
[(
*
it
)
->
size
];
*
buffer
=
{
0
};
fsMesh
.
read
(
buffer
,
(
*
it
)
->
size
);
dataDestination
->
texture
=
buffer
;
delete
buffer
;
...
...
This diff is collapsed.
Click to expand it.
MshViewer/Source/OpenGlController.cpp
+
1
−
2
View file @
c0a84c75
...
...
@@ -309,11 +309,10 @@ void OpenGLController::loadMsh(const char * path)
}
catch
(
std
::
invalid_argument
e
)
{
GLubyte
solidColor
[
4
]
=
{
255
,
0
,
0
,
255
};
GLubyte
solidColor
[
4
]
=
{
255
,
0
,
0
,
255
};
glTexImage2D
(
GL_TEXTURE_2D
,
0
,
GL_RGBA
,
1
,
1
,
0
,
GL_RGBA
,
GL_UNSIGNED_BYTE
,
(
const
GLvoid
*
)
solidColor
);
}
glTexParameteri
(
GL_TEXTURE_2D
,
GL_TEXTURE_WRAP_S
,
GL_REPEAT
);
glTexParameteri
(
GL_TEXTURE_2D
,
GL_TEXTURE_WRAP_T
,
GL_REPEAT
);
glTexParameteri
(
GL_TEXTURE_2D
,
GL_TEXTURE_MAG_FILTER
,
GL_LINEAR
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment