Compare commits

...

2 Commits

Author SHA1 Message Date
675082ab83 Clean up cmake. 2025-03-14 13:34:45 -04:00
ea25ba312a README screenshots. 2025-03-10 18:15:12 -04:00
50 changed files with 219 additions and 120 deletions

View File

@ -220,7 +220,7 @@ jobs:
if: matrix.os == 'windows-latest'
uses: actions/upload-artifact@v4
with:
name: qtk-${{ matrix.os }}
name: libqtk-${{ matrix.os }}
path: |
build/packages/*.exe
@ -235,7 +235,7 @@ jobs:
if: matrix.os == 'macos-latest'
uses: actions/upload-artifact@v4
with:
name: qtk-${{ matrix.os }}
name: libqtk-${{ matrix.os }}
path: |
build/packages/*.tar.gz

View File

@ -83,6 +83,8 @@ endif ()
set(QTK_RESOURCES "${CMAKE_SOURCE_DIR}/resources")
set(QTK_OSX_ICONS ${CMAKE_SOURCE_DIR}/resources/icons/osx/kilroy.icns)
string(TIMESTAMP YEAR "%Y")
set(QTK_COPYRIGHT "All Content © 2021-${YEAR} Shaun Reed, all rights reserved.")
# Point CMAKE_PREFIX_PATH to Qt6 install directory
# If Qtk is built within Qt Creator this is not required.

View File

@ -9,38 +9,53 @@ that allow rendering geometry in 2D and 3D using custom GLSL shader programs.
The Qtk desktop application provides a model loader using [Assimp](https://assimp.org/) within a Qt widget application.
You can fly around the scene using WASD while holding down the right mouse button.
Object names can be double-clicked in the tree view panel for quick camera navigation.
Properties of the object, like shader code and translation / scale, can be viewed and modified in the side panel.
![](resources/screenshots/screen.png)
All side panels and toolbars are dockable widgets that can be popped out
and reorganized as needed. Panels can also be stacked to create a docked widget with
tabs. The central widget that provides the camera view into the scene cannot be
detached from the main window in this way.
![](resources/screenshots/screen-1.png)
The small triangles floating near 3D models represent the light source being used for the shader.
These appear on models using phong, specular, and diffuse lighting techniques.
The default scene contains basic examples like texture mapping to make a crate from basic cube geometry
![](resources/screenshots/screen-texture.png)
Examples of Ambient, Diffuse, and Specular GLSL shaders.
| Ambient | Diffuse | Specular |
|-------------------------------------------------------|-------------------------------------------------------|--------------------------------------------------------|
| <img src="resources/screenshots/screen-ambient.png"/> | <img src="resources/screenshots/screen-diffuse.png"/> | <img src="resources/screenshots/screen-specular.png"/> |
And more advanced techniques like Phong lighting (ambient + diffuse + specular) and normal mapping.
![](resources/screenshots/screen-phong.png)
| Normal Mapping Disabled | Normal Mapping Enabled |
|------------------------------------------------------|--------------------------------------------------------|
| <img src="resources/screenshots/spartan-phong.png"/> | <img src="resources/screenshots/spartan-normals.png"/> |
See the `View` toolbar menu to enable debug console widgets for open scenes or reopen previously closed panels.
Key features that are planned:
- [x] Runtime loading of `.obj` or similar 3D models.
- [x] Drag-and-drop interaction for adding objects to the scene.
- [x] Shader / object properties panel to modify related settings.
- [ ] Runtime reloading of modified GLSL shaders attached to objects within scenes.
- [ ] Multiple views of a scene at one time.
- [ ] Camera control modes such as panning, orbiting, or following objects.
- [ ] Save / load for scene data. The current inheritance model is temporary.
- [ ] Save / load scene data. The current model requires writing C++ code.
- [ ] Basic text editor for quickly modifying shaders attached to objects.
- [ ] Shader / object properties panel to modify related settings.
- [ ] Reduce size of application resources and git references.
![](resources/screenshot.png)
Spartan with no normals -
![](resources/spartan-specular.png)
Spartan with normals -
![](resources/spartan-normals.png)
Object names can be double-clicked in the tree view panel for quick camera
navigation. All side panels and toolbars are dockable widgets that can be popped out
and reorganized as needed. Panels can also be stacked to create a docked widget with
tabs. The central widget that provides the camera view into the scene cannot be
detached from the main window in this way. See the `View` menu to enable debug
console widgets for open scenes or reopen previously closed panels.
The small triangles floating near 3D models represent the light source being used for the shader.
These appear on models using phong, specular, and diffuse lighting techniques.
For examples of using the Qtk API, see the `example-app` project in the root of
this repository.
@ -211,6 +226,11 @@ Ubuntu clang-format version 18.1.3 (1ubuntu1)
CLion has integration for IDE code reformatting actions with `clang-format`.
If you're using CLion, the `.clang-format` configuration will be picked up by CLion automatically.
This repository provides the [`tools/format.sh`](./tools/format.sh) helper script to run `clang-tidy` and `clang-format` on Ubuntu 24.04.
Running the script will build Qtk, so it's important to ensure you can manually build from source first.
If you'd still like to run these tools manually, see the instructions below.
`clang-tidy` can be run with the following commands.
```bash
@ -288,7 +308,7 @@ To generate packages for Qtk desktop application, we should
set `-DQTK_GUI=ON`. If this option is not set we will only package libqtk.
The NSIS installer will allow component-specific path modification for all of
these installation components through a GUI install application.
these installation components through a Windows GUI install application.
##### Resources

View File

Before

Width:  |  Height:  |  Size: 79 KiB

After

Width:  |  Height:  |  Size: 79 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 398 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 755 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

@ -0,0 +1,11 @@
#!/usr/bin/env bash
# $1: Input path to an image to use for generating icons.
# Helper script to generate qtk's icons for Linux given a path to an input PNG.
sudo apt install imagemagick
convert "$1" -resize 256x256 kilroy-256.png
convert "$1" -resize 128x128 kilroy-128.png
convert "$1" -resize 64x64 kilroy-64.png
convert "$1" -resize 48x48 kilroy-48.png
convert "$1" -resize 32x32 kilroy-32.png
convert "$1" -resize 16x16 kilroy-16.png

View File

@ -1,13 +0,0 @@
```bash
sudo apt install icnsutils
```
```bash
convert icon.png -resize 32x32 kilroy_32.png
convert icon.png -resize 16x16 kilroy_16.png
convert icon.png -resize 48x48 kilroy_48.png
convert icon.png -resize 128x128 kilroy_128.png
convert icon.png -resize 256x256 kilroy_256.png
png2icns png2icns kilroy.icns kilroy_*.png
```

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB

View File

@ -0,0 +1,15 @@
#!/usr/bin/env bash
# $1: Input path to an image to use for generating icons.
# Helper script to generate qtk's icons for OSX given a path to an input PNG.
sudo apt install icnsutils imagemagick
convert "$1" -resize 32x32 kilroy_32.png
convert "$1" -resize 16x16 kilroy_16.png
convert "$1" -resize 48x48 kilroy_48.png
convert "$1" -resize 128x128 kilroy_128.png
convert "$1" -resize 256x256 kilroy_256.png
# For the application bundle in OSX.
png2icns png2icns kilroy.icns kilroy_*.png
# For the splash image in DMG installers.
convert "$1" -resize 800x600! kilroy_splash.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 201 KiB

View File

@ -0,0 +1,10 @@
#!/usr/bin/env bash
# $1: Input path to an image to use for generating icons.
# Helper script to generate qtk's icons for OSX given a path to an input PNG.
sudo apt install imagemagick
# For the NSIS (un)installer executable shortcut icon.
convert "$1" -resize 256x256,128x128,64x64,48x48,32x32,16x16 -background transparent -colors 256 kilroy.ico
# For the NSIS installer splash screen.
convert "$1" -resize 164x314! -background white -flatten kilroy_splash.bmp

6
resources/qtk.desktop Normal file
View File

@ -0,0 +1,6 @@
[Desktop Entry]
Name=Qtk
Exec=/usr/bin/qtk_gui
Icon=qtk
Type=Application
Categories=Utility;

View File

@ -17,7 +17,7 @@
<file>fontawesome-free-6.2.1-desktop/svgs/regular/folder-open.svg</file>
<file>fontawesome-free-6.2.1-desktop/svgs/regular/floppy-disk.svg</file>
<file>fontawesome-free-6.2.1-desktop/svgs/brands/git-alt.svg</file>
<file>icon.png</file>
<file alias="icon.png">icons/icon.png</file>
</qresource>
<qresource prefix="/shaders">
<file alias="model.frag">shaders/fragment/model.frag</file>
@ -46,8 +46,8 @@
<file alias="solid-phong.vert">shaders/vertex/solid-phong.vert</file>
<file alias="model-basic.frag">shaders/fragment/model-basic.frag</file>
<file alias="model-basic.vert">shaders/vertex/model-basic.vert</file>
<file alias="model-specular.frag">shaders/fragment/model-specular.frag</file>
<file alias="model-specular.vert">shaders/vertex/model-specular.vert</file>
<file alias="model-phong.frag">shaders/fragment/model-phong.frag</file>
<file alias="model-phong.vert">shaders/vertex/model-phong.vert</file>
<file alias="model-normals.frag">shaders/fragment/model-normals.frag</file>
<file alias="model-normals.vert">shaders/vertex/model-normals.vert</file>
<file alias="skybox.frag">skybox/skybox.frag</file>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 316 KiB

View File

Before

Width:  |  Height:  |  Size: 30 KiB

After

Width:  |  Height:  |  Size: 30 KiB

View File

Before

Width:  |  Height:  |  Size: 89 KiB

After

Width:  |  Height:  |  Size: 89 KiB

View File

Before

Width:  |  Height:  |  Size: 263 KiB

After

Width:  |  Height:  |  Size: 263 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 428 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 205 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 188 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 264 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 176 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 288 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 437 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 359 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 349 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 660 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 646 KiB

View File

@ -103,18 +103,82 @@ configure_package_config_file(
)
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/LICENSE")
set(CPACK_RESOURCE_FILE_README "${CMAKE_SOURCE_DIR}/README.md")
set(CPACK_PACKAGE_VERSION_MAJOR "${PROJECT_VERSION_MAJOR}")
set(CPACK_PACKAGE_VERSION_MINOR "${PROJECT_VERSION_MINOR}")
set(CPACK_PACKAGE_VENDOR "Shaun Reed")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Qt OpenGL 3D graphics library.")
set(CPACK_PACKAGE_HOMEPAGE_URL "https://github.com/shaunrd0/qtk")
if (QTK_GUI)
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Qt OpenGL 3D graphics renderer.")
else()
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Qt OpenGL 3D graphics library.")
endif()
set(CPACK_PACKAGE_HOMEPAGE_URL "https://git.shaunreed.com/shaunrd0/qtk")
set(CPACK_SOURCE_IGNORE_FILES build*;install;\.git;\.github;\.idea)
set(CPACK_PACKAGE_DIRECTORY packages/)
set(CPACK_PACKAGE_CONTACT "shaunreed.com")
#set(CPACK_PACKAGE_ICON "${CMAKE_SOURCE_DIR}/resources/icon.png")
set(CPACK_THREADS 0)
set(CPACK_PACKAGE_INSTALL_DIRECTORY "Qtk")
if (WIN32)
# Windows
# Set icon for the splash image used in Windows NSIS installers.
set(CPACK_PACKAGE_ICON "${QTK_RESOURCES}/icons/win/kilroy_splash.bmp")
set(CPACK_NSIS_MODIFY_PATH ON)
set(CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL ON)
# https://nsis.sourceforge.io/Reference/CreateShortCut
set(
CPACK_NSIS_CREATE_ICONS_EXTRA
"CreateShortCut '$SMPROGRAMS\\\\$STARTMENU_FOLDER\\\\Qtk.lnk' '$INSTDIR\\\\bin\\\\qtk_gui.exe'"
)
set(
CPACK_NSIS_DELETE_ICONS_EXTRA
"Delete '$SMPROGRAMS\\\\$START_MENU\\\\Qtk.lnk'"
)
# Set icon for the installer executable.
set(CPACK_NSIS_MUI_ICON "${QTK_RESOURCES}/icons/win/kilroy.ico")
# Set icon for uninstaller executable.
set(CPACK_NSIS_MUI_UNIICON "${QTK_RESOURCES}/icons/win/kilroy.ico")
elseif(APPLE)
# OSX
# Set icon for the splash image used in OSX DMG installers.
set(CPACK_PACKAGE_ICON "${QTK_RESOURCES}/icons/osx/kilroy_splash.bmp")
# Set additional options for the OSX bundle.
set(CPACK_BUNDLE_NAME ${PROJECT_NAME})
set(CPACK_BUNDLE_PLIST $<TARGET_BUNDLE_CONTENT_DIR:qtk_gui>/Info.plist)
set(CPACK_BUNDLE_ICON ${QTK_OSX_ICONS})
else(UNIX)
# Linux
# Install icons for qtk.
install(FILES ${QTK_RESOURCES}/icons/linux/kilroy-16.png
DESTINATION /usr/share/icons/hicolor/16x16/apps
RENAME qtk.png)
install(FILES ${QTK_RESOURCES}/icons/linux/kilroy-32.png
DESTINATION /usr/share/icons/hicolor/32x32/apps
RENAME qtk.png)
install(FILES ${QTK_RESOURCES}/icons/linux/kilroy-48.png
DESTINATION /usr/share/icons/hicolor/48x48/apps
RENAME qtk.png)
install(FILES ${QTK_RESOURCES}/icons/linux/kilroy-64.png
DESTINATION /usr/share/icons/hicolor/64x64/apps
RENAME qtk.png)
install(FILES ${QTK_RESOURCES}/icons/linux/kilroy-128.png
DESTINATION /usr/share/icons/hicolor/128x128/apps
RENAME qtk.png)
install(FILES ${QTK_RESOURCES}/icons/linux/kilroy-256.png
DESTINATION /usr/share/icons/hicolor/256x256/apps
RENAME qtk.png)
# Install the desktop file for qtk.
install(FILES ${QTK_RESOURCES}/qtk.desktop
DESTINATION /usr/share/applications)
# Set additional options for the debian APT package.
set(CPACK_DEBIAN_PACKAGE_HOMEPAGE ${CPACK_PACKAGE_HOMEPAGE_URL})
set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
endif()
# Remove any assimp components if defined by submodule.
if (QTK_SUBMODULES)
get_cmake_property(CPACK_COMPONENTS_ALL COMPONENTS)
@ -122,31 +186,6 @@ if (QTK_SUBMODULES)
list(REMOVE_ITEM CPACK_COMPONENTS_ALL Unspecified)
endif()
# Windows
set(CPACK_NSIS_MODIFY_PATH ON)
set(CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL ON)
# https://nsis.sourceforge.io/Reference/CreateShortCut
set(
CPACK_NSIS_CREATE_ICONS_EXTRA
"CreateShortCut '$SMPROGRAMS\\\\$STARTMENU_FOLDER\\\\Qtk.lnk' '$INSTDIR\\\\bin\\\\qtk_gui.exe'"
)
set(
CPACK_NSIS_DELETE_ICONS_EXTRA
"Delete '$SMPROGRAMS\\\\$START_MENU\\\\Qtk.lnk'"
)
# TODO: Icons for NSIS installer.
#set(CPACK_NSIS_MUI_ICON "${CMAKE_SOURCE_DIR}/resources/icon.png")
#set(CPACK_NSIS_MUI_UNIICON "${CMAKE_SOURCE_DIR}/resources/icon.png")
# Debian
set(CPACK_DEBIAN_PACKAGE_HOMEPAGE ${CPACK_PACKAGE_HOMEPAGE_URL})
set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
# OSX
set(CPACK_BUNDLE_NAME ${PROJECT_NAME})
set(CPACK_BUNDLE_PLIST $<TARGET_BUNDLE_CONTENT_DIR:qtk_gui>/Info.plist)
set(CPACK_BUNDLE_ICON ${QTK_OSX_ICONS})
# Platform defaults for source bundles.
if(WIN32)
set(CPACK_SOURCE_GENERATOR ZIP)

View File

@ -57,15 +57,18 @@ set(
qt_add_executable(qtk_gui ${QTK_GUI_SOURCES})
target_link_libraries(qtk_gui PRIVATE qtk_plugin_library)
set_target_properties(
qtk_gui PROPERTIES
WIN32_EXECUTABLE TRUE
if (WIN32)
set_target_properties(qtk_gui PROPERTIES WIN32_EXECUTABLE TRUE)
elseif(APPLE)
set_target_properties(
qtk_gui PROPERTIES
MACOSX_BUNDLE TRUE
MACOSX_BUNDLE_BUNDLE_NAME Qtk
MACOSX_BUNDLE_ICON_FILE ${QTK_OSX_ICONS}
MACOSX_BUNDLE_GUI_IDENTIFIER ${CMAKE_PROJECT_NAME}
MACOSX_BUNDLE_INFO_STRING ${CMAKE_PROJECT_DESCRIPTION}
MACOSX_BUNDLE_COPYRIGHT "All Content (c) 2023 Shaun Reed, all rights reserved"
MACOSX_BUNDLE_COPYRIGHT ${QTK_COPYRIGHT}
MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
)
)
endif()

View File

@ -33,12 +33,14 @@ MainWindow::MainWindow(QWidget * parent) : QMainWindow(parent)
// Add GUI 'view' toolbar option to show debug console.
ui_->menuView->addAction(qtkWidget->getActionToggleConsole());
// Refresh GUI widgets when scene or objects are updated.
connect(qtkWidget->getScene(),
&Qtk::Scene::sceneUpdated,
this,
&MainWindow::refreshScene);
connect(qtkWidget, &Qtk::QtkWidget::objectFocusChanged,
connect(qtkWidget,
&Qtk::QtkWidget::objectFocusChanged,
ui_->qtk__ToolBox,
&Qtk::ToolBox::updateFocus);
}
@ -71,8 +73,8 @@ MainWindow::~MainWindow()
MainWindow * MainWindow::getMainWindow()
{
static MainWindow window;
return &window;
static auto * window = new MainWindow;
return window;
}
Qtk::QtkWidget * MainWindow::getQtkWidget(int64_t index)

View File

@ -48,10 +48,9 @@ namespace Ui
* Any application using a QtkWidget can set a custom scene in their main
* function. See the MainWindow::MainWindow constructor as an example.
*/
class EmptyScene : public Qtk::Scene {
void init() override {
setSceneName("Empty Scene");
}
class EmptyScene : public Qtk::Scene
{
void init() override { setSceneName("Empty Scene"); }
};
/**

View File

@ -21,7 +21,7 @@
</property>
<property name="windowIcon">
<iconset>
<normaloff>../resources/icon.png</normaloff>../resources/icon.png</iconset>
<normaloff>../resources/icons/icon.png</normaloff>../resources/icons/icon.png</iconset>
</property>
<property name="unifiedTitleAndToolBarOnMac">
<bool>true</bool>

View File

@ -260,8 +260,8 @@ void QtkScene::init()
/* Test spartan Model with phong lighting, specular and normal mapping. */
model = addObject(new Qtk::Model("spartanTest",
":/models/models/spartan/spartan.obj",
":/shaders/model-normals.vert",
":/shaders/model-normals.frag"));
":/shaders/model-phong.vert",
":/shaders/model-phong.frag"));
model->getTransform().setTranslation(0.0f, -1.0f, 10.0f);
model->getTransform().scale(2.0f);
model->setUniform("uMaterial.ambient", QVector3D(1.0f, 1.0f, 1.0f));

