2 Commits

Author SHA1 Message Date
64c7b3d2eb old WIP code
Some checks failed
All Builds / Qtk (-DCMAKE_PREFIX_PATH=/home/runner/work/qtk/Qt/$QT_VERSION/gcc_64/ $CONFIG, -j $(nproc), ubuntu-latest) (push) Failing after 1m23s
All Builds / Qtk-Library (-DCMAKE_PREFIX_PATH=/home/runner/work/qtk/Qt/$QT_VERSION/gcc_64/ $CONFIG, -j $(nproc), ubuntu-latest) (push) Failing after 21s
All Builds / Qtk-Plugins (-DCMAKE_PREFIX_PATH=/home/runner/work/qtk/Qt/$QT_VERSION/gcc_64/ $CONFIG, -j $(nproc), ubuntu-latest) (push) Failing after 18s
All Builds / Qtk-Assimp-Targets (-DCMAKE_PREFIX_PATH=/home/runner/work/qtk/Qt/$QT_VERSION/gcc_64/, ubuntu-latest) (push) Failing after 18s
Linting / Tidy (push) Failing after 53s
Linting / Format (app) (push) Failing after 31s
Linting / Format (src) (push) Failing after 25s
All Builds / Qtk (-DCMAKE_PREFIX_PATH=/home/runner/work/qtk/Qt/$QT_VERSION/gcc_64/ $CONFIG, -j $(nproc), macos-latest) (push) Has been cancelled
All Builds / Qtk (-DCMAKE_PREFIX_PATH=D:/a/qtk/qtk/Qt/$QT_VERSION/mingw81_64/ $CONFIG, , windows-latest) (push) Has been cancelled
All Builds / Qtk-Library (-DCMAKE_PREFIX_PATH=/home/runner/work/qtk/Qt/$QT_VERSION/gcc_64/ $CONFIG, -j $(nproc), macos-latest) (push) Has been cancelled
All Builds / Qtk-Library (-DCMAKE_PREFIX_PATH=D:/a/qtk/qtk/Qt/$QT_VERSION/mingw81_64/ $CONFIG, , windows-latest) (push) Has been cancelled
All Builds / Qtk-Plugins (-DCMAKE_PREFIX_PATH=/home/runner/work/qtk/Qt/$QT_VERSION/gcc_64/ $CONFIG, -j $(nproc), macos-latest) (push) Has been cancelled
All Builds / Qtk-Plugins (-DCMAKE_PREFIX_PATH=D:/a/qtk/qtk/Qt/$QT_VERSION/mingw81_64/ $CONFIG, , windows-latest) (push) Has been cancelled
All Builds / Qtk-Assimp-Targets (-DCMAKE_PREFIX_PATH=/home/runner/work/qtk/Qt/$QT_VERSION/gcc_64/, macos-latest) (push) Has been cancelled
2025-02-13 20:12:28 -05:00
2087b306b9 Fix order of arguments for rotation functions. 2024-03-10 15:22:31 -04:00
21 changed files with 457 additions and 635 deletions

View File

