Skip to content

Commit

Permalink
Add support for rendering OBJ models inside the Qt-OpenGL visualization.
Browse files Browse the repository at this point in the history
This commit introduces the following changes:
1. Moves the basic Qt-OpenGL models (box, cylinder, light) into the parent directory
2. Updates the CMakeLists to reflect the changes in ilpincy#1 and to install any files in the src/plugins/simulator/visualizations/qt-opengl/models/ directory following the same
scheme as the icons and textures.
3. Updates the main window code to parse and write back settings related to the model directory following the same scheme as icons and textures
4. Adds the class CQtOpenGLObjModel whose constructor takes the filename of an OBJ model stored in the model directory. The MTL (materials file) is assumed to be in the same
directory
5. Updates README.asciidoc to document the settings for the models directory
  • Loading branch information
allsey87 committed Mar 15, 2019
1 parent d406b52 commit 886037b
Show file tree
Hide file tree
Showing 12 changed files with 602 additions and 14 deletions.
6 changes: 4 additions & 2 deletions README.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,8 @@ run ARGoS:
$ ./argos3 -q all # this shows all the plugins recognized by ARGoS

If you execute ARGoS with the graphical visualization, you'll notice that
icons and textures are missing. This is normal, as ARGoS by default looks
for them in the default install location. To fix this, you need to edit
icons, models, and textures are missing. This is normal, as ARGoS by default
looks for them in the default install location. To fix this, you need to edit
the default settings of the GUI.

On Linux, edit the file +$HOME/.config/Iridia-ULB/ARGoS.conf+ as follows:
Expand All @@ -245,13 +245,15 @@ On Linux, edit the file +$HOME/.config/Iridia-ULB/ARGoS.conf+ as follows:
#
icon_dir=/PATH/TO/argos3/src/plugins/simulator/visualizations/qt-opengl/icons/
texture_dir=/PATH/TO/argos3/src/plugins/simulator/visualizations/qt-opengl/textures/
model_dir=/PATH/TO/argos3/src/plugins/simulator/visualizations/qt-opengl/models/
#
# more stuff
#

On Mac, write the following commands on the terminal window to fix the paths manually:

$ defaults write info.argos-sim.ARGoS MainWindow.texture_dir -string "/PATH/TO/argos3/src/plugins/simulator/visualizations/qt-opengl/textures/"
$ defaults write info.argos-sim.ARGoS MainWindow.model_dir -string "/PATH/TO/argos3/src/plugins/simulator/visualizations/qt-opengl/models/"
$ defaults write info.argos-sim.ARGoS MainWindow.icon_dir -string "/PATH/TO/argos3/src/plugins/simulator/visualizations/qt-opengl/icons/"
$ killall -u YOURUSERNAME cfprefsd

Expand Down
22 changes: 10 additions & 12 deletions src/plugins/simulator/visualizations/qt-opengl/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
#
# Headers
#
# argos3/plugins/simulator/visualizations/qt-opengl/models
set(ARGOS3_HEADERS_PLUGINS_SIMULATOR_VISUALIZATIONS_QTOPENGL_MODELS
models/qtopengl_box.h
models/qtopengl_cylinder.h
models/qtopengl_light.h)
# argos3/plugins/simulator/visualizations/qt-opengl
set(ARGOS3_HEADERS_PLUGINS_SIMULATOR_VISUALIZATIONS_QTOPENGL
qtopengl_application.h
qtopengl_box.h
qtopengl_camera.h
qtopengl_cylinder.h
qtopengl_light.h
qtopengl_log_stream.h
qtopengl_main_window.h
qtopengl_obj_model.h
qtopengl_render.h
qtopengl_user_functions.h
qtopengl_widget.h)
Expand All @@ -32,13 +31,13 @@ endif(ARGOS_WITH_LUA)
# Common for all builds
set(ARGOS3_SOURCES_PLUGINS_SIMULATOR_VISUALIZATIONS_QTOPENGL
${ARGOS3_HEADERS_PLUGINS_SIMULATOR_VISUALIZATIONS_QTOPENGL}
${ARGOS3_HEADERS_PLUGINS_SIMULATOR_VISUALIZATIONS_QTOPENGL_MODELS}
models/qtopengl_box.cpp
models/qtopengl_cylinder.cpp
models/qtopengl_light.cpp
qtopengl_application.cpp
qtopengl_box.cpp
qtopengl_camera.cpp
qtopengl_cylinder.cpp
qtopengl_light.cpp
qtopengl_main_window.cpp
qtopengl_obj_model.cpp
qtopengl_render.cpp
qtopengl_user_functions.cpp
qtopengl_widget.cpp)
Expand All @@ -64,9 +63,8 @@ target_link_libraries(argos3plugin_${ARGOS_BUILD_FOR}_qtopengl argos3plugin_${AR
# target_link_libraries(argos3plugin_${ARGOS_BUILD_FOR}_qtopengl ${SDL_LIBRARY})
# endif(SDL_FOUND)

install(DIRECTORY icons textures DESTINATION include/argos3/plugins/simulator/visualizations/qt-opengl)
install(FILES ${ARGOS3_HEADERS_PLUGINS_SIMULATOR_VISUALIZATIONS_QTOPENGL_MODELS} DESTINATION include/argos3/plugins/simulator/visualizations/qt-opengl/models)
install(FILES ${ARGOS3_HEADERS_PLUGINS_SIMULATOR_VISUALIZATIONS_QTOPENGL} DESTINATION include/argos3/plugins/simulator/visualizations/qt-opengl)
install(DIRECTORY icons textures models DESTINATION include/argos3/plugins/simulator/visualizations/qt-opengl)
install(FILES ${ARGOS3_HEADERS_PLUGINS_SIMULATOR_VISUALIZATIONS_QTOPENGL} DESTINATION include/argos3/plugins/simulator/visualizations/qt-opengl)
install(TARGETS argos3plugin_${ARGOS_BUILD_FOR}_qtopengl
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib/argos3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,16 @@ namespace argos {
m_strTextureDir = QString::fromStdString(CSimulator::GetInstance().GetInstallationDirectory());
m_strTextureDir += "/include/argos3/plugins/simulator/visualizations/qt-opengl/textures/";
}
if(cSettings.contains("model_dir")) {
m_strModelDir = cSettings.value("model_dir").toString();
if(m_strModelDir.at(m_strModelDir.length()-1) != '/') {
m_strModelDir.append("/");
}
}
else {
m_strModelDir = QString::fromStdString(CSimulator::GetInstance().GetInstallationDirectory());
m_strModelDir += "/include/argos3/plugins/simulator/visualizations/qt-opengl/models/";
}
cSettings.endGroup();
}

Expand All @@ -233,6 +243,7 @@ namespace argos {
cSettings.setValue("position", pos());
cSettings.setValue("icon_dir", m_strIconDir);
cSettings.setValue("texture_dir", m_strTextureDir);
cSettings.setValue("model_dir", m_strModelDir);
cSettings.endGroup();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ namespace argos {
return m_strTextureDir;
}

inline const QString& GetModelDir() const {
return m_strModelDir;
}

private:

void ReadSettingsPreCreation();
Expand Down Expand Up @@ -225,6 +229,7 @@ namespace argos {
CQTOpenGLWidget* m_pcOpenGLWidget;
QString m_strIconDir;
QString m_strTextureDir;
QString m_strModelDir;

EExperimentState m_eExperimentState;

Expand Down
Loading

0 comments on commit 886037b

Please sign in to comment.