diff --git a/src/Core/Crawl/groundclaster.cpp b/src/Core/Crawl/groundclaster.cpp index 4583c3d..1bb0be9 100644 --- a/src/Core/Crawl/groundclaster.cpp +++ b/src/Core/Crawl/groundclaster.cpp @@ -23,6 +23,13 @@ GroundClaster::GroundClaster(const QString &name, void GroundClaster::render(unsigned int ) { const IWorldItem *playerObject = getPlayer(); QVector3D camera = world()->cameraReleativePosition(); + + if (!_itemsOrder.size()) { + QuasarAppUtils::Params::log("The GroundClaster do not have any claster items.", + QuasarAppUtils::Error); + return; + } + auto object = _itemsOrder.at(_index % _itemsOrder.size()); if (playerObject->position().x() - object->position().x() > diff --git a/src/Core/Crawl/groundclaster.h b/src/Core/Crawl/groundclaster.h index 1eba85a..4c56cb2 100644 --- a/src/Core/Crawl/groundclaster.h +++ b/src/Core/Crawl/groundclaster.h @@ -17,6 +17,8 @@ namespace CRAWL { /** * @brief The GroundClaster class This is main control class for background plates of the world. * Default behavior: create the tile grid and move old tiles to end of the world. + * + * @note use This class with child classes of the GroundTile class. */ class CRAWL_EXPORT GroundClaster: public IWorldItem, public AutoGenerateClaster { diff --git a/src/Core/Crawl/groundtile.cpp b/src/Core/Crawl/groundtile.cpp new file mode 100644 index 0000000..33afab4 --- /dev/null +++ b/src/Core/Crawl/groundtile.cpp @@ -0,0 +1,14 @@ +#include "groundtile.h" +namespace CRAWL { + +GroundTile::GroundTile(const QString &name, + const QString &viewTempalte, + QObject *ptr): + ClasterItem(name, viewTempalte, ptr) { + +} + +void CRAWL::GroundTile::render(unsigned int) { + +} +} diff --git a/src/Core/Crawl/groundtile.h b/src/Core/Crawl/groundtile.h new file mode 100644 index 0000000..77b083c --- /dev/null +++ b/src/Core/Crawl/groundtile.h @@ -0,0 +1,38 @@ +//# +//# Copyright (C) 2021-2021 QuasarApp. +//# Distributed under the GPLv3 software license, see the accompanying +//# Everyone is permitted to copy and distribute verbatim copies +//# of this license document, but changing it is not allowed. +//# + +#ifndef GROUNDTILE_H +#define GROUNDTILE_H + +#include "clasteritem.h" + +namespace CRAWL { + +/** + * @brief The GroundTile class It reimplementation of the ClasterItem. The groundTile do not heve own render function because the GroundClaster class control position of this class. + * + * @note use This class with the GroundClaster class. + */ +class CRAWL_EXPORT GroundTile: public ClasterItem +{ + Q_OBJECT +public: + GroundTile(const QString& name, + const QString& viewTempalte = DEFAULT_VIEW_TEMPLATE, + QObject *ptr = nullptr); + + // IRender interface +public: + + /** + * @brief render The current render implementation do nothing. + * @param tbfMsec This is time betwin frames value. (in milleseconds) + */ + void render(unsigned int tbfMsec) override; +}; +} +#endif // GROUNDTILE_H diff --git a/src/Core/Crawl/guiobject.cpp b/src/Core/Crawl/guiobject.cpp index 5ae8483..097591f 100644 --- a/src/Core/Crawl/guiobject.cpp +++ b/src/Core/Crawl/guiobject.cpp @@ -184,4 +184,34 @@ void GuiObject::setMash(const QString &newMash) { emit mashChanged(); } +void GuiObject::setBaseColorMap(const QString &baseColorMap) { + if (_baseColorMap == baseColorMap) + return; + _baseColorMap = baseColorMap; + emit baseColorMapChanged(); +} + + +void GuiObject::setRoughnessMap(const QString &roughnessMap) { + if (_roughnessMap == roughnessMap) + return; + _roughnessMap = roughnessMap; + emit roughnessMapChanged(); +} + + +void GuiObject::setNormalMap(const QString &normalMap) { + if (_normalMap == normalMap) + return; + _normalMap = normalMap; + emit normalMapChanged(); +} + +void GuiObject::setEmissiveMap(const QString &emissiveMap) { + if (_emissiveMap == emissiveMap) + return; + _emissiveMap = emissiveMap; + emit emissiveMapChanged(); +} + } diff --git a/src/Core/Crawl/guiobject.h b/src/Core/Crawl/guiobject.h index 3558842..45c59d5 100644 --- a/src/Core/Crawl/guiobject.h +++ b/src/Core/Crawl/guiobject.h @@ -162,12 +162,36 @@ signals: protected: - int _guiId = -1; - QString _color = "#ff1111"; + /** + * @brief setBaseColorMap This method sets path to the base color map of the object. See the baseColorMap method for get more information. + * @param baseColorMap This is new value of the path to base color map. + */ + void setBaseColorMap(const QString& baseColorMap); + + /** + * @brief setRoughnessMap This method sets path to the roughness map of the object. See the roughnessMap method for get more information. + * @param roughnessMap This is new value of the path to roughness map. + */ + void setRoughnessMap(const QString& roughnessMap); + + /** + * @brief setNormalMap This method sets path to the normal map of the object. See the normalMap method for get more information. + * @param normalMap This is new value of the path to normal map. + */ + void setNormalMap(const QString& normalMap); + + /** + * @brief setEmissiveMap This method sets path to the emissive map of the object. See the emissiveMap method for get more information. + * @param emissiveMap This is new value of the path to emissive map. + */ + void setEmissiveMap(const QString& emissiveMap); private: void generateId(); + int _guiId = -1; + QString _color = "#ff1111"; + QString _baseColorMap; QString _roughnessMap; QString _normalMap; diff --git a/src/CrawlTestLvl/private/plate.cpp b/src/CrawlTestLvl/private/plate.cpp index f53345f..4ecb3c3 100644 --- a/src/CrawlTestLvl/private/plate.cpp +++ b/src/CrawlTestLvl/private/plate.cpp @@ -10,7 +10,7 @@ namespace TestLvl { -Plate::Plate(): CRAWL::ClasterItem("TestPlate") +Plate::Plate(): CRAWL::GroundTile("TestPlate") { setMash("#Cube"); setColor("#5c4f45"); diff --git a/src/CrawlTestLvl/private/plate.h b/src/CrawlTestLvl/private/plate.h index 43e1d0d..991ac08 100644 --- a/src/CrawlTestLvl/private/plate.h +++ b/src/CrawlTestLvl/private/plate.h @@ -7,14 +7,14 @@ #ifndef PLATE_H #define PLATE_H -#include "Crawl/clasteritem.h" +#include "Crawl/groundtile.h" namespace TestLvl { /** * @brief The Plate class */ -class Plate: public CRAWL::ClasterItem { +class Plate: public CRAWL::GroundTile { Q_OBJECT public: Plate(); diff --git a/src/JungleLvl/private/ground.cpp b/src/JungleLvl/private/ground.cpp index be695bc..a4f116a 100644 --- a/src/JungleLvl/private/ground.cpp +++ b/src/JungleLvl/private/ground.cpp @@ -6,12 +6,18 @@ //# #include "ground.h" +#include "groundplate.h" +namespace JungleLvl { Ground::Ground() : CRAWL::GroundClaster("JungelGroud") { - setMash("#Rectangle"); - setSize({100,100, 100}); + registerItemType(); } -void Ground::onIntersects(const IWorldItem *item) { +void Ground::onIntersects(const IWorldItem *) { } + +unsigned int Ground::itemsCount() const { + return 3; +} +} diff --git a/src/JungleLvl/private/ground.h b/src/JungleLvl/private/ground.h index a81e1d6..46b59fb 100644 --- a/src/JungleLvl/private/ground.h +++ b/src/JungleLvl/private/ground.h @@ -10,6 +10,9 @@ #include "Crawl/groundclaster.h" +namespace JungleLvl { + + /** * @brief The Ground class This is main ground plate */ @@ -21,6 +24,11 @@ public: // IWorldItem interface protected: void onIntersects(const IWorldItem *item) override; + + // AutoGenerateClaster interface +public: + unsigned int itemsCount() const override; }; +} #endif // GROUND_H diff --git a/src/JungleLvl/private/groundplate.cpp b/src/JungleLvl/private/groundplate.cpp new file mode 100644 index 0000000..79bae73 --- /dev/null +++ b/src/JungleLvl/private/groundplate.cpp @@ -0,0 +1,24 @@ +//# +//# Copyright (C) 2021-2021 QuasarApp. +//# Distributed under the GPLv3 software license, see the accompanying +//# Everyone is permitted to copy and distribute verbatim copies +//# of this license document, but changing it is not allowed. +//# + + +#include "groundplate.h" +namespace JungleLvl { + +GroundPlate::GroundPlate(): CRAWL::GroundTile("JungleGroundTile") { + setMash("#Cube"); + setSize({10, 10, 0.01}); + setBaseColorMap("qrc:/mesh/meshes/Other/Terrain_Base.jpg"); + setNormalMap("qrc:/mesh/meshes/Other/Terrain_Normal.jpg"); + +} + +void GroundPlate::onIntersects(const IWorldItem *) { + +} + +} diff --git a/src/JungleLvl/private/groundplate.h b/src/JungleLvl/private/groundplate.h new file mode 100644 index 0000000..119cde7 --- /dev/null +++ b/src/JungleLvl/private/groundplate.h @@ -0,0 +1,30 @@ +//# +//# Copyright (C) 2021-2021 QuasarApp. +//# Distributed under the GPLv3 software license, see the accompanying +//# Everyone is permitted to copy and distribute verbatim copies +//# of this license document, but changing it is not allowed. +//# + + +#ifndef GROUNDPLATE_H +#define GROUNDPLATE_H + +#include "Crawl/groundtile.h" + +namespace JungleLvl { + +/** + * @brief The GroundPlate class + */ +class GroundPlate: public CRAWL::GroundTile +{ + Q_OBJECT +public: + GroundPlate(); + + // IWorldItem interface +protected: + void onIntersects(const IWorldItem *item) override; +}; +} +#endif // GROUNDPLATE_H diff --git a/src/JungleLvl/private/world.cpp b/src/JungleLvl/private/world.cpp index 99909ed..0237550 100644 --- a/src/JungleLvl/private/world.cpp +++ b/src/JungleLvl/private/world.cpp @@ -5,6 +5,7 @@ //# of this license document, but changing it is not allowed. //# +#include "ground.h" #include "snake.h" #include "world.h" #include "Crawl/iworlditem.h" @@ -19,7 +20,8 @@ World::World() { CRAWL::WorldRule *World::initWorldRules() { return new CRAWL::WorldRule { - {} + {0, { + {registerObject(), 1}}} }; }