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
5aeebcb0
Commit
5aeebcb0
authored
Nov 15, 2015
by
Alisa Jung
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added cube manipulation
parent
7c902f1c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
11 deletions
+11
-11
myglwidget.cpp
helloqube/myglwidget.cpp
+10
-10
myglwidget.h
helloqube/myglwidget.h
+1
-1
No files found.
helloqube/myglwidget.cpp
View file @
5aeebcb0
...
...
@@ -12,8 +12,7 @@ MyGLWidget::MyGLWidget(int index, Controller* c, bool isPerspective, QQuaternion
qubeRotation
=
QQuaternion
();
cameraRotation
=
initialRotation
;
cameraStartRotation
=
initialRotation
;
translatex
=
0
;
translatey
=
0
;
cubeTranslation
=
QVector3D
(
0
,
0
,
0
);
camRotCenter
=
QVector3D
(
0
,
0
,
0
);
cameraZoom
=
cameraZoomDefault
;
clickStartPosition
=
QPoint
(
0
,
0
);
...
...
@@ -142,7 +141,7 @@ void MyGLWidget::paintGL(){
m
.
rotate
(
qubeRotation
);
//for cube translation
QMatrix4x4
translateRot1
=
QMatrix4x4
(
1
,
0
,
0
,
translatex
,
0
,
1
,
0
,
translatey
,
0
,
0
,
1
,
0
,
0
,
0
,
0
,
1
);
QMatrix4x4
translateRot1
=
QMatrix4x4
(
1
,
0
,
0
,
cubeTranslation
.
x
(),
0
,
1
,
0
,
cubeTranslation
.
y
(),
0
,
0
,
1
,
cubeTranslation
.
z
()
,
0
,
0
,
0
,
1
);
QMatrix4x4
zoomCameraMatrix
=
QMatrix4x4
(
1
,
0
,
0
,
0
,
0
,
1
,
0
,
0
,
0
,
0
,
1
,
cameraZoom
,
0
,
0
,
0
,
1
);
...
...
@@ -153,9 +152,6 @@ void MyGLWidget::paintGL(){
// glTranslatef(cameraX,cameraY,0);//TODO anständig machen, kamerarotation fehlt noch.
//stack matrices
// glMultMatrixf(translateRot1.data());//Punkte zurück schieben damit rotation um qube zentrum ist
// glMultMatrixf(m.data());
//So scheint das zumindest für die Kamera zu funktionieren:
...
...
@@ -167,6 +163,12 @@ void MyGLWidget::paintGL(){
glTranslatef
(
camRotCenter
.
x
(),
camRotCenter
.
y
(),
camRotCenter
.
z
());
//stack matrices
glMultMatrixf
(
translateRot1
.
data
());
//Punkte zurück schieben damit rotation um qube zentrum ist
glMultMatrixf
(
m
.
data
());
//tesselation
double
qubeWidth
=
1.0
;
double
dist
=
qubeWidth
/
(
double
)
tesselation
;
...
...
@@ -319,8 +321,7 @@ void MyGLWidget::translateCamera(double xDiff, double yDiff, double zDiff)
}
void
MyGLWidget
::
translateQube
(
double
xDiff
,
double
yDiff
){
translatex
+=
xDiff
;
translatey
+=
yDiff
;
cubeTranslation
+=
cameraRotation
.
conjugate
().
rotatedVector
(
QVector3D
(
xDiff
,
yDiff
,
0
));
updateGL
();
}
...
...
@@ -399,8 +400,7 @@ void MyGLWidget::setTessellation(int t){
void
MyGLWidget
::
resetCamera
(){
qubeRotation
=
QQuaternion
();
translatex
=
0
;
translatey
=
0
;
cubeTranslation
=
QVector3D
(
0
,
0
,
0
);
camRotCenter
=
QVector3D
(
0
,
0
,
0
);
cameraZoom
=
cameraZoomDefault
;
cameraRotation
=
cameraStartRotation
;
...
...
helloqube/myglwidget.h
View file @
5aeebcb0
...
...
@@ -70,7 +70,7 @@ private:
//translate camera
QPoint
clickStartPosition
;
bool
rightButtonPressed
;
double
translatex
,
translatey
;
QVector3D
cubeTranslation
;
//rotate cube
bool
leftButtonPressed
;
...
...
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