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
b0186557
Commit
b0186557
authored
Sep 27, 2016
by
Philipp Adolf
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move irregular vertices for drawing
parent
9b2e2969
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
56 additions
and
1 deletion
+56
-1
subdivision.cpp
QTProject/subdivision.cpp
+54
-1
subdivision.h
QTProject/subdivision.h
+2
-0
No files found.
QTProject/subdivision.cpp
View file @
b0186557
...
@@ -1041,5 +1041,58 @@ void Subdivision::runEdgeShader(GLuint size, GLuint vb_handle, GLuint edge_indic
...
@@ -1041,5 +1041,58 @@ void Subdivision::runEdgeShader(GLuint size, GLuint vb_handle, GLuint edge_indic
}
}
void
Subdivision
::
updateIrregularForDraw
(
const
QVector
<
Triangle
>
&
triangles
,
QMap
<
Triangle
,
Triangle
::
Neighbors
>
&
neighbors
,
Result
&
result
){
void
Subdivision
::
updateIrregularForDraw
(
const
QVector
<
Triangle
>
&
triangles
,
QMap
<
Triangle
,
Triangle
::
Neighbors
>
&
neighbors
,
Result
&
result
){
result
.
vertex_buffer_irregular
=
result
.
vertex_buffer
;
result
.
vertex_buffer_irregular
.
resize
(
result
.
vertex_buffer
.
size
());
QVectorIterator
<
Triangle
>
it
(
triangles
);
while
(
it
.
hasNext
())
{
Triangle
triangle
=
it
.
next
();
result
.
vertex_buffer_irregular
[
triangle
.
u_idx
()]
=
result
.
vertex_buffer
.
at
(
triangle
.
u_idx
());
result
.
vertex_buffer_irregular
[
triangle
.
v_idx
()]
=
result
.
vertex_buffer
.
at
(
triangle
.
v_idx
());
result
.
vertex_buffer_irregular
[
triangle
.
w_idx
()]
=
result
.
vertex_buffer
.
at
(
triangle
.
w_idx
());
Triangle
::
Neighbors
ns
=
neighbors
.
value
(
triangle
);
result
.
vertex_buffer_irregular
[
triangle
.
u_idx
()].
pos
=
updateIrregularVertexForDraw
(
triangle
.
u
(),
vertexNeighbors
(
triangle
,
ns
.
uv
,
neighbors
));
result
.
vertex_buffer_irregular
[
triangle
.
v_idx
()].
pos
=
updateIrregularVertexForDraw
(
triangle
.
v
(),
vertexNeighbors
(
triangle
,
ns
.
vw
,
neighbors
));
result
.
vertex_buffer_irregular
[
triangle
.
w_idx
()].
pos
=
updateIrregularVertexForDraw
(
triangle
.
w
(),
vertexNeighbors
(
triangle
,
ns
.
wu
,
neighbors
));
}
}
bool
Subdivision
::
containsVertex
(
QVector
<
Vertex
>
&
vertices
,
Vertex
vertex
)
{
for
(
int
i
=
0
;
i
<
vertices
.
length
();
i
++
)
{
if
(
vertex
.
samePos
(
vertices
[
i
]))
{
return
true
;
}
}
return
false
;
}
QVector3D
Subdivision
::
updateIrregularVertexForDraw
(
Vertex
currentCorner
,
QVector
<
Triangle
>
neighboring_triangles
)
{
QVector
<
Vertex
>
surroundingVertex
;
QVectorIterator
<
Triangle
>
extra
(
neighboring_triangles
);
while
(
extra
.
hasNext
())
{
Triangle
extra_triangle
=
extra
.
next
();
if
(
!
currentCorner
.
samePos
(
extra_triangle
.
u
())
&&
!
containsVertex
(
surroundingVertex
,
extra_triangle
.
u
()))
surroundingVertex
.
push_back
(
extra_triangle
.
u
());
if
(
!
currentCorner
.
samePos
(
extra_triangle
.
v
())
&&
!
containsVertex
(
surroundingVertex
,
extra_triangle
.
v
()))
surroundingVertex
.
push_back
(
extra_triangle
.
v
());
if
(
!
currentCorner
.
samePos
(
extra_triangle
.
w
())
&&
!
containsVertex
(
surroundingVertex
,
extra_triangle
.
w
()))
surroundingVertex
.
push_back
(
extra_triangle
.
w
());
}
QVector3D
newPos
(
0.0
,
0.0
,
0.0
);
double
n
=
surroundingVertex
.
length
();
double
a
=
5.0
/
8.0
-
pow
((
3.0
/
8.0
+
2.0
/
8.0
*
cos
(
2.0
*
M_PI
/
n
)),
2.0
);
double
omega
=
3.0
*
n
/
(
8.0
*
a
);
for
(
int
i
=
0
;
i
<
surroundingVertex
.
length
();
i
++
)
{
newPos
+=
surroundingVertex
[
i
].
pos
;
}
newPos
*=
1.0
/
(
omega
+
n
);
newPos
+=
omega
/
(
omega
+
n
)
*
currentCorner
.
pos
;
return
newPos
;
}
}
QTProject/subdivision.h
View file @
b0186557
...
@@ -71,6 +71,8 @@ private:
...
@@ -71,6 +71,8 @@ private:
void
runVertexShader
(
GLuint
size
,
GLuint
vb_handle
,
GLuint
vertex_indices_handle
,
GLuint
vertex_offsets_handle
,
GLuint
output_handle
,
GLuint
offset_handle
);
void
runVertexShader
(
GLuint
size
,
GLuint
vb_handle
,
GLuint
vertex_indices_handle
,
GLuint
vertex_offsets_handle
,
GLuint
output_handle
,
GLuint
offset_handle
);
void
runEdgeShader
(
GLuint
size
,
GLuint
vb_handle
,
GLuint
edge_indices_handle
,
GLuint
output_handle
,
GLuint
offset_handle
);
void
runEdgeShader
(
GLuint
size
,
GLuint
vb_handle
,
GLuint
edge_indices_handle
,
GLuint
output_handle
,
GLuint
offset_handle
);
void
updateIrregularForDraw
(
const
QVector
<
Triangle
>
&
triangles
,
QMap
<
Triangle
,
Triangle
::
Neighbors
>
&
neighbors
,
Result
&
result
);
void
updateIrregularForDraw
(
const
QVector
<
Triangle
>
&
triangles
,
QMap
<
Triangle
,
Triangle
::
Neighbors
>
&
neighbors
,
Result
&
result
);
bool
containsVertex
(
QVector
<
Vertex
>
&
vertices
,
Vertex
vertex
);
QVector3D
updateIrregularVertexForDraw
(
Vertex
currentCorner
,
QVector
<
Triangle
>
neighboring_triangles
);
QVector
<
unsigned
int
>
patchIBToTriangleIB
(
QVector
<
unsigned
int
>
ib
);
QVector
<
unsigned
int
>
patchIBToTriangleIB
(
QVector
<
unsigned
int
>
ib
);
...
...
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