Compare commits
	
		
			No commits in common. "e6bcd131b7ef26b6d900d266eefc11029e4b3103" and "0dcb6d337bcfa75a4ccee1cbf3f31eb563d8774f" have entirely different histories.
		
	
	
		
			e6bcd131b7
			...
			0dcb6d337b
		
	
		
@ -74,7 +74,7 @@ We can install this library on a system path or a custom path and then set `CMAK
 | 
				
			|||||||
Below is an example of installing on a system path.
 | 
					Below is an example of installing on a system path.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
```bash
 | 
					```bash
 | 
				
			||||||
cmake -S qtk/ -B qtk/build/ -DCMAKE_PREFIX_PATH=$HOME/Qt/6.5.0/gcc_64 -DQTK_INSTALL_GUI=OFF -DQTK_INSTALL_PLUGINS=OFF -DQTK_DEBUG=OFF
 | 
					cmake -S qtk/ -B qtk/build/ -DCMAKE_PREFIX_PATH=$HOME/Qt/6.5.0/gcc_64 -DQTK_INSTALL_GUI=OFF -DQTK_INSTALL_PLUGINS=OFF
 | 
				
			||||||
cmake --build qtk/build/ -j $(nproc --ignore=2)
 | 
					cmake --build qtk/build/ -j $(nproc --ignore=2)
 | 
				
			||||||
sudo cmake --install . --prefix=/usr/local
 | 
					sudo cmake --install . --prefix=/usr/local
 | 
				
			||||||
-- Install configuration: "Release"
 | 
					-- Install configuration: "Release"
 | 
				
			||||||
 | 
				
			|||||||
@ -2,7 +2,7 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
include("${CMAKE_CURRENT_LIST_DIR}/QtkTargets.cmake")
 | 
					include("${CMAKE_CURRENT_LIST_DIR}/QtkTargets.cmake")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
set_and_check(QTK_EXECUTABLE "${PACKAGE_PREFIX_DIR}/bin/qtk_app")
 | 
					set_and_check(QTK_EXECUTABLE "${PACKAGE_PREFIX_DIR}/bin/qtk_main")
 | 
				
			||||||
set_and_check(QTK_INCLUDE_DIR "${PACKAGE_PREFIX_DIR}/include")
 | 
					set_and_check(QTK_INCLUDE_DIR "${PACKAGE_PREFIX_DIR}/include")
 | 
				
			||||||
set_and_check(QTK_LIBRARIES "${PACKAGE_PREFIX_DIR}/lib")
 | 
					set_and_check(QTK_LIBRARIES "${PACKAGE_PREFIX_DIR}/lib")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -65,6 +65,6 @@ set(
 | 
				
			|||||||
    examplewidget.cpp examplewidget.h
 | 
					    examplewidget.cpp examplewidget.h
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
add_executable(example_app ${EXAMPLE_SOURCES})
 | 
					add_executable(example ${EXAMPLE_SOURCES})
 | 
				
			||||||
target_link_libraries(example_app PUBLIC Qt6::Widgets Qt6::OpenGLWidgets Qt6::Core)
 | 
					target_link_libraries(example PUBLIC Qt6::Widgets Qt6::OpenGLWidgets Qt6::Core)
 | 
				
			||||||
target_link_libraries(example_app PUBLIC Qtk::qtk_library)
 | 
					target_link_libraries(example PUBLIC Qtk::qtk_library)
 | 
				
			||||||
 | 
				
			|||||||
@ -1,10 +1,7 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
This is an example application that is using the Qtk API to create custom Qt 
 | 
					This is an example application that is using the Qtk API to create custom Qt 
 | 
				
			||||||
OpenGL widgets. This is very similar to `QtkWidget` in the Qtk desktop 
 | 
					OpenGL widgets. This is very similar to `QtkWidget` in the Qtk desktop 
 | 
				
			||||||
application source code, but could be modified for different uses if needed.
 | 
					application, but could be modified for different uses if needed.
 | 
				
			||||||
 | 
					 | 
				
			||||||
There are no camera controls supported in this example. The camera is fixed.
 | 
					 | 
				
			||||||
If these controls are desired, they can be implemented by the client.
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
You can import your own models within `examplescene.cpp`, inside the
 | 
					You can import your own models within `examplescene.cpp`, inside the
 | 
				
			||||||
`ExampleScene::init()` function. Rotations and translations
 | 
					`ExampleScene::init()` function. Rotations and translations
 | 
				
			||||||
 | 
				
			|||||||
@ -10,7 +10,7 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
using namespace Qtk;
 | 
					using namespace Qtk;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
ExampleScene::ExampleScene(Qtk::Scene * scene) : Qtk::SceneInterface(scene) {
 | 
					ExampleScene::ExampleScene() {
 | 
				
			||||||
  setSceneName("Example Scene");
 | 
					  setSceneName("Example Scene");
 | 
				
			||||||
  getCamera().getTransform().setTranslation(-8.0f, 0.0f, 10.0f);
 | 
					  getCamera().getTransform().setTranslation(-8.0f, 0.0f, 10.0f);
 | 
				
			||||||
  getCamera().getTransform().setRotation(-5.0f, 0.0f, 1.0f, 0.0f);
 | 
					  getCamera().getTransform().setRotation(-5.0f, 0.0f, 1.0f, 0.0f);
 | 
				
			||||||
 | 
				
			|||||||
@ -11,9 +11,9 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#include <qtk/scene.h>
 | 
					#include <qtk/scene.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class ExampleScene : public Qtk::SceneInterface {
 | 
					class ExampleScene : public Qtk::Scene {
 | 
				
			||||||
  public:
 | 
					  public:
 | 
				
			||||||
    ExampleScene(Qtk::Scene * scene);
 | 
					    ExampleScene();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    ~ExampleScene();
 | 
					    ~ExampleScene();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -11,12 +11,7 @@
 | 
				
			|||||||
#include "examplewidget.h"
 | 
					#include "examplewidget.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
ExampleWidget::ExampleWidget(QWidget * parent) :
 | 
					ExampleWidget::ExampleWidget(QWidget * parent) :
 | 
				
			||||||
    QOpenGLWidget(parent), mScene(new ExampleScene(new Qtk::SceneEmpty)) {
 | 
					    QOpenGLWidget(parent), mScene(new ExampleScene) {
 | 
				
			||||||
  // NOTE: The decorator pattern is used to save / load scenes in Qtk currently.
 | 
					 | 
				
			||||||
  // The initializer above sets mScene to the concrete decorator ExampleScene.
 | 
					 | 
				
			||||||
  // Qtk::SceneEmpty provides an empty scene as the concrete component.
 | 
					 | 
				
			||||||
  // ExampleScene is defined in client source, deriving Qtk::SceneInterface.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  QSurfaceFormat format;
 | 
					  QSurfaceFormat format;
 | 
				
			||||||
  format.setRenderableType(QSurfaceFormat::OpenGL);
 | 
					  format.setRenderableType(QSurfaceFormat::OpenGL);
 | 
				
			||||||
  format.setProfile(QSurfaceFormat::CoreProfile);
 | 
					  format.setProfile(QSurfaceFormat::CoreProfile);
 | 
				
			||||||
 | 
				
			|||||||
@ -32,7 +32,7 @@ class ExampleWidget : public QOpenGLWidget, protected QOpenGLFunctions {
 | 
				
			|||||||
    void update();
 | 
					    void update();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  private:
 | 
					  private:
 | 
				
			||||||
    Qtk::Scene * mScene;
 | 
					    ExampleScene * mScene;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif  // QTKCLIENT_EXAMPLEWIDGET_H
 | 
					#endif  // QTKCLIENT_EXAMPLEWIDGET_H
 | 
				
			||||||
 | 
				
			|||||||
@ -32,7 +32,7 @@ if (QTK_INSTALL_GUI OR QTK_INSTALL_PLUGINS)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  if(QTK_INSTALL_GUI)
 | 
					  if(QTK_INSTALL_GUI)
 | 
				
			||||||
    install(
 | 
					    install(
 | 
				
			||||||
        TARGETS qtk_app qtk_library
 | 
					        TARGETS qtk_main qtk_library
 | 
				
			||||||
        COMPONENT qtk
 | 
					        COMPONENT qtk
 | 
				
			||||||
        BUNDLE DESTINATION .
 | 
					        BUNDLE DESTINATION .
 | 
				
			||||||
        LIBRARY DESTINATION lib
 | 
					        LIBRARY DESTINATION lib
 | 
				
			||||||
@ -41,7 +41,7 @@ if (QTK_INSTALL_GUI OR QTK_INSTALL_PLUGINS)
 | 
				
			|||||||
    )
 | 
					    )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    qt_generate_deploy_app_script(
 | 
					    qt_generate_deploy_app_script(
 | 
				
			||||||
        TARGET qtk_app
 | 
					        TARGET qtk_main
 | 
				
			||||||
        OUTPUT_SCRIPT QTK_DEPLOY_SCRIPT
 | 
					        OUTPUT_SCRIPT QTK_DEPLOY_SCRIPT
 | 
				
			||||||
        NO_UNSUPPORTED_PLATFORM_ERROR
 | 
					        NO_UNSUPPORTED_PLATFORM_ERROR
 | 
				
			||||||
    )
 | 
					    )
 | 
				
			||||||
@ -58,7 +58,7 @@ if (QTK_INSTALL_GUI OR QTK_INSTALL_PLUGINS)
 | 
				
			|||||||
        )
 | 
					        )
 | 
				
			||||||
        file(TO_NATIVE_PATH "${QT6_INSTALL_PREFIX}/bin" QT6_INSTALL_PREFIX)
 | 
					        file(TO_NATIVE_PATH "${QT6_INSTALL_PREFIX}/bin" QT6_INSTALL_PREFIX)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        set(VSUSER_FILE "${CMAKE_CURRENT_BINARY_DIR}/qtk_app.vcxproj.user")
 | 
					        set(VSUSER_FILE "${CMAKE_CURRENT_BINARY_DIR}/qtk_main.vcxproj.user")
 | 
				
			||||||
        file(WRITE ${VSUSER_FILE} "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n")
 | 
					        file(WRITE ${VSUSER_FILE} "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n")
 | 
				
			||||||
        file(APPEND ${VSUSER_FILE} "<Project xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n")
 | 
					        file(APPEND ${VSUSER_FILE} "<Project xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n")
 | 
				
			||||||
        file(APPEND ${VSUSER_FILE} "  <PropertyGroup>\n")
 | 
					        file(APPEND ${VSUSER_FILE} "  <PropertyGroup>\n")
 | 
				
			||||||
@ -137,11 +137,11 @@ set(CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL ON)
 | 
				
			|||||||
# https://nsis.sourceforge.io/Reference/CreateShortCut
 | 
					# https://nsis.sourceforge.io/Reference/CreateShortCut
 | 
				
			||||||
set(
 | 
					set(
 | 
				
			||||||
    CPACK_NSIS_CREATE_ICONS_EXTRA
 | 
					    CPACK_NSIS_CREATE_ICONS_EXTRA
 | 
				
			||||||
    "CreateShortCut '$SMPROGRAMS\\\\$STARTMENU_FOLDER\\\\Qtk.lnk' '$INSTDIR\\\\bin\\\\qtk_app.exe'"
 | 
					    "CreateShortCut '$SMPROGRAMS\\$STARTMENU_FOLDER\\Qtk.lnk' '$INSTDIR\\bin\\qtk_main.exe'"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
set(
 | 
					set(
 | 
				
			||||||
    CPACK_NSIS_DELETE_ICONS_EXTRA
 | 
					    CPACK_NSIS_DELETE_ICONS_EXTRA
 | 
				
			||||||
    "Delete '$SMPROGRAMS\\\\$START_MENU\\\\Qtk.lnk'"
 | 
					    "Delete '$SMPROGRAMS\\$START_MENU\\Qtk.lnk'"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
# TODO: Icons for NSIS installer.
 | 
					# TODO: Icons for NSIS installer.
 | 
				
			||||||
#set(CPACK_NSIS_MUI_ICON "${CMAKE_SOURCE_DIR}/resources/icon.png")
 | 
					#set(CPACK_NSIS_MUI_ICON "${CMAKE_SOURCE_DIR}/resources/icon.png")
 | 
				
			||||||
@ -154,8 +154,9 @@ set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
 | 
				
			|||||||
#set(CPACK_PACKAGING_INSTALL_PREFIX /usr/local/)
 | 
					#set(CPACK_PACKAGING_INSTALL_PREFIX /usr/local/)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# OSX
 | 
					# OSX
 | 
				
			||||||
 | 
					# TODO: Fix OSX appbundle error.
 | 
				
			||||||
set(CPACK_BUNDLE_NAME ${PROJECT_NAME})
 | 
					set(CPACK_BUNDLE_NAME ${PROJECT_NAME})
 | 
				
			||||||
set(CPACK_BUNDLE_PLIST $<TARGET_BUNDLE_CONTENT_DIR:qtk_app>/Info.plist)
 | 
					set(CPACK_BUNDLE_PLIST $<TARGET_BUNDLE_CONTENT_DIR:qtk_main>/Info.plist)
 | 
				
			||||||
set(CPACK_BUNDLE_ICON ${QTK_OSX_ICONS})
 | 
					set(CPACK_BUNDLE_ICON ${QTK_OSX_ICONS})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Platform defaults for source bundles.
 | 
					# Platform defaults for source bundles.
 | 
				
			||||||
 | 
				
			|||||||
@ -50,7 +50,7 @@ target_link_libraries(qtk_collection PUBLIC qtk_plugin_library)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
set(
 | 
					set(
 | 
				
			||||||
    QTK_APP_SOURCES
 | 
					    QTK_APP_SOURCES
 | 
				
			||||||
    qtkscene.cpp qtkscene.h
 | 
					    examplescene.cpp examplescene.h
 | 
				
			||||||
    main.cpp
 | 
					    main.cpp
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -61,11 +61,11 @@ configure_file(
 | 
				
			|||||||
    @ONLY
 | 
					    @ONLY
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
qt_add_executable(qtk_app ${QTK_APP_SOURCES})
 | 
					qt_add_executable(qtk_main ${QTK_APP_SOURCES})
 | 
				
			||||||
target_link_libraries(qtk_app PRIVATE qtk_plugin_library)
 | 
					target_link_libraries(qtk_main PRIVATE qtk_plugin_library)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
set_target_properties(
 | 
					set_target_properties(
 | 
				
			||||||
    qtk_app PROPERTIES
 | 
					    qtk_main PROPERTIES
 | 
				
			||||||
      WIN32_EXECUTABLE TRUE
 | 
					      WIN32_EXECUTABLE TRUE
 | 
				
			||||||
      MACOSX_BUNDLE TRUE
 | 
					      MACOSX_BUNDLE TRUE
 | 
				
			||||||
      MACOSX_BUNDLE_BUNDLE_NAME Qtk
 | 
					      MACOSX_BUNDLE_BUNDLE_NAME Qtk
 | 
				
			||||||
 | 
				
			|||||||
@ -6,7 +6,7 @@
 | 
				
			|||||||
## Contact: shaunrd0@gmail.com  | URL: www.shaunreed.com | GitHub: shaunrd0   ##
 | 
					## Contact: shaunrd0@gmail.com  | URL: www.shaunreed.com | GitHub: shaunrd0   ##
 | 
				
			||||||
##############################################################################*/
 | 
					##############################################################################*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "qtkscene.h"
 | 
					#include "examplescene.h"
 | 
				
			||||||
#include "resources.h"
 | 
					#include "resources.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
using namespace Qtk;
 | 
					using namespace Qtk;
 | 
				
			||||||
@ -15,14 +15,13 @@ using namespace Qtk;
 | 
				
			|||||||
 * Constructors, Destructors
 | 
					 * Constructors, Destructors
 | 
				
			||||||
 ******************************************************************************/
 | 
					 ******************************************************************************/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
QtkScene::QtkScene(Qtk::Scene * scene) :
 | 
					ExampleScene::ExampleScene() {
 | 
				
			||||||
    Qtk::SceneInterface(scene) {
 | 
					  setSceneName("Example Scene");
 | 
				
			||||||
  setSceneName("Qtk Scene");
 | 
					 | 
				
			||||||
  getCamera().getTransform().setTranslation(0.0f, 0.0f, 20.0f);
 | 
					  getCamera().getTransform().setTranslation(0.0f, 0.0f, 20.0f);
 | 
				
			||||||
  getCamera().getTransform().setRotation(-5.0f, 0.0f, 1.0f, 0.0f);
 | 
					  getCamera().getTransform().setRotation(-5.0f, 0.0f, 1.0f, 0.0f);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
QtkScene::~QtkScene() {
 | 
					ExampleScene::~ExampleScene() {
 | 
				
			||||||
  delete mTestPhong;
 | 
					  delete mTestPhong;
 | 
				
			||||||
  delete mTestSpecular;
 | 
					  delete mTestSpecular;
 | 
				
			||||||
  delete mTestDiffuse;
 | 
					  delete mTestDiffuse;
 | 
				
			||||||
@ -33,7 +32,7 @@ QtkScene::~QtkScene() {
 | 
				
			|||||||
 * Public Member Functions
 | 
					 * Public Member Functions
 | 
				
			||||||
 ******************************************************************************/
 | 
					 ******************************************************************************/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void QtkScene::init() {
 | 
					void ExampleScene::init() {
 | 
				
			||||||
  // Add a skybox to the scene using default cube map images and settings.
 | 
					  // Add a skybox to the scene using default cube map images and settings.
 | 
				
			||||||
  setSkybox(new Qtk::Skybox("Skybox"));
 | 
					  setSkybox(new Qtk::Skybox("Skybox"));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -98,7 +97,7 @@ void QtkScene::init() {
 | 
				
			|||||||
  model->getTransform().scale(0.15f);
 | 
					  model->getTransform().scale(0.15f);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  model =
 | 
					  model =
 | 
				
			||||||
      addObject(new Qtk::Model("My scythe", ":/models/models/scythe/scythe.obj"));
 | 
					      addObject(new Qtk::Model("scythe", ":/models/models/scythe/scythe.obj"));
 | 
				
			||||||
  model->getTransform().setTranslation(-6.0f, 0.0f, -10.0f);
 | 
					  model->getTransform().setTranslation(-6.0f, 0.0f, -10.0f);
 | 
				
			||||||
  model->getTransform().rotate(-90.0f, 1.0f, 0.0f, 0.0f);
 | 
					  model->getTransform().rotate(-90.0f, 1.0f, 0.0f, 0.0f);
 | 
				
			||||||
  model->getTransform().rotate(90.0f, 0.0f, 1.0f, 0.0f);
 | 
					  model->getTransform().rotate(90.0f, 0.0f, 1.0f, 0.0f);
 | 
				
			||||||
@ -388,11 +387,19 @@ void QtkScene::init() {
 | 
				
			|||||||
  mesh->reallocateTexCoords(mesh->getTexCoords());
 | 
					  mesh->reallocateTexCoords(mesh->getTexCoords());
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void QtkScene::draw() {
 | 
					void ExampleScene::draw() {
 | 
				
			||||||
  // WARNING: We must call the base class draw() function first.
 | 
					  // WARNING: We must call the base class draw() function first.
 | 
				
			||||||
  // + This will handle rendering core scene components like the Skybox.
 | 
					  // + This will handle rendering core scene components like the Skybox.
 | 
				
			||||||
  Scene::draw();
 | 
					  Scene::draw();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  for(const auto & model : getModels()) {
 | 
				
			||||||
 | 
					    model->draw();
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  for(const auto & mesh : getMeshes()) {
 | 
				
			||||||
 | 
					    mesh->draw();
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  mTestPhong->bindShaders();
 | 
					  mTestPhong->bindShaders();
 | 
				
			||||||
  mTestPhong->setUniform(
 | 
					  mTestPhong->setUniform(
 | 
				
			||||||
      "uModelInverseTransposed",
 | 
					      "uModelInverseTransposed",
 | 
				
			||||||
@ -402,14 +409,14 @@ void QtkScene::draw() {
 | 
				
			|||||||
      MeshRenderer::getInstance("phongLight")->getTransform().getTranslation());
 | 
					      MeshRenderer::getInstance("phongLight")->getTransform().getTranslation());
 | 
				
			||||||
  mTestPhong->setUniform(
 | 
					  mTestPhong->setUniform(
 | 
				
			||||||
      "uCameraPosition",
 | 
					      "uCameraPosition",
 | 
				
			||||||
      QtkScene::getCamera().getTransform().getTranslation());
 | 
					      ExampleScene::getCamera().getTransform().getTranslation());
 | 
				
			||||||
  mTestPhong->releaseShaders();
 | 
					  mTestPhong->releaseShaders();
 | 
				
			||||||
  mTestPhong->draw();
 | 
					  mTestPhong->draw();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  mTestAmbient->bindShaders();
 | 
					  mTestAmbient->bindShaders();
 | 
				
			||||||
  mTestAmbient->setUniform(
 | 
					  mTestAmbient->setUniform(
 | 
				
			||||||
      "uCameraPosition",
 | 
					      "uCameraPosition",
 | 
				
			||||||
      QtkScene::getCamera().getTransform().getTranslation());
 | 
					      ExampleScene::getCamera().getTransform().getTranslation());
 | 
				
			||||||
  mTestAmbient->releaseShaders();
 | 
					  mTestAmbient->releaseShaders();
 | 
				
			||||||
  mTestAmbient->draw();
 | 
					  mTestAmbient->draw();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -423,7 +430,7 @@ void QtkScene::draw() {
 | 
				
			|||||||
                            .getTranslation());
 | 
					                            .getTranslation());
 | 
				
			||||||
  mTestDiffuse->setUniform(
 | 
					  mTestDiffuse->setUniform(
 | 
				
			||||||
      "uCameraPosition",
 | 
					      "uCameraPosition",
 | 
				
			||||||
      QtkScene::getCamera().getTransform().getTranslation());
 | 
					      ExampleScene::getCamera().getTransform().getTranslation());
 | 
				
			||||||
  mTestDiffuse->releaseShaders();
 | 
					  mTestDiffuse->releaseShaders();
 | 
				
			||||||
  mTestDiffuse->draw();
 | 
					  mTestDiffuse->draw();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -437,12 +444,12 @@ void QtkScene::draw() {
 | 
				
			|||||||
                            .getTranslation());
 | 
					                            .getTranslation());
 | 
				
			||||||
  mTestSpecular->setUniform(
 | 
					  mTestSpecular->setUniform(
 | 
				
			||||||
      "uCameraPosition",
 | 
					      "uCameraPosition",
 | 
				
			||||||
      QtkScene::getCamera().getTransform().getTranslation());
 | 
					      ExampleScene::getCamera().getTransform().getTranslation());
 | 
				
			||||||
  mTestSpecular->releaseShaders();
 | 
					  mTestSpecular->releaseShaders();
 | 
				
			||||||
  mTestSpecular->draw();
 | 
					  mTestSpecular->draw();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void QtkScene::update() {
 | 
					void ExampleScene::update() {
 | 
				
			||||||
  auto mySpartan = Model::getInstance("My spartan");
 | 
					  auto mySpartan = Model::getInstance("My spartan");
 | 
				
			||||||
  mySpartan->getTransform().rotate(0.75f, 0.0f, 1.0f, 0.0f);
 | 
					  mySpartan->getTransform().rotate(0.75f, 0.0f, 1.0f, 0.0f);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -456,12 +463,12 @@ void QtkScene::update() {
 | 
				
			|||||||
  alien->setUniform("uLight.position", position);
 | 
					  alien->setUniform("uLight.position", position);
 | 
				
			||||||
  alien->setUniform(
 | 
					  alien->setUniform(
 | 
				
			||||||
      "uCameraPosition",
 | 
					      "uCameraPosition",
 | 
				
			||||||
      QtkScene::getCamera().getTransform().getTranslation());
 | 
					      ExampleScene::getCamera().getTransform().getTranslation());
 | 
				
			||||||
  auto posMatrix = alien->getTransform().toMatrix();
 | 
					  auto posMatrix = alien->getTransform().toMatrix();
 | 
				
			||||||
  alien->setUniform("uMVP.normalMatrix", posMatrix.normalMatrix());
 | 
					  alien->setUniform("uMVP.normalMatrix", posMatrix.normalMatrix());
 | 
				
			||||||
  alien->setUniform("uMVP.model", posMatrix);
 | 
					  alien->setUniform("uMVP.model", posMatrix);
 | 
				
			||||||
  alien->setUniform("uMVP.view", QtkScene::getCamera().toMatrix());
 | 
					  alien->setUniform("uMVP.view", ExampleScene::getCamera().toMatrix());
 | 
				
			||||||
  alien->setUniform("uMVP.projection", QtkScene::getProjectionMatrix());
 | 
					  alien->setUniform("uMVP.projection", ExampleScene::getProjectionMatrix());
 | 
				
			||||||
  alien->getTransform().rotate(0.75f, 0.0f, 1.0f, 0.0f);
 | 
					  alien->getTransform().rotate(0.75f, 0.0f, 1.0f, 0.0f);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  position = MeshRenderer::getInstance("spartanTestLight")
 | 
					  position = MeshRenderer::getInstance("spartanTestLight")
 | 
				
			||||||
@ -471,12 +478,12 @@ void QtkScene::update() {
 | 
				
			|||||||
  spartan->setUniform("uLight.position", position);
 | 
					  spartan->setUniform("uLight.position", position);
 | 
				
			||||||
  spartan->setUniform(
 | 
					  spartan->setUniform(
 | 
				
			||||||
      "uCameraPosition",
 | 
					      "uCameraPosition",
 | 
				
			||||||
      QtkScene::getCamera().getTransform().getTranslation());
 | 
					      ExampleScene::getCamera().getTransform().getTranslation());
 | 
				
			||||||
  posMatrix = spartan->getTransform().toMatrix();
 | 
					  posMatrix = spartan->getTransform().toMatrix();
 | 
				
			||||||
  spartan->setUniform("uMVP.normalMatrix", posMatrix.normalMatrix());
 | 
					  spartan->setUniform("uMVP.normalMatrix", posMatrix.normalMatrix());
 | 
				
			||||||
  spartan->setUniform("uMVP.model", posMatrix);
 | 
					  spartan->setUniform("uMVP.model", posMatrix);
 | 
				
			||||||
  spartan->setUniform("uMVP.view", QtkScene::getCamera().toMatrix());
 | 
					  spartan->setUniform("uMVP.view", ExampleScene::getCamera().toMatrix());
 | 
				
			||||||
  spartan->setUniform("uMVP.projection", QtkScene::getProjectionMatrix());
 | 
					  spartan->setUniform("uMVP.projection", ExampleScene::getProjectionMatrix());
 | 
				
			||||||
  spartan->getTransform().rotate(0.75f, 0.0f, 1.0f, 0.0f);
 | 
					  spartan->getTransform().rotate(0.75f, 0.0f, 1.0f, 0.0f);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  auto phong = MeshRenderer::getInstance("testPhong");
 | 
					  auto phong = MeshRenderer::getInstance("testPhong");
 | 
				
			||||||
@ -487,12 +494,12 @@ void QtkScene::update() {
 | 
				
			|||||||
  phong->setUniform("uLight.position", position);
 | 
					  phong->setUniform("uLight.position", position);
 | 
				
			||||||
  phong->setUniform(
 | 
					  phong->setUniform(
 | 
				
			||||||
      "uCameraPosition",
 | 
					      "uCameraPosition",
 | 
				
			||||||
      QtkScene::getCamera().getTransform().getTranslation());
 | 
					      ExampleScene::getCamera().getTransform().getTranslation());
 | 
				
			||||||
  posMatrix = phong->getTransform().toMatrix();
 | 
					  posMatrix = phong->getTransform().toMatrix();
 | 
				
			||||||
  phong->setUniform("uMVP.normalMatrix", posMatrix.normalMatrix());
 | 
					  phong->setUniform("uMVP.normalMatrix", posMatrix.normalMatrix());
 | 
				
			||||||
  phong->setUniform("uMVP.model", posMatrix);
 | 
					  phong->setUniform("uMVP.model", posMatrix);
 | 
				
			||||||
  phong->setUniform("uMVP.view", QtkScene::getCamera().toMatrix());
 | 
					  phong->setUniform("uMVP.view", ExampleScene::getCamera().toMatrix());
 | 
				
			||||||
  phong->setUniform("uMVP.projection", QtkScene::getProjectionMatrix());
 | 
					  phong->setUniform("uMVP.projection", ExampleScene::getProjectionMatrix());
 | 
				
			||||||
  phong->releaseShaders();
 | 
					  phong->releaseShaders();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // Rotate lighting example cubes
 | 
					  // Rotate lighting example cubes
 | 
				
			||||||
@ -29,15 +29,15 @@
 | 
				
			|||||||
 *
 | 
					 *
 | 
				
			||||||
 * To create your own Scene from scratch see Qtk::Scene.
 | 
					 * To create your own Scene from scratch see Qtk::Scene.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
class QtkScene : public Qtk::SceneInterface {
 | 
					class ExampleScene : public Qtk::Scene {
 | 
				
			||||||
  public:
 | 
					  public:
 | 
				
			||||||
    /***************************************************************************
 | 
					    /***************************************************************************
 | 
				
			||||||
     * Contructors / Destructors
 | 
					     * Contructors / Destructors
 | 
				
			||||||
     **************************************************************************/
 | 
					     **************************************************************************/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    QtkScene(Qtk::Scene * scene);
 | 
					    ExampleScene();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    ~QtkScene();
 | 
					    ~ExampleScene();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /***************************************************************************
 | 
					    /***************************************************************************
 | 
				
			||||||
     * Inherited Public Overrides
 | 
					     * Inherited Public Overrides
 | 
				
			||||||
@ -9,7 +9,6 @@
 | 
				
			|||||||
#include <QApplication>
 | 
					#include <QApplication>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "qtkmainwindow.h"
 | 
					#include "qtkmainwindow.h"
 | 
				
			||||||
#include "qtkscene.h"
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
int main(int argc, char * argv[]) {
 | 
					int main(int argc, char * argv[]) {
 | 
				
			||||||
  Q_INIT_RESOURCE(resources);
 | 
					  Q_INIT_RESOURCE(resources);
 | 
				
			||||||
@ -17,12 +16,7 @@ int main(int argc, char * argv[]) {
 | 
				
			|||||||
  QApplication a(argc, argv);
 | 
					  QApplication a(argc, argv);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  auto window = MainWindow::getMainWindow();
 | 
					  auto window = MainWindow::getMainWindow();
 | 
				
			||||||
 | 
					 | 
				
			||||||
  // Qtk currently uses the decorator pattern to save / load scenes.
 | 
					 | 
				
			||||||
  // This is a temporary solution and will be improved in the future.
 | 
					 | 
				
			||||||
  auto emptyScene = new Qtk::SceneEmpty;
 | 
					 | 
				
			||||||
  window->getQtkWidget()->setScene(new QtkScene(emptyScene));
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  window->show();
 | 
					  window->show();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  return QApplication::exec();
 | 
					  return QApplication::exec();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -7,7 +7,7 @@
 | 
				
			|||||||
##############################################################################*/
 | 
					##############################################################################*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "qtkmainwindow.h"
 | 
					#include "qtkmainwindow.h"
 | 
				
			||||||
#include "qtkscene.h"
 | 
					#include "examplescene.h"
 | 
				
			||||||
#include "ui_qtkmainwindow.h"
 | 
					#include "ui_qtkmainwindow.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
MainWindow * MainWindow::mainWindow_ = Q_NULLPTR;
 | 
					MainWindow * MainWindow::mainWindow_ = Q_NULLPTR;
 | 
				
			||||||
@ -27,7 +27,7 @@ MainWindow::MainWindow(QWidget * parent) : QMainWindow(parent) {
 | 
				
			|||||||
  // Initialize static container for all active QtkWidgets
 | 
					  // Initialize static container for all active QtkWidgets
 | 
				
			||||||
  auto qtkWidgets = findChildren<Qtk::QtkWidget *>();
 | 
					  auto qtkWidgets = findChildren<Qtk::QtkWidget *>();
 | 
				
			||||||
  for(auto & qtkWidget : qtkWidgets) {
 | 
					  for(auto & qtkWidget : qtkWidgets) {
 | 
				
			||||||
    qtkWidget->setScene(new Qtk::SceneEmpty);
 | 
					    qtkWidget->setScene(new ExampleScene);
 | 
				
			||||||
    views_.emplace(qtkWidget->getScene()->getSceneName(), qtkWidget);
 | 
					    views_.emplace(qtkWidget->getScene()->getSceneName(), qtkWidget);
 | 
				
			||||||
    ui_->menuView->addAction(qtkWidget->getActionToggleConsole());
 | 
					    ui_->menuView->addAction(qtkWidget->getActionToggleConsole());
 | 
				
			||||||
    connect(
 | 
					    connect(
 | 
				
			||||||
@ -60,13 +60,6 @@ MainWindow * MainWindow::getMainWindow() {
 | 
				
			|||||||
  return mainWindow_;
 | 
					  return mainWindow_;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Qtk::QtkWidget * MainWindow::getQtkWidget(int64_t index) {
 | 
					 | 
				
			||||||
  if(views_.size() <= index) {
 | 
					 | 
				
			||||||
    return Q_NULLPTR;
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
  return views_.begin(index)->second;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
Qtk::QtkWidget * MainWindow::getQtkWidget(const QString & name) {
 | 
					Qtk::QtkWidget * MainWindow::getQtkWidget(const QString & name) {
 | 
				
			||||||
  if(!views_.count(name)) {
 | 
					  if(!views_.count(name)) {
 | 
				
			||||||
    return Q_NULLPTR;
 | 
					    return Q_NULLPTR;
 | 
				
			||||||
@ -76,5 +69,5 @@ Qtk::QtkWidget * MainWindow::getQtkWidget(const QString & name) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
void MainWindow::refreshScene(QString sceneName) {
 | 
					void MainWindow::refreshScene(QString sceneName) {
 | 
				
			||||||
  // TODO: Select TreeView using sceneName>
 | 
					  // TODO: Select TreeView using sceneName>
 | 
				
			||||||
  ui_->qtk__TreeView->updateView(getQtkWidget()->getScene());
 | 
					  ui_->qtk__TreeView->updateView(getQtkWidget(sceneName)->getScene());
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -53,8 +53,6 @@ class MainWindow : public QMainWindow {
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    static MainWindow * getMainWindow();
 | 
					    static MainWindow * getMainWindow();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    Qtk::QtkWidget * getQtkWidget(int64_t index = 0);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Accessor for retrieving a QtkWidget by it's objectName.
 | 
					     * Accessor for retrieving a QtkWidget by it's objectName.
 | 
				
			||||||
     * This function will not construct a new QtkWidget if none is found.
 | 
					     * This function will not construct a new QtkWidget if none is found.
 | 
				
			||||||
 | 
				
			|||||||
@ -108,13 +108,7 @@ void QtkWidget::paintGL() {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void QtkWidget::setScene(Qtk::Scene * scene) {
 | 
					void QtkWidget::setScene(Qtk::Scene * scene) {
 | 
				
			||||||
  if (mScene != Q_NULLPTR) {
 | 
					  delete mScene;
 | 
				
			||||||
    delete mScene;
 | 
					 | 
				
			||||||
    connect(
 | 
					 | 
				
			||||||
        scene, &Qtk::Scene::sceneUpdated, MainWindow::getMainWindow(),
 | 
					 | 
				
			||||||
        &MainWindow::refreshScene);
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  mScene = scene;
 | 
					  mScene = scene;
 | 
				
			||||||
  if(mScene != Q_NULLPTR) {
 | 
					  if(mScene != Q_NULLPTR) {
 | 
				
			||||||
    mConsole->setTitle(mScene->getSceneName());
 | 
					    mConsole->setTitle(mScene->getSceneName());
 | 
				
			||||||
 | 
				
			|||||||
@ -100,13 +100,6 @@ namespace Qtk {
 | 
				
			|||||||
       */
 | 
					       */
 | 
				
			||||||
      inline Qtk::Scene * getScene() { return mScene; }
 | 
					      inline Qtk::Scene * getScene() { return mScene; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      /**
 | 
					 | 
				
			||||||
       * @return Pointer to the QOpenGLDebugLogger attached to this widget.
 | 
					 | 
				
			||||||
       */
 | 
					 | 
				
			||||||
      inline QOpenGLDebugLogger * getOpenGLDebugLogger() {
 | 
					 | 
				
			||||||
        return mDebugLogger;
 | 
					 | 
				
			||||||
      }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
      /*************************************************************************
 | 
					      /*************************************************************************
 | 
				
			||||||
       * Setters
 | 
					       * Setters
 | 
				
			||||||
       ************************************************************************/
 | 
					       ************************************************************************/
 | 
				
			||||||
 | 
				
			|||||||
@ -37,7 +37,7 @@ void Qtk::TreeView::updateView(const Qtk::Scene * scene) {
 | 
				
			|||||||
  mSceneName = scene->getSceneName();
 | 
					  mSceneName = scene->getSceneName();
 | 
				
			||||||
  auto objects = scene->getObjects();
 | 
					  auto objects = scene->getObjects();
 | 
				
			||||||
  for(const auto & object : objects) {
 | 
					  for(const auto & object : objects) {
 | 
				
			||||||
    auto item = new QTreeWidgetItem(QStringList(QString(object->getName().c_str())));
 | 
					    auto item = new QTreeWidgetItem(QStringList(QString(object->getName())));
 | 
				
			||||||
    ui->treeWidget->insertTopLevelItem(0, item);
 | 
					    ui->treeWidget->insertTopLevelItem(0, item);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -45,13 +45,9 @@ void Qtk::TreeView::updateView(const Qtk::Scene * scene) {
 | 
				
			|||||||
void Qtk::TreeView::itemFocus(QTreeWidgetItem * item, int column) {
 | 
					void Qtk::TreeView::itemFocus(QTreeWidgetItem * item, int column) {
 | 
				
			||||||
  QString name = item->text(column);
 | 
					  QString name = item->text(column);
 | 
				
			||||||
  auto scene =
 | 
					  auto scene =
 | 
				
			||||||
      MainWindow::getMainWindow()->getQtkWidget()->getScene();
 | 
					      MainWindow::getMainWindow()->getQtkWidget(mSceneName)->getScene();
 | 
				
			||||||
  auto & transform = scene->getCamera().getTransform();
 | 
					  auto & transform = scene->getCamera().getTransform();
 | 
				
			||||||
  auto object = scene->getObject(name);
 | 
					  auto object = scene->getObject(name);
 | 
				
			||||||
  if (object == Q_NULLPTR) {
 | 
					 | 
				
			||||||
    qDebug() << "Attempt to get non-existing object with name '" << name
 | 
					 | 
				
			||||||
             << "'\n";
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
  Transform3D * objectTransform;
 | 
					  Transform3D * objectTransform;
 | 
				
			||||||
  if(object->getType() == Object::QTK_MESH) {
 | 
					  if(object->getType() == Object::QTK_MESH) {
 | 
				
			||||||
    objectTransform = &dynamic_cast<MeshRenderer *>(object)->getTransform();
 | 
					    objectTransform = &dynamic_cast<MeshRenderer *>(object)->getTransform();
 | 
				
			||||||
 | 
				
			|||||||
@ -38,7 +38,7 @@ MeshRenderer::MeshRenderer(const char * name, const ShapeBase & shape) :
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
MeshRenderer::~MeshRenderer() {
 | 
					MeshRenderer::~MeshRenderer() {
 | 
				
			||||||
  sInstances.remove(mName.c_str());
 | 
					  sInstances.remove(mName);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*******************************************************************************
 | 
					/*******************************************************************************
 | 
				
			||||||
 | 
				
			|||||||
@ -96,7 +96,7 @@ void Model::loadModel(const std::string & path) {
 | 
				
			|||||||
  sortModelMeshes();
 | 
					  sortModelMeshes();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // Object finished loading, insert it into ModelManager
 | 
					  // Object finished loading, insert it into ModelManager
 | 
				
			||||||
  mManager.insert(getName().c_str(), this);
 | 
					  mManager.insert(getName(), this);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void Model::processNode(aiNode * node, const aiScene * scene) {
 | 
					void Model::processNode(aiNode * node, const aiScene * scene) {
 | 
				
			||||||
@ -200,7 +200,7 @@ ModelMesh Model::processMesh(aiMesh * mesh, const aiScene * scene) {
 | 
				
			|||||||
    textures.insert(textures.end(), normalMaps.begin(), normalMaps.end());
 | 
					    textures.insert(textures.end(), normalMaps.begin(), normalMaps.end());
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  return {vertices, indices, textures, mVertexShader.c_str(), mFragmentShader.c_str()};
 | 
					  return {vertices, indices, textures, mVertexShader, mFragmentShader};
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
ModelMesh::Textures Model::loadMaterialTextures(
 | 
					ModelMesh::Textures Model::loadMaterialTextures(
 | 
				
			||||||
 | 
				
			|||||||
@ -58,7 +58,7 @@ namespace Qtk {
 | 
				
			|||||||
        loadModel(mModelPath);
 | 
					        loadModel(mModelPath);
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      inline ~Model() override { mManager.remove(getName().c_str()); }
 | 
					      inline ~Model() override { mManager.remove(getName()); }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      /*************************************************************************
 | 
					      /*************************************************************************
 | 
				
			||||||
       * Public Methods
 | 
					       * Public Methods
 | 
				
			||||||
@ -197,7 +197,7 @@ namespace Qtk {
 | 
				
			|||||||
      /** The directory this model and it's textures are stored. */
 | 
					      /** The directory this model and it's textures are stored. */
 | 
				
			||||||
      std::string mDirectory {};
 | 
					      std::string mDirectory {};
 | 
				
			||||||
      /** File names for shaders and 3D model on disk. */
 | 
					      /** File names for shaders and 3D model on disk. */
 | 
				
			||||||
      std::string mVertexShader, mFragmentShader, mModelPath;
 | 
					      const char *mVertexShader, *mFragmentShader, *mModelPath;
 | 
				
			||||||
  };
 | 
					  };
 | 
				
			||||||
}  // namespace Qtk
 | 
					}  // namespace Qtk
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -73,7 +73,7 @@ void ModelMesh::initMesh(const char * vert, const char * frag) {
 | 
				
			|||||||
  initializeOpenGLFunctions();
 | 
					  initializeOpenGLFunctions();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // Create VAO, VBO, EBO
 | 
					  // Create VAO, VBO, EBO
 | 
				
			||||||
  bool status = mVAO->create();
 | 
					  mVAO->create();
 | 
				
			||||||
  mVBO->create();
 | 
					  mVBO->create();
 | 
				
			||||||
  mEBO->create();
 | 
					  mEBO->create();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -92,7 +92,7 @@ namespace Qtk {
 | 
				
			|||||||
        return mShape.mVertices;
 | 
					        return mShape.mVertices;
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      [[nodiscard]] inline std::string getName() const { return mName; }
 | 
					      [[nodiscard]] inline const char * getName() const { return mName; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      [[nodiscard]] inline const Type & getType() const { return mType; }
 | 
					      [[nodiscard]] inline const Type & getType() const { return mType; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -160,7 +160,7 @@ namespace Qtk {
 | 
				
			|||||||
      Transform3D mTransform;
 | 
					      Transform3D mTransform;
 | 
				
			||||||
      Shape mShape;
 | 
					      Shape mShape;
 | 
				
			||||||
      Texture mTexture;
 | 
					      Texture mTexture;
 | 
				
			||||||
      std::string mName;
 | 
					      const char * mName;
 | 
				
			||||||
      bool mBound;
 | 
					      bool mBound;
 | 
				
			||||||
      Type mType = QTK_OBJECT;
 | 
					      Type mType = QTK_OBJECT;
 | 
				
			||||||
  };
 | 
					  };
 | 
				
			||||||
 | 
				
			|||||||
@ -37,23 +37,6 @@ Scene::~Scene() {
 | 
				
			|||||||
 * Public Methods
 | 
					 * Public Methods
 | 
				
			||||||
 ******************************************************************************/
 | 
					 ******************************************************************************/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void Scene::draw() {
 | 
					 | 
				
			||||||
  if(!mInit) {
 | 
					 | 
				
			||||||
    initializeOpenGLFunctions();
 | 
					 | 
				
			||||||
    init();
 | 
					 | 
				
			||||||
    mInit = true;
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
  if(mSkybox != Q_NULLPTR) {
 | 
					 | 
				
			||||||
    mSkybox->draw();
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
  for(auto & model : mModels) {
 | 
					 | 
				
			||||||
    model->draw();
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
  for(const auto & mesh : mMeshes) {
 | 
					 | 
				
			||||||
    mesh->draw();
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
std::vector<Object *> Scene::getObjects() const {
 | 
					std::vector<Object *> Scene::getObjects() const {
 | 
				
			||||||
  // All scene objects must inherit from Qtk::Object.
 | 
					  // All scene objects must inherit from Qtk::Object.
 | 
				
			||||||
  std::vector<Object *> objects(mMeshes.begin(), mMeshes.end());
 | 
					  std::vector<Object *> objects(mMeshes.begin(), mMeshes.end());
 | 
				
			||||||
@ -68,7 +51,7 @@ std::vector<Object *> Scene::getObjects() const {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
Object * Scene::getObject(const QString & name) {
 | 
					Object * Scene::getObject(const QString & name) {
 | 
				
			||||||
  for(auto object : getObjects()) {
 | 
					  for(auto object : getObjects()) {
 | 
				
			||||||
    if(object->getName() == name.toStdString()) {
 | 
					    if(object->getName() == name) {
 | 
				
			||||||
      return object;
 | 
					      return object;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
@ -91,3 +74,24 @@ template <> Model * Scene::addObject(Model * object) {
 | 
				
			|||||||
  sceneUpdated(mSceneName);
 | 
					  sceneUpdated(mSceneName);
 | 
				
			||||||
  return object;
 | 
					  return object;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/*******************************************************************************
 | 
				
			||||||
 | 
					 * Private Methods
 | 
				
			||||||
 | 
					 ******************************************************************************/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void Scene::privateDraw() {
 | 
				
			||||||
 | 
					  if(!mInit) {
 | 
				
			||||||
 | 
					    initializeOpenGLFunctions();
 | 
				
			||||||
 | 
					    init();
 | 
				
			||||||
 | 
					    mInit = true;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					  if(mSkybox != Q_NULLPTR) {
 | 
				
			||||||
 | 
					    mSkybox->draw();
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					  for(auto & model : mModels) {
 | 
				
			||||||
 | 
					    model->draw();
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					  for(const auto & mesh : mMeshes) {
 | 
				
			||||||
 | 
					    mesh->draw();
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -10,7 +10,6 @@
 | 
				
			|||||||
#define QTK_SCENE_H
 | 
					#define QTK_SCENE_H
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <QMatrix4x4>
 | 
					#include <QMatrix4x4>
 | 
				
			||||||
 | 
					 | 
				
			||||||
#include <utility>
 | 
					#include <utility>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "camera3d.h"
 | 
					#include "camera3d.h"
 | 
				
			||||||
@ -66,7 +65,7 @@ namespace Qtk {
 | 
				
			|||||||
       *
 | 
					       *
 | 
				
			||||||
       * This function is only called when the widget is redrawn.
 | 
					       * This function is only called when the widget is redrawn.
 | 
				
			||||||
       */
 | 
					       */
 | 
				
			||||||
      virtual void draw();
 | 
					      virtual void draw() { privateDraw(); };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      /**
 | 
					      /**
 | 
				
			||||||
       * Function called to update the QOpenGLWidget. Does not trigger a redraw.
 | 
					       * Function called to update the QOpenGLWidget. Does not trigger a redraw.
 | 
				
			||||||
@ -166,7 +165,6 @@ namespace Qtk {
 | 
				
			|||||||
       */
 | 
					       */
 | 
				
			||||||
      inline void setSceneName(QString name) { mSceneName = std::move(name); }
 | 
					      inline void setSceneName(QString name) { mSceneName = std::move(name); }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      std::vector<Model *> mModels {};
 | 
					 | 
				
			||||||
    signals:
 | 
					    signals:
 | 
				
			||||||
      /**
 | 
					      /**
 | 
				
			||||||
       * Signal thrown when the scene is modified by adding or removing objects.
 | 
					       * Signal thrown when the scene is modified by adding or removing objects.
 | 
				
			||||||
@ -177,6 +175,16 @@ namespace Qtk {
 | 
				
			|||||||
      void sceneUpdated(QString sceneName);
 | 
					      void sceneUpdated(QString sceneName);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private:
 | 
					    private:
 | 
				
			||||||
 | 
					      /*************************************************************************
 | 
				
			||||||
 | 
					       * Private Methods
 | 
				
			||||||
 | 
					       ************************************************************************/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      /**
 | 
				
			||||||
 | 
					       * Handles drawing members encapsulated by this base class.
 | 
				
			||||||
 | 
					       * Child classes do not need to draw these objects manually.
 | 
				
			||||||
 | 
					       */
 | 
				
			||||||
 | 
					      void privateDraw();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      /*************************************************************************
 | 
					      /*************************************************************************
 | 
				
			||||||
       * Private Members
 | 
					       * Private Members
 | 
				
			||||||
       ************************************************************************/
 | 
					       ************************************************************************/
 | 
				
			||||||
@ -191,33 +199,8 @@ namespace Qtk {
 | 
				
			|||||||
      /* MeshRenderers used simple geometry. */
 | 
					      /* MeshRenderers used simple geometry. */
 | 
				
			||||||
      std::vector<MeshRenderer *> mMeshes {};
 | 
					      std::vector<MeshRenderer *> mMeshes {};
 | 
				
			||||||
      /* Models used for storing 3D models in the scene. */
 | 
					      /* Models used for storing 3D models in the scene. */
 | 
				
			||||||
 | 
					      std::vector<Model *> mModels {};
 | 
				
			||||||
  };
 | 
					  };
 | 
				
			||||||
 | 
					 | 
				
			||||||
  class SceneEmpty : public Scene {
 | 
					 | 
				
			||||||
    public:
 | 
					 | 
				
			||||||
      void init() override {
 | 
					 | 
				
			||||||
        setSceneName("Empty Scene");
 | 
					 | 
				
			||||||
      }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
      void draw() override { Scene::draw(); }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
      void update() override { Scene::update(); }
 | 
					 | 
				
			||||||
  };
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  class SceneInterface : public Scene {
 | 
					 | 
				
			||||||
    public:
 | 
					 | 
				
			||||||
      explicit SceneInterface(Scene * scene) : mScene(scene) {}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
      void init() override { mScene->init(); }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
      void draw() override { mScene->draw(); }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
      void update() override { mScene->update(); }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    protected:
 | 
					 | 
				
			||||||
      Scene * mScene;
 | 
					 | 
				
			||||||
  };
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
}  // namespace Qtk
 | 
					}  // namespace Qtk
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif  // QTK_SCENE_H
 | 
					#endif  // QTK_SCENE_H
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user