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
4685d45b
Commit
4685d45b
authored
Dec 04, 2015
by
Kai Westerkamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
shader start
parent
53b97ddc
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
45 additions
and
30 deletions
+45
-30
controler.cpp
A3/controler.cpp
+5
-4
glview.cpp
A3/glview.cpp
+3
-0
mainwindow.cpp
A3/mainwindow.cpp
+10
-2
mainwindow.h
A3/mainwindow.h
+3
-0
phong.frag
A3/phong.frag
+16
-9
phong.vert
A3/phong.vert
+3
-0
scene.cpp
A3/scene.cpp
+2
-1
scenevolume.cpp
A3/scenevolume.cpp
+3
-14
No files found.
A3/controler.cpp
View file @
4685d45b
...
@@ -176,6 +176,8 @@ void Controler::addVolume(QString filePath){
...
@@ -176,6 +176,8 @@ void Controler::addVolume(QString filePath){
int
count
=
0
;
int
count
=
0
;
// std::cout<<std::hex;
// std::cout<<std::hex;
int
printLine
=
150
;
for
(
int
k
=
0
;
k
<
z
;
k
++
)
for
(
int
k
=
0
;
k
<
z
;
k
++
)
{
{
data
[
k
]
=
new
char
*
[
y
];
data
[
k
]
=
new
char
*
[
y
];
...
@@ -186,14 +188,13 @@ void Controler::addVolume(QString filePath){
...
@@ -186,14 +188,13 @@ void Controler::addVolume(QString filePath){
for
(
int
i
=
0
;
i
<
x
;
i
++
)
for
(
int
i
=
0
;
i
<
x
;
i
++
)
{
{
data
[
k
][
j
][
i
]
=
rawdata
.
at
(
count
++
);
data
[
k
][
j
][
i
]
=
rawdata
.
at
(
count
++
);
if
(
k
==
150
){
if
(
k
==
printLine
){
int
temp
=
((
uchar
)
data
[
k
][
j
][
i
])
*
9
/
256
;
int
temp
=
((
uchar
)
data
[
k
][
j
][
i
])
*
9
/
256
;
std
::
cout
<<
temp
;
std
::
cout
<<
temp
;
// std::cout<<((uint)data[k][j][i]);
}
}
}
}
if
(
k
==
150
){
if
(
k
==
printLine
){
//
std::cout<<std::endl;
std
::
cout
<<
std
::
endl
;
}
}
}
}
}
}
...
...
A3/glview.cpp
View file @
4685d45b
...
@@ -110,6 +110,9 @@ void GLView::paintGL ()
...
@@ -110,6 +110,9 @@ void GLView::paintGL ()
glMatrixMode
(
GL_PROJECTION
);
glMatrixMode
(
GL_PROJECTION
);
glLoadIdentity
();
glLoadIdentity
();
glActiveTexture
(
GL_TEXTURE0
);
glBindTexture
(
GL_TEXTURE_3D
,
texture3D
);
displayShader
->
setUniformValue
(
"volumeData"
,
0
);
shader
->
setUniformValue
(
"shaded"
,
true
);
shader
->
setUniformValue
(
"shaded"
,
true
);
...
...
A3/mainwindow.cpp
View file @
4685d45b
...
@@ -290,9 +290,10 @@ MainWindow::MainWindow(QWidget *parent)
...
@@ -290,9 +290,10 @@ MainWindow::MainWindow(QWidget *parent)
//Assemble Tool Bar
//Assemble Tool Bar
initToolbar
();
initToolbar
();
scene
->
simpleScene
();
timer
=
new
QTimer
(
this
);
//controler->addVolume("D:/Projekte/GraPa/A3/lobster.raw");
connect
(
timer
,
SIGNAL
(
timeout
()),
this
,
SLOT
(
initScene
()));
timer
->
start
(
1000
);
setStatusBar
(
statusBar
);
setStatusBar
(
statusBar
);
initDoc
();
initDoc
();
...
@@ -300,6 +301,13 @@ MainWindow::MainWindow(QWidget *parent)
...
@@ -300,6 +301,13 @@ MainWindow::MainWindow(QWidget *parent)
}
}
void
MainWindow
::
initScene
(){
//scene->simpleScene();
controler
->
addVolume
(
"D:/Projekte/GraPa/A3/lobster.raw"
);
timer
->
stop
();
}
void
MainWindow
::
initDoc
()
void
MainWindow
::
initDoc
()
{
{
...
...
A3/mainwindow.h
View file @
4685d45b
...
@@ -77,6 +77,8 @@ private:
...
@@ -77,6 +77,8 @@ private:
QSpinBox
*
gridStepInput
;
QSpinBox
*
gridStepInput
;
QToolButton
*
showGridButton
;
QToolButton
*
showGridButton
;
QTimer
*
timer
;
void
initDoc
();
void
initDoc
();
...
@@ -104,6 +106,7 @@ public slots:
...
@@ -104,6 +106,7 @@ public slots:
void
showSingle
();
void
showSingle
();
void
showDual
();
void
showDual
();
void
showQuad
();
void
showQuad
();
void
initScene
();
};
};
#endif // MAINWINDOW_H
#endif // MAINWINDOW_H
A3/phong.frag
View file @
4685d45b
uniform
bool
shaded
;
uniform
bool
shaded
;
uniform
bool
volume
;
uniform
sampler3D
volumeData
;
varying
vec4
pick
;
varying
vec4
pick
;
varying
vec3
position
;
varying
vec3
position
;
...
@@ -7,6 +10,16 @@ varying vec3 normal;
...
@@ -7,6 +10,16 @@ varying vec3 normal;
void
main
(
void
)
void
main
(
void
)
{
{
vec3
V
=
normalize
(
-
position
);
if
(
volume
){
// gl_FragData[0] = vec4(gl_TexCoord[0].xyz,1);
gl_FragData
[
0
]
=
vec4
(
texture3D
(
volumeData
,
gl_TexCoord
[
0
].
xyz
).
x
);
}
else
if
(
shaded
){
vec3
N
=
normalize
(
normal
);
vec3
N
=
normalize
(
normal
);
vec3
L
=
normalize
(
gl_LightSource
[
0
].
position
.
xyz
-
position
);
vec3
L
=
normalize
(
gl_LightSource
[
0
].
position
.
xyz
-
position
);
...
@@ -16,8 +29,6 @@ void main(void)
...
@@ -16,8 +29,6 @@ void main(void)
vec4
Idiff
=
gl_FrontLightProduct
[
0
].
diffuse
*
diffuse
;
vec4
Idiff
=
gl_FrontLightProduct
[
0
].
diffuse
*
diffuse
;
Idiff
=
clamp
(
Idiff
,
0
.
0
,
1
.
0
);
Idiff
=
clamp
(
Idiff
,
0
.
0
,
1
.
0
);
vec3
V
=
normalize
(
-
position
);
vec3
R
=
normalize
(
reflect
(
-
L
,
N
));
vec3
R
=
normalize
(
reflect
(
-
L
,
N
));
...
@@ -25,17 +36,13 @@ void main(void)
...
@@ -25,17 +36,13 @@ void main(void)
vec4
Ispec
=
gl_FrontLightProduct
[
0
].
specular
*
specular
;
vec4
Ispec
=
gl_FrontLightProduct
[
0
].
specular
*
specular
;
Ispec
=
clamp
(
Ispec
,
0
.
0
,
1
.
0
);
Ispec
=
clamp
(
Ispec
,
0
.
0
,
1
.
0
);
vec4
color
=
(
vec4
color
=
(
Iamb
+
Idiff
+
Ispec
);
Iamb
+
Idiff
+
Ispec
);
if
(
shaded
)
gl_FragData
[
0
]
=
color
;
gl_FragData
[
0
]
=
color
;
}
else
else
gl_FragData
[
0
]
=
vec4
(
1
,
1
,
0
,
1
);
gl_FragData
[
0
]
=
vec4
(
1
,
1
,
0
,
1
);
gl_FragData
[
1
]
=
pick
;
gl_FragData
[
1
]
=
pick
;
gl_FragData
[
1
]
=
vec4
(
abs
(
normal
),
1
);
//
gl_FragData[1] = vec4(abs(normal),1);
}
}
A3/phong.vert
View file @
4685d45b
...
@@ -12,6 +12,7 @@ varying vec3 position;
...
@@ -12,6 +12,7 @@ varying vec3 position;
varying
vec3
normal
;
varying
vec3
normal
;
varying
vec4
pick
;
varying
vec4
pick
;
void
main
(
void
)
void
main
(
void
)
{
{
normal
=
normalize
(
gl_NormalMatrix
*
gl_Normal
);
normal
=
normalize
(
gl_NormalMatrix
*
gl_Normal
);
...
@@ -20,6 +21,8 @@ void main(void)
...
@@ -20,6 +21,8 @@ void main(void)
pick
=
vec4
(
pickID
);
pick
=
vec4
(
pickID
);
gl_Position
=
gl_ModelViewProjectionMatrix
*
gl_Vertex
;
gl_Position
=
gl_ModelViewProjectionMatrix
*
gl_Vertex
;
gl_TexCoord
[
0
]
=
gl_MultiTexCoord0
;
}
}
A3/scene.cpp
View file @
4685d45b
...
@@ -17,6 +17,7 @@ Scene::~Scene( )
...
@@ -17,6 +17,7 @@ Scene::~Scene( )
int
Scene
::
simpleScene
()
int
Scene
::
simpleScene
()
{
{
/*
addCube();
addCube();
moveActive(QVector3D(4,0,0));
moveActive(QVector3D(4,0,0));
...
@@ -33,7 +34,7 @@ int Scene::simpleScene()
...
@@ -33,7 +34,7 @@ int Scene::simpleScene()
addCone();
addCone();
moveActive(QVector3D(0,-1.5,-1.5));
moveActive(QVector3D(0,-1.5,-1.5));
*/
return
active
->
getID
();
return
active
->
getID
();
...
...
A3/scenevolume.cpp
View file @
4685d45b
...
@@ -35,23 +35,12 @@ void SceneVolume::draw(QGLShaderProgram *shader){
...
@@ -35,23 +35,12 @@ void SceneVolume::draw(QGLShaderProgram *shader){
glPushMatrix
();
glPushMatrix
();
applyTransformation
();
applyTransformation
();
shader
->
setUniformValue
(
"volume"
,
true
);
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
x
=
lx
/
2
;
float
y
=
ly
/
2
;
float
y
=
ly
/
2
;
float
z
=
lz
/
2
;
float
z
=
lz
/
2
;
glBegin
(
GL_QUADS
);
glBegin
(
GL_QUADS
);
glNormal3f
(
0
,
1
,
0
);
glNormal3f
(
0
,
1
,
0
);
glTexCoord3i
(
1
,
1
,
0
);
glTexCoord3i
(
1
,
1
,
0
);
...
@@ -124,9 +113,9 @@ void SceneVolume::draw(QGLShaderProgram *shader){
...
@@ -124,9 +113,9 @@ void SceneVolume::draw(QGLShaderProgram *shader){
glVertex3f
(
x
,
-
y
,
-
z
);
glVertex3f
(
x
,
-
y
,
-
z
);
glEnd
();
glEnd
();
glPopMatrix
();
glPopMatrix
();
shader
->
setUniformValue
(
"volume"
,
false
);
}
}
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