Skip to content

Commit

Permalink
v1.9 Beta add GUI button to render model
Browse files Browse the repository at this point in the history
  • Loading branch information
SoulBasic committed Oct 30, 2020
1 parent 76d61fc commit a000d45
Show file tree
Hide file tree
Showing 20 changed files with 418 additions and 124 deletions.
17 changes: 15 additions & 2 deletions J3DEngine/transtest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -457,9 +457,10 @@ void MsgProc(UINT msg, WPARAM wp, LPARAM lp)


if (status == EXIT_SUCCESS) {
string cmdt = "osgcv.dll " + textureMeshWorkingDir + "/TEXTURE_Mesh.obj " + textureMeshWorkingDir + "/TEXTURE_Mesh.osgb";

if (isOsgb)
{
string cmdt = "osgcv.dll " + textureMeshWorkingDir + "/TEXTURE_Mesh.obj " + textureMeshWorkingDir + "/TEXTURE_Mesh.osgb";
::system(cmdt.c_str());
}
Global::process = PROCESSCLOSE;
Expand Down Expand Up @@ -785,6 +786,14 @@ void MsgProc(UINT msg, WPARAM wp, LPARAM lp)
break;
}
Sleep(5000);

bool isOsgb = false;

if ("osgb" == exportFormat)
{
exportFormat = "obj";
isOsgb = true;
}
char* cmd2[9];
char t2[200];
GetModuleFileNameA(NULL, t2, 200);
Expand All @@ -803,7 +812,11 @@ void MsgProc(UINT msg, WPARAM wp, LPARAM lp)
printf("任务失败,请检查路径和文件是否正确\n");
break;
}

