//Format: first two entries: edge vertices. last two entries: distant 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
Triangletriangle=triangles[i];
Vertexx,y,z;
unsignedintx_i=ib[i];
unsignedinty_i=ib[i+1];
unsignedintz_i=ib[i+2];
unsignedintx_i=triangle.u_idx();
unsignedinty_i=triangle.v_idx();
unsignedintz_i=triangle.w_idx();
//get vertices x,y,z from vertex buffer
x=vb[x_i];//todo maybe check array length
y=vb[y_i];
z=vb[z_i];
x=triangle.u();
y=triangle.v();
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.
qWarning()<<"Could not find all indices for edge points at ib "<<i<<". Keep old triangle.";
}
//keep old, unsubdivided triangle.
tables.index_buffer.push_back(ib[i]);
tables.index_buffer.push_back(ib[i+1]);
tables.index_buffer.push_back(ib[i+2]);
tables.index_buffer.push_back(x_i);
tables.index_buffer.push_back(y_i);
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.