@@ -1,331 +0,0 @@
name: All Builds
on:
pull_request:
workflow_dispatch:
env:
QT_VERSION: 6.6.0
jobs:
Qtk:
env:
CONFIG: -DQTK_SUBMODULES=ON -DQTK_DEBUG=OFF -DQTK_CCACHE=OFF -DQTK_GUI=ON -DQTK_PLUGINS=OFF -DQTK_EXAMPLE=ON
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
include:
- os: ubuntu-latest
cmake: -DCMAKE_PREFIX_PATH=/home/runner/work/qtk/Qt/$QT_VERSION/gcc_64/ $CONFIG
flags: -j $(nproc)
- os: windows-latest
cmake: -DCMAKE_PREFIX_PATH=D:/a/qtk/qtk/Qt/$QT_VERSION/mingw81_64/ $CONFIG
flags: ''
- os: macos-latest
cmake: -DCMAKE_PREFIX_PATH=/home/runner/work/qtk/Qt/$QT_VERSION/gcc_64/ $CONFIG
flags: -j $(nproc)
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: Install Debian packaging dependencies
if: matrix.os == 'ubuntu-latest'
run: |
apt update -y
apt install libxcb-cursor0 python3 -y
- name: Install Qt
uses: jurplel/install-qt-action@v2
with:
version: ${{ env.QT_VERSION }}
# Windows
- name: Chocolatey Action
if: matrix.os == 'windows-latest'
uses: crazy-max/ghaction-chocolatey@v2
with:
args: install pkgconfiglite --checksum e87b5ea3c9142256af60f2d5b917aa63b571e6a0 --checksum-type sha1
- name: Configure Qtk Application
shell: bash
run: cmake -B build/ ${{ matrix.cmake }}
- name: Build Qtk Application
shell: bash
run: cmake --build build/ --config Release --target qtk_gui ${{ matrix.flags }}
- name: Build Qtk Example
if: matrix.os != 'windows-latest'
shell: bash
run: cmake --build build/ --config Release --target qtk_example ${{ matrix.flags }}
# Packaging
- name: Install Qtk Application
shell: bash
run: cmake --install build/ --config Release --component qtk_gui
- name: Package Qtk Application
shell: bash
run: cmake --build build/ --target package --config Release
- name: Package Qtk (DEB)
if: matrix.os == 'ubuntu-latest'
shell: bash
run: |
cd build
cpack -C Release -G DEB
- name: Upload package artifacts (DEB)
if: matrix.os == 'ubuntu-latest'
uses: actions/upload-artifact@v3
with:
name: qtk-gui-${{ matrix.os }}
path: |
build/packages/*.deb
- name: Package Qtk (WIN)
if: matrix.os == 'windows-latest'
shell: bash
run: |
cd build
cpack -C Release -G NSIS
- name: Upload package artifacts (WIN)
if: matrix.os == 'windows-latest'
uses: actions/upload-artifact@v3
with:
name: qtk-gui-${{ matrix.os }}
path: |
build/packages/*.exe
- name: Package Qtk (OSX)
if: matrix.os == 'macos-latest'
shell: bash
run: |
cd build
cpack -C Release -G TGZ
- name: Upload package artifacts (OSX)
if: matrix.os == 'macos-latest'
uses: actions/upload-artifact@v3
with:
name: qtk-gui-${{ matrix.os }}
path: |
build/packages/*.tar.gz
- name: Upload Qtk install directory
uses: actions/upload-artifact@v3
with:
name: qtk-gui-${{ matrix.os }}-install
path: install/*
# TODO: Enable after trimming resources.
# - name: Package Qtk Application Sources
# if: matrix.os != 'macos-latest'
# shell: bash
# run: |
# cmake --build build/ --target package_source
#
# - name: Upload package artifacts
# uses: actions/upload-artifact@v3
# with:
# name: qtk-${{ matrix.os }}-packages
# path: |
# build/packages/*
# !build/packages/_CPack_Packages/*
Qtk-Library:
env:
CONFIG: -DQTK_SUBMODULES=ON -DQTK_DEBUG=OFF -DQTK_CCACHE=OFF -DQTK_GUI=OFF -DQTK_PLUGINS=OFF -DQTK_EXAMPLE=OFF
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
include:
- os: ubuntu-latest
cmake: -DCMAKE_PREFIX_PATH=/home/runner/work/qtk/Qt/$QT_VERSION/gcc_64/ $CONFIG
flags: -j $(nproc)
- os: windows-latest
cmake: -DCMAKE_PREFIX_PATH=D:/a/qtk/qtk/Qt/$QT_VERSION/mingw81_64/ $CONFIG
flags: ''
- os: macos-latest
cmake: -DCMAKE_PREFIX_PATH=/home/runner/work/qtk/Qt/$QT_VERSION/gcc_64/ $CONFIG
flags: -j $(nproc)
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: Install Qt
uses: jurplel/install-qt-action@v2
with:
version: ${{ env.QT_VERSION }}
# Windows
- name: Chocolatey Action
if: matrix.os == 'windows-latest'
uses: crazy-max/ghaction-chocolatey@v2
with:
args: install pkgconfiglite --checksum e87b5ea3c9142256af60f2d5b917aa63b571e6a0 --checksum-type sha1
- name: Configure Qtk Library
shell: bash
run: cmake -B build/ ${{ matrix.cmake }}
- name: Build Qtk Library
shell: bash
run: cmake --build build/ --config Release --target qtk_library -- ${{ matrix.flags }}
# Packaging
- name: Install Qtk Library
shell: bash
run: cmake --install build/ --config Release --prefix=$(pwd)/install --component qtk_library
- name: Package Qtk Library
shell: bash
run: cmake --build build/ --target package --config Release
- name: Package Qtk Library (DEB)
if: matrix.os == 'ubuntu-latest'
shell: bash
run: |
cd build
cpack -C Release -G DEB
- name: Upload package artifacts (DEB)
if: matrix.os == 'ubuntu-latest'
uses: actions/upload-artifact@v3
with:
name: libqtk-${{ matrix.os }}
path: |
build/packages/*.deb
- name: Package Qtk Library (WIN)
if: matrix.os == 'windows-latest'
shell: bash
run: |
cd build
cpack -C Release -G NSIS
- name: Upload package artifacts (WIN)
if: matrix.os == 'windows-latest'
uses: actions/upload-artifact@v3
with:
name: qtk-${{ matrix.os }}
path: |
build/packages/*.exe
- name: Package Qtk Library (OSX)
if: matrix.os == 'macos-latest'
shell: bash
run: |
cd build
cpack -C Release -G TGZ
- name: Upload package artifacts (OSX)
if: matrix.os == 'macos-latest'
uses: actions/upload-artifact@v3
with:
name: qtk-${{ matrix.os }}
path: |
build/packages/*.tar.gz
- name: Upload libqtk install
uses: actions/upload-artifact@v3
if: always()
with:
name: libqtk-${{ matrix.os }}-install
path: install/*
Qtk-Plugins:
env:
CONFIG: -DQTK_SUBMODULES=ON -DQTK_DEBUG=OFF -DQTK_CCACHE=OFF -DQTK_GUI=OFF -DQTK_PLUGINS=ON -DQTK_EXAMPLE=OFF
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
include:
- os: ubuntu-latest
cmake: -DCMAKE_PREFIX_PATH=/home/runner/work/qtk/Qt/$QT_VERSION/gcc_64/ $CONFIG
flags: -j $(nproc)
- os: windows-latest
cmake: -DCMAKE_PREFIX_PATH=D:/a/qtk/qtk/Qt/$QT_VERSION/mingw81_64/ $CONFIG
flags: ''
- os: macos-latest
cmake: -DCMAKE_PREFIX_PATH=/home/runner/work/qtk/Qt/$QT_VERSION/gcc_64/ $CONFIG
flags: -j $(nproc)
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: Install Qt
uses: jurplel/install-qt-action@v2
with:
version: ${{ env.QT_VERSION }}
- name: Chocolatey Action
if: matrix.os == 'windows-latest'
uses: crazy-max/ghaction-chocolatey@v2
with:
args: install pkgconfiglite --checksum e87b5ea3c9142256af60f2d5b917aa63b571e6a0 --checksum-type sha1
- name: Configure Qtk Plugins
shell: bash
run: cmake -B build/ ${{ matrix.cmake }}
- name: Build Qtk Plugins
shell: bash
run: cmake --build build/ --config Release --target qtk_plugins -- ${{ matrix.flags }}
# Packaging
- name: Install Qtk Plugins
shell: bash
run: cmake --install build/ --config Release --component qtk_plugins
Qtk-Assimp-Targets:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
include:
- os: ubuntu-latest
cmake: -DCMAKE_PREFIX_PATH=/home/runner/work/qtk/Qt/$QT_VERSION/gcc_64/
- os: macos-latest
cmake: -DCMAKE_PREFIX_PATH=/home/runner/work/qtk/Qt/$QT_VERSION/gcc_64/
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: Install Qt
uses: jurplel/install-qt-action@v2
with:
version: ${{ env.QT_VERSION }}
- name: Install Assimp MacOS
if: matrix.os == 'macos-latest'
shell: bash
run: |
brew install assimp
- name: Install Assimp Ubuntu
if: matrix.os == 'ubuntu-latest'
shell: bash
run: |
apt install libassimp-dev
- name: Configure Qtk
shell: bash
run: cmake -B build/ ${{ matrix.cmake }} -DQTK_CCACHE=OFF -DQTK_ASSIMP_NEW_INTERFACE=ON
- name: Build Qtk
shell: bash
run: cmake --build build/ --config Release

View File

@@ -1,76 +0,0 @@
name: Linting
on:
push:
workflow_dispatch:
jobs:
Tidy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install Assimp Ubuntu
run: |
python3 --version
- name: Install Assimp Ubuntu
run: |
apt update -y
apt install libassimp-dev -y
- name: Install Qt
uses: jurplel/install-qt-action@v3
with:
version: '6.5.0'
- name: Build Qtk
run: |
cmake -B build -DQTK_SUBMODULES=OFF -DQTK_CCACHE=OFF -DQTK_PLUGINS=OFF -DQTK_GUI=ON
cmake --build build --target qtk_gui -- -j $(nproc)
- uses: cpp-linter/cpp-linter-action@v2
id: linter
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
# Use clang-tools 14
version: '14'
# Don't use clang-format with this action
# + Set to `file` to use .clang-format (Qtk formats with clang 15)
style: ''
# Use .clang-tidy file
tidy-checks: ''
# Check the entire repo for source files to tidy
files-changed-only: false
# Ignore qtk build and external assimp directories
ignore: '.github|build|extern/assimp/assimp'
# Point to compile_commands.json produced by build
database: 'build'
# Use thread comments as feedback
thread-comments: true
# Show file annotations on GH
file-annotations: true
- name: Fail CI if checks don't pass
if: steps.linter.outputs.checks-failed != 0
run: exit 1
Format:
runs-on: ubuntu-latest
strategy:
matrix:
path:
- 'src'
- 'app'
steps:
- uses: actions/checkout@v3
- name: Setup docker
uses: crazy-max/ghaction-setup-docker@v3
- name: clang-format Check
uses: jidicula/clang-format-action@v4.9.0
with:
clang-format-version: '15'
check-path: ${{ matrix.path }}

View File

@@ -13,8 +13,8 @@ using namespace Qtk;
ExampleScene::ExampleScene(Qtk::Scene * scene) : Qtk::SceneInterface(scene) {
setSceneName("Example Scene");
getCamera().getTransform().setTranslation(-8.0f, 0.0f, 10.0f);
getCamera().getTransform().setRotation(-5.0f, 0.0f, 1.0f, 0.0f);
getCamera().setTranslation({-8.0f, 0.0f, 10.0f});
getCamera().setRotation(0.0f, 1.0f, 0.0f, -5.0f);
}
ExampleScene::~ExampleScene() {}
@@ -64,10 +64,10 @@ void ExampleScene::update() {
// Pitch forward and roll sideways
MeshRenderer::getInstance("leftTriangle")
->getTransform()
.rotate(0.75f, 1.0f, 0.0f, 0.0f);
.rotate(1.0f, 0.0f, 0.0f, 0.75f);
MeshRenderer::getInstance("rightTriangle")
->getTransform()
.rotate(0.75f, 0.0f, 0.0f, 1.0f);
.rotate(0.0f, 0.0f, 1.0f, 0.75f);
static float translateX = 0.025f;
float limit = -9.0f; // Origin position.x - 2.0f
@@ -86,12 +86,12 @@ void ExampleScene::update() {
.translate(-translateX, 0.0f, 0.0f);
MeshRenderer::getInstance("topTriangle")
->getTransform()
.rotate(0.75f, 0.2f, 0.0f, 0.4f);
.rotate(0.2f, 0.0f, 0.4f, 0.75f);
MeshRenderer::getInstance("bottomTriangle")
->getTransform()
.rotate(0.75f, 0.0f, 0.2f, 0.4f);
.rotate(0.0f, 0.2f, 0.4f, 0.75f);
MeshRenderer::getInstance("centerCube")
->getTransform()
.rotate(0.75f, 0.2f, 0.4f, 0.6f);
.rotate(0.2f, 0.4f, 0.6f, 0.75f);
}

View File

@@ -47,13 +47,13 @@ target_link_libraries(qtk_plugins PUBLIC qtk_plugin_library)
################################################################################
# Final Qtk Application
################################################################################
# Source files for the main window and core application
set(
QTK_GUI_SOURCES
qtkscene.cpp qtkscene.h
# logger.cpp logger.h
main.cpp
)
qt_add_executable(qtk_gui ${QTK_GUI_SOURCES})
target_link_libraries(qtk_gui PRIVATE qtk_plugin_library)

View File

@@ -28,6 +28,7 @@ DebugConsole::DebugConsole(
auto qtkWidget = dynamic_cast<QtkWidget *>(owner);
if(qtkWidget) {
connect(qtkWidget, &QtkWidget::sendLog, this, &DebugConsole::sendLog);
connect(
qtkWidget->getLogger(), &Logger::sendLog, this, &DebugConsole::sendLog);
}
}

View File

@@ -61,7 +61,8 @@ namespace Qtk {
* @param context The DebugContext to use for the message.
* Default value is Status.
*/
inline void sendLog(QString message, DebugContext context = Status) {
inline void sendLog(QString message, Qtk::DebugContext context = Status) {
// qDebug() << "[LOGGER]: " << qPrintable(message) << "; LOGGER";
mConsole->setTextColor(logColor(context));
mConsole->append(logPrefix(message, context));
}

107
src/app/logger.cpp Normal file
View File

@@ -0,0 +1,107 @@
/*##############################################################################
## Author: Shaun Reed ##
## Legal: All Content (c) 2023 Shaun Reed, all rights reserved ##
## About: Logger for Qtk ##
## ##
## Contact: shaunrd0@gmail.com | URL: www.shaunreed.com | GitHub: shaunrd0 ##
##############################################################################*/
#include "logger.h"
#include "qtkwidget.h"
using namespace Qtk;
Logger::Logger(Qtk::QtkWidget * parent) : QObject(parent) {
// connect(
// this, SIGNAL(sendLog(QString, Qtk::DebugContext)), this,
// SLOT(log(QString, Qtk::DebugContext)));
if(parent != Q_NULLPTR) {
connect(
parent, SIGNAL(sendLog(QString, Qtk::DebugContext)), this,
SLOT(log(QString, Qtk::DebugContext)));
}
}
std::pair<QString, DebugContext> Logger::log(const QOpenGLDebugMessage & msg) {
QString error_msg;
DebugContext context;
// Format based on severity
switch(msg.severity()) {
case QOpenGLDebugMessage::NotificationSeverity:
error_msg += "--";
context = Status;
break;
case QOpenGLDebugMessage::HighSeverity:
error_msg += "!!";
context = Fatal;
break;
case QOpenGLDebugMessage::MediumSeverity:
error_msg += "!~";
context = Error;
break;
case QOpenGLDebugMessage::LowSeverity:
error_msg += "~~";
context = Warn;
break;
case QOpenGLDebugMessage::InvalidSeverity:
error_msg += "??";
context = Invalid;
break;
case QOpenGLDebugMessage::AnySeverity:
error_msg += "**";
context = Any;
break;
}
error_msg += " (";
// Format based on source
#define CASE(c) \
case QOpenGLDebugMessage::c: \
error_msg += #c; \
break
switch(msg.source()) {
CASE(APISource);
CASE(WindowSystemSource);
CASE(ShaderCompilerSource);
CASE(ThirdPartySource);
CASE(ApplicationSource);
CASE(OtherSource);
CASE(InvalidSource);
CASE(AnySource);
}
#undef CASE
error_msg += " : ";
// Format based on type
#define CASE(c) \
case QOpenGLDebugMessage::c: \
error_msg += #c; \
break
switch(msg.type()) {
CASE(InvalidType);
CASE(ErrorType);
CASE(DeprecatedBehaviorType);
CASE(UndefinedBehaviorType);
CASE(PortabilityType);
CASE(PerformanceType);
CASE(OtherType);
CASE(MarkerType);
CASE(GroupPushType);
CASE(GroupPopType);
CASE(AnyType);
}
#undef CASE
error_msg += ")\n" + msg.message();
log(error_msg, context);
return {error_msg, context};
}
void Logger::log(const QString & message, DebugContext context) {
const QString log_msg = "[LOGGER]: " + message + "; LOGGER";
qDebug() << qPrintable(log_msg);
emit sendLog(log_msg, context);
}

37
src/app/logger.h Normal file
View File

@@ -0,0 +1,37 @@
/*##############################################################################
## Author: Shaun Reed ##
## Legal: All Content (c) 2023 Shaun Reed, all rights reserved ##
## About: Logger for Qtk ##
## ##
## Contact: shaunrd0@gmail.com | URL: www.shaunreed.com | GitHub: shaunrd0 ##
##############################################################################*/
#ifndef QTK_LOGGER_H
#define QTK_LOGGER_H
#include <QOpenGLDebugMessage>
#include <QString>
#include "qtk/qtkapi.h"
namespace Qtk {
class QtkWidget;
class Logger : public QObject {
Q_OBJECT
public:
explicit Logger(Qtk::QtkWidget * parent = nullptr);
public slots:
std::pair<QString, DebugContext> log(
const QOpenGLDebugMessage & msg);
void log(
const QString & message,
Qtk::DebugContext context = Qtk::DebugContext::Status);
signals:
void sendLog(const QString & message, Qtk::DebugContext context);
};
} // namespace Qtk
#endif // QTK_LOGGER_H

View File

@@ -16,8 +16,9 @@ using namespace Qtk;
QtkScene::QtkScene(Qtk::Scene * scene) : Qtk::SceneInterface(scene) {
setSceneName("Qtk Scene");
getCamera().getTransform().setTranslation(0.0f, 0.0f, 20.0f);
getCamera().getTransform().setRotation(-5.0f, 0.0f, 1.0f, 0.0f);
getCamera().setTranslation({0.0f, 0.0f, 20.0f});
getCamera().setRotation(
QQuaternion::fromAxisAndAngle(0.0f, 1.0f, 0.0f, -5.0f));
}
QtkScene::~QtkScene() {
@@ -89,7 +90,7 @@ void QtkScene::init() {
model->getTransform().setTranslation(2.0f, 2.0f, -10.0f);
// Sometimes the models are very large
model->getTransform().scale(0.0025f);
model->getTransform().rotate(-110.0f, 0.0f, 1.0f, 0.0f);
model->getTransform().rotate(0.0f, 1.0f, 0.0f, -110.0f);
model = addObject(
new Qtk::Model("alien", ":/models/models/alien-hominid/alien.obj"));
@@ -99,8 +100,8 @@ void QtkScene::init() {
model = addObject(
new Qtk::Model("My scythe", ":/models/models/scythe/scythe.obj"));
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, 0.0f, 1.0f, 0.0f);
model->getTransform().rotate(1.0f, 0.0f, 0.0f, -90.0f);
model->getTransform().rotate(0.0f, 1.0f, 0.0f, 90.0f);
model = addObject(
new Qtk::Model("masterChief", ":/models/models/spartan/spartan.obj"));
@@ -331,14 +332,14 @@ void QtkScene::init() {
mesh->reallocateNormals(mesh->getNormals());
mesh->reallocateTexCoords(mesh->getTexCoords(), 3);
mesh->releaseShaders();
mesh->getTransform().rotate(45.0f, 0.0f, 1.0f, 0.0f);
mesh->getTransform().rotate(0.0f, 1.0f, 0.0f, 45.0f);
// Texturing a cube using a cube map
// + Cube map texturing works with both QTK_DRAW_ARRAYS and QTK_DRAW_ELEMENTS
mesh =
addObject(new Qtk::MeshRenderer("testCubeMap", Cube(QTK_DRAW_ELEMENTS)));
mesh->getTransform().setTranslation(-3.0f, 1.0f, -2.0f);
mesh->getTransform().setRotation(45.0f, 0.0f, 1.0f, 0.0f);
mesh->getTransform().setRotation(0.0f, 1.0f, 0.0f, 45.0f);
mesh->setShaders(
":/shaders/texture-cubemap.vert", ":/shaders/texture-cubemap.frag");
mesh->setCubeMap(":/textures/crate.png");
@@ -439,10 +440,10 @@ void QtkScene::draw() {
void QtkScene::update() {
auto mySpartan = Model::getInstance("My spartan");
mySpartan->getTransform().rotate(0.75f, 0.0f, 1.0f, 0.0f);
mySpartan->getTransform().rotate(0.0f, 1.0f, 0.0f, 0.75f);
auto myCube = MeshRenderer::getInstance("My cube");
myCube->getTransform().rotate(-0.75f, 0.0f, 1.0f, 0.0f);
myCube->getTransform().rotate(-0.0f, 1.0f, 0.0f, 0.75f);
auto position = MeshRenderer::getInstance("alienTestLight")
->getTransform()
@@ -456,7 +457,7 @@ void QtkScene::update() {
alien->setUniform("uMVP.model", posMatrix);
alien->setUniform("uMVP.view", QtkScene::getCamera().toMatrix());
alien->setUniform("uMVP.projection", QtkScene::getProjectionMatrix());
alien->getTransform().rotate(0.75f, 0.0f, 1.0f, 0.0f);
alien->getTransform().rotate(0.0f, 1.0f, 0.0f, 0.75f);
position = MeshRenderer::getInstance("spartanTestLight")
->getTransform()
@@ -470,10 +471,10 @@ void QtkScene::update() {
spartan->setUniform("uMVP.model", posMatrix);
spartan->setUniform("uMVP.view", QtkScene::getCamera().toMatrix());
spartan->setUniform("uMVP.projection", QtkScene::getProjectionMatrix());
spartan->getTransform().rotate(0.75f, 0.0f, 1.0f, 0.0f);
spartan->getTransform().rotate(0.0f, 1.0f, 0.0f, 0.75f);
auto phong = MeshRenderer::getInstance("testPhong");
phong->getTransform().rotate(0.75f, 1.0f, 0.5f, 0.0f);
phong->getTransform().rotate(1.0f, 0.5f, 0.0f, 0.75f);
phong->bindShaders();
position =
MeshRenderer::getInstance("testLight")->getTransform().getTranslation();
@@ -488,27 +489,27 @@ void QtkScene::update() {
phong->releaseShaders();
// Rotate lighting example cubes
mTestPhong->getTransform().rotate(0.75f, 0.5f, 0.3f, 0.2f);
mTestPhong->getTransform().rotate(0.5f, 0.3f, 0.2f, 0.75f);
MeshRenderer::getInstance("noLight")->getTransform().rotate(
0.75f, 0.5f, 0.3f, 0.2f);
mTestAmbient->getTransform().rotate(0.75f, 0.5f, 0.3f, 0.2f);
mTestDiffuse->getTransform().rotate(0.75f, 0.5f, 0.3f, 0.2f);
mTestSpecular->getTransform().rotate(0.75f, 0.5f, 0.3f, 0.2f);
0.5f, 0.3f, 0.2f, 0.75f);
mTestAmbient->getTransform().rotate(0.5f, 0.3f, 0.2f, 0.75f);
mTestDiffuse->getTransform().rotate(0.5f, 0.3f, 0.2f, 0.75f);
mTestSpecular->getTransform().rotate(0.5f, 0.3f, 0.2f, 0.75f);
// Examples of various translations and rotations
// Rotate in multiple directions simultaneously
MeshRenderer::getInstance("rgbNormalsCube")
->getTransform()
.rotate(0.75f, 0.2f, 0.4f, 0.6f);
.rotate(0.2f, 0.4f, 0.6f, 0.75f);
// Pitch forward and roll sideways
MeshRenderer::getInstance("leftTriangle")
->getTransform()
.rotate(0.75f, 1.0f, 0.0f, 0.0f);
.rotate(1.0f, 0.0f, 0.0f, 0.75f);
MeshRenderer::getInstance("rightTriangle")
->getTransform()
.rotate(0.75f, 0.0f, 0.0f, 1.0f);
.rotate(0.0f, 0.0f, 1.0f, 0.75f);
// Move between two positions over time
static float translateX = 0.025f;
@@ -529,15 +530,15 @@ void QtkScene::update() {
// And lets rotate the triangles in two directions at once
MeshRenderer::getInstance("topTriangle")
->getTransform()
.rotate(0.75f, 0.2f, 0.0f, 0.4f);
.rotate(0.2f, 0.0f, 0.4f, 0.75f);
MeshRenderer::getInstance("bottomTriangle")
->getTransform()
.rotate(0.75f, 0.0f, 0.2f, 0.4f);
.rotate(0.0f, 0.2f, 0.4f, 0.75f);
// And make the bottom triangle green, instead of RGB
// Rotate center cube in several directions simultaneously
// + Not subject to gimbal lock since we are using quaternions :)
MeshRenderer::getInstance("centerCube")
->getTransform()
.rotate(0.75f, 0.2f, 0.4f, 0.6f);
.rotate(0.2f, 0.4f, 0.6f, 0.75f);
}

View File

@@ -10,16 +10,12 @@
#include <QMimeData>
#include <QVBoxLayout>
#include <qtk/input.h>
#include <qtk/scene.h>
#include <qtk/shape.h>
#include <QVBoxLayout>
#include <qtk/input.h>
#include <qtk/scene.h>
#include <qtk/shape.h>
#include "debugconsole.h"
#include "qtk/qtkmessagelogger.h"
#include "qtkmainwindow.h"
#include "qtkwidget.h"
@@ -35,8 +31,9 @@ QtkWidget::QtkWidget(QWidget * parent, const QString & name) :
QtkWidget(parent, name, Q_NULLPTR) {}
QtkWidget::QtkWidget(QWidget * parent, const QString & name, Scene * scene) :
QOpenGLWidget(parent), mDebugLogger(Q_NULLPTR),
mConsole(new DebugConsole(this, name)), mScene(Q_NULLPTR) {
QOpenGLWidget(parent), mDebugLogger(new QOpenGLDebugLogger(this)),
mConsole(new DebugConsole(this, name)), mScene(Q_NULLPTR),
mLogger(new Qtk::Logger(this)) {
setAcceptDrops(true);
setScene(scene);
setObjectName(name);
@@ -79,13 +76,20 @@ void QtkWidget::initializeGL() {
toggleConsole();
// Initialize OpenGL debug context
mDebugLogger = new QOpenGLDebugLogger(this);
if(mDebugLogger->initialize()) {
qDebug() << "GL_DEBUG Debug Logger" << mDebugLogger << "\n";
connect(
mDebugLogger, SIGNAL(messageLogged(QOpenGLDebugMessage)), this,
SLOT(messageLogged(QOpenGLDebugMessage)));
mDebugLogger, SIGNAL(messageLogged(QOpenGLDebugMessage)), mLogger,
SLOT(log(QOpenGLDebugMessage)));
// connect(
// Qtk::QtkMessageLogger::get(),
// &Qtk::QtkMessageLogger::messageLogged, mLogger,
// &Qtk::Logger::parseError);
mDebugLogger->startLogging();
QString msg;
QTextStream stream(&msg);
stream << "Logging started on GL_DEBUG Debug Logger: " << mDebugLogger;
mDebugLogger->logMessage(QOpenGLDebugMessage::createApplicationMessage(
stream.string()->toStdString().c_str()));
}
printContextInformation();
@@ -210,74 +214,6 @@ void QtkWidget::update() {
QWidget::update();
}
void QtkWidget::messageLogged(const QOpenGLDebugMessage & msg) {
QString error;
DebugContext context;
// Format based on severity
switch(msg.severity()) {
case QOpenGLDebugMessage::NotificationSeverity:
error += "--";
context = Status;
break;
case QOpenGLDebugMessage::HighSeverity:
error += "!!";
context = Fatal;
break;
case QOpenGLDebugMessage::MediumSeverity:
error += "!~";
context = Error;
break;
case QOpenGLDebugMessage::LowSeverity:
error += "~~";
context = Warn;
break;
}
error += " (";
// Format based on source
#define CASE(c) \
case QOpenGLDebugMessage::c: \
error += #c; \
break
switch(msg.source()) {
CASE(APISource);
CASE(WindowSystemSource);
CASE(ShaderCompilerSource);
CASE(ThirdPartySource);
CASE(ApplicationSource);
CASE(OtherSource);
CASE(InvalidSource);
}
#undef CASE
error += " : ";
// Format based on type
#define CASE(c) \
case QOpenGLDebugMessage::c: \
error += #c; \
break
switch(msg.type()) {
CASE(InvalidType);
CASE(ErrorType);
CASE(DeprecatedBehaviorType);
CASE(UndefinedBehaviorType);
CASE(PortabilityType);
CASE(PerformanceType);
CASE(OtherType);
CASE(MarkerType);
CASE(GroupPushType);
CASE(GroupPopType);
}
#undef CASE
error += ")\n" + msg.message() + "\n";
qDebug() << qPrintable(error);
sendLog("(OpenGL) " + error.replace("\n", "\n(OpenGL) "), context);
}
/*******************************************************************************
* Private Methods
******************************************************************************/
@@ -294,10 +230,10 @@ void QtkWidget::updateCameraInput() {
static const float rotSpeed = 0.5f;
// Handle rotations
Scene::getCamera().getTransform().rotate(
-rotSpeed * Input::mouseDelta().x(), Camera3D::LocalUp);
Scene::getCamera().getTransform().rotate(
-rotSpeed * Input::mouseDelta().y(), Scene::getCamera().getRight());
Scene::getCamera().rotate(QQuaternion::fromAxisAndAngle(
Camera3D::LocalUp, -rotSpeed * Input::mouseDelta().x()));
Scene::getCamera().rotate(QQuaternion::fromAxisAndAngle(
Scene::getCamera().getRight(), -rotSpeed * Input::mouseDelta().y()));
// Handle translations
QVector3D translation;
@@ -319,7 +255,7 @@ void QtkWidget::updateCameraInput() {
if(Input::keyPressed(Qt::Key_E)) {
translation += Scene::getCamera().getUp() / 2.0f;
}
Scene::getCamera().getTransform().translate(transSpeed * translation);
Scene::getCamera().translate(transSpeed * translation);
}
}
@@ -352,6 +288,5 @@ void QtkWidget::printContextInformation() {
auto message = QString(glType) + glVersion + "(" + glProfile + ")"
+ "\nOpenGL Vendor: " + glVendor
+ "\nRendering Device: " + glRenderer;
qDebug() << qPrintable(message);
sendLog("(OpenGL) " + message.replace("\n", "\n(OpenGL) "), Status);
emit sendLog("(OpenGL) " + message.replace("\n", "\n(OpenGL) "), Status);
}

View File

@@ -19,6 +19,7 @@
#include <qtk/qtkapi.h>
#include <qtk/scene.h>
#include "logger.h"
namespace Qtk {
class DebugConsole;
@@ -107,6 +108,8 @@ namespace Qtk {
return mDebugLogger;
}
inline Logger * getLogger() { return mLogger; }
/*************************************************************************
* Setters
************************************************************************/
@@ -129,7 +132,7 @@ namespace Qtk {
* @param message The message to log.
* @param context The context of the log message.
*/
void sendLog(const QString & message, DebugContext context = Status);
void sendLog(const QString & message, Qtk::DebugContext context = Status);
// TODO: Use this signal in treeview and toolbox to update object
// properties
@@ -178,7 +181,7 @@ namespace Qtk {
*
* @param msg The message logged.
*/
void messageLogged(const QOpenGLDebugMessage & msg);
// void messageLogged(const QOpenGLDebugMessage & msg);
private:
/*************************************************************************
@@ -204,6 +207,7 @@ namespace Qtk {
* Private Members
************************************************************************/
Qtk::Logger * mLogger;
QOpenGLDebugLogger * mDebugLogger;
Qtk::Scene * mScene;
Qtk::DebugConsole * mConsole;

View File

@@ -46,7 +46,6 @@ void Qtk::TreeView::updateView(const Qtk::Scene * scene) {
void Qtk::TreeView::itemFocus(QTreeWidgetItem * item, int column) {
QString name = item->text(column);
auto scene = MainWindow::getMainWindow()->getQtkWidget()->getScene();
auto & transform = scene->getCamera().getTransform();
auto object = scene->getObject(name);
Transform3D * objectTransform;
// If the object is a mesh or model, focus the camera on it.
@@ -59,13 +58,11 @@ void Qtk::TreeView::itemFocus(QTreeWidgetItem * item, int column) {
objectTransform = &dynamic_cast<Model *>(object)->getTransform();
}
auto focusScale = objectTransform->getScale();
float width = focusScale.x() / 2.0f;
float height = focusScale.y() / 2.0f;
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);
Qtk::Scene::getCamera().setTranslation(pos);
Qtk::Scene::getCamera().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

@@ -24,6 +24,8 @@ set(
skybox.h
texture.h
transform3D.h
qtkmessagelogger.h
../app/logger.h
)
set(
@@ -41,6 +43,8 @@ set(
skybox.cpp
texture.cpp
transform3D.cpp
qtkmessagelogger.cpp
../app/logger.cpp
)
qt6_add_big_resources(QTK_LIBRARY_SOURCES "${QTK_RESOURCES}/resources.qrc")

View File

@@ -29,28 +29,3 @@ const QMatrix4x4 & Camera3D::toMatrix() {
mWorld.translate(-mTransform.getTranslation());
return mWorld;
}
/*******************************************************************************
* Qt Streams
******************************************************************************/
QDataStream & operator<<(QDataStream & out, Camera3D & transform) {
out << transform.getTransform();
return out;
}
QDataStream & operator>>(QDataStream & in, Camera3D & transform) {
in >> transform.getTransform();
return in;
}
QDebug operator<<(QDebug dbg, const Camera3D & transform) {
dbg << "Camera3D\n{\n";
dbg << "Position: <" << transform.getTranslation().x() << ", "
<< transform.getTranslation().y() << ", "
<< transform.getTranslation().z() << ">\n";
dbg << "Rotation: <" << transform.getRotation().x() << ", "
<< transform.getRotation().y() << ", " << transform.getRotation().z()
<< " | " << transform.getRotation().scalar() << ">\n}";
return dbg;
}

View File

@@ -32,7 +32,9 @@ namespace Qtk {
/**
* @return Transform3D associated with this camera.
*/
inline Transform3D & getTransform() { return mTransform; }
[[nodiscard]] inline const Transform3D & getTransform() const {
return mTransform;
}
/**
* @return Current translation of the camera as a QVector3D.
@@ -78,33 +80,85 @@ namespace Qtk {
*/
const QMatrix4x4 & toMatrix();
/**
* Set the translation for this camera.
* TODO: Replace these methods by inheriting from a base class.
*
* @param translation QVector3D for the new translation.
*/
inline void setTranslation(const QVector3D & translation) {
mTransform.setTranslation(translation);
}
/**
* Set the rotation for this camera.
*
* @param rotation QQuaternion for the new rotation.
*/
inline void setRotation(const QQuaternion & rotation) {
mTransform.setRotation(rotation);
}
/**
* Sets a rotation upon an axis represented by the 3D vector (x, y, z)
*
* @param ax X axis to set angle for.
* @param ay Y axis to set angle for.
* @param az Z axis to set angle for.
* @param angle Angle to set rotation.
*/
inline void setRotation(float ax, float ay, float az, float angle) {
mTransform.setRotation(ax, ay, az, angle);
}
/**
* Translate the camera by the given position.
*
* @param position QVector3D for the position to translate by.
*/
inline void translate(const QVector3D & position) {
mTransform.translate(position);
}
/**
* Rotate the camera by the given rotation.
*
* @param rotation QQaternion for the rotation to apply.
*/
inline void rotate(const QQuaternion & rotation) {
mTransform.rotate(rotation);
}
/**
* Sets a rotation upon an axis represented by the 3D vector (x, y, z)
*
* @param ax X axis to set angle for.
* @param ay Y axis to set angle for.
* @param az Z axis to set angle for.
* @param angle Angle to set rotation.
*/
inline void rotate(float ax, float ay, float az, float angle) {
mTransform.rotate(ax, ay, az, angle);
}
private:
/*************************************************************************
* Private Methods
************************************************************************/
#ifndef QT_NO_DATASTREAM
friend QDataStream & operator<<(QDataStream & out, Camera3D & transform);
friend QDataStream & operator>>(QDataStream & in, Camera3D & transform);
#endif
/*************************************************************************
* Private Members
************************************************************************/
Transform3D mTransform;
QMatrix4x4 mWorld;
};
// Qt Streams
/*************************************************************************
* Qt Streams
************************************************************************/
#ifndef QT_NO_DATASTREAM
QDataStream & operator<<(QDataStream & out, const Camera3D & transform);
QDataStream & operator>>(QDataStream & in, Camera3D & transform);
#endif
#ifndef QT_NO_DEBUG_STREAM
QDebug operator<<(QDebug dbg, const Camera3D & transform);
friend QDataStream & operator<<(
QDataStream & out, const Camera3D & camera);
friend QDataStream & operator>>(QDataStream & in, Camera3D & camera);
#endif
};
} // namespace Qtk
Q_DECLARE_TYPEINFO(Qtk::Camera3D, Q_MOVABLE_TYPE);

View File

@@ -22,6 +22,8 @@
#define QTKAPI
#endif
#include "qtk/qtkmessagelogger.h"
/**
* Initialize Qt resources required by the Qtk library.
* This cannot be defined within any namespace, but can be called by ctors.
@@ -35,7 +37,7 @@ namespace Qtk {
/**
* Flag to set context for debug messages.
*/
enum DebugContext { Status, Debug, Warn, Error, Fatal };
enum DebugContext { Status, Debug, Warn, Error, Fatal, Invalid, Any };
/**
* Find top level parent for a widget.

View File

@@ -0,0 +1,61 @@
#include "qtkmessagelogger.h"
#include "camera3d.h"
#include "transform3D.h"
Qtk::QtkDebug Qtk::QtkDebug::operator<<(const Qtk::Transform3D & transform) {}
#ifndef QT_NO_DEBUG_STREAM
QDebug Qtk::operator<<(QDebug dbg, const Qtk::Transform3D & transform) {
dbg << "Transform3D\n{\n";
dbg << "Position: <" << transform.getTranslation().x() << ", "
<< transform.getTranslation().y() << ", "
<< transform.getTranslation().z() << ">\n";
dbg << "Scale: <" << transform.getScale().x() << ", "
<< transform.getScale().y() << ", " << transform.getScale().z() << ">\n";
dbg << "Rotation: <" << transform.getRotation().x() << ", "
<< transform.getRotation().y() << ", " << transform.getRotation().z()
<< " | " << transform.getRotation().scalar() << ">\n}";
return dbg;
}
QDebug Qtk::operator<<(QDebug dbg, const Qtk::Camera3D & transform) {
dbg << "Camera3D\n{\n";
dbg << "Position: <" << transform.getTranslation().x() << ", "
<< transform.getTranslation().y() << ", "
<< transform.getTranslation().z() << ">\n";
dbg << "Rotation: <" << transform.getRotation().x() << ", "
<< transform.getRotation().y() << ", " << transform.getRotation().z()
<< " | " << transform.getRotation().scalar() << ">\n}";
return dbg;
}
#endif
#ifndef QT_NO_DATASTREAM
QDataStream & Qtk::operator<<(
QDataStream & out, const Qtk::Transform3D & transform) {
out << transform.mTranslation;
out << transform.mScale;
out << transform.mRotation;
return out;
}
QDataStream & Qtk::operator>>(QDataStream & in, Qtk::Transform3D & transform) {
in >> transform.mTranslation;
in >> transform.mScale;
in >> transform.mRotation;
transform.m_dirty = true;
return in;
}
QDataStream & Qtk::operator<<(QDataStream & out, const Qtk::Camera3D & camera) {
out << camera.getTransform();
return out;
}
QDataStream & Qtk::operator>>(QDataStream & in, Qtk::Camera3D & camera) {
in >> camera.mTransform;
return in;
}
#endif

View File

@@ -0,0 +1,96 @@
#ifndef QTK_QTKMESSAGELOGGER_H
#define QTK_QTKMESSAGELOGGER_H
#include "qtkapi.h"
#include <QDebug>
#include <QMessageLogger>
#include <Qt>
// #define qtkDebug Qtk::QtkMessageLogger::get().debug
// #define qtkInfo Qtk::QtkMessageLogger::get().info
// #define qtkWarning Qtk::QtkMessageLogger::get().warning
// #define qtkCritical Qtk::QtkMessageLogger::get().critical
// #define qtkFatal Qtk::QtkMessageLogger::get().fatal
#define qtkDebug \
Qtk::QtkMessageLogger( \
QT_MESSAGELOG_FILE, QT_MESSAGELOG_LINE, QT_MESSAGELOG_FUNC) \
.logger() \
.debug
#define qtkInfo \
Qtk::QtkMessageLogger( \
QT_MESSAGELOG_FILE, QT_MESSAGELOG_LINE, QT_MESSAGELOG_FUNC) \
.logger() \
.info
#define qtkWarning \
Qtk::QtkMessageLogger( \
QT_MESSAGELOG_FILE, QT_MESSAGELOG_LINE, QT_MESSAGELOG_FUNC) \
.logger() \
.warning
#define qtkCritical \
Qtk::QtkMessageLogger( \
QT_MESSAGELOG_FILE, QT_MESSAGELOG_LINE, QT_MESSAGELOG_FUNC) \
.logger() \
.critical
#define qtkFatal \
Qtk::QtkMessageLogger( \
QT_MESSAGELOG_FILE, QT_MESSAGELOG_LINE, QT_MESSAGELOG_FUNC) \
.logger() \
.fatal
namespace Qtk {
class Transform3D;
class Camera3D;
class QTKAPI QtkDebug : public QDebug {
public:
QtkDebug operator<<(const Transform3D & transform);
};
#ifndef QT_NO_DEBUG_STREAM
QDebug operator<<(QDebug dbg, const Transform3D & transform);
QDebug operator<<(QDebug dbg, const Camera3D & camera);
#endif
#ifndef QT_NO_DATASTREAM
QDataStream & operator<<(QDataStream & out, const Transform3D & transform);
QDataStream & operator>>(QDataStream & in, Transform3D & transform);
QDataStream & operator<<(QDataStream & out, const Camera3D & camera);
QDataStream & operator>>(QDataStream & in, Camera3D & camera);
#endif
class QTKAPI QtkMessageLogger {
public:
QtkMessageLogger(const char * file, int line, const char * function) :
mQMessageLogger(file, line, function) {
qDebug();
}
// static QtkMessageLogger * get() {
// if(mQtkMessageLogger == Q_NULLPTR) {
// mQtkMessageLogger = new QtkMessageLogger();
// }
// return mQtkMessageLogger;
// }
// QtkDebug debug() const {}
[[nodiscard]] inline const QMessageLogger & logger() const {
return mQMessageLogger;
}
inline QtkDebug debug() const { return {}; };
static QtkMessageLogger * mQtkMessageLogger;
QMessageLogger mQMessageLogger;
};
} // namespace Qtk
#endif // QTK_QTKMESSAGELOGGER_H

View File

@@ -19,8 +19,8 @@ QMatrix4x4 Scene::mProjection;
******************************************************************************/
Scene::Scene() : mSceneName("Default Scene") {
mCamera.getTransform().setTranslation(0.0f, 0.0f, 20.0f);
mCamera.getTransform().setRotation(-5.0f, 0.0f, 1.0f, 0.0f);
mCamera.setTranslation({0.0f, 0.0f, 20.0f});
mCamera.setRotation({-5.0f, 0.0f, 1.0f, 0.0f});
}
Scene::~Scene() {

View File

@@ -42,6 +42,7 @@ void Transform3D::rotate(const QQuaternion & dr) {
void Transform3D::setTranslation(const QVector3D & t) {
m_dirty = true;
qtkDebug() << "Setting translation to " << t;
mTranslation = t;
}
@@ -77,45 +78,3 @@ QVector3D Transform3D::getUp() const {
QVector3D Transform3D::getRight() const {
return mRotation.rotatedVector(LocalRight);
}
/*******************************************************************************
* Private Methods
******************************************************************************/
namespace Qtk {
#ifndef QT_NO_DEBUG_STREAM
QDebug operator<<(QDebug dbg, const Transform3D & transform) {
dbg << "Transform3D\n{\n";
dbg << "Position: <" << transform.getTranslation().x() << ", "
<< transform.getTranslation().y() << ", "
<< transform.getTranslation().z() << ">\n";
dbg << "Scale: <" << transform.getScale().x() << ", "
<< transform.getScale().y() << ", " << transform.getScale().z()
<< ">\n";
dbg << "Rotation: <" << transform.getRotation().x() << ", "
<< transform.getRotation().y() << ", " << transform.getRotation().z()
<< " | " << transform.getRotation().scalar() << ">\n}";
return dbg;
}
#endif
#ifndef QT_NO_DATASTREAM
QDataStream & operator<<(QDataStream & out, const Transform3D & transform) {
out << transform.mTranslation;
out << transform.mScale;
out << transform.mRotation;
return out;
}
QDataStream & operator>>(QDataStream & in, Transform3D & transform) {
in >> transform.mTranslation;
in >> transform.mScale;
in >> transform.mRotation;
transform.m_dirty = true;
return in;
}
#endif
} // namespace Qtk

View File

@@ -116,12 +116,12 @@ namespace Qtk {
/**
* Apply rotation upon an axis represented by the 3D vector (x, y, z)
*
* @param angle Angle to rotate.
* @param ax X axis to apply the rotation on.
* @param ay Y axis to apply the rotation on.
* @param az Z axis to apply the rotation on.
* @param angle Angle to rotate.
*/
inline void rotate(float angle, float ax, float ay, float az) {
inline void rotate(float ax, float ay, float az, float angle) {
rotate(QQuaternion::fromAxisAndAngle(ax, ay, az, angle));
}
@@ -178,12 +178,12 @@ namespace Qtk {
/**
* Sets a rotation upon an axis represented by the 3D vector (x, y, z)
*
* @param angle Angle to set rotation.
* @param ax X axis to set angle for.
* @param ay Y axis to set angle for.
* @param az Z axis to set angle for.
* @param angle Angle to set rotation.
*/
inline void setRotation(float angle, float ax, float ay, float az) {
inline void setRotation(float ax, float ay, float az, float angle) {
setRotation(QQuaternion::fromAxisAndAngle(ax, ay, az, angle));
}
@@ -249,6 +249,10 @@ namespace Qtk {
bool m_dirty;
/*************************************************************************
* Qt Streams
************************************************************************/
#ifndef QT_NO_DATASTREAM
friend QDataStream & operator<<(
QDataStream & out, const Transform3D & transform);
@@ -256,15 +260,6 @@ namespace Qtk {
QDataStream & in, Transform3D & transform);
#endif
};
#ifndef QT_NO_DEBUG_STREAM
QDebug operator<<(QDebug dbg, const Transform3D & transform);
#endif
#ifndef QT_NO_DATASTREAM
QDataStream & operator<<(QDataStream & out, const Transform3D & transform);
QDataStream & operator>>(QDataStream & in, Transform3D & transform);
#endif
} // namespace Qtk
Q_DECLARE_TYPEINFO(Qtk::Transform3D, Q_MOVABLE_TYPE);