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
182c5e2e
Commit
182c5e2e
authored
Aug 18, 2016
by
Philipp Adolf
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Split triangles after subdivision
parent
0f5dfb05
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
13 deletions
+34
-13
mesh.cpp
QTProject/mesh.cpp
+19
-8
mesh.h
QTProject/mesh.h
+3
-3
subdivision.cpp
QTProject/subdivision.cpp
+12
-2
No files found.
QTProject/mesh.cpp
View file @
182c5e2e
...
...
@@ -50,25 +50,36 @@ void Mesh::SubdivEntry::updateIndices() {
}
void
Mesh
::
SubdivEntry
::
init
(
QOpenGLFunctions_4_3_Core
*
f
,
QVector
<
Vertex
>&
Vertices
,
QVector
<
unsigned
int
>&
Indices
){
QVector
<
unsigned
int
>&
Indices
_irregular
){
f
->
glGenBuffers
(
1
,
&
VB_handle
);
f
->
glBindBuffer
(
GL_ARRAY_BUFFER
,
VB_handle
);
f
->
glBufferData
(
GL_ARRAY_BUFFER
,
sizeof
(
Vertex
)
*
Vertices
.
size
(),
&
Vertices
[
0
],
GL_STATIC_DRAW
);
this
->
init
(
f
,
VB_handle
,
Vertices
,
Indices
);
QVector
<
unsigned
int
>
patches
;
this
->
init
(
f
,
VB_handle
,
Vertices
,
Indices_irregular
,
patches
);
}
void
Mesh
::
SubdivEntry
::
init
(
QOpenGLFunctions_4_3_Core
*
f
,
GLuint
VB_handle
,
QVector
<
Vertex
>&
Vertices
,
QVector
<
unsigned
int
>&
Indices
){
void
Mesh
::
SubdivEntry
::
init
(
QOpenGLFunctions_4_3_Core
*
f
,
GLuint
VB_handle
,
QVector
<
Vertex
>&
Vertices
,
QVector
<
unsigned
int
>&
Indices
_irregular
,
QVector
<
unsigned
int
>&
patches
){
this
->
f
=
f
;
this
->
VB_handle
=
VB_handle
;
vertices
=
Vertices
;
indices
=
Indices
;
indices
=
Indices_irregular
;
indicesRegular
=
patches
;
qDebug
()
<<
"Vertices"
<<
vertices
.
length
();
qDebug
()
<<
"Indices irregular"
<<
indices
.
length
();
qDebug
()
<<
"Indices patches"
<<
patches
.
length
();
f
->
glGenBuffers
(
1
,
&
IB_handle
);
f
->
glBindBuffer
(
GL_ELEMENT_ARRAY_BUFFER
,
IB_handle
);
f
->
glBufferData
(
GL_ELEMENT_ARRAY_BUFFER
,
sizeof
(
unsigned
int
)
*
Indices
.
size
(),
&
Indices
[
0
],
GL_STATIC_DRAW
);
f
->
glBufferData
(
GL_ELEMENT_ARRAY_BUFFER
,
sizeof
(
unsigned
int
)
*
indices
.
size
(),
&
indices
[
0
],
GL_STATIC_DRAW
);
f
->
glGenBuffers
(
1
,
&
IB_Regular
);
f
->
glBindBuffer
(
GL_ELEMENT_ARRAY_BUFFER
,
IB_Regular
);
f
->
glBufferData
(
GL_ELEMENT_ARRAY_BUFFER
,
sizeof
(
unsigned
int
)
*
patches
.
size
(),
&
patches
[
0
],
GL_STATIC_DRAW
);
}
...
...
@@ -103,10 +114,10 @@ void Mesh::MeshEntry::init(QOpenGLFunctions_4_3_Core *f,QVector<Vertex>& Vertice
}
}
void
Mesh
::
MeshEntry
::
update
(
GLuint
VB
,
QVector
<
Vertex
>&
Vertices
,
QVector
<
unsigned
int
>&
Indices
)
{
void
Mesh
::
MeshEntry
::
update
(
GLuint
VB
_handle
,
QVector
<
Vertex
>&
Vertices
,
QVector
<
unsigned
int
>&
Indices_irregular
,
QVector
<
unsigned
int
>&
patches
)
{
SubdivEntry
*
entry
=
new
SubdivEntry
;
buffers
.
push_back
(
std
::
shared_ptr
<
SubdivEntry
>
(
entry
));
entry
->
init
(
f
,
VB
,
Vertices
,
Indic
es
);
entry
->
init
(
f
,
VB_handle
,
Vertices
,
Indices_irregular
,
patch
es
);
}
Mesh
::
MeshEntry
::~
MeshEntry
()
...
...
QTProject/mesh.h
View file @
182c5e2e
...
...
@@ -70,9 +70,9 @@ public:
QOpenGLFunctions_4_3_Core
*
f
;
void
init
(
QOpenGLFunctions_4_3_Core
*
f
,
QVector
<
Vertex
>&
Vertices
,
QVector
<
unsigned
int
>&
Indices
);
QVector
<
unsigned
int
>&
Indices
_irregular
);
void
init
(
QOpenGLFunctions_4_3_Core
*
f
,
GLuint
VB_handle
,
QVector
<
Vertex
>&
Vertices
,
QVector
<
unsigned
int
>&
Indices
);
QVector
<
unsigned
int
>&
Indices
_irregular
,
QVector
<
unsigned
int
>&
patches
);
void
addRegular
(
QVector
<
unsigned
int
>&
Indices
);
void
updateIndices
();
};
...
...
@@ -84,7 +84,7 @@ public:
void
init
(
QOpenGLFunctions_4_3_Core
*
f
,
QVector
<
Vertex
>&
Vertices
,
QVector
<
unsigned
int
>&
Indices
);
void
update
(
GLuint
VB_handle
,
QVector
<
Vertex
>&
Vertices
,
QVector
<
unsigned
int
>&
Indic
es
);
void
update
(
GLuint
VB_handle
,
QVector
<
Vertex
>&
Vertices
,
QVector
<
unsigned
int
>&
Indices_irregular
,
QVector
<
unsigned
int
>&
patch
es
);
QString
name
;
...
...
QTProject/subdivision.cpp
View file @
182c5e2e
...
...
@@ -74,8 +74,18 @@ void Subdivision::subdivide(Mesh *mesh, int level) {
Tables
tables
=
precomputeTables
(
input
);
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
);
QVector
<
unsigned
int
>
regular
;
QVector
<
unsigned
int
>
irregular
;
findRegular
(
tables
.
index_buffer
,
result
.
vertex_buffer
,
regular
,
irregular
);
qDebug
()
<<
"Indices"
<<
tables
.
index_buffer
.
length
();
qDebug
()
<<
"regular"
<<
regular
.
length
();
qDebug
()
<<
"irregular"
<<
irregular
.
length
();
QVector
<
unsigned
int
>
patches
=
getPatchIndexBuffer
(
regular
);
qDebug
()
<<
"patches"
<<
patches
.
length
();
current_mesh
->
update
(
result
.
vb_handle
,
result
.
vertex_buffer
,
irregular
,
patches
);
//return new Mesh(f, mesh, result.vertex_buffer, tables.index_buffer);
}
...
...
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