//Format: first two entries: edge vertices. last two entries: distant vertices.
//Format: first two entries: edge vertices. last two entries: distant vertices.
unsignedintnib_offset=vb.length();//offset in new index buffer for edge vertices
unsignedintnib_offset=vb.length();//offset in new index buffer for edge vertices
for(inti=0;i<ib.length();i+=3){
for(inti=0;i<triangles.length();i++){
//schaue alle dreiecke an
//schaue alle dreiecke an
Triangletriangle=triangles[i];
Vertexx,y,z;
Vertexx,y,z;
unsignedintx_i=ib[i];
unsignedintx_i=triangle.u_idx();
unsignedinty_i=ib[i+1];
unsignedinty_i=triangle.v_idx();
unsignedintz_i=ib[i+2];
unsignedintz_i=triangle.w_idx();
//get vertices x,y,z from vertex buffer
//get vertices x,y,z from vertex buffer
x=vb[x_i];//todo maybe check array length
x=triangle.u();
y=vb[y_i];
y=triangle.v();
z=vb[z_i];
z=triangle.w();
QVector<unsignedint>edge_indices_buffer;//push all edge indices into this, then check if enough edge indices were found. if yes, copy to Tables and add to new index buffer.
QVector<unsignedint>edge_indices_buffer;//push all edge indices into this, then check if enough edge indices were found. if yes, copy to Tables and add to new index buffer.
qWarning()<<"Could not find all indices for edge points at ib "<<i<<". Keep old triangle.";
qWarning()<<"Could not find all indices for edge points at ib "<<i<<". Keep old triangle.";
}
}
//keep old, unsubdivided triangle.
//keep old, unsubdivided triangle.
tables.index_buffer.push_back(ib[i]);
tables.index_buffer.push_back(x_i);
tables.index_buffer.push_back(ib[i+1]);
tables.index_buffer.push_back(y_i);
tables.index_buffer.push_back(ib[i+2]);
tables.index_buffer.push_back(z_i);
}
}
//Wichtig: Wir gehen davon aus, dass wir geschlossene Oberflächen haben, dh für jede Kante von einem Dreieck wird eine passende Kante bei einem anderen Dreieck gefunden.
//Wichtig: Wir gehen davon aus, dass wir geschlossene Oberflächen haben, dh für jede Kante von einem Dreieck wird eine passende Kante bei einem anderen Dreieck gefunden.