void MainWindow::on_pushButton_released() { QFile file("rule.file"); if(file.open(QIODevice::WriteOnly | QIODevice::Truncate)){ QTextStream out(&file); out << ui->textEdit->toPlainText(); out.flush(); file.close(); } Model new_m; material_map.clear(); readMtl("default.mtl", true); errors.clear(); parseFile("rule.file", new_m); //printf("Errors : %ld\n", errors.size()); if(errors.size() > 0){ new_m.faces.clear(); std::string all; for(size_t i = 0; i < errors.size(); i++){ all += errors[i]; all += "\n"; } QString str = QString::fromStdString(all); text->setText(str); err->show(); } BBox scope; getBBox(new_m, scope); translate(new_m, -(scope.max.x + scope.min.x)/2.0, -(scope.max.x + scope.min.x)/2.0, -(scope.max.x + scope.min.x)/2.0); model_size = std::max(std::max(scope.max.y - scope.min.y, scope.max.x - scope.min.x), scope.max.z - scope.min.z); //scale(new_m, 1.0/model_size, 1.0/model_size, 1.0/model_size); //scaleTextures(new_m); sortFacesByMaterial(new_m); m = new_m; update_model = true; }
void mesh3DS::buildMesh(){ calculateNormals(); sortFacesByMaterial(); }