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
a47eefe9
Commit
a47eefe9
authored
Dec 01, 2016
by
Anakin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
move the model to the center,
clean up variables, use delete[]
parent
1c0ed61b
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
24 additions
and
9 deletions
+24
-9
MshViewer/Header/Object.h
MshViewer/Header/Object.h
+1
-1
MshViewer/Header/OpenGLController.h
MshViewer/Header/OpenGLController.h
+1
-0
MshViewer/Source/Object.cpp
MshViewer/Source/Object.cpp
+12
-4
MshViewer/Source/OpenGlController.cpp
MshViewer/Source/OpenGlController.cpp
+10
-4
No files found.
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
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