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
a47eefe9
Commit
a47eefe9
authored
Dec 01, 2016
by
Anakin
Browse files
move the model to the center,
clean up variables, use delete[]
parent
1c0ed61b
Changes
4
Hide whitespace changes
Inline
Side-by-side
MshViewer/Header/Object.h
View file @
a47eefe9
...
...
@@ -71,5 +71,5 @@ private:
public:
std
::
vector
<
Modl
*>*
getModels
()
const
;
std
::
vector
<
std
::
string
>
getTextureList
()
const
;
Bbox
getBoundgBox
()
const
;
};
MshViewer/Header/OpenGLController.h
View file @
a47eefe9
...
...
@@ -72,6 +72,7 @@ private:
// data
std
::
vector
<
Modl
*>*
vModels
=
NULL
;
std
::
vector
<
textureData
*>
vTextures
;
Bbox
sceneBoundingBox
;
// transformation =========================
//values
...
...
MshViewer/Source/Object.cpp
View file @
a47eefe9
...
...
@@ -134,6 +134,9 @@ void Object::analyseMsh2Chunks(std::list<ChunkHeader*>& chunkList)
fsMesh
.
read
(
reinterpret_cast
<
char
*>
(
&
boundingBox
.
extents
[
i
]),
sizeof
(
float
));
}
}
for
(
ChunkHeader
*
it
:
tempSinfChunks
)
delete
it
;
}
else
if
(
!
strcmp
(
"MATL"
,
it
->
name
))
...
...
@@ -217,7 +220,7 @@ void Object::analyseMatdChunks(std::list<ChunkHeader*>& chunkList)
*
buffer
=
{
0
};
fsMesh
.
read
(
buffer
,
it
->
size
);
vTextures
.
back
()
=
buffer
;
delete
buffer
;
delete
[]
buffer
;
}
}
}
...
...
@@ -241,7 +244,7 @@ void Object::analyseModlChunks(Modl* dataDestination, std::list<ChunkHeader*>& c
*
buffer
=
{
0
};
fsMesh
.
read
(
buffer
,
it
->
size
);
dataDestination
->
parent
=
buffer
;
delete
buffer
;
delete
[]
buffer
;
}
else
if
(
!
strcmp
(
"NAME"
,
it
->
name
))
...
...
@@ -251,7 +254,7 @@ void Object::analyseModlChunks(Modl* dataDestination, std::list<ChunkHeader*>& c
*
buffer
=
{
0
};
fsMesh
.
read
(
buffer
,
it
->
size
);
dataDestination
->
name
=
buffer
;
delete
buffer
;
delete
[]
buffer
;
}
else
if
(
!
strcmp
(
"FLGS"
,
it
->
name
))
...
...
@@ -515,7 +518,7 @@ void Object::analyseClthChunks(Modl * dataDestination, std::list<ChunkHeader*>&
tempData
->
textureIndex
=
vTextures
.
size
()
-
1
;
}
delete
buffer
;
delete
[]
buffer
;
}
else
if
(
!
strcmp
(
"CPOS"
,
it
->
name
))
...
...
@@ -594,6 +597,11 @@ std::vector<std::string> Object::getTextureList() const
return
vTextures
;
}
Bbox
Object
::
getBoundgBox
()
const
{
return
boundingBox
;
}
/////////////////////////////////////////////////////////////////////////
// public functions
...
...
MshViewer/Source/OpenGlController.cpp
View file @
a47eefe9
...
...
@@ -122,8 +122,8 @@ void OpenGLController::deleteVectors()
Segment
*
segmCuror
=
cursor
->
segmLst
.
back
();
cursor
->
segmLst
.
pop_back
();
delete
segmCuror
->
uv
;
delete
segmCuror
->
vertex
;
delete
[]
segmCuror
->
uv
;
delete
[]
segmCuror
->
vertex
;
while
(
!
segmCuror
->
meshIndices
.
empty
())
{
...
...
@@ -243,8 +243,13 @@ glm::mat4 OpenGLController::getMVPMatrix(unsigned int index)
m4x4ModelRot
=
glm
::
rotate
(
m4x4ModelRot
,
fRotationY
,
glm
::
vec3
(
0
,
1
,
0
));
m4x4ModelRot
=
glm
::
rotate
(
m4x4ModelRot
,
fRotationZ
,
glm
::
vec3
(
0
,
0
,
1
));
glm
::
mat4
m4x4ModelCenter
=
glm
::
translate
(
glm
::
mat4
(
1.0
f
),
glm
::
vec3
(
-
sceneBoundingBox
.
center
[
0
],
-
sceneBoundingBox
.
center
[
1
],
-
sceneBoundingBox
.
center
[
2
])
);
// Return MVP
return
m4x4Projection
*
m4x4View
*
m4x4ModelRot
*
getModelMatrix
(
index
);
return
m4x4Projection
*
m4x4View
*
m4x4ModelRot
*
m4x4ModelCenter
*
getModelMatrix
(
index
);
}
...
...
@@ -378,11 +383,12 @@ void OpenGLController::loadMsh(const char * path)
Object
obj
(
path
);
vModels
=
obj
.
getModels
();
tempTexList
=
obj
.
getTextureList
();
sceneBoundingBox
=
obj
.
getBoundgBox
();
}
catch
(
std
::
invalid_argument
e
)
{
MessageBox
(
NULL
,
e
.
what
(),
"MeshViewer 2.0 Error"
,
MB_OK
|
MB_ICONERROR
);
return
;
exit
(
1
);
return
;
}
// collect vertex data of all models
...
...
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