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
53b97ddc
Commit
53b97ddc
authored
Dec 04, 2015
by
Kai Westerkamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Opengl functions
File read draw bounds
parent
1e6720cf
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
295 additions
and
117 deletions
+295
-117
camera.cpp
A3/camera.cpp
+2
-1
controler.cpp
A3/controler.cpp
+84
-0
controler.h
A3/controler.h
+3
-0
glview.cpp
A3/glview.cpp
+43
-20
glview.h
A3/glview.h
+5
-0
mainwindow.cpp
A3/mainwindow.cpp
+0
-0
mainwindow.h
A3/mainwindow.h
+13
-0
scene.cpp
A3/scene.cpp
+9
-92
scene.h
A3/scene.h
+3
-2
scenevolume.cpp
A3/scenevolume.cpp
+126
-1
scenevolume.h
A3/scenevolume.h
+7
-1
No files found.
A3/camera.cpp
View file @
53b97ddc
...
@@ -15,7 +15,8 @@ void Camera::home()
...
@@ -15,7 +15,8 @@ void Camera::home()
void
Camera
::
setHome
(
QQuaternion
*
rotation
,
QVector3D
*
translation
)
void
Camera
::
setHome
(
QQuaternion
*
rotation
,
QVector3D
*
translation
)
{
{
//qDebug()<<*rotation<<" trans:"<<*translation;
//qDebug()<<"Cam Home"<<*rotation<<" trans:"<<*translation;
this
->
homeRotation
=
rotation
;
this
->
homeRotation
=
rotation
;
this
->
homeTranslation
=
translation
;
this
->
homeTranslation
=
translation
;
home
();
home
();
...
...
A3/controler.cpp
View file @
53b97ddc
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
#include "glview.h"
#include "glview.h"
#include "scene.h"
#include "scene.h"
#include "mainwindow.h"
#include "mainwindow.h"
#include <iostream>
Controler
::
Controler
(
MainWindow
*
mainwindow
,
Scene
*
scene
)
Controler
::
Controler
(
MainWindow
*
mainwindow
,
Scene
*
scene
)
{
{
...
@@ -128,3 +129,86 @@ void Controler::setCamMode(){
...
@@ -128,3 +129,86 @@ void Controler::setCamMode(){
void
Controler
::
setEditMode
(){
void
Controler
::
setEditMode
(){
viewMode
=
EDIT
;
viewMode
=
EDIT
;
}
}
void
Controler
::
addVolume
()
{
QString
fn
=
QFileDialog
::
getOpenFileName
(
NULL
,
tr
(
"Open Volume..."
),
QString
(
"D:
\\
Projekte
\\
GraPa
\\
A3"
),
tr
(
"Volume Files (*.raw )"
));
if
(
fn
.
isEmpty
())
return
;
qDebug
()
<<
"Opening File:"
<<
fn
;
addVolume
(
fn
);
}
void
Controler
::
addVolume
(
QString
filePath
){
QFile
file
(
filePath
);
if
(
!
file
.
open
(
QIODevice
::
ReadOnly
))
{
QMessageBox
::
information
(
0
,
"error"
,
file
.
errorString
());
}
QByteArray
line1
=
file
.
readLine
();
QTextStream
l1
(
line1
);
QStringList
line1Text
=
l1
.
readLine
().
split
(
" "
);
int
x
=
line1Text
[
0
].
toInt
();
int
y
=
line1Text
[
1
].
toInt
();
int
z
=
line1Text
[
2
].
toInt
();
qDebug
()
<<
line1Text
<<
x
<<
y
<<
z
;
QByteArray
line2
=
file
.
readLine
();
QTextStream
l2
(
line2
);
QStringList
line1Text2
=
l2
.
readLine
().
split
(
" "
);
double
dx
=
line1Text2
[
0
].
toDouble
();
double
dy
=
line1Text2
[
1
].
toDouble
();
double
dz
=
line1Text2
[
2
].
toDouble
();
qDebug
()
<<
line1Text2
<<
dx
<<
dy
<<
dz
;
QByteArray
rawdata
=
file
.
readAll
();
//qDebug()<<rawdata;
char
***
data
=
new
char
**
[
z
];
int
count
=
0
;
// std::cout<<std::hex;
for
(
int
k
=
0
;
k
<
z
;
k
++
)
{
data
[
k
]
=
new
char
*
[
y
];
for
(
int
j
=
0
;
j
<
y
;
j
++
)
{
data
[
k
][
j
]
=
new
char
[
x
];
for
(
int
i
=
0
;
i
<
x
;
i
++
)
{
data
[
k
][
j
][
i
]
=
rawdata
.
at
(
count
++
);
if
(
k
==
150
){
int
temp
=
((
uchar
)
data
[
k
][
j
][
i
])
*
9
/
256
;
std
::
cout
<<
temp
;
// std::cout<<((uint)data[k][j][i]);
}
}
if
(
k
==
150
){
//std::cout<<std::endl;
}
}
}
//qDebug()<<file.readData(data,file.size()-file.pos());
for
(
int
i
=
0
;
i
<
4
;
i
++
)
mainwindow
->
getViews
()[
i
]
->
loadData
(
x
,
y
,
z
,
rawdata
.
data
());
SceneVolume
*
volume
=
new
SceneVolume
(
x
,
y
,
z
,
dx
,
dy
,
dz
);
scene
->
addSceneObjectTaActive
(
volume
);
file
.
close
();
qDebug
()
<<
"File Read finish"
;
}
A3/controler.h
View file @
53b97ddc
...
@@ -25,6 +25,9 @@ public slots:
...
@@ -25,6 +25,9 @@ public slots:
void
setCamMode
();
void
setCamMode
();
void
setEditMode
();
void
setEditMode
();
void
addVolume
();
void
addVolume
(
QString
filePath
);
private
:
private
:
MainWindow
*
mainwindow
;
MainWindow
*
mainwindow
;
Scene
*
scene
;
Scene
*
scene
;
...
...
A3/glview.cpp
View file @
53b97ddc
...
@@ -24,6 +24,8 @@ QSize GLView::sizeHint() const
...
@@ -24,6 +24,8 @@ QSize GLView::sizeHint() const
void
GLView
::
initializeGL
(
)
{
void
GLView
::
initializeGL
(
)
{
Q_ASSERT
(
initializeOpenGLFunctions
());
glClearColor
(
0.0
,
0.0
,
0.0
,
0.0
);
glClearColor
(
0.0
,
0.0
,
0.0
,
0.0
);
glEnable
(
GL_DEPTH_TEST
);
glEnable
(
GL_DEPTH_TEST
);
...
@@ -85,14 +87,14 @@ void GLView::paintGL ()
...
@@ -85,14 +87,14 @@ void GLView::paintGL ()
{
{
bool
useFBO
=
true
;
bool
useFBO
=
true
;
//QOpenGLFunctions functions = QOpenGLContext::currentContext()->functions();
//QOpenGLFunctions functions = QOpenGLContext::currentContext()->functions();
QGLFunctions
functions
=
QGLFunctions
(
this
->
context
());
//
QGLFunctions functions = QGLFunctions(this->context());
// QOpenGLFunctions_4_3_Core functions = *this;
shader
->
bind
();
shader
->
bind
();
if
(
useFBO
){
if
(
useFBO
){
functions
.
glBindFramebuffer
(
GL_FRAMEBUFFER
,
fbo
);
glBindFramebuffer
(
GL_FRAMEBUFFER
,
fbo
);
GLenum
buffers
[]
=
{
GL_COLOR_ATTACHMENT0
,
GL_COLOR_ATTACHMENT1
};
GLenum
buffers
[]
=
{
GL_COLOR_ATTACHMENT0
,
GL_COLOR_ATTACHMENT1
};
// functions.
glDrawBuffers(2,buffers);
glDrawBuffers
(
2
,
buffers
);
//http://stackoverflow.com/questions/7207422/setting-up-opengl-multiple-render-targets
//http://stackoverflow.com/questions/7207422/setting-up-opengl-multiple-render-targets
}
}
...
@@ -110,7 +112,6 @@ void GLView::paintGL ()
...
@@ -110,7 +112,6 @@ void GLView::paintGL ()
shader
->
setUniformValue
(
"shaded"
,
true
);
shader
->
setUniformValue
(
"shaded"
,
true
);
//qDebug()<<"IsLinked"<<shader->isLinked();
//set Projection and Camera Rotation
//set Projection and Camera Rotation
camera
->
setupCamera
(
aspect
);
camera
->
setupCamera
(
aspect
);
...
@@ -153,7 +154,7 @@ void GLView::paintGL ()
...
@@ -153,7 +154,7 @@ void GLView::paintGL ()
displayShader
->
bind
();
displayShader
->
bind
();
//
//
functions
.
glBindFramebuffer
(
GL_FRAMEBUFFER
,
0
);
glBindFramebuffer
(
GL_FRAMEBUFFER
,
0
);
glClear
(
GL_COLOR_BUFFER_BIT
|
GL_DEPTH_BUFFER_BIT
);
glClear
(
GL_COLOR_BUFFER_BIT
|
GL_DEPTH_BUFFER_BIT
);
glViewport
(
0
,
0
,
this
->
width
(),
this
->
height
());
glViewport
(
0
,
0
,
this
->
width
(),
this
->
height
());
...
@@ -162,11 +163,11 @@ void GLView::paintGL ()
...
@@ -162,11 +163,11 @@ void GLView::paintGL ()
glMatrixMode
(
GL_PROJECTION
);
glMatrixMode
(
GL_PROJECTION
);
glLoadIdentity
();
glLoadIdentity
();
functions
.
glActiveTexture
(
GL_TEXTURE0
);
glActiveTexture
(
GL_TEXTURE0
);
glBindTexture
(
GL_TEXTURE_2D
,
color
);
glBindTexture
(
GL_TEXTURE_2D
,
color
);
displayShader
->
setUniformValue
(
"Texture"
,
0
);
displayShader
->
setUniformValue
(
"Texture"
,
0
);
functions
.
glActiveTexture
(
GL_TEXTURE1
);
glActiveTexture
(
GL_TEXTURE1
);
glBindTexture
(
GL_TEXTURE_2D
,
picID
);
glBindTexture
(
GL_TEXTURE_2D
,
picID
);
displayShader
->
setUniformValue
(
"TextureID"
,
1
);
displayShader
->
setUniformValue
(
"TextureID"
,
1
);
...
@@ -293,10 +294,11 @@ void GLView::resizeGL(int width , int height )
...
@@ -293,10 +294,11 @@ void GLView::resizeGL(int width , int height )
{
{
aspect
=
1.0
*
width
/
height
;
aspect
=
1.0
*
width
/
height
;
QGLFunctions
functions
=
QGLFunctions
(
this
->
context
());
//QGLFunctions functions = QGLFunctions(this->context());
//QOpenGLFunctions_4_3_Core functions = *this;
functions
.
glGenFramebuffers
(
1
,
&
fbo
);
glGenFramebuffers
(
1
,
&
fbo
);
functions
.
glBindFramebuffer
(
GL_FRAMEBUFFER
,
fbo
);
glBindFramebuffer
(
GL_FRAMEBUFFER
,
fbo
);
...
@@ -321,26 +323,47 @@ void GLView::resizeGL(int width , int height )
...
@@ -321,26 +323,47 @@ void GLView::resizeGL(int width , int height )
// Create the depth buffer
// Create the depth buffer
functions
.
glGenRenderbuffers
(
1
,
&
depth
);
glGenRenderbuffers
(
1
,
&
depth
);
functions
.
glBindRenderbuffer
(
GL_RENDERBUFFER
,
depth
);
glBindRenderbuffer
(
GL_RENDERBUFFER
,
depth
);
functions
.
glRenderbufferStorage
(
GL_RENDERBUFFER
,
GL_DEPTH_COMPONENT
,
width
,
height
);
glRenderbufferStorage
(
GL_RENDERBUFFER
,
GL_DEPTH_COMPONENT
,
width
,
height
);
functions
.
glFramebufferTexture2D
(
GL_FRAMEBUFFER
,
GL_COLOR_ATTACHMENT0
,
GL_TEXTURE_2D
,
color
,
0
);
glFramebufferTexture2D
(
GL_FRAMEBUFFER
,
GL_COLOR_ATTACHMENT0
,
GL_TEXTURE_2D
,
color
,
0
);
functions
.
glFramebufferTexture2D
(
GL_FRAMEBUFFER
,
GL_COLOR_ATTACHMENT1
,
GL_TEXTURE_2D
,
picID
,
0
);
glFramebufferTexture2D
(
GL_FRAMEBUFFER
,
GL_COLOR_ATTACHMENT1
,
GL_TEXTURE_2D
,
picID
,
0
);
functions
.
glFramebufferRenderbuffer
(
GL_FRAMEBUFFER
,
GL_DEPTH_ATTACHMENT
,
GL_RENDERBUFFER
,
depth
);
glFramebufferRenderbuffer
(
GL_FRAMEBUFFER
,
GL_DEPTH_ATTACHMENT
,
GL_RENDERBUFFER
,
depth
);
GLenum
err
=
functions
.
glCheckFramebufferStatus
(
GL_FRAMEBUFFER
);
GLenum
err
=
glCheckFramebufferStatus
(
GL_FRAMEBUFFER
);
if
(
err
==
GL_FRAMEBUFFER_COMPLETE
){
if
(
err
==
GL_FRAMEBUFFER_COMPLETE
){
qDebug
()
<<
"FBO OK"
;
//
qDebug()<<"FBO OK";
}
else
{
}
else
{
qDebug
()
<<
"FBO ERROR"
<<
err
;
qDebug
()
<<
"FBO ERROR"
<<
err
;
}
}
functions
.
glBindFramebuffer
(
GL_FRAMEBUFFER
,
0
);
glBindFramebuffer
(
GL_FRAMEBUFFER
,
0
);
}
}
void
GLView
::
loadData
(
int
width
,
int
height
,
int
depth
,
char
*
data
)
{
glEnable
(
GL_TEXTURE_3D
);
glGenTextures
(
1
,
&
texture3D
);
glBindTexture
(
GL_TEXTURE_3D
,
texture3D
);
// Filtering
glTexParameteri
(
GL_TEXTURE_3D
,
GL_TEXTURE_MIN_FILTER
,
GL_LINEAR
);
glTexParameteri
(
GL_TEXTURE_3D
,
GL_TEXTURE_MAG_FILTER
,
GL_LINEAR
);
// Wrap
glTexParameteri
(
GL_TEXTURE_3D
,
GL_TEXTURE_WRAP_S
,
GL_CLAMP
);
glTexParameteri
(
GL_TEXTURE_3D
,
GL_TEXTURE_WRAP_T
,
GL_CLAMP
);
glTexParameteri
(
GL_TEXTURE_3D
,
GL_TEXTURE_WRAP_R
,
GL_CLAMP
);
glTexImage3D
(
GL_TEXTURE_3D
,
0
,
GL_R8
,
//
width
,
height
,
depth
,
0
,
GL_RED
,
GL_UNSIGNED_BYTE
,
data
);
// Imagedata as ByteBuffer
}
void
GLView
::
setAcive
(
bool
active
)
void
GLView
::
setAcive
(
bool
active
)
...
...
A3/glview.h
View file @
53b97ddc
...
@@ -27,11 +27,13 @@ public slots:
...
@@ -27,11 +27,13 @@ public slots:
void
setGridSize
(
int
size
){
gridSize
=
size
;}
void
setGridSize
(
int
size
){
gridSize
=
size
;}
void
setGridStepSize
(
int
size
){
gridStepSize
=
size
;}
void
setGridStepSize
(
int
size
){
gridStepSize
=
size
;}
void
showGrid
(
bool
bo
){
isGridEnabled
=
bo
;}
void
showGrid
(
bool
bo
){
isGridEnabled
=
bo
;}
void
loadData
(
int
width
,
int
height
,
int
depth
,
char
*
data
);
public
:
public
:
GLView
(
Scene
*
scene
,
Camera
*
camera
,
Controler
*
controler
);
GLView
(
Scene
*
scene
,
Camera
*
camera
,
Controler
*
controler
);
void
setHome
(
QQuaternion
*
rotation
,
QVector3D
*
translation
);
void
setHome
(
QQuaternion
*
rotation
,
QVector3D
*
translation
);
QSize
minimumSizeHint
()
const
;
QSize
minimumSizeHint
()
const
;
QSize
sizeHint
()
const
;
QSize
sizeHint
()
const
;
...
@@ -56,6 +58,9 @@ private:
...
@@ -56,6 +58,9 @@ private:
GLuint
picID
;
GLuint
picID
;
GLuint
depth
;
GLuint
depth
;
GLuint
texture3D
;
void
drawGrid
();
void
drawGrid
();
void
initShader
();
void
initShader
();
...
...
A3/mainwindow.cpp
View file @
53b97ddc
This diff is collapsed.
Click to expand it.
A3/mainwindow.h
View file @
53b97ddc
...
@@ -69,6 +69,7 @@ private:
...
@@ -69,6 +69,7 @@ private:
GLView
*
frontView
;
GLView
*
frontView
;
GLView
*
leftView
;
GLView
*
leftView
;
GLView
*
topView
;
GLView
*
topView
;
GLView
**
views
;
QTreeView
*
sceneView
;
QTreeView
*
sceneView
;
...
@@ -79,11 +80,23 @@ private:
...
@@ -79,11 +80,23 @@ private:
void
initDoc
();
void
initDoc
();
void
initViews
();
public
:
public
:
MainWindow
(
QWidget
*
parent
=
0
);
MainWindow
(
QWidget
*
parent
=
0
);
~
MainWindow
();
~
MainWindow
();
void
setActiveView
(
GLView
*
active
);
void
setActiveView
(
GLView
*
active
);
GLView
**
getViews
();
void
initSplits
();
void
initToolbar
();
void
initGrid
();
void
initPrimitivesMenu
();
public
slots
:
public
slots
:
void
updateGL
();
void
updateGL
();
void
updateStatusBar
();
void
updateStatusBar
();
...
...
A3/scene.cpp
View file @
53b97ddc
#include "scene.h"
#include "scene.h"
#include <iostream>
Scene
::
Scene
(
)
Scene
::
Scene
(
)
...
@@ -17,8 +17,6 @@ Scene::~Scene( )
...
@@ -17,8 +17,6 @@ Scene::~Scene( )
int
Scene
::
simpleScene
()
int
Scene
::
simpleScene
()
{
{
addCube
();
addCube
();
moveActive
(
QVector3D
(
4
,
0
,
0
));
moveActive
(
QVector3D
(
4
,
0
,
0
));
...
@@ -37,8 +35,6 @@ int Scene::simpleScene()
...
@@ -37,8 +35,6 @@ int Scene::simpleScene()
moveActive
(
QVector3D
(
0
,
-
1.5
,
-
1.5
));
moveActive
(
QVector3D
(
0
,
-
1.5
,
-
1.5
));
//addVolume("D:/Projekte/GraPa/A3/MRI-head.raw");
return
active
->
getID
();
return
active
->
getID
();
}
}
...
@@ -65,7 +61,7 @@ void Scene::addSceneObjectTaActive(SceneObject *obj){
...
@@ -65,7 +61,7 @@ void Scene::addSceneObjectTaActive(SceneObject *obj){
activeIndex
=
index
(
parent
->
childCount
()
-
1
,
0
,
parentIndex
);
activeIndex
=
index
(
parent
->
childCount
()
-
1
,
0
,
parentIndex
);
active
=
obj
;
active
=
obj
;
qDebug
()
<<
"Adding"
<<
obj
->
getName
()
<<
" to "
<<
getItem
(
parentIndex
)
->
getName
()
<<
" Active"
<<
getItem
(
activeIndex
)
->
getName
();
//
qDebug()<<"Adding"<<obj->getName()<<" to "<<getItem(parentIndex)->getName()<<" Active"<<getItem(activeIndex)->getName();
emit
activChanged
();
emit
activChanged
();
}
}
...
@@ -114,7 +110,6 @@ void Scene::addNode()
...
@@ -114,7 +110,6 @@ void Scene::addNode()
{
{
SceneNode
*
node
=
new
SceneNode
();
SceneNode
*
node
=
new
SceneNode
();
node
->
setName
(
"Graph Node"
);
node
->
setName
(
"Graph Node"
);
addSceneObjectTaActive
(
node
);
addSceneObjectTaActive
(
node
);
}
}
...
@@ -125,9 +120,9 @@ void Scene::deletActive()
...
@@ -125,9 +120,9 @@ void Scene::deletActive()
SceneNode
*
parent
=
static_cast
<
SceneNode
*>
(
active
->
getParent
());
SceneNode
*
parent
=
static_cast
<
SceneNode
*>
(
active
->
getParent
());
int
pos
=
active
->
childNumber
();
int
pos
=
active
->
childNumber
();
qDebug
()
<<
"Delet Active in Scene"
<<
parentIndex
<<
parent
->
childCount
()
<<
pos
;
//
qDebug()<<"Delet Active in Scene"<<parentIndex<<parent->childCount()<<pos;
foreach
(
SceneObject
*
t
,
parent
->
getChildren
())
{
foreach
(
SceneObject
*
t
,
parent
->
getChildren
())
{
qDebug
()
<<
t
->
getName
()
<<
t
->
childNumber
();
//
qDebug()<<t->getName()<<t->childNumber();
}
}
beginRemoveRows
(
parentIndex
,
pos
,
pos
);
beginRemoveRows
(
parentIndex
,
pos
,
pos
);
...
@@ -135,93 +130,12 @@ void Scene::deletActive()
...
@@ -135,93 +130,12 @@ void Scene::deletActive()
endRemoveRows
();
endRemoveRows
();
active
=
parent
;
active
=
parent
;
activeIndex
=
parentIndex
;
activeIndex
=
parentIndex
;
qDebug
()
<<
"Delet Active in Scene"
<<
active
<<
activeIndex
<<
active
->
getName
();
//
qDebug()<<"Delet Active in Scene"<<active<<activeIndex<<active->getName();
emit
activChanged
();
emit
activChanged
();
}
}
void
Scene
::
addVolume
()
{
QString
fn
=
QFileDialog
::
getOpenFileName
(
NULL
,
tr
(
"Open Volume..."
),
QString
(
"D:
\\
Projekte
\\
GraPa
\\
A3"
),
tr
(
"Volume Files (*.raw )"
));
if
(
fn
.
isEmpty
())
return
;
qDebug
()
<<
"Opening File:"
<<
fn
;
addVolume
(
fn
);
}
void
Scene
::
addVolume
(
QString
filePath
){
QFile
file
(
filePath
);
if
(
!
file
.
open
(
QIODevice
::
ReadOnly
))
{
QMessageBox
::
information
(
0
,
"error"
,
file
.
errorString
());
}
QByteArray
line1
=
file
.
readLine
();
QTextStream
l1
(
line1
);
QStringList
line1Text
=
l1
.
readLine
().
split
(
" "
);
int
x
=
line1Text
[
0
].
toInt
();
int
y
=
line1Text
[
1
].
toInt
();
int
z
=
line1Text
[
2
].
toInt
();
qDebug
()
<<
line1Text
<<
x
<<
y
<<
z
;
QByteArray
line2
=
file
.
readLine
();
QTextStream
l2
(
line2
);
QStringList
line1Text2
=
l2
.
readLine
().
split
(
" "
);
double
dx
=
line1Text2
[
0
].
toDouble
();
double
dy
=
line1Text2
[
1
].
toDouble
();
double
dz
=
line1Text2
[
2
].
toDouble
();
qDebug
()
<<
line1Text2
<<
dx
<<
dy
<<
dz
;
QByteArray
rawdata
=
file
.
readAll
();
//qDebug()<<rawdata;
char
***
data
=
new
char
**
[
z
];
int
count
=
0
;
// std::cout<<std::hex;
for
(
int
k
=
0
;
k
<
z
;
k
++
)
{
data
[
k
]
=
new
char
*
[
y
];
for
(
int
j
=
0
;
j
<
y
;
j
++
)
{
if
(
k
==
150
){
std
::
cout
<<
std
::
endl
;
}
data
[
k
][
j
]
=
new
char
[
x
];
for
(
int
i
=
0
;
i
<
x
;
i
++
)
{
data
[
k
][
j
][
i
]
=
rawdata
.
at
(
count
++
);
if
(
k
==
150
){
int
temp
=
((
uchar
)
data
[
k
][
j
][
i
])
*
9
/
256
;
std
::
cout
<<
temp
;
// std::cout<<((uint)data[k][j][i]);
}
}
}
}
//qDebug()<<file.readData(data,file.size()-file.pos());
file
.
close
();
qDebug
()
<<
"File Read finish"
;
}
void
Scene
::
setTesselation
(
int
tesselation
)
void
Scene
::
setTesselation
(
int
tesselation
)
{
{
this
->
tesselation
=
tesselation
;
this
->
tesselation
=
tesselation
;
...
@@ -249,8 +163,11 @@ SceneNode *Scene::getRoot()
...
@@ -249,8 +163,11 @@ SceneNode *Scene::getRoot()
void
Scene
::
moveActive
(
QVector3D
dir
)
void
Scene
::
moveActive
(
QVector3D
dir
)
{
{
if
(
active
!=
NULL
)
if
(
active
!=
NULL
){
active
->
move
(
dir
);
active
->
move
(
dir
);
//qDebug()<<"Move Active"<<active->getName()<<dir;
}
}
}
...
...
A3/scene.h
View file @
53b97ddc
...
@@ -10,6 +10,7 @@
...
@@ -10,6 +10,7 @@
#include <scenenode.h>
#include <scenenode.h>
#include <sceneobject.h>
#include <sceneobject.h>
#include <sceneprimitive.h>
#include <sceneprimitive.h>
#include <scenevolume.h>
class
Scene
:
public
QAbstractItemModel
// QAbstractItemModel
class
Scene
:
public
QAbstractItemModel
// QAbstractItemModel
{
{
...
@@ -55,11 +56,11 @@ public slots:
...
@@ -55,11 +56,11 @@ public slots:
void
addCone
();
void
addCone
();
void
addNode
();
void
addNode
();
void
deletActive
();
void
deletActive
();
void
addVolume
();
void
addVolume
(
QString
filePath
);
signals
:
signals
:
void
activChanged
();
void
activChanged
();
void
changedVolumeData
(
int
width
,
int
height
,
int
depth
,
byte
*
data
);
private
:
private
:
SceneNode
*
root
;
SceneNode
*
root
;
...
...
A3/scenevolume.cpp
View file @
53b97ddc
#include "scenevolume.h"
#include "scenevolume.h"
SceneVolume
::
SceneVolume
()
SceneVolume
::
SceneVolume
(
int
width
,
int
height
,
int
depth
,
double
dx
,
double
dy
,
double
dz
)
{
{
this
->
width
=
width
;
this
->
height
=
height
;
this
->
depth
=
depth
;
this
->
dx
=
dx
;
this
->
dy
=
dy
;
this
->
dz
=
dz
;
lx
=
width
*
dx
;
ly
=
height
*
dy
;
lz
=
depth
*
dz
;
qDebug
()
<<
lx
<<
ly
<<
lz
;
double
max
=
qMax
(
lx
,
qMax
(
ly
,
lz
));
lx
=
lx
/
max
;
ly
=
ly
/
max
;
lz
=
lz
/
max
;
qDebug
()
<<
max
<<
lx
<<
ly
<<
lz
;
this
->
setName
(
"Volume"
);
}
}
void
SceneVolume
::
draw
(
QGLShaderProgram
*
shader
){
glPushMatrix
();
applyTransformation
();
float
color
[]
=
{
0.0
,
1.0
,
1.0
};
glMaterialfv
(
GL_FRONT
,
GL_AMBIENT
,
color
);
GLfloat
white
[]
=
{
1.0
,
1.0
,
1.0
};
glMaterialfv
(
GL_FRONT
,
GL_DIFFUSE
,
color
);
glMaterialfv
(
GL_FRONT
,
GL_SPECULAR
,
white
);
GLfloat
mShininess
[]
=
{
128
};
glMaterialfv
(
GL_FRONT
,
GL_SHININESS
,
mShininess
);
float
x
=
lx
/
2
;
float
y
=
ly
/
2
;
float
z
=
lz
/
2
;
glBegin
(
GL_QUADS
);
glNormal3f
(
0
,
1
,
0
);
glTexCoord3i
(
1
,
1
,
0
);
glVertex3f
(
x
,
y
,
-
z
);
glTexCoord3i
(
0
,
1
,
0
);
glVertex3f
(
-
x
,
y
,
-
z
);
glTexCoord3i
(
0
,
1
,
1
);
glVertex3f
(
-
x
,
y
,
z
);
glTexCoord3i
(
1
,
1
,
1
);
glVertex3f
(
x
,
y
,
z
);
glEnd
();
glBegin
(
GL_QUADS
);
glNormal3f
(
0
,
-
1
,
0
);
glTexCoord3i
(
1
,
0
,
1
);
glVertex3f
(
x
,
-
y
,
z
);
glTexCoord3i
(
0
,
0
,
1
);
glVertex3f
(
-
x
,
-
y
,
z
);
glTexCoord3i
(
0
,
0
,
0
);
glVertex3f
(
-
x
,
-
y
,
-
z
);
glTexCoord3i
(
1
,
0
,
0
);
glVertex3f
(
x
,
-
y
,
-
z
);
glEnd
();
glBegin
(
GL_QUADS
);
glNormal3f
(
0
,
0
,
1
);
glTexCoord3i
(
1
,
1
,
1
);
glVertex3f
(
x
,
y
,
z
);
glTexCoord3i
(
0
,
1
,
1
);
glVertex3f
(
-
x
,
y
,
z
);
glTexCoord3i
(
0
,
0
,
1
);
glVertex3f
(
-
x
,
-
y
,
z
);
glTexCoord3i
(
1
,
0
,
1
);
glVertex3f
(
x
,
-
y
,
z
);
glEnd
();
glBegin
(
GL_QUADS
);
glNormal3f
(
0
,
0
,
-
1
);
glTexCoord3i
(
1
,
0
,
0
);
glVertex3f
(
x
,
-
y
,
-
z
);
glTexCoord3i
(
0
,
0
,
0
);
glVertex3f
(
-
x
,
-
y
,
-
z
);
glTexCoord3i
(
0
,
1
,
0
);
glVertex3f
(
-
x
,
y
,
-
z
);
glTexCoord3i
(
1
,
1
,
0
);
glVertex3f
(
x
,
y
,
-
z
);
glEnd
();
glBegin
(
GL_QUADS
);
glNormal3f
(
-
1
,
0
,
0
);
glTexCoord3i
(
0
,
1
,
1
);
glVertex3f
(
-
x
,
y
,
z
);
glTexCoord3i
(
0
,
1
,
0
);
glVertex3f
(
-
x
,
y
,
-
z
);
glTexCoord3i
(
0
,
0
,
0
);
glVertex3f
(
-
x
,
-
y
,
-
z
);
glTexCoord3i
(
0
,
0
,
1
);
glVertex3f
(
-
x
,
-
y
,
z
);
glEnd
();
glBegin
(
GL_QUADS
);
glNormal3f
(
1
,
0
,
0
);
glTexCoord3i
(
1
,
1
,
0
);
glVertex3f
(
x
,
y
,
-
z
);
glTexCoord3i
(
1
,
1
,
1
);
glVertex3f
(
x
,
y
,
z
);
glTexCoord3i
(
1
,
0
,
1
);
glVertex3f
(
x
,
-
y
,
z
);
glTexCoord3i
(
1
,
0
,
0
);
glVertex3f
(
x
,
-
y
,
-
z
);
glEnd
();
glPopMatrix
();
}
A3/scenevolume.h
View file @
53b97ddc
...
@@ -6,8 +6,14 @@
...
@@ -6,8 +6,14 @@
class
SceneVolume
:
public
SceneObject
class
SceneVolume
:
public
SceneObject
{
{
private
:
double
lx
,
ly
,
lz
;
double
dx
,
dy
,
dz
;
int
width
,
height
,
depth
;
public
:
public
:
SceneVolume
();
SceneVolume
(
int
width
,
int
height
,
int
depth
,
double
dx
,
double
dy
,
double
dz
);
void
draw
(
QGLShaderProgram
*
shader
);
};
};
#endif // SCENEVOLUME_H
#endif // SCENEVOLUME_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