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
11b65874
Commit
11b65874
authored
Sep 01, 2016
by
Alisa Jung
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'patchRender' of…
Merge branch 'patchRender' of
ssh://git.breab.org:2223/kai/Unterteilungsalgorithmen
into patchRender
parents
c19a9d28
fc9a48c7
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
55 additions
and
22 deletions
+55
-22
main.cpp
QTProject/main.cpp
+4
-1
mainwindow.cpp
QTProject/mainwindow.cpp
+11
-1
mainwindow.h
QTProject/mainwindow.h
+4
-0
mesh.cpp
QTProject/mesh.cpp
+1
-1
subdivision.cpp
QTProject/subdivision.cpp
+31
-16
subdivision.h
QTProject/subdivision.h
+4
-3
No files found.
QTProject/main.cpp
View file @
11b65874
...
...
@@ -5,7 +5,10 @@
int
main
(
int
argc
,
char
*
argv
[])
{
QApplication
a
(
argc
,
argv
);
QLoggingCategory
::
setFilterRules
(
"subdiv.trace.debug=false
\n
"
);
QLoggingCategory
::
setFilterRules
(
"mesh.debug=false
\n
"
"mesh.render.debug=false
\n
"
"subdiv.debug=true
\n
"
"subdiv.trace.debug=false
\n
"
);
// If you want to enable debug output for some categories use something like this:
//QLoggingCategory::setFilterRules("*.debug=false\n"
...
...
QTProject/mainwindow.cpp
View file @
11b65874
...
...
@@ -47,7 +47,7 @@ MainWindow::MainWindow(QWidget *parent) :
subdivSlider
->
setSingleStep
(
1
);
connect
(
subdivSlider
,
SIGNAL
(
valueChanged
(
int
)),
m_centralWidget
,
SLOT
(
subdivide
(
int
)));
this
,
SLOT
(
sliderfix
(
int
)));
toolBar
->
addWidget
(
subdivSlider
);
...
...
@@ -57,6 +57,16 @@ MainWindow::MainWindow(QWidget *parent) :
// showMaximized();
}
void
MainWindow
::
sliderfix
(
int
pos
){
int
move
=
pos
-
oldSliderpos
;
move
>
0
?
move
=
1
:
move
=
-
1
;
int
newPos
=
oldSliderpos
+
move
;
// qDebug()<<"SliderPos"<<oldSliderpos<<move<<newPos;
m_centralWidget
->
subdivide
(
newPos
);
subdivSlider
->
setSliderPosition
(
newPos
);
oldSliderpos
=
newPos
;
}
MainWindow
::~
MainWindow
()
{
}
QTProject/mainwindow.h
View file @
11b65874
...
...
@@ -19,7 +19,11 @@ public:
explicit
MainWindow
(
QWidget
*
parent
=
0
);
~
MainWindow
();
public
slots
:
void
sliderfix
(
int
pos
);
private
:
int
oldSliderpos
=
0
;
MainWidget
*
m_centralWidget
;
QToolBar
*
toolBar
;
...
...
QTProject/mesh.cpp
View file @
11b65874
...
...
@@ -476,7 +476,7 @@ void Mesh::renderMesh(QOpenGLShaderProgram *shader, int index, int subdivision,
f
->
glBindBuffer
(
GL_ELEMENT_ARRAY_BUFFER
,
depthEntry
->
IB_regular_handle
);
f
->
glPatchParameteri
(
GL_PATCH_VERTICES
,
12
);
f
->
glDrawElements
(
GL_PATCHES
,
depthEntry
->
indices_regular
.
size
(),
GL_UNSIGNED_INT
,
0
);
qCDebug
(
log_mesh
)
<<
"Patches "
<<
entry
->
indices_regular
.
size
()
/
12
<<
" Subdivision Level: "
<<
subdivision
;
// qCDebug(log_mesh_render
)<<"Patches "<<entry->indices_regular.size()/12<<" Subdivision Level: "<< subdivision;
}
}
}
else
{
...
...
QTProject/subdivision.cpp
View file @
11b65874
...
...
@@ -65,9 +65,10 @@ void Subdivision::subdivide(Mesh *mesh, int level) {
input
.
vb_handle
=
entry
->
VB_handle
;
input
.
vertex_buffer
=
entry
->
vertices
;
input
.
index_buffer
=
entry
->
indices_irregular
;
input
.
index_irregular_buffer
=
entry
->
indices_irregular
;
input
.
index_regular_buffer
=
getTriangles
(
entry
->
indices_regular
);
if
(
input
.
index_buffer
.
isEmpty
())
{
if
(
input
.
index_
irregular_
buffer
.
isEmpty
())
{
// current_mesh->update(input.vb_handle, input.vertex_buffer, input.index_buffer, entry->indices_regular);
}
else
{
Tables
tables
=
precomputeTables
(
input
);
...
...
@@ -137,8 +138,11 @@ struct Edge {
Subdivision
::
Tables
Subdivision
::
precomputeTables
(
Input
input
)
{
Tables
tables
;
QVector
<
unsigned
int
>
ib
=
input
.
index_buffer
;
qCDebug
(
log_subdiv_trace
)
<<
"Index Buffer: "
<<
ib
;
QVector
<
unsigned
int
>
ib
=
input
.
index_irregular_buffer
;
qCDebug
(
log_subdiv_trace
)
<<
"Index Buffer Irregular: "
<<
ib
;
QVector
<
unsigned
int
>
ib_regular
=
input
.
index_regular_buffer
;
qCDebug
(
log_subdiv_trace
)
<<
"Index Buffer Regular: "
<<
ib_regular
;
QVector
<
Vertex
>
vb
=
input
.
vertex_buffer
;
qCDebug
(
log_subdiv_trace
)
<<
"Vertex Buffer: "
<<
vb
;
...
...
@@ -147,16 +151,20 @@ Subdivision::Tables Subdivision::precomputeTables(Input input) {
for
(
int
i
=
0
;
i
<
ib
.
length
();
i
+=
3
)
{
triangles
.
push_back
(
Triangle
(
vb
,
ib
[
i
],
ib
[
i
+
1
],
ib
[
i
+
2
]));
}
QVector
<
Triangle
>
triangles_regular
;
for
(
int
i
=
0
;
i
<
ib_regular
.
length
();
i
+=
3
)
{
triangles
.
push_back
(
Triangle
(
vb
,
ib_regular
[
i
],
ib_regular
[
i
+
1
],
ib_regular
[
i
+
2
]));
}
precomputeEdgeTable
(
tables
,
triangles
,
(
unsigned
int
)
vb
.
length
());
precomputeVertexTable
(
tables
,
vb
,
ib
);
precomputeEdgeTable
(
tables
,
triangles
,
triangles_regular
,
(
unsigned
int
)
vb
.
length
());
precomputeVertexTable
(
tables
,
vb
,
ib
,
ib_regular
);
//tables.patch_index_regular = getPatchIndexBuffer(ib, QVector<unsigned int>());//TODO pass regular and irregular index buffer?
qCDebug
(
log_subdiv
)
<<
"Precompute Tables Done"
;
return
tables
;
}
void
Subdivision
::
precomputeEdgeTable
(
Subdivision
::
Tables
&
tables
,
QVector
<
Triangle
>
&
triangles
,
unsigned
int
offset
)
{
void
Subdivision
::
precomputeEdgeTable
(
Subdivision
::
Tables
&
tables
,
QVector
<
Triangle
>
&
triangles
,
QVector
<
Triangle
>
&
triangles_regular
,
unsigned
int
offset
)
{
//compute edge table
//Format: first two entries: edge vertices. last two entries: distant vertices.
...
...
@@ -188,6 +196,12 @@ void Subdivision::precomputeEdgeTable(Subdivision::Tables &tables, QVector<Trian
insert_edge
(
opposite_edges
,
triangles
[
j
],
edge_b
,
edge_a
);
}
}
for
(
int
j
=
0
;
j
<
triangles_regular
.
length
();
j
++
){
if
(
triangle
.
get_shared_edge
(
triangles_regular
[
j
],
edge_a
,
edge_b
))
{
insert_edge
(
opposite_edges
,
triangle
,
edge_a
,
edge_b
);
// no need to insert the opposite edge of a regular triangle - it won't be processed by the outer loop
}
}
QVector
<
Triangle
::
Edge
>
opposite
=
opposite_edges
.
value
(
triangle
);
...
...
@@ -272,10 +286,11 @@ void Subdivision::precomputeEdgeTable(Subdivision::Tables &tables, QVector<Trian
}
}
void
Subdivision
::
precomputeVertexTable
(
Subdivision
::
Tables
&
tables
,
QVector
<
Vertex
>
&
vb
,
QVector
<
unsigned
int
>
&
ib
)
{
void
Subdivision
::
precomputeVertexTable
(
Subdivision
::
Tables
&
tables
,
QVector
<
Vertex
>
&
vb
,
QVector
<
unsigned
int
>
&
ib
,
QVector
<
unsigned
int
>
&
ib_regular
)
{
//compute vertex table
//Format: First entry: original vertex. Other entries: adjacent vertices.
QVector
<
QVector
<
unsigned
int
>
>
duplicates
;
//for debugging
QVector
<
unsigned
int
>
ib_combined
=
ib
+
ib_regular
;
unsigned
int
offset
=
0
;
for
(
int
i
=
0
;
i
<
vb
.
length
();
i
++
){
//hat evtl viel redundanz
...
...
@@ -289,21 +304,21 @@ void Subdivision::precomputeVertexTable(Subdivision::Tables &tables, QVector<Ver
QVector
<
unsigned
int
>
d
;
for
(
int
j
=
0
;
j
<
ib
.
length
();
j
++
){
for
(
int
j
=
0
;
j
<
ib
_combined
.
length
();
j
++
){
//suche verweise auf vertex im indexbuffer
if
(
vb
[
ib
[
j
]].
samePos
(
originalVertex
)){
if
(
vb
[
ib
_combined
[
j
]].
samePos
(
originalVertex
)){
d
.
push_back
(
j
);
unsigned
int
i1
,
i2
;
//indices for neighbour vertices
if
(
j
%
3
==
0
){
i1
=
ib
[
j
+
1
];
i2
=
ib
[
j
+
2
];
i1
=
ib
_combined
[
j
+
1
];
i2
=
ib
_combined
[
j
+
2
];
}
else
if
(
j
%
3
==
1
){
i1
=
ib
[
j
-
1
];
i2
=
ib
[
j
+
1
];
i1
=
ib
_combined
[
j
-
1
];
i2
=
ib
_combined
[
j
+
1
];
}
else
{
i1
=
ib
[
j
-
2
];
i2
=
ib
[
j
-
1
];
i1
=
ib
_combined
[
j
-
2
];
i2
=
ib
_combined
[
j
-
1
];
}
Vertex
v1
,
v2
;
//neighbour vertices;
...
...
QTProject/subdivision.h
View file @
11b65874
...
...
@@ -22,7 +22,8 @@ private:
struct
Input
{
GLuint
vb_handle
;
QVector
<
unsigned
int
>
index_buffer
;
QVector
<
unsigned
int
>
index_irregular_buffer
;
QVector
<
unsigned
int
>
index_regular_buffer
;
QVector
<
Vertex
>
vertex_buffer
;
};
...
...
@@ -53,8 +54,8 @@ private:
QOpenGLShaderProgram
*
initComputeShaderProgram
(
QString
&
source
);
Tables
precomputeTables
(
Input
input
);
void
precomputeEdgeTable
(
Subdivision
::
Tables
&
tables
,
QVector
<
Triangle
>
&
triangles
,
unsigned
int
offset
);
void
precomputeVertexTable
(
Subdivision
::
Tables
&
tables
,
QVector
<
Vertex
>
&
vb
,
QVector
<
unsigned
int
>
&
ib
);
void
precomputeEdgeTable
(
Subdivision
::
Tables
&
tables
,
QVector
<
Triangle
>
&
triangles
,
QVector
<
Triangle
>
&
triangles_regular
,
unsigned
int
offset
);
void
precomputeVertexTable
(
Subdivision
::
Tables
&
tables
,
QVector
<
Vertex
>
&
vb
,
QVector
<
unsigned
int
>
&
ib
,
QVector
<
unsigned
int
>
&
ib_regular
);
void
findRegular
(
QVector
<
unsigned
int
>
index_buffer
,
QVector
<
Vertex
>
vertex_buffer
,
QVector
<
unsigned
int
>
&
regular
,
QVector
<
unsigned
int
>
&
irregular
);
Result
runShader
(
Input
input
,
Tables
&
tables
);
void
runVertexShader
(
GLuint
size
,
GLuint
vb_handle
,
GLuint
vertex_indices_handle
,
GLuint
vertex_offsets_handle
,
GLuint
output_handle
);
...
...
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