Commit 04d2f796 by Alisa Jung

finished index table for vertex points

parent b3ed332c
......@@ -71,7 +71,8 @@ void Subdivision::precomputeTables(Mesh *mesh) {
QVector<Vertex> vb = firstMeshEntry->getVertexBuffer();
//qDebug()<<"Vertex Buffer: "<<vb;
//compute edge table
//Format: first two entries: edge vertices. last two entries: distant vertices.
QVector<QVector<unsigned int>> edgeIndices_base;
for (int i = 0; i < ib.length(); i+=3){
......@@ -144,6 +145,85 @@ void Subdivision::precomputeTables(Mesh *mesh) {
}
//TODO save/return edge table
//compute vertex table
//Format: First entry: original vertex. Other entries: adjacent vertices.
QVector<QVector<unsigned int>> vertexIndices_base;
QVector<QVector<unsigned int>> duplicates;//for debugging
for (unsigned int i = 0; i < vb.length(); i++){
//hat evtl viel redundanz
QVector<unsigned int> adjacent_indices;
QVector<Vertex> adj_v;//helfer
adjacent_indices.push_back(i);
Vertex originalVertex = vb[i];
QVector<unsigned int> d;
for (int j = 0; j < ib.length(); j++){
if (j == 31 && i == 0){
qDebug()<<"j is 31, i is 0: ";
}
//suche verweise auf vertex im indexbuffer
if (vb[ib[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];
} else if(j%3==1){
i1 = ib[j+1];
i2 = ib[j-1];
} else{
i1 = ib[j-1];
i2 = ib[j-2];
}
if (j == 31 && i == 0){
qDebug()<<"i1: "<<i1<<", i2: "<<i2;
}
Vertex v1,v2; //neighbour vertices;
v1 = vb[i1];
v2 = vb[i2];
//check if vertices where already used
//Note: Can't use contain. Contain uses equal (would have to implement equal, but we're only interested in the position here.
bool found1 = false;
bool found2 = false;
for (int k = 0; k < adj_v.length(); k++){
if (adj_v[k].samePos(v1)) found1 = true;
if(adj_v[k].samePos(v2)) found2 = true;
}
if (!found1){
adj_v.push_back(v1);
adjacent_indices.push_back(i1);
}
if (!found2){
adj_v.push_back(v2);
adjacent_indices.push_back(i2);
}
//if one adjacent vertex is referenced by multiple different indices, only its first index will appear in the adjacent_indices list.1
}
}
vertexIndices_base.push_back(adjacent_indices);
if (!duplicates.contains(d)) duplicates.push_back(d);
}
qDebug()<<"Done with vertex index table. "<<vertexIndices_base.length()<<" vertices processed. Table:";
for(int i = 0; i < vertexIndices_base.length(); i++){
qDebug()<<vertexIndices_base[i];
}
qDebug()<<"Duplicates: ";
for (int i = 0; i < duplicates.length(); i++){
qDebug()<<duplicates[i];
}
}
void Subdivision::runShader(Mesh *mesh) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment