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 ()
...
@@ -23,6 +23,7 @@ void CubeWidget::initializeGL ()
tesselation
=
0
;
tesselation
=
0
;
// enable default shading
// enable default shading
home
();
showFlat
();
showFlat
();
glEnable
(
GL_LIGHTING
);
glEnable
(
GL_LIGHTING
);
...
@@ -42,9 +43,11 @@ void CubeWidget::paintGL ( )
...
@@ -42,9 +43,11 @@ void CubeWidget::paintGL ( )
{
{
glClear
(
GL_COLOR_BUFFER_BIT
|
GL_DEPTH_BUFFER_BIT
);
glClear
(
GL_COLOR_BUFFER_BIT
|
GL_DEPTH_BUFFER_BIT
);
glLoadIdentity
();
glLoadIdentity
();
glTranslatef
(
0.0
f
,
0.0
f
,
-
3.0
f
);
glTranslatef
(
0.0
f
,
0.0
f
,
-
zoom
);
glRotated
(
45
,
1
,
0
,
0
);
QMatrix4x4
mat
=
QMatrix4x4
();
glRotated
(
45
,
0
,
1
,
0
);
mat
.
rotate
(
*
rotation
);
glMultMatrixf
(
mat
.
data
());
GLfloat
red
[]
=
{
1.0
,
0.0
,
0.0
};
GLfloat
red
[]
=
{
1.0
,
0.0
,
0.0
};
...
@@ -67,12 +70,7 @@ void CubeWidget::paintGL ( )
...
@@ -67,12 +70,7 @@ void CubeWidget::paintGL ( )
}
}
}
}
setMaterial
(
magenta
);
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
x
=
-
0.5
;
x
<
0.5
;
x
+=
increment
)
{
for
(
float
y
=
-
0.5
;
y
<
0.5
;
y
+=
increment
)
{
for
(
float
y
=
-
0.5
;
y
<
0.5
;
y
+=
increment
)
{
glVertex3f
(
x
+
increment
,
-
0.5
f
,
y
+
increment
);
glVertex3f
(
x
+
increment
,
-
0.5
f
,
y
+
increment
);
...
@@ -132,7 +130,7 @@ void CubeWidget::resizeGL(int width , int height )
...
@@ -132,7 +130,7 @@ void CubeWidget::resizeGL(int width , int height )
glViewport
(
0
,
0
,
width
,
height
);
glViewport
(
0
,
0
,
width
,
height
);
glLoadIdentity
();
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
);
glMatrixMode
(
GL_MODELVIEW
);
}
}
...
@@ -193,6 +191,29 @@ void CubeWidget::setTessellation(int t)
...
@@ -193,6 +191,29 @@ void CubeWidget::setTessellation(int t)
qDebug
()
<<
"Tesselation"
<<
t
;
qDebug
()
<<
"Tesselation"
<<
t
;
}
}
void
CubeWidget
::
mousePressEvent
(
QMouseEvent
*
event
)
{}
void
CubeWidget
::
home
()
void
CubeWidget
::
mouseMoveEvent
(
QMouseEvent
*
event
)
{}
{
void
CubeWidget
::
wheelEvent
(
QWheelEvent
*
event
)
{}
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 @@
...
@@ -6,6 +6,8 @@
#include <QGLFunctions>
#include <QGLFunctions>
#include <QOpenGLFunctions>
#include <QOpenGLFunctions>
#include <math.h>
#include <math.h>
#include <QMatrix4x4>
#include <QQuaternion>
...
@@ -31,11 +33,15 @@ public slots:
...
@@ -31,11 +33,15 @@ public slots:
void
showFlat
();
void
showFlat
();
void
showGouraut
();
void
showGouraut
();
void
showPhong
();
void
showPhong
();
void
home
();
void
setTessellation
(
int
t
);
void
setTessellation
(
int
t
);
private
:
private
:
int
tesselation
;
int
tesselation
;
int
zoom
;
QQuaternion
*
rotation
;
QPoint
*
lastPos
;
void
perspective
(
GLdouble
fovy
,
GLdouble
aspect
,
GLdouble
zNear
,
GLdouble
zFar
);
void
perspective
(
GLdouble
fovy
,
GLdouble
aspect
,
GLdouble
zNear
,
GLdouble
zFar
);
void
setMaterial
(
GLfloat
*
color
);
void
setMaterial
(
GLfloat
*
color
);
};
};
...
...
A1/hellocube/mainwindow.cpp
View file @
229da88d
...
@@ -60,6 +60,7 @@ MainWindow::MainWindow(QWidget *parent)
...
@@ -60,6 +60,7 @@ MainWindow::MainWindow(QWidget *parent)
connect
(
aboutAction
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
showAboutBox
()));
connect
(
aboutAction
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
showAboutBox
()));
camHome
=
new
QAction
(
QIcon
(
":/img/cam_home.png"
),
"Cam Home"
,
toolBar
);
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
=
new
QSlider
(
Qt
::
Horizontal
,
toolBar
);
slider
->
setMinimum
(
0
);
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