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
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
85 additions
and
20 deletions
+85
-20
mesh.cpp
QTProject/mesh.cpp
+4
-0
mesh.h
QTProject/mesh.h
+8
-1
subdivision.cpp
QTProject/subdivision.cpp
+71
-19
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(){
...
@@ -195,6 +195,10 @@ QVector<unsigned int> Mesh::MeshEntry::getIndexBuffer(){
return
indices
;
return
indices
;
}
}
QVector
<
Vertex
>
Mesh
::
MeshEntry
::
getVertexBuffer
(){
return
vertices
;
}
void
Mesh
::
initNode
(
const
aiScene
*
scene
,
aiNode
*
node
,
Node
&
newNode
,
QString
debugoffset
){
void
Mesh
::
initNode
(
const
aiScene
*
scene
,
aiNode
*
node
,
Node
&
newNode
,
QString
debugoffset
){
newNode
.
name
=
node
->
mName
.
length
!=
0
?
node
->
mName
.
C_Str
()
:
""
;
newNode
.
name
=
node
->
mName
.
length
!=
0
?
node
->
mName
.
C_Str
()
:
""
;
newNode
.
transformation
=
QMatrix4x4
(
node
->
mTransformation
[
0
]);
newNode
.
transformation
=
QMatrix4x4
(
node
->
mTransformation
[
0
]);
...
...
QTProject/mesh.h
View file @
b3ed332c
...
@@ -28,6 +28,12 @@ struct Vertex
...
@@ -28,6 +28,12 @@ struct Vertex
this
->
tex
=
tex
;
this
->
tex
=
tex
;
this
->
normal
=
normal
;
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
);
QDebug
operator
<<
(
QDebug
d
,
const
Vertex
&
v
);
...
@@ -46,6 +52,8 @@ public:
...
@@ -46,6 +52,8 @@ public:
MeshEntry
();
MeshEntry
();
~
MeshEntry
();
~
MeshEntry
();
QVector
<
unsigned
int
>
getIndexBuffer
();
QVector
<
unsigned
int
>
getIndexBuffer
();
QVector
<
Vertex
>
getVertexBuffer
();
void
init
(
QOpenGLFunctions_4_3_Core
*
f
,
QVector
<
Vertex
>&
Vertices
,
void
init
(
QOpenGLFunctions_4_3_Core
*
f
,
QVector
<
Vertex
>&
Vertices
,
QVector
<
unsigned
int
>&
Indices
);
QVector
<
unsigned
int
>&
Indices
);
...
@@ -113,7 +121,6 @@ private:
...
@@ -113,7 +121,6 @@ private:
void
renderNode
(
QOpenGLShaderProgram
*
shader
,
Node
&
node
,
QMatrix4x4
V
,
QMatrix4x4
P
,
QMatrix4x4
M
);
void
renderNode
(
QOpenGLShaderProgram
*
shader
,
Node
&
node
,
QMatrix4x4
V
,
QMatrix4x4
P
,
QMatrix4x4
M
);
void
renderMesh
(
QOpenGLShaderProgram
*
shader
,
int
index
);
void
renderMesh
(
QOpenGLShaderProgram
*
shader
,
int
index
);
void
findObjectDimension
(
Node
node
,
QMatrix4x4
transform
,
QVector3D
&
min
,
QVector3D
&
max
);
void
findObjectDimension
(
Node
node
,
QMatrix4x4
transform
,
QVector3D
&
min
,
QVector3D
&
max
);
...
...
QTProject/subdivision.cpp
View file @
b3ed332c
...
@@ -14,6 +14,15 @@ void Subdivision::init() {
...
@@ -14,6 +14,15 @@ void Subdivision::init() {
shader
=
initComputeShaderProgram
();
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
(){
QOpenGLShaderProgram
*
Subdivision
::
initComputeShaderProgram
(){
QString
source
=
QLatin1String
(
":/subdivision.compute"
);
QString
source
=
QLatin1String
(
":/subdivision.compute"
);
...
@@ -55,43 +64,86 @@ void Subdivision::precomputeTables(Mesh *mesh) {
...
@@ -55,43 +64,86 @@ void Subdivision::precomputeTables(Mesh *mesh) {
qDebug
()
<<
"Mesh found. Index:"
<<
firstMeshEntryIndex
;
qDebug
()
<<
"Mesh found. Index:"
<<
firstMeshEntryIndex
;
//die drei zeilen machen das bild schwarz. wenn man davor returnt tuts.
//die drei zeilen machen das bild schwarz. wenn man davor returnt tuts.
Mesh
::
MeshEntry
firstMeshEntry
=
mesh
->
getMeshEntry
(
firstMeshEntryIndex
);
Mesh
::
MeshEntry
*
firstMeshEntry
=
mesh
->
getMeshEntry
(
firstMeshEntryIndex
);
QVector
<
unsigned
int
>
ib
=
firstMeshEntry
.
getIndexBuffer
();
QVector
<
unsigned
int
>
ib
=
firstMeshEntry
->
getIndexBuffer
();
qDebug
()
<<
"Index Buffer: "
<<
ib
;
qDebug
()
<<
"Index Buffer: "
<<
ib
;
return
;
QVector
<
Vertex
>
vb
=
firstMeshEntry
->
getVertexBuffer
();
//todo find adjacent triangles:
//qDebug()<<"Vertex Buffer: "<<vb;
/*
QVector
<
QVector
<
unsigned
int
>>
edgeIndices_base
;
for
(
int
i
=
0
;
i
<
ib
.
length
();
i
+=
3
){
for
(
int
i
=
0
;
i
<
ib
.
length
();
i
+=
3
){
//schaue alle dreiecke an
//schaue alle dreiecke an
unsigned int x, y, z;
Vertex
x
,
y
,
z
;
x_index = ib[i];
unsigned
int
x_i
=
ib
[
i
];
y_index = ib[i+1];
unsigned
int
y_i
=
ib
[
i
+
1
];
z_index = ib[i+2];
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
//get vertices x,y,z from vertex buffer
for
(
int
j
=
i
+
3
;
j
<
ib
.
length
();
j
+=
3
){
for
(
int
j
=
i
+
3
;
j
<
ib
.
length
();
j
+=
3
){
//search all following triangles for common edge
//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
];
a
=
vb
[
a_i
];
b
_index = ib[j+1
];
b
=
vb
[
b_i
];
c
_index = in[j+2
];
c
=
vb
[
c_i
];
//get vertices for a,b,c from vertex buffer
//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
));
}
//for xy
if
(
y
.
samePos
(
a
)
&&
z
.
samePos
(
c
)){
edgeIndices_base
.
push_back
(
fillVector
(
y_i
,
z_i
,
x_i
,
b_i
));
//for yz
}
if
(
y
.
samePos
(
b
)
&&
z
.
samePos
(
a
)){
//for zx
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
}
}
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
)
{
void
Subdivision
::
runShader
(
Mesh
*
mesh
)
{
...
...
QTProject/subdivision.h
View file @
b3ed332c
...
@@ -22,6 +22,8 @@ private:
...
@@ -22,6 +22,8 @@ private:
QOpenGLShaderProgram
*
initComputeShaderProgram
();
QOpenGLShaderProgram
*
initComputeShaderProgram
();
void
precomputeTables
(
Mesh
*
mesh
);
void
precomputeTables
(
Mesh
*
mesh
);
void
runShader
(
Mesh
*
mesh
);
void
runShader
(
Mesh
*
mesh
);
QVector
<
unsigned
int
>
fillVector
(
unsigned
int
a
,
unsigned
int
b
,
unsigned
int
c
,
unsigned
int
d
);
};
};
#endif
#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