void OSGViewerWidget::saveCameraParameters(void) { MainWindow* main_window = MainWindow::getInstance(); QString filename = QFileDialog::getSaveFileName(main_window, "Save Camera Parameters", main_window->getWorkspace(), "Camera Paramters(*.txt)"); if (filename.isEmpty()) return; filename = QFileInfo(filename).path() + "/" + QFileInfo(filename).baseName(); osg::Vec3 eye, center, up; getCamera()->getViewMatrixAsLookAt(eye, center, up); QFile txt_file(filename+".txt"); txt_file.open(QIODevice::WriteOnly | QIODevice::Text); QTextStream txt_file_stream(&txt_file); txt_file_stream << eye.x() << " " << eye.y() << " " << eye.z() << "\n"; txt_file_stream << center.x() << " " << center.y() << " " << center.z() << "\n"; txt_file_stream << up.x() << " " << up.y() << " " << up.z() << "\n"; QFile inc_file(filename+".inc"); inc_file.open(QIODevice::WriteOnly | QIODevice::Text); QTextStream inc_file_stream(&inc_file); inc_file_stream << QString("\tcamera\n\t{\n\t perspective\n\t up -y\n\t right x*image_width/image_height\n\t %1\t %2\t %3\t}\n") .arg(QString(" location <%1, %2, %3>\n").arg(eye[0]).arg(eye[1]).arg(eye[2])) .arg(QString(" sky <%1, %2, %3>\n").arg(up[0]).arg(up[1]).arg(up[2])) .arg(QString(" look_at <%1, %2, %3>\n").arg(center[0]).arg(center[1]).arg(center[2])); return; }
static void fq_ok_plus(Button *b) { inc_file(); mb_gclose_ok(b); }