Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
grapa_alisa
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
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Alisa Jung
grapa_alisa
Commits
46873760
Commit
46873760
authored
Nov 23, 2015
by
Alisa Jung
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
grid
parent
fbbc62b6
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
96 additions
and
2 deletions
+96
-2
helloqube.pro.user
helloqube/helloqube.pro.user
+1
-1
mainwindow.cpp
helloqube/mainwindow.cpp
+15
-0
mainwindow.h
helloqube/mainwindow.h
+4
-0
myglwidget.cpp
helloqube/myglwidget.cpp
+70
-1
myglwidget.h
helloqube/myglwidget.h
+6
-0
No files found.
helloqube/helloqube.pro.user
View file @
46873760
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 3.5.1, 2015-11-23T
17:08:38
. -->
<!-- Written by QtCreator 3.5.1, 2015-11-23T
22:09:40
. -->
<qtcreator>
<data>
<variable>
EnvironmentId
</variable>
...
...
helloqube/mainwindow.cpp
View file @
46873760
...
...
@@ -220,6 +220,21 @@ MainWindow::MainWindow(QWidget *parent)
}
gridSizeInput
=
new
QSpinBox
(
toolBar
);
gridSizeInput
->
setRange
(
0
,
100
);
gridSizeInput
->
setValue
(
5
);
toolBar
->
addWidget
(
gridSizeInput
);
gridSizeInput
->
setToolTip
(
"Grid Size"
);
gridStepInput
=
new
QSpinBox
(
toolBar
);
gridStepInput
->
setRange
(
1
,
10
);
toolBar
->
addWidget
(
gridStepInput
);
gridStepInput
->
setToolTip
(
"Grid Step Size"
);
for
(
int
i
=
0
;
i
<
4
;
i
++
){
connect
(
gridSizeInput
,
SIGNAL
(
valueChanged
(
int
)),
allWidgets
[
i
],
SLOT
(
setGridSize
(
int
)));
connect
(
gridStepInput
,
SIGNAL
(
valueChanged
(
int
)),
allWidgets
[
i
],
SLOT
(
setGridStepSize
(
int
)));
}
qDebug
(
"Done initializing"
);
...
...
helloqube/mainwindow.h
View file @
46873760
...
...
@@ -23,6 +23,7 @@
#include <QDockWidget>
#include <QLineEdit>
#include <QInputDialog>
#include <QSpinBox>
class
MainWindow
:
public
QMainWindow
{
Q_OBJECT
...
...
@@ -92,6 +93,9 @@ private:
QLineEdit
*
textInput
;
QSpinBox
*
gridSizeInput
;
QSpinBox
*
gridStepInput
;
public
slots
:
void
showAboutBox
(
)
;
void
showTextEditBox
();
...
...
helloqube/myglwidget.cpp
View file @
46873760
...
...
@@ -21,6 +21,9 @@ MyGLWidget::MyGLWidget(int index, Controller* c, bool isPerspective, QQuaternion
scene
=
controller
->
getSceneGraph
();
scene
->
registerView
(
this
);
gridSize
=
5
;
gridStepSize
=
1
;
}
MyGLWidget
::~
MyGLWidget
()
...
...
@@ -222,6 +225,8 @@ void MyGLWidget::paintGL(){
glTranslatef
(
camRotCenter
.
x
(),
camRotCenter
.
y
(),
camRotCenter
.
z
());
// scene->drawAll();
drawGrid
();
const
QList
<
RigidBodyTransformation
*>
graph
=
scene
->
getGraph
();
QList
<
RigidBodyTransformation
*>::
const_iterator
i
;
for
(
i
=
graph
.
begin
();
i
!=
graph
.
end
();
++
i
){
...
...
@@ -428,7 +433,6 @@ void MyGLWidget::drawBox(int tesselation){
//4.1.1 Unit Qube + Tesselation + Diffuse Material
GLfloat
specularColor
[]
=
{
1
,
1
,
1
};
GLfloat
shininess
[]
=
{
128
};
//specular exponent
glMaterialfv
(
GL_FRONT
,
GL_SPECULAR
,
specularColor
);
...
...
@@ -587,3 +591,68 @@ void MyGLWidget::drawTorus(int tesselation){
glEnd
();
}
void
MyGLWidget
::
drawGrid
(){
GLfloat
specularColor
[]
=
{
0
,
0
,
0
};
GLfloat
shininess
[]
=
{
128
};
glMaterialfv
(
GL_FRONT
,
GL_SPECULAR
,
specularColor
);
glMaterialfv
(
GL_FRONT
,
GL_SHININESS
,
shininess
);
GLfloat
grey
[]
=
{
1
,
0.5
,
0.5
};
glMaterialfv
(
GL_FRONT
,
GL_DIFFUSE
,
grey
);
glNormal3f
(
0
,
1
,
0
);
phongShader
->
release
();
glDisable
(
GL_LIGHTING
);
glEnable
(
GL_COLOR_MATERIAL
);
glLineWidth
(
1
);
glPolygonMode
(
GL_FRONT_AND_BACK
,
GL_LINES
);
glBegin
(
GL_LINES
);
float
stepSize
=
gridStepSize
;
float
x
=
stepSize
;
float
y
=
stepSize
;
if
(
stepSize
<=
0
)
stepSize
=
1
;
for
(;
x
<
gridSize
;
x
+=
stepSize
){
glVertex3f
(
x
,
0
,
-
gridSize
);
glVertex3f
(
x
,
0
,
gridSize
);
glVertex3f
(
-
x
,
0
,
-
gridSize
);
glVertex3f
(
-
x
,
0
,
gridSize
);
}
for
(;
y
<
gridSize
;
y
+=
stepSize
){
glVertex3f
(
-
gridSize
,
0
,
y
);
glVertex3f
(
gridSize
,
0
,
y
);
glVertex3f
(
-
gridSize
,
0
,
-
y
);
glVertex3f
(
gridSize
,
0
,
-
y
);
}
glEnd
();
GLfloat
red
[]
=
{
1
,
0
,
0
};
glMaterialfv
(
GL_FRONT_AND_BACK
,
GL_DIFFUSE
,
red
);
glBegin
(
GL_LINES
);
glVertex3f
(
0
,
0
,
-
gridSize
);
glVertex3f
(
0
,
0
,
gridSize
);
glEnd
();
GLfloat
green
[]
=
{
0
,
1
,
0
};
glMaterialfv
(
GL_FRONT_AND_BACK
,
GL_DIFFUSE
,
green
);
glBegin
(
GL_LINES
);
glVertex3f
(
-
gridSize
,
0
,
0
);
glVertex3f
(
gridSize
,
0
,
0
);
glEnd
();
glPolygonMode
(
GL_FRONT
,
GL_FILL
);
glEnable
(
GL_LIGHTING
);
phongShader
->
bind
();
}
void
MyGLWidget
::
setGridSize
(
int
size
){
gridSize
=
size
;
updateGL
();
}
void
MyGLWidget
::
setGridStepSize
(
int
stepSize
){
gridStepSize
=
stepSize
;
updateGL
();
}
helloqube/myglwidget.h
View file @
46873760
...
...
@@ -102,9 +102,15 @@ private:
void
drawCylinder
(
int
tesselation
);
void
drawCone
(
int
tesselation
);
void
drawTorus
(
int
tesselation
);
void
drawGrid
();
int
gridSize
;
int
gridStepSize
;
public
slots
:
//4.1.1 slots for shading modes
void
resetCamera
();
void
setGridSize
(
int
size
);
void
setGridStepSize
(
int
stepSize
);
};
#endif // GLWIDGET_H
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