if (isOsgb)
{
string cmdt = "osgcv.dll " + textureMeshWorkingDir + "/TEXTURE_Mesh.obj " + textureMeshWorkingDir + "/TEXTURE_Mesh.osgb";
::system(cmdt.c_str());
}
Global::process = PROCESSCLOSE;
}
}
Expand Down
Binary file modified J3DEngine/x64/Release/Global.obj
Binary file not shown.
Binary file modified J3DEngine/x64/Release/transtest.obj
Binary file not shown.
Binary file modified J3DEngine/x64/Release/vc141.pdb
Binary file not shown.
121 changes: 108 additions & 13 deletions J3DGUI/QT3DReconstruction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ void QT3DReconstruction::timerSlot()
Global::connectEngine();
if (ui.label_engine->text() != u8"成功连接到J3DEngine ")
{
ui.textBrowser->insertPlainText(u8"与J3DEngine成功建立连接\n");
QPalette pa;
pa.setColor(QPalette::WindowText, Qt::green);
ui.label_engine->setPalette(pa);
Expand All @@ -95,7 +94,6 @@ void QT3DReconstruction::timerSlot()
{
if (ui.label_engine->text() != u8"未连接到J3DEngine ")
{
ui.textBrowser->insertPlainText(u8"与J3DEngine失去连接,之后将重新尝试连接\n");
QPalette pa;
pa.setColor(QPalette::WindowText, Qt::red);
ui.label_engine->setPalette(pa);
Expand Down Expand Up @@ -309,8 +307,8 @@ void QT3DReconstruction::on_action_triggered() //textureMesh

void QT3DReconstruction::on_actionopen_mvs_file_triggered()
{
QString fileName = QFileDialog::getOpenFileName(NULL, "ViewJ3D", ".",
"J3D Model Format(*.J3D);;Stanford Polygon File Format(*.ply);;Alias Wavefront Object(*.obj);;All Files(*.*)");
QString fileName = QFileDialog::getOpenFileName(NULL, "ViewJ3D", ".",
"J3D Model Format(*.J3D);;Stanford Polygon File Format(*.ply);;Alias Wavefront Object(*.obj);;All Files(*.*)");
if (fileName == "")
{
QMessageBox::information(NULL, u8"失败", u8"打开J3D文件失败,请检查路径是否正确 ", QMessageBox::Ok, QMessageBox::Ok);
Expand Down Expand Up @@ -339,7 +337,7 @@ bool QT3DReconstruction::openView(QString fileName)
cmd[1] = "-k";
cmd[2] = "2324";
cmd[3] = "-i";
cmd[4] = const_cast<char*>(fileName.toStdString().c_str());
cmd[4] = fileName.toStdString().c_str();
LPCTSTR* l = cmd;

if (!InitializeViewer(5, l))
Expand All @@ -366,6 +364,7 @@ bool QT3DReconstruction::openView(QString fileName)
J3DViewer->window.SetVisible(true);
// enter viewer loop
J3DViewerAva = true;
J3DFile = Jutil::SparseFileName(fileName.toStdString());
J3DViewer->Loop();
FinalizeViewer();
return true;
Expand All @@ -376,8 +375,8 @@ bool QT3DReconstruction::openView(QString fileName)
bool QT3DReconstruction::InitializeViewer(size_t argc, LPCTSTR* argv)
{
// initialize log and console
//OPEN_LOG();
//OPEN_LOGCONSOLE();
OPEN_LOG();
OPEN_LOGCONSOLE();

// group of options allowed only on command line
boost::program_options::options_description generic("Generic options");
Expand Down Expand Up @@ -515,8 +514,8 @@ void QT3DReconstruction::FinalizeViewer()

if (OPT::bLogFile)
CLOSE_LOGFILE();
//CLOSE_LOGCONSOLE();
//CLOSE_LOG();
CLOSE_LOGCONSOLE();
CLOSE_LOG();
}

void QT3DReconstruction::on_action_fullauto_triggered()
Expand All @@ -526,9 +525,9 @@ void QT3DReconstruction::on_action_fullauto_triggered()

void QT3DReconstruction::on_action_2_triggered()
{
QString fileName = QFileDialog::getOpenFileName(NULL,
"ViewJ3D", ".",
"J3D Model Format(*.J3D);;Stanford Polygon File Format(*.ply);;Alias Wavefront Object(*.obj);;OpenSceneGraph(*.osg);;OpenSceneGraph Binary(*.osgb);;All Files(*.*)");
QString fileName = QFileDialog::getOpenFileName(NULL,
"ViewJ3D", ".",
"J3D Model Format(*.J3D);;Stanford Polygon File Format(*.ply);;Alias Wavefront Object(*.obj);;OpenSceneGraph(*.osg);;OpenSceneGraph Binary(*.osgb);;All Files(*.*)");
if (fileName == "")
{
QMessageBox::information(NULL, u8"失败", u8"打开J3D文件失败,请检查路径是否正确 ", QMessageBox::Ok, QMessageBox::Ok);
Expand Down Expand Up @@ -592,7 +591,7 @@ bool QT3DReconstruction::openViewCompatibility(QString fileName, bool isOSG)
PROCESS_INFORMATION pi;
si.dwFlags = STARTF_USESHOWWINDOW;
si.wShowWindow = true;

if (!CreateProcess(
NULL,
(LPSTR)cmd.toStdString().c_str(),
Expand All @@ -617,3 +616,99 @@ void QT3DReconstruction::closeEvent(QCloseEvent *event)
WinExec("taskkill /f /im J3DView.dll", SW_HIDE);
QMainWindow::closeEvent(event);
}

void QT3DReconstruction::on_pushButton_camera_clicked()
{
if (!J3DViewerAva)return;
J3DViewer->window.Key(GLFW_KEY_C, NULL, GLFW_RELEASE, 0);
}

void QT3DReconstruction::on_pushButton_pointcloud_clicked()
{
if (!J3DViewerAva)return;
J3DViewer->window.Key(GLFW_KEY_P, NULL, GLFW_RELEASE, 0);
}

void QT3DReconstruction::on_pushButton_mesh_clicked()
{
if (!J3DViewerAva)return;
J3DViewer->window.Key(GLFW_KEY_M, NULL, GLFW_RELEASE, 0);
}

void QT3DReconstruction::on_pushButton_texture_clicked()
{
if (!J3DViewerAva)return;
J3DViewer->window.Key(GLFW_KEY_T, NULL, GLFW_RELEASE, 0);
}
void QT3DReconstruction::on_pushButton_pointplus_clicked()
{
if (!J3DViewerAva)return;
J3DViewer->window.Key(GLFW_KEY_UP, NULL, GLFW_RELEASE, 0);
}

void QT3DReconstruction::on_pushButton_pointsub_clicked()
{
if (!J3DViewerAva)return;
J3DViewer->window.Key(GLFW_KEY_DOWN, NULL, GLFW_RELEASE, 0);
}

void QT3DReconstruction::on_pushButton_pointnumplus_clicked()
{
if (!J3DViewerAva)return;
J3DViewer->window.Key(GLFW_KEY_DOWN, NULL, GLFW_RELEASE, GLFW_PRESS);
}

void QT3DReconstruction::on_pushButton_pointnumsub_clicked()
{
if (!J3DViewerAva)return;
J3DViewer->window.Key(GLFW_KEY_UP, NULL, GLFW_RELEASE, GLFW_PRESS);
}

void QT3DReconstruction::on_pushButton_viewportplus_clicked()
{
if (!J3DViewerAva)return;
J3DViewer->window.Key(GLFW_KEY_LEFT, NULL, GLFW_RELEASE, 0);
}

void QT3DReconstruction::on_pushButton_viewportsub_clicked()
{
if (!J3DViewerAva)return;
J3DViewer->window.Key(GLFW_KEY_RIGHT, NULL, GLFW_RELEASE, 0);
}

void QT3DReconstruction::on_pushButton_export_clicked()
{
if (!J3DViewerAva)
{
QMessageBox::information(NULL, u8"失败", u8"请先加载J3D模型 ", QMessageBox::Ok, QMessageBox::Ok);
return;
}

string type = "." + ui.comboBox->currentText().toStdString();
bool isOsgb = false;
if (".osgb" == type)
{
type = ".obj";
isOsgb = true;
}
string temp = J3DFile.getDir() + "/"+ J3DFile.getFrontName() + "_export" + type;
cout << "temp=" << temp << endl;
cout << temp.c_str() << endl;
J3DViewer->Export(temp.c_str(), type.c_str(), false, true);

if (isOsgb)
{
string temp1 = J3DFile.getDir() + "/" + J3DFile.getFrontName() + "_export.osgb";
converseType(temp.c_str(), temp1.c_str());
}

QMessageBox::information(NULL, u8"完成", u8"成功输出文件", QMessageBox::Ok, QMessageBox::Ok);
}


bool QT3DReconstruction::converseType(QString fileNameSrc, QString fileNameDes)
{
QString cmd = "osgcv.dll " + fileNameSrc + " "+ fileNameDes;
::system(cmd.toStdString().c_str());
return true;
}
25 changes: 24 additions & 1 deletion J3DGUI/QT3DReconstruction.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class QT3DReconstruction : public QMainWindow
bool openView(QString fileName);
bool openViewCompatibility(QString fileName, bool isOSG);
bool openViewCompatibility(QString fileName);
bool converseType(QString fileNameSrc, QString fileNameDes);
private slots:

void on_actionMatchFeature_triggered();
Expand Down Expand Up @@ -76,6 +77,28 @@ private slots:

void on_action_2_triggered();

void on_pushButton_camera_clicked();

void on_pushButton_pointcloud_clicked();

void on_pushButton_mesh_clicked();

void on_pushButton_texture_clicked();

void on_pushButton_pointplus_clicked();

void on_pushButton_pointsub_clicked();

void on_pushButton_pointnumplus_clicked();

void on_pushButton_pointnumsub_clicked();

void on_pushButton_viewportplus_clicked();

void on_pushButton_viewportsub_clicked();

void on_pushButton_export_clicked();

private:

Ui::QT3DReconstructionClass ui;
Expand All @@ -91,7 +114,7 @@ private slots:
QTimer* timer;
VIEWER::Scene* J3DViewer;
bool J3DViewerAva;

Jutil::SparseFileName J3DFile;
void closeEvent(QCloseEvent *event);
protected:

Expand Down
2 changes: 1 addition & 1 deletion J3DGUI/QT3DReconstruction.pro.user
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 4.11.1, 2020-10-28T15:06:04. -->
<!-- Written by QtCreator 4.11.1, 2020-10-30T16:11:47. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
Expand Down
Loading

0 comments on commit a000d45

Please sign in to comment.