Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
U
Unterteilungsalgorithmen
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
3
Issues
3
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
Unterteilungsalgorithmen
Commits
2e7a899f
Commit
2e7a899f
authored
Jul 11, 2016
by
Kai Westerkamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "torus update"
This reverts commit
6ee50809
. Added 12 Patch start
parent
749bd796
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
163 additions
and
123 deletions
+163
-123
J.Stam Evaluation of Loop Subdivision Surfaces.pdf
J.Stam Evaluation of Loop Subdivision Surfaces.pdf
+0
-0
torus.obj
Models/torus.obj
+32
-44
torusMitNormalen.obj
Models/torusMitNormalen.obj
+60
-0
mainwidget.cpp
QTProject/mainwidget.cpp
+3
-3
mesh.cpp
QTProject/mesh.cpp
+41
-19
subdivide.frag
QTProject/subdivide.frag
+4
-8
subdivide.geo
QTProject/subdivide.geo
+4
-13
subdivide.tcs
QTProject/subdivide.tcs
+2
-12
subdivide.tes
QTProject/subdivide.tes
+17
-18
subdivide.vert
QTProject/subdivide.vert
+0
-6
No files found.
J.Stam Evaluation of Loop Subdivision Surfaces.pdf
0 → 100644
View file @
2e7a899f
File added
Models/torus.obj
View file @
2e7a899f
...
...
@@ -14,47 +14,35 @@ v 0.5 0 0.5
v 0 0.5 0.5
v -0.5 0 0.5
v 0 -0.5 0.5
vn 0 0 -1
vn 0 0 1
vn -0.5 -0.5 0
vn 0.5 0.5 0
vn 0.5 -0.5 0
vn -0.5 0.5 0
f 1//1 2//1 6//1
f 1//1 6//1 5//1
f 2//1 3//1 7//1
f 2//1 7//1 6//1
f 3//1 4//1 8//1
f 3//1 8//1 7//1
f 4//1 1//1 5//1
f 4//1 5//1 8//1
f 5//3 6//3 14//3
f 5//3 14//3 13//3
f 6//5 7//5 15//5
f 6//5 15//5 14//5
f 7//4 8//4 16//4
f 7//4 16//4 15//4
f 8//6 5//6 13//6
f 8//6 13//6 16//6
f 13//2 14//2 10//2
f 13//2 10//2 9//2
f 14//2 15//2 11//2
f 14//2 11//2 10//2
f 15//2 16//2 12//2
f 15//2 12//2 11//2
f 16//2 13//2 9//2
f 16//2 9//2 12//2
f 9//4 10//4 2//4
f 9//4 2//4 1/4
f 10//6 11//6 3//6
f 10//6 3//6 2//6
f 11//3 12//3 4//3
f 11//3 4//3 3//3
f 12//5 9//5 1//5
f 12//5 1//5 4//5
f 1 6 2
f 1 5 6
f 2 7 3
f 2 6 7
f 3 8 4
f 3 7 8
f 4 5 1
f 4 8 5
f 5 14 6
f 5 13 14
f 6 15 7
f 6 14 15
f 7 16 8
f 7 15 16
f 8 13 5
f 8 16 13
f 13 10 14
f 13 9 10
f 14 11 15
f 14 10 11
f 15 12 16
f 15 11 12
f 16 9 13
f 16 12 9
f 9 2 10
f 9 1 2
f 10 3 11
f 10 2 3
f 11 4 12
f 11 3 4
f 12 1 9
f 12 4 1
Models/torusMitNormalen.obj
0 → 100644
View file @
2e7a899f
v 1 0 -0.5
v 0 1 -0.5
v -1 0 -0.5
v 0 -1 -0.5
v 0.5 0 -0.5
v 0 0.5 -0.5
v -0.5 0 -0.5
v 0 -0.5 -0.5
v 1 0 0.5
v 0 1 0.5
v -1 0 0.5
v 0 -1 0.5
v 0.5 0 0.5
v 0 0.5 0.5
v -0.5 0 0.5
v 0 -0.5 0.5
vn 0 0 -1
vn 0 0 1
vn -0.5 -0.5 0
vn 0.5 0.5 0
vn 0.5 -0.5 0
vn -0.5 0.5 0
f 1//1 2//1 6//1
f 1//1 6//1 5//1
f 2//1 3//1 7//1
f 2//1 7//1 6//1
f 3//1 4//1 8//1
f 3//1 8//1 7//1
f 4//1 1//1 5//1
f 4//1 5//1 8//1
f 5//3 6//3 14//3
f 5//3 14//3 13//3
f 6//5 7//5 15//5
f 6//5 15//5 14//5
f 7//4 8//4 16//4
f 7//4 16//4 15//4
f 8//6 5//6 13//6
f 8//6 13//6 16//6
f 13//2 14//2 10//2
f 13//2 10//2 9//2
f 14//2 15//2 11//2
f 14//2 11//2 10//2
f 15//2 16//2 12//2
f 15//2 12//2 11//2
f 16//2 13//2 9//2
f 16//2 9//2 12//2
f 9//4 10//4 2//4
f 9//4 2//4 1/4
f 10//6 11//6 3//6
f 10//6 3//6 2//6
f 11//3 12//3 4//3
f 11//3 4//3 3//3
f 12//5 9//5 1//5
f 12//5 1//5 4//5
QTProject/mainwidget.cpp
View file @
2e7a899f
...
...
@@ -5,8 +5,8 @@ MainWidget::MainWidget(Camera *cam)
this
->
cam
=
cam
;
startTime
=
QTime
::
currentTime
();
rotTime
=
QTime
::
currentTime
();
wireframe
=
fals
e
;
rotation
=
tru
e
;
wireframe
=
tru
e
;
rotation
=
fals
e
;
subdivision
=
new
Subdivision
(
this
);
subdivLevel
=
0
;
}
...
...
@@ -110,7 +110,7 @@ void MainWidget::initializeGL(){
subdivision
->
init
();
//loadNewMesh( "../Models/demon_head.3ds");
loadNewMesh
(
"../Models/
box
.obj"
);
loadNewMesh
(
"../Models/
torus
.obj"
);
}
void
MainWidget
::
loadNewMesh
(){
...
...
QTProject/mesh.cpp
View file @
2e7a899f
...
...
@@ -21,15 +21,40 @@ Mesh::MeshEntry::MeshEntry()
void
Mesh
::
MeshEntry
::
init
(
QOpenGLFunctions_4_3_Core
*
f
,
QVector
<
Vertex
>&
Vertices
,
QVector
<
unsigned
int
>&
Indices
){
this
->
f
=
f
;
numIndex
=
Indices
.
size
();
f
->
glGenBuffers
(
1
,
&
VB_handle
);
f
->
glBindBuffer
(
GL_ARRAY_BUFFER
,
VB_handle
);
f
->
glBufferData
(
GL_ARRAY_BUFFER
,
sizeof
(
Vertex
)
*
Vertices
.
size
(),
&
Vertices
[
0
],
GL_STATIC_DRAW
);
//for(int i = 0; i < Vertices.length(); i++){
// qDebug()<<"V:"<<i<<Vertices[i];
//}
QVector
<
unsigned
int
>
Indices2
;
for
(
int
i
=
0
;
i
<
Indices
.
length
();
i
+=
3
){
// qDebug()<<"T:"<<Indices[i]<<Indices[i+1]<<Indices[i+2];
Indices2
.
push_back
(
0
);
//0
Indices2
.
push_back
(
0
);
//1
Indices2
.
push_back
(
0
);
//2
Indices2
.
push_back
(
Indices
[
i
]);
//3
Indices2
.
push_back
(
0
);
//4
Indices2
.
push_back
(
0
);
//5
Indices2
.
push_back
(
Indices
[
i
+
1
]);
//6
Indices2
.
push_back
(
Indices
[
i
+
2
]);
//7
Indices2
.
push_back
(
0
);
//8
Indices2
.
push_back
(
0
);
//9
Indices2
.
push_back
(
0
);
//10
Indices2
.
push_back
(
0
);
//11
}
numIndex
=
Indices2
.
size
();
f
->
glGenBuffers
(
1
,
&
IB_handle
);
f
->
glBindBuffer
(
GL_ELEMENT_ARRAY_BUFFER
,
IB_handle
);
f
->
glBufferData
(
GL_ELEMENT_ARRAY_BUFFER
,
sizeof
(
unsigned
int
)
*
numIndex
,
&
Indices
[
0
],
GL_STATIC_DRAW
);
f
->
glBufferData
(
GL_ELEMENT_ARRAY_BUFFER
,
sizeof
(
unsigned
int
)
*
numIndex
,
&
Indices
2
[
0
],
GL_STATIC_DRAW
);
indices
=
Indices
;
vertices
=
Vertices
;
...
...
@@ -47,20 +72,20 @@ void Mesh::MeshEntry::init(QOpenGLFunctions_4_3_Core *f,QVector<Vertex>& Vertice
}
}
void
Mesh
::
MeshEntry
::
update
(
GLuint
VB
,
QVector
<
Vertex
>&
Vertices
,
QVector
<
unsigned
int
>&
Indices
){
numIndex
=
Indices
.
size
();
indices
=
Indices
;
vertices
=
Vertices
;
void
Mesh
::
MeshEntry
::
update
(
GLuint
VB
,
QVector
<
Vertex
>&
Vertices
,
QVector
<
unsigned
int
>&
Indices
){
numIndex
=
Indices
.
size
();
indices
=
Indices
;
vertices
=
Vertices
;
f
->
glDeleteBuffers
(
1
,
&
IB_handle
);
f
->
glGenBuffers
(
1
,
&
IB_handle
);
f
->
glBindBuffer
(
GL_ELEMENT_ARRAY_BUFFER
,
IB_handle
);
f
->
glBufferData
(
GL_ELEMENT_ARRAY_BUFFER
,
sizeof
(
unsigned
int
)
*
numIndex
,
&
Indices
[
0
],
GL_STATIC_DRAW
);
f
->
glDeleteBuffers
(
1
,
&
IB_handle
);
f
->
glGenBuffers
(
1
,
&
IB_handle
);
f
->
glBindBuffer
(
GL_ELEMENT_ARRAY_BUFFER
,
IB_handle
);
f
->
glBufferData
(
GL_ELEMENT_ARRAY_BUFFER
,
sizeof
(
unsigned
int
)
*
numIndex
,
&
Indices
[
0
],
GL_STATIC_DRAW
);
f
->
glDeleteBuffers
(
1
,
&
VB_handle
);
VB_handle
=
VB
;
f
->
glDeleteBuffers
(
1
,
&
VB_handle
);
VB_handle
=
VB
;
}
}
Mesh
::
MeshEntry
::~
MeshEntry
()
{
...
...
@@ -111,6 +136,7 @@ Mesh::Mesh(QOpenGLFunctions_4_3_Core *f,QString fileName)
//aiProcess_JoinIdenticalVertices |
//aiProcess_SortByPType |
// ? aiProcess_FlipUVs |
aiProcess_JoinIdenticalVertices
|
aiProcess_Triangulate
);
...
...
@@ -393,11 +419,9 @@ void Mesh::renderNode(QOpenGLShaderProgram *shader, Node &node, QMatrix4x4 V,QMa
QMatrix4x4
MV
=
V
*
M
;
QMatrix4x4
MVP
=
P
*
MV
;
QMatrix3x3
normalMat
=
MV
.
normalMatrix
();
shader
->
setUniformValue
(
"MVP"
,
MVP
);
shader
->
setUniformValue
(
"MV"
,
MV
);
shader
->
setUniformValue
(
"N"
,
normalMat
);
for
(
int
i
=
0
;
i
<
node
.
meshes
.
size
()
;
i
++
)
{
int
index
=
node
.
meshes
[
i
];
...
...
@@ -414,7 +438,7 @@ void Mesh::renderMesh(QOpenGLShaderProgram *shader, int index, int subdivision)
{
int
MaterialIndex
=
entries
[
index
].
materialIndex
;
if
(
MaterialIndex
<
materials
.
size
())
{
// qDebug()<<materials[MaterialIndex].Diffuse<<materials[MaterialIndex].Specular<<materials[MaterialIndex].Shininess<<materials[MaterialIndex].hasTexture;
// qDebug()<<materials[MaterialIndex].Diffuse<<materials[MaterialIndex].Specular<<materials[MaterialIndex].Shininess<<materials[MaterialIndex].hasTexture;
shader
->
setUniformValue
(
"materialInfo.Diffuse"
,
materials
[
MaterialIndex
].
Diffuse
);
shader
->
setUniformValue
(
"materialInfo.Specular"
,
materials
[
MaterialIndex
].
Specular
);
...
...
@@ -429,12 +453,10 @@ void Mesh::renderMesh(QOpenGLShaderProgram *shader, int index, int subdivision)
// Draw Vertex Array
f
->
glBindBuffer
(
GL_ARRAY_BUFFER
,
entries
[
index
].
VB_handle
);
f
->
glVertexAttribPointer
(
positionIndex
,
3
,
GL_FLOAT
,
GL_FALSE
,
sizeof
(
Vertex
),
0
);
f
->
glVertexAttribPointer
(
normalIndex
,
3
,
GL_FLOAT
,
GL_FALSE
,
sizeof
(
Vertex
),
(
const
GLvoid
*
)
16
);
//3*4+4
f
->
glVertexAttribPointer
(
uvIndex
,
2
,
GL_FLOAT
,
GL_FALSE
,
sizeof
(
Vertex
),
(
const
GLvoid
*
)
32
);
// 12+4+12+4
f
->
glBindBuffer
(
GL_ELEMENT_ARRAY_BUFFER
,
entries
[
index
].
IB_handle
);
f
->
glPatchParameteri
(
GL_PATCH_VERTICES
,
3
);
f
->
glPatchParameteri
(
GL_PATCH_VERTICES
,
12
);
f
->
glDrawElements
(
GL_PATCHES
,
entries
[
index
].
numIndex
,
GL_UNSIGNED_INT
,
0
);
}
...
...
QTProject/subdivide.frag
View file @
2e7a899f
...
...
@@ -3,7 +3,6 @@ layout(location = 0) out vec3 color;
in
vec3
gCamPosition
;
in
vec3
gCamNormal
;
in
vec2
gUV
;
in
vec3
gTriDistance
;
in
vec3
gPatchDistance
;
...
...
@@ -25,18 +24,15 @@ uniform Material materialInfo;
vec3
phong
(
vec3
lightPos
){
vec3
dcolor
=
materialInfo
.
Diffuse
;
vec3
dcolor2
=
texture2D
(
colorTexture
,
gUV
).
xyz
;
if
(
materialInfo
.
hasTexture
){
dcolor
=
dcolor2
;
}
vec3
V
=
normalize
(
-
gCamPosition
);
vec3
N
=
normalize
(
gCamNormal
);
vec3
L
=
normalize
(
lightPos
-
gCamPosition
);
vec3
R
=
normalize
(
reflect
(
-
L
,
N
));
float
diffuse
=
max
(
dot
(
L
,
N
),
0
.
0
);
diffuse
=
abs
(
dot
(
L
,
N
));
float
specular
=
pow
(
max
(
dot
(
R
,
V
),
0
.
0
),
materialInfo
.
Shininess
);
//return vec3(diffuse );
...
...
@@ -67,7 +63,7 @@ void addWireframe(){
void
main
()
{
color
=
phong
(
LightPos
);
//
color = abs(normalize(gCamNormal));
//
color = abs(normalize(gCamNormal));
addWireframe
();
...
...
QTProject/subdivide.geo
View file @
2e7a899f
...
...
@@ -3,13 +3,9 @@
layout (triangles) in;
layout (triangle_strip, max_vertices = 3) out;
in vec2 teUV[3];
out vec2 gUV;
in vec3 teCamPosition[3];
out vec3 gCamPosition;
in vec3 teCamNormal[3];
out vec3 gCamNormal;
out vec3 gTriDistance;
...
...
@@ -26,28 +22,23 @@ void main(void)
//normal = cross(teCamPosition[1]-teCamPosition[0],teCamPosition[2]-teCamPosition[0]);
gTriDistance = vec3(1, 0, 0);
gUV = teUV[0];
gCamPosition = teCamPosition[0];
gCamNormal = teCamNormal[0];
//gCamNormal = normal;
gCamNormal = normal;
gPatchDistance = tePatchDistance[0];
gl_Position = gl_in[0].gl_Position;
EmitVertex();
gTriDistance = vec3(0, 1, 0);
gUV = teUV[1];
gCamPosition = teCamPosition[1];
gCamNormal = teCamNormal[1];
//gCamNormal = normal;
gCamNormal = normal;
gPatchDistance = tePatchDistance[1];
gl_Position = gl_in[1].gl_Position;
EmitVertex();
gTriDistance = vec3(0, 0, 1);
gUV = teUV[2];
gCamPosition = teCamPosition[2];
gCamNormal = teCamNormal[2];
// gCamNormal = normal;
gCamNormal = normal;
gPatchDistance = tePatchDistance[2];
gl_Position = gl_in[2].gl_Position;
EmitVertex();
...
...
QTProject/subdivide.tcs
View file @
2e7a899f
#version 430
layout(vertices =
3
) out;
layout(vertices =
12
) out;
in vec3 vPosition[];
out vec3 tcPosition[];
in vec3 vNormal[];
out vec3 tcNormal[];
in vec2 vUV[];
out vec2 tcUV[];
uniform vec3 CamPos;
void main()
{
tcPosition[gl_InvocationID] = vPosition[gl_InvocationID];
tcNormal[gl_InvocationID] = vNormal[gl_InvocationID];
tcUV[gl_InvocationID] = vUV[gl_InvocationID];
float tesselation = 1.0;
...
...
QTProject/subdivide.tes
View file @
2e7a899f
...
...
@@ -4,40 +4,39 @@ layout(triangles, equal_spacing, cw) in;
in vec3 tcPosition[];
out vec3 teCamPosition;
in vec3 tcNormal[];
out vec3 teCamNormal;
in vec2 tcUV[];
out vec2 teUV;
out vec3 tePatchDistance;
uniform mat4x4 MV;
uniform mat4x4 MVP;
uniform mat3x3 N;
void main()
{
vec3 p0 = tcPosition[0];
vec3 p1 = tcPosition[1];
vec3 p2 = tcPosition[2];
vec3 p3 = tcPosition[3];
vec3 p4 = tcPosition[4];
vec3 p5 = tcPosition[5];
vec3 p6 = tcPosition[6];
vec3 p7 = tcPosition[7];
vec3 p8 = tcPosition[8];
vec3 p9 = tcPosition[9];
vec3 p10 = tcPosition[10];
vec3 p11 = tcPosition[11];
tePatchDistance = gl_TessCoord.xyz;
vec3 p0 = gl_TessCoord.x * tcPosition[0];
vec3 p1 = gl_TessCoord.y * tcPosition[1];
vec3 p2 = gl_TessCoord.z * tcPosition[2];
vec4 pos = vec4((p0 + p1 + p2),1);
vec3 d0 = gl_TessCoord.x * p3;
vec3 d1 = gl_TessCoord.y * p6;
vec3 d2 = gl_TessCoord.z * p7;
vec4 pos = vec4((d0 + d1 + d2),1);
teCamPosition = vec4(MV*pos).xyz;
gl_Position = MVP * pos;
vec3 n0 = gl_TessCoord.x * tcNormal[0];
vec3 n1 = gl_TessCoord.y * tcNormal[1];
vec3 n2 = gl_TessCoord.z * tcNormal[2];
teCamNormal = N*(n0 + n1 + n2);
vec2 u0 = gl_TessCoord.x * tcUV[0];
vec2 u1 = gl_TessCoord.y * tcUV[1];
vec2 u2 = gl_TessCoord.z * tcUV[2];
teUV = (u0 + u1 + u2);
}
QTProject/subdivide.vert
View file @
2e7a899f
#version 430
layout
(
location
=
0
)
in
vec3
Position
;
layout
(
location
=
1
)
in
vec3
Normal
;
layout
(
location
=
2
)
in
vec2
UV
;
out
vec3
vPosition
;
out
vec3
vNormal
;
out
vec2
vUV
;
void
main
(
void
)
{
//transofrmation im tesselation evaluation , einfach nur durchreichen
vPosition
.
xyz
=
Position
.
xyz
;
vNormal
.
xyz
=
Normal
.
xyz
;
vUV
=
UV
;
}
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