Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
GraPa
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kai Westerkamp
GraPa
Commits
229da88d
Commit
229da88d
authored
Oct 26, 2015
by
Kai Westerkamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
for Desktop
parent
450e6140
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
12 deletions
+40
-12
cubewidget.cpp
A1/hellocube/cubewidget.cpp
+33
-12
cubewidget.h
A1/hellocube/cubewidget.h
+6
-0
mainwindow.cpp
A1/hellocube/mainwindow.cpp
+1
-0
No files found.
A1/hellocube/cubewidget.cpp
View file @
229da88d
...
...
@@ -23,6 +23,7 @@ void CubeWidget::initializeGL ()
tesselation
=
0
;
// enable default shading
home
();
showFlat
();
glEnable
(
GL_LIGHTING
);
...
...
@@ -42,9 +43,11 @@ void CubeWidget::paintGL ( )
{
glClear
(
GL_COLOR_BUFFER_BIT
|
GL_DEPTH_BUFFER_BIT
);
glLoadIdentity
();
glTranslatef
(
0.0
f
,
0.0
f
,
-
3.0
f
);
glRotated
(
45
,
1
,
0
,
0
);
glRotated
(
45
,
0
,
1
,
0
);
glTranslatef
(
0.0
f
,
0.0
f
,
-
zoom
);
QMatrix4x4
mat
=
QMatrix4x4
();
mat
.
rotate
(
*
rotation
);
glMultMatrixf
(
mat
.
data
());
GLfloat
red
[]
=
{
1.0
,
0.0
,
0.0
};
...
...
@@ -67,12 +70,7 @@ void CubeWidget::paintGL ( )
}
}
setMaterial
(
magenta
);
glVertex3f
(
0.5
f
,
-
0.5
f
,
0.5
f
);
glVertex3f
(
-
0.5
f
,
-
0.5
f
,
0.5
f
);
glVertex3f
(
-
0.5
f
,
-
0.5
f
,
-
0.5
f
);
glVertex3f
(
0.5
f
,
-
0.5
f
,
-
0.5
f
);
for
(
float
x
=
-
0.5
;
x
<
0.5
;
x
+=
increment
)
{
for
(
float
y
=
-
0.5
;
y
<
0.5
;
y
+=
increment
)
{
glVertex3f
(
x
+
increment
,
-
0.5
f
,
y
+
increment
);
...
...
@@ -132,7 +130,7 @@ void CubeWidget::resizeGL(int width , int height )
glViewport
(
0
,
0
,
width
,
height
);
glLoadIdentity
();
perspective
(
45.0
,
1.0
*
width
/
height
,
0.01
,
5
.0
);
perspective
(
45.0
,
1.0
*
width
/
height
,
0.01
,
100
.0
);
glMatrixMode
(
GL_MODELVIEW
);
}
...
...
@@ -193,6 +191,29 @@ void CubeWidget::setTessellation(int t)
qDebug
()
<<
"Tesselation"
<<
t
;
}
void
CubeWidget
::
mousePressEvent
(
QMouseEvent
*
event
)
{}
void
CubeWidget
::
mouseMoveEvent
(
QMouseEvent
*
event
)
{}
void
CubeWidget
::
wheelEvent
(
QWheelEvent
*
event
)
{}
void
CubeWidget
::
home
()
{
zoom
=
3
;
rotation
=
new
QQuaternion
();
updateGL
();
}
void
CubeWidget
::
mousePressEvent
(
QMouseEvent
*
event
)
{
}
void
CubeWidget
::
mouseMoveEvent
(
QMouseEvent
*
event
)
{
//http://web.cse.ohio-state.edu/~hwshen/781/Site/Slides_files/trackball.pdf
}
void
CubeWidget
::
wheelEvent
(
QWheelEvent
*
event
)
{
if
(
event
->
delta
()
<
0
)
zoom
++
;
else
zoom
--
;
updateGL
();
}
A1/hellocube/cubewidget.h
View file @
229da88d
...
...
@@ -6,6 +6,8 @@
#include <QGLFunctions>
#include <QOpenGLFunctions>
#include <math.h>
#include <QMatrix4x4>
#include <QQuaternion>
...
...
@@ -31,11 +33,15 @@ public slots:
void
showFlat
();
void
showGouraut
();
void
showPhong
();
void
home
();
void
setTessellation
(
int
t
);
private
:
int
tesselation
;
int
zoom
;
QQuaternion
*
rotation
;
QPoint
*
lastPos
;
void
perspective
(
GLdouble
fovy
,
GLdouble
aspect
,
GLdouble
zNear
,
GLdouble
zFar
);
void
setMaterial
(
GLfloat
*
color
);
};
...
...
A1/hellocube/mainwindow.cpp
View file @
229da88d
...
...
@@ -60,6 +60,7 @@ MainWindow::MainWindow(QWidget *parent)
connect
(
aboutAction
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
showAboutBox
()));
camHome
=
new
QAction
(
QIcon
(
":/img/cam_home.png"
),
"Cam Home"
,
toolBar
);
connect
(
camHome
,
SIGNAL
(
triggered
(
bool
)),
mainWidget
,
SLOT
(
home
()));
slider
=
new
QSlider
(
Qt
::
Horizontal
,
toolBar
);
slider
->
setMinimum
(
0
);
...
...
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