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
bbe657d0
Commit
bbe657d0
authored
Nov 12, 2016
by
Anakin
Browse files
reset view before loading a new file,
reset view when pressing space
parent
1ab38547
Changes
3
Hide whitespace changes
Inline
Side-by-side
MshViewer/Header/OpenGLController.h
View file @
bbe657d0
...
...
@@ -116,6 +116,7 @@ public:
void
addTransX
(
double
value
);
void
addTransY
(
double
value
);
void
addTransZ
(
double
value
);
void
resetView
();
// main routine
GLFWwindow
*
getWindow
()
const
;
...
...
MshViewer/Source/OpenGlController.cpp
View file @
bbe657d0
...
...
@@ -269,6 +269,16 @@ void OpenGLController::addTransZ(double value)
dTranslationZ
+=
value
;
}
void
OpenGLController
::
resetView
()
{
dTranslationX
=
0
;
dTranslationY
=
0
;
dTranslationZ
=
5
;
fRotationX
=
0
;
fRotationY
=
0
;
fRotationZ
=
0
;
}
void
OpenGLController
::
updateScene
()
{
// get new matrices
...
...
@@ -327,7 +337,7 @@ void OpenGLController::loadMsh(const char * path)
catch
(
std
::
invalid_argument
e
)
{
MessageBox
(
NULL
,
e
.
what
(),
"MeshViewer 2.0 Error"
,
MB_OK
|
MB_ICONERROR
);
exit
(
1
);
return
;
exit
(
1
);
}
// collect vertex data of all models
...
...
MshViewer/Source/callback.cpp
View file @
bbe657d0
...
...
@@ -78,6 +78,8 @@ void mouseWheel(GLFWwindow *window, double xoffset, double yoffset)
void
keyPress
(
GLFWwindow
*
window
,
int
key
,
int
scancode
,
int
action
,
int
mods
)
{
OpenGLController
*
controller
=
reinterpret_cast
<
OpenGLController
*>
(
glfwGetWindowUserPointer
(
window
));
if
(
action
==
GLFW_PRESS
||
action
==
GLFW_REPEAT
)
{
switch
(
key
)
...
...
@@ -93,6 +95,9 @@ void keyPress(GLFWwindow *window, int key, int scancode, int action, int mods)
case
GLFW_KEY_PLUS_GER
:
case
GLFW_KEY_KP_ADD
:
mouse
.
speed
+=
0.1
;
break
;
case
GLFW_KEY_SPACE
:
controller
->
resetView
();
break
;
default:
break
;
}
...
...
@@ -102,6 +107,10 @@ void keyPress(GLFWwindow *window, int key, int scancode, int action, int mods)
void
dragNdrop
(
GLFWwindow
*
window
,
int
count
,
const
char
**
paths
)
{
OpenGLController
*
controller
=
reinterpret_cast
<
OpenGLController
*>
(
glfwGetWindowUserPointer
(
window
));
if
(
count
>
0
)
controller
->
loadMsh
(
paths
[
0
]);
if
(
count
<
1
)
return
;
controller
->
resetView
();
controller
->
loadMsh
(
paths
[
0
]);
}
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