move test implementation of world to submodule

This commit is contained in:
Andrei Yankovich 2021-06-15 17:39:57 +03:00
parent ad221f815d
commit 7b655a6433
22 changed files with 33 additions and 219 deletions

3
.gitmodules vendored
View File

@ -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

View File

@ -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)

View File

@ -159,6 +159,7 @@ bool ClientApp::init(QQmlApplicationEngine *engine) {
return false;
_engine->setWorld(getLastWorld());
_engine->setQmlEngine(engine);
return true;
}

View File

@ -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);

View File

@ -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)

View File

@ -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 {

View File

@ -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;

View File

@ -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();

1
src/CrawlTestLvl Submodule

@ -0,0 +1 @@
Subproject commit fd1ec0371698b23a0ad5635471b45e6b35f009f7

View File

@ -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)

View File

@ -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>

View File

@ -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();
}

View File

@ -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);
}

View File

@ -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

View File

@ -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)
}

View File

@ -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

View File

@ -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);
}

View File

@ -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

View File

@ -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;
}

View File

@ -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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 117 KiB

Binary file not shown.