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