diff --git a/.gitmodules b/.gitmodules index dcbba75..4cbe56c 100644 --- a/.gitmodules +++ b/.gitmodules @@ -7,3 +7,6 @@ [submodule "submodules/ViewSolutions"] path = submodules/ViewSolutions url = https://github.com/QuasarApp/ViewSolutions.git +[submodule "src/CrawlTestLvl"] + path = src/CrawlTestLvl + url = ssh://web@quasarapp.ddns.net:2022/QuasarApp/CrawlTestLvl.git diff --git a/CMakeLists.txt b/CMakeLists.txt index 2d15f9f..d86df86 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -64,7 +64,7 @@ add_subdirectory(submodules/SimpleQmlNotify) add_subdirectory(submodules/ViewSolutions) add_subdirectory(src/Core) -add_subdirectory(src/Empty) +add_subdirectory(src/CrawlTestLvl) add_subdirectory(src/Client) diff --git a/src/Core/SnakeProject/clientapp.cpp b/src/Core/SnakeProject/clientapp.cpp index 3b795e7..91c1a61 100644 --- a/src/Core/SnakeProject/clientapp.cpp +++ b/src/Core/SnakeProject/clientapp.cpp @@ -159,6 +159,7 @@ bool ClientApp::init(QQmlApplicationEngine *engine) { return false; _engine->setWorld(getLastWorld()); + _engine->setQmlEngine(engine); return true; } diff --git a/src/Core/SnakeProject/guiobject.h b/src/Core/SnakeProject/guiobject.h index ba70b2a..9f80259 100644 --- a/src/Core/SnakeProject/guiobject.h +++ b/src/Core/SnakeProject/guiobject.h @@ -32,7 +32,7 @@ class GuiObject: public QObject, public IRender public: - GuiObject(const QString& viewTempalte = "GraphicItem", QObject *ptr = nullptr); + GuiObject(const QString& viewTempalte = ":/SnakeProjectModule/GraphicItem.qml", QObject *ptr = nullptr); QString color() const; void setColor(QString color); diff --git a/src/Core/SnakeProjectModule/GraphicItem.qml b/src/Core/SnakeProjectModule/GraphicItem.qml index cc99293..5fe3612 100644 --- a/src/Core/SnakeProjectModule/GraphicItem.qml +++ b/src/Core/SnakeProjectModule/GraphicItem.qml @@ -6,14 +6,23 @@ Model { property var model: null property int guiId: (model) ? model.guiId : -1; + property bool fMapColor: model && (model.baseColorMap.length || model.emissiveMap.length || model.roughnessMap.length || model.normalMap.length) DefaultMaterial { - id: material_001_material - diffuseColor: "#ffcccccc" + id: defaultMaterial + diffuseColor: (model)? model.color: "#ffcccccc" + } + + PrincipledMaterial { + id: objMaterial + baseColorMap: Texture { source: (model)? model.baseColorMap: "" } + emissiveMap: Texture { source: (model)? model.emissiveMap: "" } + roughnessMap: Texture { source: (model)? model.roughnessMap: "" } + normalMap: Texture { source: (model)? model.normalMap: "" } } materials: [ - material_001_material + (fMapColor)? objectMaterial: defaultMaterial ] rotation: (model)? model.ratation: Qt.quaternion(0, 0, 0, 0) diff --git a/src/Core/SnakeProjectModule/Scene.qml b/src/Core/SnakeProjectModule/Scene.qml index 344d86c..b01d07c 100644 --- a/src/Core/SnakeProjectModule/Scene.qml +++ b/src/Core/SnakeProjectModule/Scene.qml @@ -14,7 +14,7 @@ View3D { property var player: (model)? model.player: null property var world: (model)? model.world: null property var gameMenuModel: (model)? model.menu: null - property var releativeCameraPosition: (model)? model.cameraReleativePosition: null + property var releativeCameraPosition: (world)? world.cameraReleativePosition: null property var progress: (model)? model.prepareLvlProgress: null property var gameMenu: null @@ -27,6 +27,10 @@ View3D { model.scane = mainScane } + onReleativeCameraPositionChanged: { + console.log(releativeCameraPosition) + } + onGameMenuModelChanged: { if (!gameMenuModel) { return; @@ -69,6 +73,9 @@ View3D { } DirectionalLight { + position: Qt.vector3d(0,0,100) + eulerRotation.z: 90 + } Node { diff --git a/src/Core/private/engine.cpp b/src/Core/private/engine.cpp index 6abb5fd..e95dcec 100644 --- a/src/Core/private/engine.cpp +++ b/src/Core/private/engine.cpp @@ -42,12 +42,15 @@ bool Engine::add(GuiObject *obj) { // Using QQmlComponent QQmlComponent component(_engine, - QUrl::fromLocalFile("MyItem.qml"), + QUrl::fromLocalFile(obj->viewTemplate()), _scane); QObject *object = component.create(); - if (!object) + if (!object) { + QuasarAppUtils::Params::log("Failed to create gui object: " + obj->viewTemplate(), + QuasarAppUtils::Error); return false; + } if (!object->setProperty("model", QVariant::fromValue(obj))) return false; diff --git a/src/Core/private/engine.h b/src/Core/private/engine.h index 2a68b4a..d46bf9b 100644 --- a/src/Core/private/engine.h +++ b/src/Core/private/engine.h @@ -13,7 +13,7 @@ class IWorld; class Engine : public QObject { Q_OBJECT - Q_PROPERTY(QString hdr READ hdr NOTIFY hdrChanged) + Q_PROPERTY(QString hdr READ hdr NOTIFY worldChanged) Q_PROPERTY(QObject* player READ player NOTIFY playerChanged) Q_PROPERTY(QObject* world READ world NOTIFY worldChanged) @@ -106,7 +106,6 @@ private slots: void handleGameObjectsChanged(Diff diff); signals: - void hdrChanged(); void scaneChanged(); void playerChanged(); void worldChanged(); diff --git a/src/CrawlTestLvl b/src/CrawlTestLvl new file mode 160000 index 0000000..fd1ec03 --- /dev/null +++ b/src/CrawlTestLvl @@ -0,0 +1 @@ +Subproject commit fd1ec0371698b23a0ad5635471b45e6b35f009f7 diff --git a/src/Empty/CMakeLists.txt b/src/Empty/CMakeLists.txt deleted file mode 100644 index 2591406..0000000 --- a/src/Empty/CMakeLists.txt +++ /dev/null @@ -1,33 +0,0 @@ -# -# Copyright (C) 2020-2021 QuasarApp. -# Distributed under the lgplv3 software license, see the accompanying -# Everyone is permitted to copy and distribute verbatim copies -# of this license document, but changing it is not allowed. -# - -cmake_minimum_required(VERSION 3.14) -set(CURRENT_PROJECT "Empty") - -add_definitions(-DSnakeProject_LIBRARY) - - -file(GLOB SOURCE_CPP - "*.cpp" - "private/*.cpp" - "*.qrc" - "private/*.qrc" -) - -set(PUBLIC_INCUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}") -set(PRIVATE_INCUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/private") - -set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ../Client/modules) - -add_library(${CURRENT_PROJECT} ${SOURCE_CPP} ${SOURCE_QRC}) - -target_link_libraries(${CURRENT_PROJECT} PUBLIC ${PROJECT_NAME}Core) - -target_include_directories(${CURRENT_PROJECT} PUBLIC ${PUBLIC_INCUDE_DIR}) -target_include_directories(${CURRENT_PROJECT} PRIVATE ${PRIVATE_INCUDE_DIR}) - -set(QML_IMPORT_PATH ${QML_IMPORT_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/src" CACHE STRING "" FORCE) diff --git a/src/Empty/Empty.qrc b/src/Empty/Empty.qrc deleted file mode 100644 index b1878e4..0000000 --- a/src/Empty/Empty.qrc +++ /dev/null @@ -1,11 +0,0 @@ -<RCC> - <qresource prefix="/"/> - <qresource prefix="/SnakeTr"/> - <qresource prefix="/images"/> - <qresource prefix="/mesh"> - <file>res/meshes/cube.mesh</file> - </qresource> - <qresource prefix="/hdr"> - <file>res/hdr/testHDR.jpg</file> - </qresource> -</RCC> diff --git a/src/Empty/empty.cpp b/src/Empty/empty.cpp deleted file mode 100644 index 6989e66..0000000 --- a/src/Empty/empty.cpp +++ /dev/null @@ -1,9 +0,0 @@ -#include "SnakeProject/iworld.h" -#include "world.h" - -inline void initResources() { Q_INIT_RESOURCE(Empty); } - -extern "C" IWorld* worldInstance() { - initResources(); - return new World(); -} diff --git a/src/Empty/private/box.cpp b/src/Empty/private/box.cpp deleted file mode 100644 index 420ca4f..0000000 --- a/src/Empty/private/box.cpp +++ /dev/null @@ -1,12 +0,0 @@ -#include "box.h" - - -Box::Box() { - setMash(":/mesh/res/meshes/cube.mesh"); - setSize({10,10,10}); - setZ(1); -} - -void Box::onIntersects(const IWorldItem *item) { - Q_UNUSED(item); -} diff --git a/src/Empty/private/box.h b/src/Empty/private/box.h deleted file mode 100644 index db95968..0000000 --- a/src/Empty/private/box.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef BOX_H -#define BOX_H -#include "SnakeProject/iworlditem.h" - -class Box: public IWorldItem { - -public: - Box(); - - // IWorldItem interface -protected: - void onIntersects(const IWorldItem *item) override; -}; - -#endif // BOX_H diff --git a/src/Empty/private/plate.cpp b/src/Empty/private/plate.cpp deleted file mode 100644 index 7753780..0000000 --- a/src/Empty/private/plate.cpp +++ /dev/null @@ -1,12 +0,0 @@ -#include "plate.h" - -Plate::Plate() -{ - setMash(":/mesh/res/meshes/cube.mesh"); - setSize({100,100,0}); - setZ(0); -} - -void Plate::onIntersects(const IWorldItem *item) { - Q_UNUSED(item) -} diff --git a/src/Empty/private/plate.h b/src/Empty/private/plate.h deleted file mode 100644 index 61ce67a..0000000 --- a/src/Empty/private/plate.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef PLATE_H -#define PLATE_H -#include "SnakeProject/iground.h" - -class Plate: public IGround { -public: - Plate(); - - // IWorldItem interface -protected: - void onIntersects(const IWorldItem *item) override; -}; - -#endif // PLATE_H diff --git a/src/Empty/private/snake.cpp b/src/Empty/private/snake.cpp deleted file mode 100644 index 0b60902..0000000 --- a/src/Empty/private/snake.cpp +++ /dev/null @@ -1,9 +0,0 @@ -#include "snake.h" - -void Snake::onIntersects(const IWorldItem *item) { - Q_UNUSED(item); -} - -void Snake::setControl(const IControl *control) { - Q_UNUSED(control); -} diff --git a/src/Empty/private/snake.h b/src/Empty/private/snake.h deleted file mode 100644 index 331d5c0..0000000 --- a/src/Empty/private/snake.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef SNAKE_H -#define SNAKE_H - -#include "SnakeProject/iplayer.h" - -class Snake : public IPlayer { - - - // IWorldItem interface -protected: - void onIntersects(const IWorldItem *item) override; - - // IPlayer interface -public: - void setControl(const IControl *control) override; -}; - -#endif // SNAKE_H diff --git a/src/Empty/private/world.cpp b/src/Empty/private/world.cpp deleted file mode 100644 index 3a6d9ce..0000000 --- a/src/Empty/private/world.cpp +++ /dev/null @@ -1,52 +0,0 @@ -#include "box.h" -#include "plate.h" -#include "world.h" -#include <snake.h> -#include "SnakeProject/iworlditem.h" - -IGround *World::generateGroundTile() { - return new Plate(); -} - -IPlayer *World::initPlayer() const { - return new Snake(); -} - -WorldRule *World::initWorldRules() const { - return new WorldRule { - {0, {{"Box", 10}}} - }; -} - -QString World::initHdrBackGround() const { - return "qrc:/hdr/res/hdr/testHDR.jpg"; -} - -QString World::description() const { - return "This a test lvl"; -} - -QString World::imagePreview() const { - return "qrc:/hdr/res/hdr/testHDR.jpg"; - -} - -QString World::name() const { - return "Test"; -} - -int World::costToUnlock() const { - return 0; -} - -QVector3D World::initCameraPosition() { - return {0, 0, 100}; -} - -IWorldItem *World::generate(const QString &objectType) const { - if (objectType == "Box") { - return new Box(); - } - - return nullptr; -} diff --git a/src/Empty/private/world.h b/src/Empty/private/world.h deleted file mode 100644 index 695fd29..0000000 --- a/src/Empty/private/world.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef WORLD_H -#define WORLD_H - -#include "SnakeProject/iworld.h" - -class World : public IWorld { - - // IWorld interface -public: - IGround *generateGroundTile() override; - IPlayer *initPlayer() const override; - WorldRule *initWorldRules() const override; - QString initHdrBackGround() const override; - QString description() const override; - QString imagePreview() const override; - QString name() const override; - int costToUnlock() const override; - QVector3D initCameraPosition() override; - -protected: - IWorldItem *generate(const QString &objectType) const override; -}; - -#endif // WORLD_H diff --git a/src/Empty/res/hdr/testHDR.jpg b/src/Empty/res/hdr/testHDR.jpg deleted file mode 100644 index 33bd925..0000000 Binary files a/src/Empty/res/hdr/testHDR.jpg and /dev/null differ diff --git a/src/Empty/res/meshes/cube.mesh b/src/Empty/res/meshes/cube.mesh deleted file mode 100644 index 603b326..0000000 Binary files a/src/Empty/res/meshes/cube.mesh and /dev/null differ