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
c2d8d532
Commit
c2d8d532
authored
Jul 21, 2016
by
Kai Westerkamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test
parent
40d7dd3a
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
36 additions
and
26 deletions
+36
-26
mainwidget.cpp
QTProject/mainwidget.cpp
+14
-0
mesh.cpp
QTProject/mesh.cpp
+5
-20
subdivide.tcs
QTProject/subdivide.tcs
+2
-0
subdivideRegular.tcs
QTProject/subdivideRegular.tcs
+3
-1
subdivideRegular.tes
QTProject/subdivideRegular.tes
+8
-4
subdivision.cpp
QTProject/subdivision.cpp
+3
-1
subdivision.h
QTProject/subdivision.h
+1
-0
No files found.
QTProject/mainwidget.cpp
View file @
c2d8d532
...
...
@@ -213,10 +213,24 @@ void MainWidget::paintGL(){
rot
.
rotate
(
time
/
100.0
*
36
/
5
,
QVector3D
(
0
,
1
,
0
));
}
regularShader
->
bind
();
regularShader
->
setUniformValue
(
"wireframe"
,
wireframe
);
regularShader
->
setUniformValue
(
"colorTexture"
,
0
);
regularShader
->
setUniformValue
(
"LightPos"
,
QVector3D
(
0
,
100
,
100
));
regularShader
->
setUniformValue
(
"subdiv"
,
subdivLevel
);
mesh
->
render
(
regularShader
,
cam
->
getMatrix
()
*
rot
,
m_projection
,
subdivLevel
,
true
);
regularShader
->
release
();
subdevisionShader
->
bind
();
subdevisionShader
->
setUniformValue
(
"wireframe"
,
wireframe
);
subdevisionShader
->
setUniformValue
(
"colorTexture"
,
0
);
subdevisionShader
->
setUniformValue
(
"LightPos"
,
QVector3D
(
0
,
100
,
100
));
subdevisionShader
->
setUniformValue
(
"subdiv"
,
1
);
mesh
->
render
(
subdevisionShader
,
cam
->
getMatrix
()
*
rot
,
m_projection
,
subdivLevel
,
false
);
...
...
QTProject/mesh.cpp
View file @
c2d8d532
...
...
@@ -24,26 +24,10 @@ Mesh::SubdivEntry::~SubdivEntry()
void
Mesh
::
SubdivEntry
::
addRegular
(
QVector
<
unsigned
int
>&
Indices
){
//TODO fixme
for
(
int
i
=
0
;
i
<
Indices
.
length
();
i
+=
3
){
// qDebug()<<"T:"<<Indices[i]<<Indices[i+1]<<Indices[i+2];
indicesRegular
.
push_back
(
0
);
//0
indicesRegular
.
push_back
(
0
);
//1
indicesRegular
.
push_back
(
0
);
//2
indicesRegular
.
push_back
(
Indices
[
i
]);
//3
indicesRegular
.
push_back
(
0
);
//4
indicesRegular
.
push_back
(
0
);
//5
indicesRegular
.
push_back
(
Indices
[
i
+
1
]);
//6
indicesRegular
.
push_back
(
Indices
[
i
+
2
]);
//7
indicesRegular
.
push_back
(
0
);
//8
indicesRegular
.
push_back
(
0
);
//9
indicesRegular
.
push_back
(
0
);
//10
indicesRegular
.
push_back
(
0
);
//11
}
f
->
glGenBuffers
(
1
,
&
IB_handle
);
f
->
glBindBuffer
(
GL_ELEMENT_ARRAY_BUFFER
,
IB_handle
);
indicesRegular
=
Indices
;
indices
.
clear
();
f
->
glGenBuffers
(
1
,
&
IB_Regular
);
f
->
glBindBuffer
(
GL_ELEMENT_ARRAY_BUFFER
,
IB_Regular
);
f
->
glBufferData
(
GL_ELEMENT_ARRAY_BUFFER
,
sizeof
(
unsigned
int
)
*
indicesRegular
.
size
(),
&
indicesRegular
[
0
],
GL_STATIC_DRAW
);
}
...
...
@@ -477,6 +461,7 @@ void Mesh::renderMesh(QOpenGLShaderProgram *shader, int index, int subdivision,
if
(
regular
){
f
->
glBindBuffer
(
GL_ELEMENT_ARRAY_BUFFER
,
entry
->
IB_Regular
);
f
->
glPatchParameteri
(
GL_PATCH_VERTICES
,
12
);
f
->
glDrawElements
(
GL_PATCHES
,
entry
->
indicesRegular
.
size
(),
GL_UNSIGNED_INT
,
0
);
}
else
{
...
...
QTProject/subdivide.tcs
View file @
c2d8d532
...
...
@@ -5,6 +5,8 @@ layout(vertices = 3) out;
in vec3 vPosition[];
out vec3 tcPosition[];
uniform float subdiv;
void main()
{
tcPosition[gl_InvocationID] = vPosition[gl_InvocationID];
...
...
QTProject/subdivideRegular.tcs
View file @
c2d8d532
...
...
@@ -5,12 +5,14 @@ layout(vertices = 12) out;
in vec3 vPosition[];
out vec3 tcPosition[];
uniform float subdiv;
void main()
{
tcPosition[gl_InvocationID] = vPosition[gl_InvocationID];
float tesselation =
1.0
;
float tesselation =
subdiv
;
gl_TessLevelOuter[0] = tesselation;
gl_TessLevelOuter[1] = tesselation;
...
...
QTProject/subdivideRegular.tes
View file @
c2d8d532
...
...
@@ -56,14 +56,18 @@ void main()
vec3 p10 = tcPosition[10];
vec3 p11 = tcPosition[11];
vec3 newPos= a0*p0+a1*p1+a2*p2+a3*p3+a4*p4+a5*p5+a6*p6+a7*p7+a8*p8+a9*p9+a10*p10+a11*p11;
vec4 pos = vec4(newPos/12,1);
tePatchDistance = gl_TessCoord.xyz;
teCamPosition = vec4(MV*pos).xyz;
gl_Position = MVP * pos;
vec3 d0 = gl_TessCoord.x * p3;
vec3 d1 = gl_TessCoord.y * p6;
vec3 d2 = gl_TessCoord.z * p7;
pos = vec4((d0 + d1 + d2),1);
tePatchDistance = gl_TessCoord.xyz;
teCamPosition = vec4(MV*pos).xyz;
gl_Position = MVP * pos;
}
QTProject/subdivision.cpp
View file @
c2d8d532
...
...
@@ -75,6 +75,8 @@ void Subdivision::subdivide(Mesh *mesh, int level) {
Result
result
=
runShader
(
input
,
tables
);
current_mesh
->
update
(
result
.
vb_handle
,
result
.
vertex_buffer
,
tables
.
index_buffer
);
current_mesh
->
buffers
[
currentMax
+
1
]
->
addRegular
(
tables
.
index_regular
);
qDebug
()
<<
tables
.
index_regular
.
size
();
//return new Mesh(f, mesh, result.vertex_buffer, tables.index_buffer);
}
...
...
@@ -358,7 +360,7 @@ Subdivision::Tables Subdivision::precomputeTables(Input input) {
}
}
qDebug
()
<<
"Precompute Tables Done"
;
getPatchIndexBuffer
(
ib
);
tables
.
index_regular
=
getPatchIndexBuffer
(
ib
);
return
tables
;
}
...
...
QTProject/subdivision.h
View file @
c2d8d532
...
...
@@ -32,6 +32,7 @@ private:
QVector
<
GLuint
>
vertex_indices
;
QVector
<
GLuint
>
vertex_offsets
;
QVector
<
GLuint
>
index_buffer
;
QVector
<
GLuint
>
index_regular
;
};
struct
Result
...
...
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