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
b9e72246
Commit
b9e72246
authored
Nov 21, 2015
by
Kai Westerkamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
scene Graph update
active Objects
parent
640cd99a
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
120 additions
and
17 deletions
+120
-17
controler.cpp
A2/controler.cpp
+1
-1
glview.cpp
A2/glview.cpp
+6
-0
mainwindow.cpp
A2/mainwindow.cpp
+7
-1
mainwindow.h
A2/mainwindow.h
+1
-0
scene.cpp
A2/scene.cpp
+25
-7
scene.h
A2/scene.h
+12
-4
scenenode.cpp
A2/scenenode.cpp
+12
-0
scenenode.h
A2/scenenode.h
+1
-0
sceneobject.cpp
A2/sceneobject.cpp
+15
-4
sceneobject.h
A2/sceneobject.h
+2
-0
sceneprimitive.cpp
A2/sceneprimitive.cpp
+31
-0
sceneprimitive.h
A2/sceneprimitive.h
+7
-0
No files found.
A2/controler.cpp
View file @
b9e72246
...
...
@@ -104,7 +104,7 @@ void Controler::move(QPointF * newPos){
if
((
viewMode
==
CAMERA
)
^
ctrlPressed
){
activeView
->
getCamera
()
->
move
(
QVector3D
(
dx
,
dy
,
0.0
));
}
else
if
((
viewMode
==
EDIT
)
^
ctrlPressed
){
scene
->
move
(
0
,
activeView
->
getCamera
()
->
rotation
->
rotatedVector
(
QVector3D
(
dx
,
dy
,
0.0
)));
scene
->
move
Active
(
activeView
->
getCamera
()
->
rotation
->
rotatedVector
(
QVector3D
(
dx
,
dy
,
0.0
)));
}
else
{
qDebug
()
<<
"möp"
<<
viewMode
<<
" "
<<
CAMERA
<<
" "
<<
EDIT
;
}
...
...
A2/glview.cpp
View file @
b9e72246
...
...
@@ -60,6 +60,12 @@ void GLView::home(){
void
GLView
::
paintGL
()
{
// QGLFramebufferObjectFormat format;
// format.setSamples();
// format.setAttachment(QGLFramebufferObject::);
glClear
(
GL_COLOR_BUFFER_BIT
|
GL_DEPTH_BUFFER_BIT
);
glViewport
(
0
,
0
,
this
->
width
(),
this
->
height
());
...
...
A2/mainwindow.cpp
View file @
b9e72246
...
...
@@ -16,7 +16,10 @@ MainWindow::MainWindow(QWidget *parent)
//Views
scene
=
new
Scene
();
connect
(
scene
,
SIGNAL
(
activChanged
()),
this
,
SLOT
(
updateStatusBar
()));
scene
->
simpleScene
();
controler
=
new
Controler
(
this
,
scene
);
Camera
*
perspectiveCam
=
new
Camera
(
true
);
...
...
@@ -150,10 +153,13 @@ MainWindow::MainWindow(QWidget *parent)
addToolBar
(
toolBar
);
statusBar
->
showMessage
(
"Hello"
);
setStatusBar
(
statusBar
);
}
void
MainWindow
::
updateStatusBar
()
{
statusBar
->
showMessage
(
scene
->
getActive
()
->
getName
());
}
void
MainWindow
::
showSingle
(){
...
...
A2/mainwindow.h
View file @
b9e72246
...
...
@@ -65,6 +65,7 @@ public:
void
updateGL
();
public
slots
:
void
updateStatusBar
();
void
showAboutBox
();
void
showSingle
();
void
showDual
();
...
...
A2/scene.cpp
View file @
b9e72246
#include "scene.h"
Scene
::
Scene
()
Scene
::
Scene
(
)
{
root
=
new
SceneNode
(
this
);
}
void
Scene
::
simpleScene
()
int
Scene
::
simpleScene
()
{
float
red
[]
=
{
1.0
,
0.0
,
0.0
};
...
...
@@ -35,29 +37,45 @@ void Scene::simpleScene()
torus
->
setMaterial
(
magenta
);
root
->
add
(
torus
);
active
=
cylinder
;
emit
activChanged
();
return
cylinder
->
getID
();
}
SceneObject
*
Scene
::
setActive
(
int
id
){
active
=
root
->
find
(
id
);
emit
activChanged
();
return
active
;
}
SceneObject
*
Scene
::
getActive
(){
return
active
;
}
void
Scene
::
draw
()
{
root
->
draw
();
}
Scene
Object
*
Scene
::
getRoot
()
Scene
Node
*
Scene
::
getRoot
()
{
return
root
;
}
void
Scene
::
move
(
int
id
,
QVector3D
dir
)
void
Scene
::
move
Active
(
QVector3D
dir
)
{
if
(
active
!=
NULL
)
active
->
move
(
dir
);
}
void
Scene
::
rotate
(
int
id
,
QQuaternion
rot
)
void
Scene
::
rotate
Active
(
QQuaternion
rot
)
{
if
(
active
!=
NULL
)
active
->
rotate
(
rot
);
}
A2/scene.h
View file @
b9e72246
...
...
@@ -17,16 +17,24 @@ public:
Scene
();
void
draw
();
void
simpleScene
();
int
simpleScene
();
void
move
(
int
id
,
QVector3D
dir
);
void
rotate
(
int
id
,
QQuaternion
rot
);
void
moveActive
(
QVector3D
dir
);
void
rotateActive
(
QQuaternion
rot
);
SceneObject
*
getActive
();
SceneObject
*
setActive
(
int
id
);
signals
:
void
activChanged
();
private
:
SceneNode
*
root
;
SceneObject
*
active
;
Scene
Object
*
getRoot
();
Scene
Node
*
getRoot
();
};
...
...
A2/scenenode.cpp
View file @
b9e72246
...
...
@@ -13,6 +13,18 @@ void SceneNode::add(SceneObject *child)
childs
.
append
(
child
);
}
SceneObject
*
SceneNode
::
find
(
int
id
)
{
foreach
(
SceneObject
*
obj
,
childs
)
{
SceneObject
*
temp
=
obj
->
find
(
id
);
if
(
temp
!=
NULL
)
return
temp
;
}
return
NULL
;
}
void
SceneNode
::
draw
()
{
...
...
A2/scenenode.h
View file @
b9e72246
...
...
@@ -12,6 +12,7 @@ private:
public
:
SceneNode
(
QObject
*
parent
);
SceneObject
*
find
(
int
id
);
void
draw
();
void
add
(
SceneObject
*
child
);
};
...
...
A2/sceneobject.cpp
View file @
b9e72246
...
...
@@ -4,15 +4,16 @@ SceneObject::SceneObject(QObject *parent)
:
QObject
(
parent
)
{
id
=
3
;
name
=
QString
(
"Scene Object "
+
id
);
rotation
=
QQuaternion
();
translation
=
QVector3D
();
}
int
SceneObject
::
getID
()
{
return
id
;
}
int
SceneObject
::
getID
()
{
return
id
;}
QString
SceneObject
::
getName
(){
return
name
;}
void
SceneObject
::
move
(
QVector3D
dir
)
{
...
...
@@ -25,6 +26,16 @@ void SceneObject::rotate(QQuaternion rot)
void
SceneObject
::
draw
(){
qDebug
()
<<
"Drawing abstract Scene Element"
;}
SceneObject
*
SceneObject
::
find
(
int
id
)
{
if
(
this
->
id
==
id
){
return
this
;
}
else
{
return
NULL
;
}
}
void
SceneObject
::
applyTransformation
()
{
...
...
A2/sceneobject.h
View file @
b9e72246
...
...
@@ -21,7 +21,9 @@ public:
SceneObject
(
QObject
*
parent
=
0
);
virtual
void
draw
();
virtual
SceneObject
*
find
(
int
id
);
int
getID
();
QString
getName
();
void
move
(
QVector3D
dir
);
void
rotate
(
QQuaternion
rot
);
...
...
A2/sceneprimitive.cpp
View file @
b9e72246
#include "sceneprimitive.h"
#include "algorithm"
int
ScenePrimitive
::
quaderCount
=
1
;
int
ScenePrimitive
::
sphereCount
=
1
;
int
ScenePrimitive
::
cylinderCount
=
1
;
int
ScenePrimitive
::
torusCount
=
1
;
ScenePrimitive
::
ScenePrimitive
(
PrimitiveType
type
,
int
tesselation
,
QObject
*
parent
)
:
SceneObject
(
parent
)
{
...
...
@@ -14,6 +21,30 @@ ScenePrimitive::ScenePrimitive(PrimitiveType type, int tesselation, QObject *par
this
->
color
[
0
]
=
0.0
;
this
->
color
[
1
]
=
0.0
;
this
->
color
[
2
]
=
0.0
;
switch
(
this
->
type
)
{
case
Quader
:
name
=
QString
(
"Quader %1"
).
arg
(
ScenePrimitive
::
quaderCount
);
ScenePrimitive
::
quaderCount
++
;
break
;
case
Sphere
:
name
=
QString
(
"Sphere %1"
).
arg
(
ScenePrimitive
::
sphereCount
);
ScenePrimitive
::
sphereCount
++
;
break
;
case
Cylinder
:
name
=
QString
(
"Cylinder %1"
).
arg
(
ScenePrimitive
::
cylinderCount
);
qDebug
()
<<
ScenePrimitive
::
cylinderCount
;
ScenePrimitive
::
cylinderCount
++
;
break
;
case
Torus
:
name
=
QString
(
"Torus %1"
).
arg
(
ScenePrimitive
::
torusCount
);
ScenePrimitive
::
torusCount
++
;
break
;
default
:
qDebug
()
<<
"Enum Error"
;
break
;
}
}
void
ScenePrimitive
::
draw
(){
...
...
A2/sceneprimitive.h
View file @
b9e72246
...
...
@@ -9,6 +9,11 @@ class ScenePrimitive : public SceneObject
{
Q_OBJECT
private
:
static
int
quaderCount
;
static
int
sphereCount
;
static
int
cylinderCount
;
static
int
torusCount
;
PrimitiveType
type
;
int
tesselation
;
GLUquadric
*
qobj
;
...
...
@@ -17,6 +22,8 @@ private:
void
drawCube
(
int
tesselation
);
public
:
void
draw
();
void
setMaterial
(
float
*
color
);
...
...
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