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
b3ed332c
Commit
b3ed332c
authored
Jun 16, 2016
by
Alisa Jung
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
precomputation of edge table. results seem correct for cube.
parent
cbc4b424
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
86 additions
and
21 deletions
+86
-21
mesh.cpp
QTProject/mesh.cpp
+4
-0
mesh.h
QTProject/mesh.h
+8
-1
subdivision.cpp
QTProject/subdivision.cpp
+72
-20
subdivision.h
QTProject/subdivision.h
+2
-0
No files found.
QTProject/mesh.cpp
View file @
b3ed332c
...
...
@@ -195,6 +195,10 @@ QVector<unsigned int> Mesh::MeshEntry::getIndexBuffer(){
return
indices
;
}
QVector
<
Vertex
>
Mesh
::
MeshEntry
::
getVertexBuffer
(){
return
vertices
;
}
void
Mesh
::
initNode
(
const
aiScene
*
scene
,
aiNode
*
node
,
Node
&
newNode
,
QString
debugoffset
){
newNode
.
name
=
node
->
mName
.
length
!=
0
?
node
->
mName
.
C_Str
()
:
""
;
newNode
.
transformation
=
QMatrix4x4
(
node
->
mTransformation
[
0
]);
...
...
QTProject/mesh.h
View file @
b3ed332c
...
...
@@ -28,6 +28,12 @@ struct Vertex
this
->
tex
=
tex
;
this
->
normal
=
normal
;
}
bool
samePos
(
const
Vertex
&
other
)
const
{
return
pos
==
other
.
pos
;
}
//TODO add some kind of toString so we can log vertices.
};
QDebug
operator
<<
(
QDebug
d
,
const
Vertex
&
v
);
...
...
@@ -46,6 +52,8 @@ public:
MeshEntry
();
~
MeshEntry
();
QVector
<
unsigned
int
>
getIndexBuffer
();
QVector
<
Vertex
>
getVertexBuffer
();
void
init
(
QOpenGLFunctions_4_3_Core
*
f
,
QVector
<
Vertex
>&
Vertices
,
QVector
<
unsigned
int
>&
Indices
);
...
...
@@ -113,7 +121,6 @@ private:
void
renderNode
(
QOpenGLShaderProgram
*
shader
,
Node
&
node
,
QMatrix4x4
V
,
QMatrix4x4
P
,
QMatrix4x4
M
);
void
renderMesh
(
QOpenGLShaderProgram
*
shader
,
int
index
);
void
findObjectDimension
(
Node
node
,
QMatrix4x4
transform
,
QVector3D
&
min
,
QVector3D
&
max
);
...
...
QTProject/subdivision.cpp
View file @
b3ed332c
...
...
@@ -14,6 +14,15 @@ void Subdivision::init() {
shader
=
initComputeShaderProgram
();
}
QVector
<
unsigned
int
>
Subdivision
::
fillVector
(
unsigned
int
a
,
unsigned
int
b
,
unsigned
int
c
,
unsigned
int
d
){
QVector
<
unsigned
int
>
x
;
x
.
push_back
(
a
);
x
.
push_back
(
b
);
x
.
push_back
(
c
);
x
.
push_back
(
d
);
return
x
;
}
QOpenGLShaderProgram
*
Subdivision
::
initComputeShaderProgram
(){
QString
source
=
QLatin1String
(
":/subdivision.compute"
);
...
...
@@ -55,43 +64,86 @@ void Subdivision::precomputeTables(Mesh *mesh) {
qDebug
()
<<
"Mesh found. Index:"
<<
firstMeshEntryIndex
;
//die drei zeilen machen das bild schwarz. wenn man davor returnt tuts.
Mesh
::
MeshEntry
firstMeshEntry
=
mesh
->
getMeshEntry
(
firstMeshEntryIndex
);
QVector
<
unsigned
int
>
ib
=
firstMeshEntry
.
getIndexBuffer
();
Mesh
::
MeshEntry
*
firstMeshEntry
=
mesh
->
getMeshEntry
(
firstMeshEntryIndex
);
QVector
<
unsigned
int
>
ib
=
firstMeshEntry
->
getIndexBuffer
();
qDebug
()
<<
"Index Buffer: "
<<
ib
;
return
;
//todo find adjacent triangles:
/*
QVector
<
Vertex
>
vb
=
firstMeshEntry
->
getVertexBuffer
();
//qDebug()<<"Vertex Buffer: "<<vb;
QVector
<
QVector
<
unsigned
int
>>
edgeIndices_base
;
for
(
int
i
=
0
;
i
<
ib
.
length
();
i
+=
3
){
//schaue alle dreiecke an
unsigned int x, y, z;
x_index = ib[i];
y_index = ib[i+1];
z_index = ib[i+2];
Vertex
x
,
y
,
z
;
unsigned
int
x_i
=
ib
[
i
];
unsigned
int
y_i
=
ib
[
i
+
1
];
unsigned
int
z_i
=
ib
[
i
+
2
];
x
=
vb
[
x_i
];
//todo maybe check array length
y
=
vb
[
y_i
];
z
=
vb
[
z_i
];
//get vertices x,y,z from vertex buffer
for
(
int
j
=
i
+
3
;
j
<
ib
.
length
();
j
+=
3
){
//search all following triangles for common edge
Vertex
a
,
b
,
c
;
unsigned
int
a_i
,
b_i
,
c_i
;
a_i
=
ib
[
j
];
b_i
=
ib
[
j
+
1
];
c_i
=
ib
[
j
+
2
];
a
_index = ib[j
];
b
_index = ib[j+1
];
c
_index = in[j+2
];
a
=
vb
[
a_i
];
b
=
vb
[
b_i
];
c
=
vb
[
c_i
];
//get vertices for a,b,c from vertex buffer
//comparisons: xy = ba, cb, ac.
//yz = ba, cb, ac
//zx = ba, cb, ac
//TODO if oder else if?
if
(
x
.
samePos
(
a
)
&&
y
.
samePos
(
c
)){
edgeIndices_base
.
push_back
(
fillVector
(
x_i
,
y_i
,
z_i
,
b_i
));
}
if
(
x
.
samePos
(
a
)
&&
z
.
samePos
(
b
)){
edgeIndices_base
.
push_back
(
fillVector
(
x_i
,
z_i
,
y_i
,
c_i
));
}
if
(
x
.
samePos
(
b
)
&&
y
.
samePos
(
a
)){
edgeIndices_base
.
push_back
(
fillVector
(
x_i
,
y_i
,
z_i
,
c_i
));
}
if
(
x
.
samePos
(
b
)
&&
z
.
samePos
(
c
)){
edgeIndices_base
.
push_back
(
fillVector
(
x_i
,
z_i
,
y_i
,
a_i
));
}
if
(
x
.
samePos
(
c
)
&&
y
.
samePos
(
b
)){
edgeIndices_base
.
push_back
(
fillVector
(
x_i
,
y_i
,
z_i
,
a_i
));
}
if
(
x
.
samePos
(
c
)
&&
z
.
samePos
(
a
)){
edgeIndices_base
.
push_back
(
fillVector
(
x_i
,
z_i
,
y_i
,
b_i
));
}
if
(
y
.
samePos
(
a
)
&&
z
.
samePos
(
c
)){
edgeIndices_base
.
push_back
(
fillVector
(
y_i
,
z_i
,
x_i
,
b_i
));
}
if
(
y
.
samePos
(
b
)
&&
z
.
samePos
(
a
)){
edgeIndices_base
.
push_back
(
fillVector
(
y_i
,
z_i
,
x_i
,
c_i
));
}
if
(
y
.
samePos
(
c
)
&&
z
.
samePos
(
b
)){
edgeIndices_base
.
push_back
(
fillVector
(
y_i
,
z_i
,
x_i
,
a_i
));
}
}
//quadratische Laufzeit ftw
}
//for xy
//for yz
//for zx
qDebug
()
<<
"Done with edge table. "
<<
edgeIndices_base
.
length
()
<<
" edges found. Table: "
<<
edgeIndices_base
;
if
(
true
){
qDebug
()
<<
"Table (long version):"
;
for
(
int
i
=
0
;
i
<
edgeIndices_base
.
length
();
i
++
){
qDebug
()
<<
"blub:"
<<
edgeIndices_base
[
i
];
}
}
*
* */
//TODO save/return edge table
}
void
Subdivision
::
runShader
(
Mesh
*
mesh
)
{
...
...
QTProject/subdivision.h
View file @
b3ed332c
...
...
@@ -22,6 +22,8 @@ private:
QOpenGLShaderProgram
*
initComputeShaderProgram
();
void
precomputeTables
(
Mesh
*
mesh
);
void
runShader
(
Mesh
*
mesh
);
QVector
<
unsigned
int
>
fillVector
(
unsigned
int
a
,
unsigned
int
b
,
unsigned
int
c
,
unsigned
int
d
);
};
#endif
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