View File

@ -83,7 +83,11 @@ void QtkWidget::initializeGL()
// Connect the frameSwapped signal to call the update() function
connect(this, SIGNAL(frameSwapped()), this, SLOT(update()));
toggleConsole();
// Add the debug console widget to the window and set its hidden state.
MainWindow::getMainWindow()->addDockWidget(
Qt::DockWidgetArea::BottomDockWidgetArea, mConsole);
mConsole->setHidden(!mConsoleActive);
// Initialize OpenGL debug context
mDebugLogger = new QOpenGLDebugLogger(this);
if (mDebugLogger->initialize()) {
@ -144,15 +148,8 @@ void QtkWidget::setScene(Scene * scene)
void QtkWidget::toggleConsole()
{
if (mConsoleActive) {
mConsole->setHidden(true);
mConsoleActive = false;
} else {
MainWindow::getMainWindow()->addDockWidget(
Qt::DockWidgetArea::BottomDockWidgetArea, mConsole);
mConsole->setHidden(false);
mConsoleActive = true;
}
mConsole->setHidden(mConsoleActive);
mConsoleActive = !mConsoleActive;
}
/*******************************************************************************

View File

@ -210,7 +210,7 @@ namespace Qtk
QOpenGLDebugLogger * mDebugLogger;
Qtk::Scene * mScene;
Qtk::DebugConsole * mConsole;
bool mConsoleActive = false;
bool mConsoleActive = true;
};
} // namespace Qtk

View File

@ -41,36 +41,33 @@ void Qtk::TreeView::updateView(const Qtk::Scene * scene)
mSceneName = scene->getSceneName();
auto objects = scene->getObjects();
for (const auto & object : objects) {
auto item =
new QTreeWidgetItem(QStringList(QString(object->getName().c_str())));
ui->treeWidget->insertTopLevelItem(0, item);
QStringList list(QStringList(QString(object->getName().c_str())));
ui->treeWidget->insertTopLevelItem(0, new QTreeWidgetItem(list));
}
}
void Qtk::TreeView::itemFocus(QTreeWidgetItem * item, int column)
{
QString name = item->text(column);
const QString & name = item->text(column);
auto scene = MainWindow::getMainWindow()->getQtkWidget()->getScene();
auto & transform = Qtk::Scene::getCamera().getTransform();
auto object = scene->getObject(name);
Transform3D * objectTransform;
// If the object is a mesh or model, focus the camera on it.
if (object == Q_NULLPTR) {
qDebug() << "Attempt to get non-existing object with name '" << name
<< "'\n";
} else if (object->getType() == Object::QTK_MESH) {
objectTransform = &dynamic_cast<MeshRenderer *>(object)->getTransform();
} else if (object->getType() == Object::QTK_MODEL) {
objectTransform = &dynamic_cast<Model *>(object)->getTransform();
return;
}
auto focusScale = objectTransform->getScale();
const Transform3D & objectTransform = object->getTransform();
auto & camera_transform = Qtk::Scene::getCamera().getTransform();
auto focusScale = objectTransform.getScale();
float width = focusScale.x() / 2.0f;
float height = focusScale.y() / 2.0f;
QVector3D pos = objectTransform->getTranslation();
QVector3D pos = objectTransform.getTranslation();
// pos.setX(pos.x() + width);
pos.setY(pos.y() + height);
transform.setTranslation(pos);
transform.translate(0.0f, 0.0f, 3.0f);
camera_transform.setTranslation(pos);
camera_transform.translate(0.0f, 0.0f, 3.0f);
// Emit signal from qtk widget for new object focus. Triggers GUI updates.
emit MainWindow::getMainWindow() -> getQtkWidget()->objectFocusChanged(name);

View File

@ -216,7 +216,7 @@ namespace Qtk
/**
* @return Transform3D attached to this MeshRenderer.
*/
inline Transform3D & getTransform() { return mTransform; }
inline Transform3D & getTransform() override { return mTransform; }
[[nodiscard]] inline std::string getVertexShader() const override
{

View File

@ -129,7 +129,7 @@ namespace Qtk
/**
* @return Transform3D attached to this Model.
*/
inline Transform3D & getTransform() { return mTransform; }
inline Transform3D & getTransform() override { return mTransform; }
[[nodiscard]] inline std::string getVertexShader() const override
{

View File

@ -111,6 +111,11 @@ namespace Qtk
return mTransform;
}
[[nodiscard]] inline virtual Transform3D & getTransform()
{
return mTransform;
}
[[nodiscard]] inline virtual std::string getVertexShader() const
{
return "Base Object has no vertex shader.";

View File

@ -118,11 +118,9 @@ void Scene::setSkybox(Skybox * skybox)
void Scene::initSceneObjectName(Object * object)
{
if (!mObjectCount.count(object->getName())) {
mObjectCount[object->getName()] = 1;
} else {
mObjectCount[object->getName()]++;
}
mObjectCount[object->getName()] = mObjectCount.count(object->getName()) + 1;
// If the object exists make it's name unique.
auto count = mObjectCount[object->getName()];
if (count > 1) {
object->setName(object->getName() + " (" + std::to_string(count) + ")");

View File

@ -1,7 +1,15 @@
#!/usr/bin/env bash
# Helper script to run clang-tidy and clang-format.
# This should be executed from the root of the repository:
#
# git clone https://git.shaunreed.com/shaunrd0/qtk
# cd qtk
# ./tools/format.sh
# Configure and build qtk
cmake -B build && cmake --build build -- -j $(nproc --ignore=1)
clang-tidy -p build/ --fix --config-file=.clang-tidy \
src/**/*.cpp src/**/*.h example-app/*.cpp example-app/*.h
clang-format -i --style=file:.clang-format \
src/**/*.cpp src/**/*.h example-app/*.cpp example-app/*.h
# Run clang-tidy and clang-format
SOURCES="src/**/*.cpp src/**/*.h example-app/*.cpp example-app/*.h"
clang-tidy -p build/ --fix --config-file=.clang-tidy $SOURCES
clang-format -i --style=file:.clang-format $SOURCES