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
548150f3
Commit
548150f3
authored
8 years ago
by
Anakin
Browse files
Options
Downloads
Patches
Plain Diff
evaluate most of MODL chunk,
missing GEOM chunk,
parent
59446f08
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
MshViewer/Header/Object.h
+33
-2
33 additions, 2 deletions
MshViewer/Header/Object.h
MshViewer/Source/Object.cpp
+86
-3
86 additions, 3 deletions
MshViewer/Source/Object.cpp
MshViewer/main.cpp
+5
-0
5 additions, 0 deletions
MshViewer/main.cpp
with
124 additions
and
5 deletions
MshViewer/Header/Object.h
+
33
−
2
View file @
548150f3
...
...
@@ -2,7 +2,16 @@
#include
<vector>
#include
<list>
#include
<fstream>
//#include <windows.h>
#include
<string>
enum
mtyp
{
null
,
dynamicMesh
,
cloth
,
bone
,
staticMesh
,
shadowMesh
=
6
};
struct
chunkHeader
{
char
name
[
5
];
...
...
@@ -10,6 +19,28 @@ struct chunkHeader {
std
::
streampos
position
;
};
struct
modl
{
std
::
string
name
;
std
::
uint32_t
size
;
std
::
streampos
position
;
std
::
string
parent
;
mtyp
type
;
std
::
uint32_t
zeroBaseIndex
;
std
::
uint32_t
renderFlags
;
struct
{
float
scale
[
3
];
float
rotation
[
4
];
float
translation
[
3
];
}
tran
;
struct
{
std
::
uint32_t
type
;
float
data1
;
float
data2
;
float
data3
;
}
swci
;
};
class
Object
{
public:
...
...
@@ -19,7 +50,7 @@ public:
private:
std
::
list
<
chunkHeader
*>
lChunkMsh2
;
std
::
list
<
std
::
list
<
chunkHeader
*>*>
lChunk
Modls
;
std
::
list
<
modl
*>
l
Modls
;
std
::
fstream
fsMesh
;
...
...
This diff is collapsed.
Click to expand it.
MshViewer/Source/Object.cpp
+
86
−
3
View file @
548150f3
...
...
@@ -33,9 +33,92 @@ Object::Object(const char* path)
{
if
(
!
strcmp
(
"MODL"
,
(
*
it
)
->
name
))
{
std
::
list
<
chunkHeader
*>*
tempModlList
=
new
std
::
list
<
chunkHeader
*>
;
loadChunks
(
*
tempModlList
,
(
*
it
)
->
position
,
(
*
it
)
->
size
);
lChunkModls
.
push_back
(
tempModlList
);
modl
*
tempModl
=
new
modl
;
tempModl
->
size
=
(
*
it
)
->
size
;
tempModl
->
position
=
(
*
it
)
->
position
;
std
::
list
<
chunkHeader
*>
tempChunks
;
loadChunks
(
tempChunks
,
(
*
it
)
->
position
,
(
*
it
)
->
size
);
// evaluate MODL subchunks
for
(
std
::
list
<
chunkHeader
*>::
iterator
it
=
tempChunks
.
begin
();
it
!=
tempChunks
.
end
();
it
++
)
{
if
(
!
strcmp
(
"MTYP"
,
(
*
it
)
->
name
))
{
fsMesh
.
seekg
((
*
it
)
->
position
);
std
::
uint32_t
tempType
;
fsMesh
.
read
(
reinterpret_cast
<
char
*>
(
&
tempType
),
sizeof
(
tempType
));
tempModl
->
type
=
(
mtyp
)
tempType
;
}
if
(
!
strcmp
(
"MNDX"
,
(
*
it
)
->
name
))
{
fsMesh
.
seekg
((
*
it
)
->
position
);
fsMesh
.
read
(
reinterpret_cast
<
char
*>
(
&
tempModl
->
zeroBaseIndex
),
sizeof
(
tempModl
->
zeroBaseIndex
));
}
if
(
!
strcmp
(
"PRNT"
,
(
*
it
)
->
name
))
{
fsMesh
.
seekg
((
*
it
)
->
position
);
char
tempName
[
33
]
=
{
0
};
fsMesh
.
read
(
reinterpret_cast
<
char
*>
(
&
tempName
[
0
]),
(
*
it
)
->
size
>
32
?
32
:
(
*
it
)
->
size
);
tempModl
->
parent
=
tempName
;
}
if
(
!
strcmp
(
"NAME"
,
(
*
it
)
->
name
))
{
fsMesh
.
seekg
((
*
it
)
->
position
);
char
tempName
[
33
]
=
{
0
};
fsMesh
.
read
(
reinterpret_cast
<
char
*>
(
&
tempName
[
0
]),
(
*
it
)
->
size
>
32
?
32
:
(
*
it
)
->
size
);
tempModl
->
name
=
tempName
;
}
if
(
!
strcmp
(
"FLGS"
,
(
*
it
)
->
name
))
{
fsMesh
.
seekg
((
*
it
)
->
position
);
fsMesh
.
read
(
reinterpret_cast
<
char
*>
(
&
tempModl
->
renderFlags
),
sizeof
(
tempModl
->
renderFlags
));
}
if
(
!
strcmp
(
"TRAN"
,
(
*
it
)
->
name
))
{
fsMesh
.
seekg
((
*
it
)
->
position
);
fsMesh
.
read
(
reinterpret_cast
<
char
*>
(
&
tempModl
->
tran
.
scale
[
0
]),
sizeof
(
float
));
fsMesh
.
read
(
reinterpret_cast
<
char
*>
(
&
tempModl
->
tran
.
scale
[
1
]),
sizeof
(
float
));
fsMesh
.
read
(
reinterpret_cast
<
char
*>
(
&
tempModl
->
tran
.
scale
[
2
]),
sizeof
(
float
));
fsMesh
.
read
(
reinterpret_cast
<
char
*>
(
&
tempModl
->
tran
.
rotation
[
0
]),
sizeof
(
float
));
fsMesh
.
read
(
reinterpret_cast
<
char
*>
(
&
tempModl
->
tran
.
rotation
[
1
]),
sizeof
(
float
));
fsMesh
.
read
(
reinterpret_cast
<
char
*>
(
&
tempModl
->
tran
.
rotation
[
2
]),
sizeof
(
float
));
fsMesh
.
read
(
reinterpret_cast
<
char
*>
(
&
tempModl
->
tran
.
rotation
[
3
]),
sizeof
(
float
));
fsMesh
.
read
(
reinterpret_cast
<
char
*>
(
&
tempModl
->
tran
.
translation
[
0
]),
sizeof
(
float
));
fsMesh
.
read
(
reinterpret_cast
<
char
*>
(
&
tempModl
->
tran
.
translation
[
1
]),
sizeof
(
float
));
fsMesh
.
read
(
reinterpret_cast
<
char
*>
(
&
tempModl
->
tran
.
translation
[
2
]),
sizeof
(
float
));
}
if
(
!
strcmp
(
"GEOM"
,
(
*
it
)
->
name
))
{
}
if
(
!
strcmp
(
"SWCI"
,
(
*
it
)
->
name
))
{
fsMesh
.
seekg
((
*
it
)
->
position
);
fsMesh
.
read
(
reinterpret_cast
<
char
*>
(
&
tempModl
->
swci
.
type
),
sizeof
(
tempModl
->
swci
.
type
));
fsMesh
.
read
(
reinterpret_cast
<
char
*>
(
&
tempModl
->
swci
.
data1
),
sizeof
(
tempModl
->
swci
.
data1
));
fsMesh
.
read
(
reinterpret_cast
<
char
*>
(
&
tempModl
->
swci
.
data2
),
sizeof
(
tempModl
->
swci
.
data2
));
fsMesh
.
read
(
reinterpret_cast
<
char
*>
(
&
tempModl
->
swci
.
data3
),
sizeof
(
tempModl
->
swci
.
data3
));
}
}
lModls
.
push_back
(
tempModl
);
//clean up
while
(
!
tempChunks
.
empty
())
{
chunkHeader
*
tempCursor
=
tempChunks
.
front
();
tempChunks
.
pop_front
();
delete
tempCursor
;
}
}
}
...
...
This diff is collapsed.
Click to expand it.
MshViewer/main.cpp
+
5
−
0
View file @
548150f3
...
...
@@ -9,6 +9,8 @@
int
main
(
int
argc
,
char
**
argv
)
{
//goto openGL;
try
{
Object
obj
(
"..
\\
Release
\\
Msh
\\
cube.msh"
);
}
...
...
@@ -21,6 +23,9 @@ int main(int argc, char** argv)
return
0
;
openGL
:
OpenGLController
*
scene
=
OpenGLController
::
getInstance
();
scene
->
loadMsh
(
"test.msh"
);
...
...
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