From 75714de191b7c024cf7dde1b2c9cb690d2010802 Mon Sep 17 00:00:00 2001 From: EndrII Date: Fri, 27 Aug 2021 23:02:41 +0300 Subject: [PATCH 01/32] fiw warnings of qt crqator 5.0 --- src/JungleLvl/private/world.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/JungleLvl/private/world.h b/src/JungleLvl/private/world.h index 063a7e6..cebe5e7 100644 --- a/src/JungleLvl/private/world.h +++ b/src/JungleLvl/private/world.h @@ -14,6 +14,7 @@ namespace JungleLvl { class World : public CRAWL::IWorld { + Q_OBJECT // IWorld interface public: From ec8d499b9f7d2a80cf4dca2a8084dc7a775e9015 Mon Sep 17 00:00:00 2001 From: IgorekLoschinin Date: Sat, 4 Sep 2021 17:10:25 +0300 Subject: [PATCH 02/32] ref #97 Create a class for control position of group objects. --- src/Core/Crawl/controlpos.cpp | 44 ++++++++++++++++++++++++++++++++ src/Core/Crawl/controlpos.h | 48 +++++++++++++++++++++++++++++++++++ 2 files changed, 92 insertions(+) create mode 100644 src/Core/Crawl/controlpos.cpp create mode 100644 src/Core/Crawl/controlpos.h diff --git a/src/Core/Crawl/controlpos.cpp b/src/Core/Crawl/controlpos.cpp new file mode 100644 index 0000000..191e63b --- /dev/null +++ b/src/Core/Crawl/controlpos.cpp @@ -0,0 +1,44 @@ +//# +//# 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 "controlpos.h" + +namespace CRAWL { + +ControlPos::ControlPos() { + +} + +void ControlPos::add(ClasterItem *object) { + + GroupObject::updatePosition(); + +} + +void ControlPos::remove(ClasterItem *object) { + + GroupObject::updatePosition(); + +} + +void ControlPos::changeLayout(const _Figure &fig) { + + if (fig == CIRCLE) { + GroupObject::updatePosition(); + } + + if (fig == SQUARE) { + GroupObject::updatePosition(); + } + + if (fig == LINE) { + GroupObject::updatePosition(); + } + +} + +} diff --git a/src/Core/Crawl/controlpos.h b/src/Core/Crawl/controlpos.h new file mode 100644 index 0000000..1b87a74 --- /dev/null +++ b/src/Core/Crawl/controlpos.h @@ -0,0 +1,48 @@ +//# +//# 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 CONTROLPOS_H +#define CONTROLPOS_H + +#include + + +namespace CRAWL { + +/** + * @brief The ControlPos class + */ +class ControlPos: public GroupObject { +public: + ControlPos(); + +// Claster interface +public: + void add(ClasterItem *object); + void remove(ClasterItem *object); + +private: + + /** + * @brief The _Figure enum + */ + enum _Figure { + CIRCLE, + SQUARE, + LINE + }; + + /** + * @brief changeLayout + * @param fig + */ + void changeLayout(const _Figure &fig); + +}; + +} +#endif // CONTROLPOS_H From aa16e2b1bff6e9adaf7345f45425b5162abd4d52 Mon Sep 17 00:00:00 2001 From: IgorekLoschinin Date: Wed, 8 Sep 2021 22:20:52 +0300 Subject: [PATCH 03/32] ref #97 Added method for update position and draw-circle and square. --- src/Core/Crawl/controlpos.cpp | 68 +++++++++++++++++++++++++++++------ src/Core/Crawl/controlpos.h | 50 +++++++++++++++++++------- 2 files changed, 96 insertions(+), 22 deletions(-) diff --git a/src/Core/Crawl/controlpos.cpp b/src/Core/Crawl/controlpos.cpp index 191e63b..86a38ec 100644 --- a/src/Core/Crawl/controlpos.cpp +++ b/src/Core/Crawl/controlpos.cpp @@ -6,6 +6,8 @@ //# #include "controlpos.h" +#include "clasteritem.h" +#include namespace CRAWL { @@ -15,28 +17,74 @@ ControlPos::ControlPos() { void ControlPos::add(ClasterItem *object) { - GroupObject::updatePosition(); + Claster::add(object); + updatePosition(); } void ControlPos::remove(ClasterItem *object) { - GroupObject::updatePosition(); + Claster::remove(object->guiId()); + updatePosition(); } -void ControlPos::changeLayout(const _Figure &fig) { +void ControlPos::changeLayout(const Refresh &fig) { + _shape = fig; +} - if (fig == CIRCLE) { - GroupObject::updatePosition(); +void ControlPos::setDistance(int dist) { + _distance = dist; +} + +void ControlPos::updatePosition() { + + switch (_shape) { + case CIRCLE: + drawCircle(); + break; + + case SQUARE: + drawSquare(); + break; + + case LINE: + break; + + default: + break; + } + +} + +void ControlPos::drawCircle() { + + float step = 360 / objects().size(); + int temp = 1; + + for (ClasterItem* object: objects()) { + + float x = _distance * qCos(step*temp); + float y = _distance * qSin(step*temp); + GroupObject::updatePosition(object->guiId(), {x, y, 0}); + + temp++; } - if (fig == SQUARE) { - GroupObject::updatePosition(); - } +} - if (fig == LINE) { - GroupObject::updatePosition(); +void ControlPos::drawSquare() { + + float step = 360 / objects().size(); + int temp = 1; + + for (ClasterItem* object: objects()) { + + float x = _distance * qCos(step*temp); + float y = _distance * qSin(step*temp); + GroupObject::updatePosition(object->guiId(), {x, y, 0}); + + temp++; } } diff --git a/src/Core/Crawl/controlpos.h b/src/Core/Crawl/controlpos.h index 1b87a74..8f234c2 100644 --- a/src/Core/Crawl/controlpos.h +++ b/src/Core/Crawl/controlpos.h @@ -14,7 +14,18 @@ namespace CRAWL { /** - * @brief The ControlPos class + * @brief The Refresh enum Lists the shapes to convert the group object to. + */ +enum Refresh { + CIRCLE, + SPHERE, + SQUARE, + CUBE, + LINE +}; + +/** + * @brief The ControlPos class The class that control position of group objects. */ class ControlPos: public GroupObject { public: @@ -25,22 +36,37 @@ public: void add(ClasterItem *object); void remove(ClasterItem *object); + /** + * @brief changeLayout This method defines the shape of the group object. + * @param fig This is the name of the figure to change the group object. + */ + void changeLayout(const Refresh &fig); + + /** + * @brief setDistance This method sets, depending on the shape selected, the radius for the circle or the indentation for the square. + * @param dist This is the radius or margin. + */ + void setDistance(int dist); + private: - /** - * @brief The _Figure enum - */ - enum _Figure { - CIRCLE, - SQUARE, - LINE - }; + int _distance; + Refresh _shape; /** - * @brief changeLayout - * @param fig + * @brief updatePosition This method updates the coordinates of the positions of all objects. */ - void changeLayout(const _Figure &fig); + void updatePosition(); + + /** + * @brief drawCircle This method updates the coordinates to a circle shape. + */ + void drawCircle(); + + /** + * @brief drawSquare This method updates the coordinates to a square shape. + */ + void drawSquare(); }; From 525222e4a0cd108bc578486fdbee8f9e43572850 Mon Sep 17 00:00:00 2001 From: Igor loschinin Date: Wed, 8 Sep 2021 22:59:42 +0300 Subject: [PATCH 04/32] Update src/Core/Crawl/controlpos.h Co-authored-by: Andrei Yankovich --- src/Core/Crawl/controlpos.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Core/Crawl/controlpos.h b/src/Core/Crawl/controlpos.h index 8f234c2..c98d24b 100644 --- a/src/Core/Crawl/controlpos.h +++ b/src/Core/Crawl/controlpos.h @@ -18,9 +18,7 @@ namespace CRAWL { */ enum Refresh { CIRCLE, - SPHERE, SQUARE, - CUBE, LINE }; From 74bb6f30f8c2149c4cffc49218e060a42b722f0c Mon Sep 17 00:00:00 2001 From: IgorekLoschinin Date: Thu, 9 Sep 2021 22:37:05 +0300 Subject: [PATCH 05/32] ref #97 Added method draw square. --- src/Core/Crawl/controlpos.cpp | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/src/Core/Crawl/controlpos.cpp b/src/Core/Crawl/controlpos.cpp index 86a38ec..be6ed0d 100644 --- a/src/Core/Crawl/controlpos.cpp +++ b/src/Core/Crawl/controlpos.cpp @@ -59,8 +59,13 @@ void ControlPos::updatePosition() { void ControlPos::drawCircle() { + if (objects().size() == 0) { + QuasarAppUtils::Params::log(QString("The number of objects is zero. Add object.")); + return; + } + float step = 360 / objects().size(); - int temp = 1; + int temp = 0; for (ClasterItem* object: objects()) { @@ -75,16 +80,28 @@ void ControlPos::drawCircle() { void ControlPos::drawSquare() { - float step = 360 / objects().size(); - int temp = 1; + if (objects().size() == 0) { + QuasarAppUtils::Params::log(QString("The number of objects is zero. Add object.")); + return; + } - for (ClasterItem* object: objects()) { + int height = qFloor(qSqrt(objects().size())); + int width = qCeil(qSqrt(objects().size())); - float x = _distance * qCos(step*temp); - float y = _distance * qSin(step*temp); - GroupObject::updatePosition(object->guiId(), {x, y, 0}); + int coutObj = 0; + for (int y = 0; y < height; y++) { - temp++; + coutObj = coutObj+y; + for (int x = 0; x < width; x++) { + + if (coutObj == objects().size()) { + return; + } + GroupObject::updatePosition(objects()[coutObj]->guiId(), {float(x + _distance), + float(y + _distance), + 0}); + coutObj++; + } } } From f1364a5b9f4fc2fd802c73c714ac4e80ecb3f70f Mon Sep 17 00:00:00 2001 From: Igor loschinin Date: Fri, 10 Sep 2021 11:15:10 +0300 Subject: [PATCH 06/32] Update src/Core/Crawl/controlpos.h Co-authored-by: Andrei Yankovich --- src/Core/Crawl/controlpos.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Core/Crawl/controlpos.h b/src/Core/Crawl/controlpos.h index c98d24b..c0af58f 100644 --- a/src/Core/Crawl/controlpos.h +++ b/src/Core/Crawl/controlpos.h @@ -48,8 +48,6 @@ public: private: - int _distance; - Refresh _shape; /** * @brief updatePosition This method updates the coordinates of the positions of all objects. @@ -65,6 +63,9 @@ private: * @brief drawSquare This method updates the coordinates to a square shape. */ void drawSquare(); + + int _distance; + Refresh _shape; }; From 7a07b2303733ab86908db4c19662688b9580f0b3 Mon Sep 17 00:00:00 2001 From: Igor loschinin Date: Fri, 10 Sep 2021 11:16:58 +0300 Subject: [PATCH 07/32] Update src/Core/Crawl/controlpos.cpp Co-authored-by: Andrei Yankovich --- src/Core/Crawl/controlpos.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Core/Crawl/controlpos.cpp b/src/Core/Crawl/controlpos.cpp index be6ed0d..0f6d1b1 100644 --- a/src/Core/Crawl/controlpos.cpp +++ b/src/Core/Crawl/controlpos.cpp @@ -60,7 +60,7 @@ void ControlPos::updatePosition() { void ControlPos::drawCircle() { if (objects().size() == 0) { - QuasarAppUtils::Params::log(QString("The number of objects is zero. Add object.")); + QuasarAppUtils::Params::log(QString("The number of objects is zero. Add object.", QuasarAppUtils::Error)); return; } From 765769cc0244f43b9b566071f33b13787e37ebd6 Mon Sep 17 00:00:00 2001 From: Igor loschinin Date: Fri, 10 Sep 2021 11:18:22 +0300 Subject: [PATCH 08/32] Update src/Core/Crawl/controlpos.cpp Co-authored-by: Andrei Yankovich --- src/Core/Crawl/controlpos.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Core/Crawl/controlpos.cpp b/src/Core/Crawl/controlpos.cpp index 0f6d1b1..b1ce011 100644 --- a/src/Core/Crawl/controlpos.cpp +++ b/src/Core/Crawl/controlpos.cpp @@ -31,10 +31,12 @@ void ControlPos::remove(ClasterItem *object) { void ControlPos::changeLayout(const Refresh &fig) { _shape = fig; + updatePosition(); } void ControlPos::setDistance(int dist) { _distance = dist; + updatePosition(); } void ControlPos::updatePosition() { From a97f114b78ad6bc7fb6c4e67177168cdf5ae0968 Mon Sep 17 00:00:00 2001 From: Igor loschinin Date: Fri, 10 Sep 2021 11:18:54 +0300 Subject: [PATCH 09/32] Update src/Core/Crawl/controlpos.cpp Co-authored-by: Andrei Yankovich --- src/Core/Crawl/controlpos.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Core/Crawl/controlpos.cpp b/src/Core/Crawl/controlpos.cpp index b1ce011..696a2b7 100644 --- a/src/Core/Crawl/controlpos.cpp +++ b/src/Core/Crawl/controlpos.cpp @@ -24,7 +24,7 @@ void ControlPos::add(ClasterItem *object) { void ControlPos::remove(ClasterItem *object) { - Claster::remove(object->guiId()); + Claster::remove(object); updatePosition(); } From 1c726805839771a2fdd3dc23d613cd5e63ff3d46 Mon Sep 17 00:00:00 2001 From: IgorekLoschinin Date: Fri, 10 Sep 2021 21:50:03 +0300 Subject: [PATCH 10/32] ref #97 Fixing methon darwSquare, added a new the method drawLine. --- src/Core/Crawl/controlpos.cpp | 42 ++++++++++++++++++++++------------- src/Core/Crawl/controlpos.h | 5 +++++ 2 files changed, 32 insertions(+), 15 deletions(-) diff --git a/src/Core/Crawl/controlpos.cpp b/src/Core/Crawl/controlpos.cpp index 696a2b7..33d1ed5 100644 --- a/src/Core/Crawl/controlpos.cpp +++ b/src/Core/Crawl/controlpos.cpp @@ -51,6 +51,7 @@ void ControlPos::updatePosition() { break; case LINE: + drawLine(); break; default: @@ -62,7 +63,7 @@ void ControlPos::updatePosition() { void ControlPos::drawCircle() { if (objects().size() == 0) { - QuasarAppUtils::Params::log(QString("The number of objects is zero. Add object.", QuasarAppUtils::Error)); + QuasarAppUtils::Params::log(QString("The number of objects is zero. Add object."), QuasarAppUtils::Error); return; } @@ -83,29 +84,40 @@ void ControlPos::drawCircle() { void ControlPos::drawSquare() { if (objects().size() == 0) { - QuasarAppUtils::Params::log(QString("The number of objects is zero. Add object.")); + QuasarAppUtils::Params::log(QString("The number of objects is zero. Add object."), QuasarAppUtils::Error); return; } int height = qFloor(qSqrt(objects().size())); - int width = qCeil(qSqrt(objects().size())); - int coutObj = 0; - for (int y = 0; y < height; y++) { + int indObject = 0; + for (auto idObj = objects().keyBegin(); idObj != objects().keyEnd(); idObj++) { - coutObj = coutObj+y; - for (int x = 0; x < width; x++) { + int x = indObject % height; + int y = qCeil(indObject / height); + + GroupObject::updatePosition(idObj, {x + _distance, + y + _distance, + 0}); + indObject++; - if (coutObj == objects().size()) { - return; - } - GroupObject::updatePosition(objects()[coutObj]->guiId(), {float(x + _distance), - float(y + _distance), - 0}); - coutObj++; - } } } +void ControlPos::drawLine() { + + if (objects().size() == 0) { + QuasarAppUtils::Params::log(QString("The number of objects is zero. Add object."), QuasarAppUtils::Error); + return; + } + + float xObject = 0; + for (ClasterItem* object: objects()) { + GroupObject::updatePosition(object->guiId(), {xObject + _distance, 0, 0}); + + xObject++; + } +} + } diff --git a/src/Core/Crawl/controlpos.h b/src/Core/Crawl/controlpos.h index c0af58f..c1c6d95 100644 --- a/src/Core/Crawl/controlpos.h +++ b/src/Core/Crawl/controlpos.h @@ -63,6 +63,11 @@ private: * @brief drawSquare This method updates the coordinates to a square shape. */ void drawSquare(); + + /** + * @brief drawLine This method updates the coordinates to a line shape. + */ + void drawLine(); int _distance; Refresh _shape; From 8c844f7c33be923a7f43a2aee17d21624a00eac6 Mon Sep 17 00:00:00 2001 From: IgorekLoschinin Date: Sat, 11 Sep 2021 10:31:39 +0300 Subject: [PATCH 11/32] ref #97 Fixing: added pointer idObj. --- src/Core/Crawl/controlpos.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Core/Crawl/controlpos.cpp b/src/Core/Crawl/controlpos.cpp index 33d1ed5..e26b3ed 100644 --- a/src/Core/Crawl/controlpos.cpp +++ b/src/Core/Crawl/controlpos.cpp @@ -93,10 +93,10 @@ void ControlPos::drawSquare() { int indObject = 0; for (auto idObj = objects().keyBegin(); idObj != objects().keyEnd(); idObj++) { - int x = indObject % height; - int y = qCeil(indObject / height); + float x = indObject % height; + float y = qCeil(indObject / height); - GroupObject::updatePosition(idObj, {x + _distance, + GroupObject::updatePosition(*idObj, {x + _distance, y + _distance, 0}); indObject++; From 5b1efc3412f0b087f6e14a4bf9fb305f7810c616 Mon Sep 17 00:00:00 2001 From: IgorekLoschinin Date: Sat, 11 Sep 2021 19:42:51 +0300 Subject: [PATCH 12/32] ref #97 Added file for testing groupobj object. --- src/CrawlTestLvl/private/groupobjbox.cpp | 18 ++++++++++++++ src/CrawlTestLvl/private/groupobjbox.h | 23 +++++++++++++++++ src/CrawlTestLvl/private/groupobjboxitem.cpp | 20 +++++++++++++++ src/CrawlTestLvl/private/groupobjboxitem.h | 26 ++++++++++++++++++++ 4 files changed, 87 insertions(+) create mode 100644 src/CrawlTestLvl/private/groupobjbox.cpp create mode 100644 src/CrawlTestLvl/private/groupobjbox.h create mode 100644 src/CrawlTestLvl/private/groupobjboxitem.cpp create mode 100644 src/CrawlTestLvl/private/groupobjboxitem.h diff --git a/src/CrawlTestLvl/private/groupobjbox.cpp b/src/CrawlTestLvl/private/groupobjbox.cpp new file mode 100644 index 0000000..5379362 --- /dev/null +++ b/src/CrawlTestLvl/private/groupobjbox.cpp @@ -0,0 +1,18 @@ +//# +//# 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 "groupobjbox.h" +#include "groupobjboxitem.h" + +namespace TestLvl { + +GroupObjBox::GroupObjBox() { + +} + +} diff --git a/src/CrawlTestLvl/private/groupobjbox.h b/src/CrawlTestLvl/private/groupobjbox.h new file mode 100644 index 0000000..0af83a2 --- /dev/null +++ b/src/CrawlTestLvl/private/groupobjbox.h @@ -0,0 +1,23 @@ +//# +//# 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 GROUPOBJBOX_H +#define GROUPOBJBOX_H + +#include "Crawl/controlpos.h" +#include "Crawl/iworlditem.h" + +namespace TestLvl { + +class GroupObjBox: public CRAWL::ControlPos { +public: + GroupObjBox(); + +}; + +} +#endif // GROUPOBJBOX_H diff --git a/src/CrawlTestLvl/private/groupobjboxitem.cpp b/src/CrawlTestLvl/private/groupobjboxitem.cpp new file mode 100644 index 0000000..29fea3a --- /dev/null +++ b/src/CrawlTestLvl/private/groupobjboxitem.cpp @@ -0,0 +1,20 @@ +//# +//# 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 "groupobjboxitem.h" + +namespace TestLvl { + +GroupObjboxItem::GroupObjboxItem(): CRAWL::ClasterItem("GroupObjboxItem") { + +} + +void GroupObjboxItem::render(unsigned int tbfMsec) { + +} + +} diff --git a/src/CrawlTestLvl/private/groupobjboxitem.h b/src/CrawlTestLvl/private/groupobjboxitem.h new file mode 100644 index 0000000..cd6a3b1 --- /dev/null +++ b/src/CrawlTestLvl/private/groupobjboxitem.h @@ -0,0 +1,26 @@ +//# +//# 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 GROUPOBJBOXITEM_H +#define GROUPOBJBOXITEM_H + +#include "box.h" +#include "Crawl/clasteritem.h" + +namespace TestLvl { + +class GroupObjboxItem: public CRAWL::ClasterItem { + Q_OBJECT +public: + GroupObjboxItem(); + + void render(unsigned int tbfMsec); +}; + +} + +#endif // GROUPOBJBOXITEM_H From c084a87dda0aec67f81c6dfed9f9baa060935067 Mon Sep 17 00:00:00 2001 From: IgorekLoschinin Date: Mon, 13 Sep 2021 22:00:21 +0300 Subject: [PATCH 13/32] ref #97 Added setting group obj. --- src/CrawlTestLvl/private/groupobjbox.cpp | 4 +++- src/CrawlTestLvl/private/groupobjboxitem.cpp | 2 +- src/CrawlTestLvl/private/groupobjboxitem.h | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/CrawlTestLvl/private/groupobjbox.cpp b/src/CrawlTestLvl/private/groupobjbox.cpp index 5379362..92f88b9 100644 --- a/src/CrawlTestLvl/private/groupobjbox.cpp +++ b/src/CrawlTestLvl/private/groupobjbox.cpp @@ -5,7 +5,6 @@ //# of this license document, but changing it is not allowed. //# - #include "groupobjbox.h" #include "groupobjboxitem.h" @@ -13,6 +12,9 @@ namespace TestLvl { GroupObjBox::GroupObjBox() { + setDistance(2); + changeLayout(CRAWL::Refresh::CIRCLE); + } } diff --git a/src/CrawlTestLvl/private/groupobjboxitem.cpp b/src/CrawlTestLvl/private/groupobjboxitem.cpp index 29fea3a..008bea3 100644 --- a/src/CrawlTestLvl/private/groupobjboxitem.cpp +++ b/src/CrawlTestLvl/private/groupobjboxitem.cpp @@ -9,7 +9,7 @@ namespace TestLvl { -GroupObjboxItem::GroupObjboxItem(): CRAWL::ClasterItem("GroupObjboxItem") { +GroupObjboxItem::GroupObjboxItem(): CRAWL::ClasterItem("GroupObjboxItem"), Box { } diff --git a/src/CrawlTestLvl/private/groupobjboxitem.h b/src/CrawlTestLvl/private/groupobjboxitem.h index cd6a3b1..60c8bbb 100644 --- a/src/CrawlTestLvl/private/groupobjboxitem.h +++ b/src/CrawlTestLvl/private/groupobjboxitem.h @@ -13,7 +13,7 @@ namespace TestLvl { -class GroupObjboxItem: public CRAWL::ClasterItem { +class GroupObjboxItem: public CRAWL::ClasterItem, public Box { Q_OBJECT public: GroupObjboxItem(); From 7601938d83b613dcf703228c4bb3e882f86d3606 Mon Sep 17 00:00:00 2001 From: IgorekLoschinin Date: Thu, 16 Sep 2021 20:49:02 +0300 Subject: [PATCH 14/32] ref #97 Fixing add implement for methods init and render. --- src/CrawlTestLvl/private/groupobjbox.cpp | 7 +++++-- src/CrawlTestLvl/private/groupobjboxitem.cpp | 6 +++++- src/CrawlTestLvl/private/groupobjboxitem.h | 5 ++++- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/CrawlTestLvl/private/groupobjbox.cpp b/src/CrawlTestLvl/private/groupobjbox.cpp index 92f88b9..38e7f1e 100644 --- a/src/CrawlTestLvl/private/groupobjbox.cpp +++ b/src/CrawlTestLvl/private/groupobjbox.cpp @@ -5,6 +5,7 @@ //# of this license document, but changing it is not allowed. //# +#include "box.h" #include "groupobjbox.h" #include "groupobjboxitem.h" @@ -12,9 +13,11 @@ namespace TestLvl { GroupObjBox::GroupObjBox() { - setDistance(2); + setDistance(10); changeLayout(CRAWL::Refresh::CIRCLE); -} + +} + } diff --git a/src/CrawlTestLvl/private/groupobjboxitem.cpp b/src/CrawlTestLvl/private/groupobjboxitem.cpp index 008bea3..89135c4 100644 --- a/src/CrawlTestLvl/private/groupobjboxitem.cpp +++ b/src/CrawlTestLvl/private/groupobjboxitem.cpp @@ -9,7 +9,11 @@ namespace TestLvl { -GroupObjboxItem::GroupObjboxItem(): CRAWL::ClasterItem("GroupObjboxItem"), Box { +GroupObjboxItem::GroupObjboxItem(): CRAWL::ClasterItem("GroupObjboxItem") { + +} + +void GroupObjboxItem::init() { } diff --git a/src/CrawlTestLvl/private/groupobjboxitem.h b/src/CrawlTestLvl/private/groupobjboxitem.h index 60c8bbb..77615a7 100644 --- a/src/CrawlTestLvl/private/groupobjboxitem.h +++ b/src/CrawlTestLvl/private/groupobjboxitem.h @@ -14,10 +14,13 @@ namespace TestLvl { class GroupObjboxItem: public CRAWL::ClasterItem, public Box { - Q_OBJECT + public: GroupObjboxItem(); + // IRender interface +public: + void init(); void render(unsigned int tbfMsec); }; From 9ba0df95eb1651520eb50efa388693dc34b4ecf8 Mon Sep 17 00:00:00 2001 From: IgorekLoschinin Date: Thu, 16 Sep 2021 21:54:32 +0300 Subject: [PATCH 15/32] ref #97 Added objects in testworld. --- src/CrawlTestLvl/private/groupobjbox.cpp | 19 +++++++++++++++++-- src/CrawlTestLvl/private/groupobjbox.h | 7 ++++++- src/CrawlTestLvl/private/world.cpp | 9 ++++++++- 3 files changed, 31 insertions(+), 4 deletions(-) diff --git a/src/CrawlTestLvl/private/groupobjbox.cpp b/src/CrawlTestLvl/private/groupobjbox.cpp index 38e7f1e..3c48aaf 100644 --- a/src/CrawlTestLvl/private/groupobjbox.cpp +++ b/src/CrawlTestLvl/private/groupobjbox.cpp @@ -11,11 +11,26 @@ namespace TestLvl { -GroupObjBox::GroupObjBox() { +GroupObjBox::GroupObjBox(): CRAWL::IWorldItem("GroupObjBox") { - setDistance(10); + setDistance(2); changeLayout(CRAWL::Refresh::CIRCLE); + add(new GroupObjboxItem); + add(new GroupObjboxItem); + add(new GroupObjboxItem); + add(new GroupObjboxItem); + add(new GroupObjboxItem); + +} + +void GroupObjBox::render(unsigned int tbfMsec) +{ + +} + +void GroupObjBox::init() +{ } diff --git a/src/CrawlTestLvl/private/groupobjbox.h b/src/CrawlTestLvl/private/groupobjbox.h index 0af83a2..dccb9ae 100644 --- a/src/CrawlTestLvl/private/groupobjbox.h +++ b/src/CrawlTestLvl/private/groupobjbox.h @@ -13,10 +13,15 @@ namespace TestLvl { -class GroupObjBox: public CRAWL::ControlPos { +class GroupObjBox: public CRAWL::ControlPos, public CRAWL::IWorldItem { public: GroupObjBox(); + + // IRender interface +public: + void render(unsigned int tbfMsec); + void init(); }; } diff --git a/src/CrawlTestLvl/private/world.cpp b/src/CrawlTestLvl/private/world.cpp index 7bf6964..5d60741 100644 --- a/src/CrawlTestLvl/private/world.cpp +++ b/src/CrawlTestLvl/private/world.cpp @@ -18,6 +18,7 @@ #include #include #include +#include namespace TestLvl { @@ -36,7 +37,13 @@ CRAWL::WorldRule *World::initWorldRules() { {registerObject(), 1}, {registerObject(), 1}, - {registerObject(), 1}}} + {registerObject(), 1}}}, + {2, + { + {registerObject(),20} + } + }, + }; } From b2c1eda16cb223f75f0e7b370a9aec6972589ef0 Mon Sep 17 00:00:00 2001 From: Igor loschinin Date: Fri, 17 Sep 2021 20:05:03 +0300 Subject: [PATCH 16/32] Update src/CrawlTestLvl/private/world.cpp Co-authored-by: Andrei Yankovich --- src/CrawlTestLvl/private/world.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CrawlTestLvl/private/world.cpp b/src/CrawlTestLvl/private/world.cpp index 5d60741..0b3cf2e 100644 --- a/src/CrawlTestLvl/private/world.cpp +++ b/src/CrawlTestLvl/private/world.cpp @@ -38,7 +38,7 @@ CRAWL::WorldRule *World::initWorldRules() { {registerObject(), 1}, {registerObject(), 1}}}, - {2, + {500, { {registerObject(),20} } From 0643c0001ec9f7d4b3f9ec5c27ee6ef8f4585b03 Mon Sep 17 00:00:00 2001 From: IgorekLoschinin Date: Fri, 17 Sep 2021 21:12:33 +0300 Subject: [PATCH 17/32] ref #97 Chanhe name class ControlPos to layout, delete groupobjitem. --- src/Core/Crawl/{controlpos.cpp => layout.cpp} | 20 ++++++------- src/Core/Crawl/{controlpos.h => layout.h} | 10 +++---- src/CrawlTestLvl/private/box.cpp | 2 +- src/CrawlTestLvl/private/box.h | 4 +-- src/CrawlTestLvl/private/groupobjbox.cpp | 30 ++++++++++++++----- src/CrawlTestLvl/private/groupobjbox.h | 7 +++-- src/CrawlTestLvl/private/groupobjboxitem.cpp | 24 --------------- src/CrawlTestLvl/private/groupobjboxitem.h | 29 ------------------ src/CrawlTestLvl/private/world.cpp | 4 +-- 9 files changed, 47 insertions(+), 83 deletions(-) rename src/Core/Crawl/{controlpos.cpp => layout.cpp} (85%) rename src/Core/Crawl/{controlpos.h => layout.h} (93%) delete mode 100644 src/CrawlTestLvl/private/groupobjboxitem.cpp delete mode 100644 src/CrawlTestLvl/private/groupobjboxitem.h diff --git a/src/Core/Crawl/controlpos.cpp b/src/Core/Crawl/layout.cpp similarity index 85% rename from src/Core/Crawl/controlpos.cpp rename to src/Core/Crawl/layout.cpp index e26b3ed..9e6f62b 100644 --- a/src/Core/Crawl/controlpos.cpp +++ b/src/Core/Crawl/layout.cpp @@ -5,41 +5,41 @@ //# of this license document, but changing it is not allowed. //# -#include "controlpos.h" +#include "layout.h" #include "clasteritem.h" #include namespace CRAWL { -ControlPos::ControlPos() { +Layout::Layout() { } -void ControlPos::add(ClasterItem *object) { +void Layout::add(ClasterItem *object) { Claster::add(object); updatePosition(); } -void ControlPos::remove(ClasterItem *object) { +void Layout::remove(ClasterItem *object) { Claster::remove(object); updatePosition(); } -void ControlPos::changeLayout(const Refresh &fig) { +void Layout::changeLayout(const Refresh &fig) { _shape = fig; updatePosition(); } -void ControlPos::setDistance(int dist) { +void Layout::setDistance(int dist) { _distance = dist; updatePosition(); } -void ControlPos::updatePosition() { +void Layout::updatePosition() { switch (_shape) { case CIRCLE: @@ -60,7 +60,7 @@ void ControlPos::updatePosition() { } -void ControlPos::drawCircle() { +void Layout::drawCircle() { if (objects().size() == 0) { QuasarAppUtils::Params::log(QString("The number of objects is zero. Add object."), QuasarAppUtils::Error); @@ -81,7 +81,7 @@ void ControlPos::drawCircle() { } -void ControlPos::drawSquare() { +void Layout::drawSquare() { if (objects().size() == 0) { QuasarAppUtils::Params::log(QString("The number of objects is zero. Add object."), QuasarAppUtils::Error); @@ -105,7 +105,7 @@ void ControlPos::drawSquare() { } -void ControlPos::drawLine() { +void Layout::drawLine() { if (objects().size() == 0) { QuasarAppUtils::Params::log(QString("The number of objects is zero. Add object."), QuasarAppUtils::Error); diff --git a/src/Core/Crawl/controlpos.h b/src/Core/Crawl/layout.h similarity index 93% rename from src/Core/Crawl/controlpos.h rename to src/Core/Crawl/layout.h index c1c6d95..ba5828f 100644 --- a/src/Core/Crawl/controlpos.h +++ b/src/Core/Crawl/layout.h @@ -5,8 +5,8 @@ //# of this license document, but changing it is not allowed. //# -#ifndef CONTROLPOS_H -#define CONTROLPOS_H +#ifndef LAYOUT_H +#define LAYOUT_H #include @@ -25,9 +25,9 @@ enum Refresh { /** * @brief The ControlPos class The class that control position of group objects. */ -class ControlPos: public GroupObject { +class Layout: public GroupObject { public: - ControlPos(); + Layout(); // Claster interface public: @@ -75,4 +75,4 @@ private: }; } -#endif // CONTROLPOS_H +#endif // LAYOUT_H diff --git a/src/CrawlTestLvl/private/box.cpp b/src/CrawlTestLvl/private/box.cpp index f1df44c..1803795 100644 --- a/src/CrawlTestLvl/private/box.cpp +++ b/src/CrawlTestLvl/private/box.cpp @@ -11,7 +11,7 @@ namespace TestLvl { -Box::Box(): IWorldItem("Box") { +Box::Box(): ClasterItem("Box") { setMash("qrc:/mesh/meshes/cube.mesh"); setSize({2,2,2}); setColor(QColor::fromRgb(rand()).name()); diff --git a/src/CrawlTestLvl/private/box.h b/src/CrawlTestLvl/private/box.h index 16adf4b..0b2f757 100644 --- a/src/CrawlTestLvl/private/box.h +++ b/src/CrawlTestLvl/private/box.h @@ -7,12 +7,12 @@ #ifndef BOX_H #define BOX_H -#include "Crawl/iworlditem.h" +#include "Crawl/clasteritem.h" namespace TestLvl { -class Box: public CRAWL::IWorldItem { +class Box: public CRAWL::ClasterItem { public: Box(); diff --git a/src/CrawlTestLvl/private/groupobjbox.cpp b/src/CrawlTestLvl/private/groupobjbox.cpp index 3c48aaf..ff2a33a 100644 --- a/src/CrawlTestLvl/private/groupobjbox.cpp +++ b/src/CrawlTestLvl/private/groupobjbox.cpp @@ -7,20 +7,34 @@ #include "box.h" #include "groupobjbox.h" -#include "groupobjboxitem.h" namespace TestLvl { -GroupObjBox::GroupObjBox(): CRAWL::IWorldItem("GroupObjBox") { +GroupObjBox::GroupObjBox(): CRAWL::ClasterItem("GroupObjBox") { setDistance(2); changeLayout(CRAWL::Refresh::CIRCLE); - add(new GroupObjboxItem); - add(new GroupObjboxItem); - add(new GroupObjboxItem); - add(new GroupObjboxItem); - add(new GroupObjboxItem); + add(new Box); + add(new Box); + add(new Box); + add(new Box); + add(new Box); + add(new Box); + add(new Box); + add(new Box); + add(new Box); + add(new Box); + add(new Box); + add(new Box); + add(new Box); + add(new Box); + add(new Box); + add(new Box); + add(new Box); + add(new Box); + add(new Box); + add(new Box); } @@ -35,4 +49,6 @@ void GroupObjBox::init() } + + } diff --git a/src/CrawlTestLvl/private/groupobjbox.h b/src/CrawlTestLvl/private/groupobjbox.h index dccb9ae..7946724 100644 --- a/src/CrawlTestLvl/private/groupobjbox.h +++ b/src/CrawlTestLvl/private/groupobjbox.h @@ -8,12 +8,12 @@ #ifndef GROUPOBJBOX_H #define GROUPOBJBOX_H -#include "Crawl/controlpos.h" -#include "Crawl/iworlditem.h" +#include "Crawl/layout.h" +#include "Crawl/clasteritem.h" namespace TestLvl { -class GroupObjBox: public CRAWL::ControlPos, public CRAWL::IWorldItem { +class GroupObjBox: public CRAWL::Layout, public CRAWL::ClasterItem { public: GroupObjBox(); @@ -22,6 +22,7 @@ public: public: void render(unsigned int tbfMsec); void init(); + }; } diff --git a/src/CrawlTestLvl/private/groupobjboxitem.cpp b/src/CrawlTestLvl/private/groupobjboxitem.cpp deleted file mode 100644 index 89135c4..0000000 --- a/src/CrawlTestLvl/private/groupobjboxitem.cpp +++ /dev/null @@ -1,24 +0,0 @@ -//# -//# 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 "groupobjboxitem.h" - -namespace TestLvl { - -GroupObjboxItem::GroupObjboxItem(): CRAWL::ClasterItem("GroupObjboxItem") { - -} - -void GroupObjboxItem::init() { - -} - -void GroupObjboxItem::render(unsigned int tbfMsec) { - -} - -} diff --git a/src/CrawlTestLvl/private/groupobjboxitem.h b/src/CrawlTestLvl/private/groupobjboxitem.h deleted file mode 100644 index 77615a7..0000000 --- a/src/CrawlTestLvl/private/groupobjboxitem.h +++ /dev/null @@ -1,29 +0,0 @@ -//# -//# 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 GROUPOBJBOXITEM_H -#define GROUPOBJBOXITEM_H - -#include "box.h" -#include "Crawl/clasteritem.h" - -namespace TestLvl { - -class GroupObjboxItem: public CRAWL::ClasterItem, public Box { - -public: - GroupObjboxItem(); - - // IRender interface -public: - void init(); - void render(unsigned int tbfMsec); -}; - -} - -#endif // GROUPOBJBOXITEM_H diff --git a/src/CrawlTestLvl/private/world.cpp b/src/CrawlTestLvl/private/world.cpp index 0b3cf2e..d0d5927 100644 --- a/src/CrawlTestLvl/private/world.cpp +++ b/src/CrawlTestLvl/private/world.cpp @@ -32,7 +32,7 @@ CRAWL::WorldRule *World::initWorldRules() { using Day = CRAWL::Day; return new CRAWL::WorldRule { - {0, {{registerObject(), 1000}, + {0, {{registerObject(), 1}, {registerObject(), 10}, {registerObject(), 1}, @@ -40,7 +40,7 @@ CRAWL::WorldRule *World::initWorldRules() { {registerObject(), 1}}}, {500, { - {registerObject(),20} + {registerObject(),1} } }, From 0c092ce3d89e4d5779f8ca64cc3955fb70395f64 Mon Sep 17 00:00:00 2001 From: IgorekLoschinin Date: Fri, 17 Sep 2021 22:42:05 +0300 Subject: [PATCH 18/32] ref #97 draw circle. --- src/CrawlTestLvl/private/groupobjbox.cpp | 6 +++--- src/CrawlTestLvl/private/groupobjbox.h | 2 +- src/CrawlTestLvl/private/world.cpp | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/CrawlTestLvl/private/groupobjbox.cpp b/src/CrawlTestLvl/private/groupobjbox.cpp index ff2a33a..da2ade8 100644 --- a/src/CrawlTestLvl/private/groupobjbox.cpp +++ b/src/CrawlTestLvl/private/groupobjbox.cpp @@ -10,9 +10,9 @@ namespace TestLvl { -GroupObjBox::GroupObjBox(): CRAWL::ClasterItem("GroupObjBox") { +GroupObjBox::GroupObjBox(): CRAWL::IWorldItem("GroupObjBox") { - setDistance(2); + setDistance(20); changeLayout(CRAWL::Refresh::CIRCLE); add(new Box); @@ -40,7 +40,7 @@ GroupObjBox::GroupObjBox(): CRAWL::ClasterItem("GroupObjBox") { void GroupObjBox::render(unsigned int tbfMsec) { - + Layout::render(tbfMsec); } void GroupObjBox::init() diff --git a/src/CrawlTestLvl/private/groupobjbox.h b/src/CrawlTestLvl/private/groupobjbox.h index 7946724..190ece7 100644 --- a/src/CrawlTestLvl/private/groupobjbox.h +++ b/src/CrawlTestLvl/private/groupobjbox.h @@ -13,7 +13,7 @@ namespace TestLvl { -class GroupObjBox: public CRAWL::Layout, public CRAWL::ClasterItem { +class GroupObjBox: public CRAWL::Layout, public CRAWL::IWorldItem { public: GroupObjBox(); diff --git a/src/CrawlTestLvl/private/world.cpp b/src/CrawlTestLvl/private/world.cpp index d0d5927..49dd068 100644 --- a/src/CrawlTestLvl/private/world.cpp +++ b/src/CrawlTestLvl/private/world.cpp @@ -33,14 +33,14 @@ CRAWL::WorldRule *World::initWorldRules() { return new CRAWL::WorldRule { {0, {{registerObject(), 1}, - {registerObject(), 10}, - {registerObject(), 1}, +// {registerObject(), 10}, +// {registerObject(), 1}, {registerObject(), 1}, {registerObject(), 1}}}, - {500, + {30, { - {registerObject(),1} + {registerObject(),5} } }, From 09a31bbf2fd3d041bb83989c5b177f19986d157a Mon Sep 17 00:00:00 2001 From: IgorekLoschinin Date: Sat, 18 Sep 2021 10:30:54 +0300 Subject: [PATCH 19/32] ref #105 Fixing: change a item count with 3 to 5. --- src/JungleLvl/private/ground.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/JungleLvl/private/ground.cpp b/src/JungleLvl/private/ground.cpp index baf9bbb..ca56459 100644 --- a/src/JungleLvl/private/ground.cpp +++ b/src/JungleLvl/private/ground.cpp @@ -14,6 +14,6 @@ Ground::Ground() : CRAWL::GroundClaster("JungelGroud") { } unsigned int Ground::itemsCount() const { - return 3; + return 5; } } From 4b9c3dd71ba84b5d112c3af4100923e1cbfcd8a2 Mon Sep 17 00:00:00 2001 From: IgorekLoschinin Date: Sat, 18 Sep 2021 12:06:37 +0300 Subject: [PATCH 20/32] ref #97 Added class boxitem. --- src/CrawlTestLvl/private/boxitem.cpp | 22 +++++++++++++ src/CrawlTestLvl/private/boxitem.h | 25 ++++++++++++++ src/CrawlTestLvl/private/groupobjbox.cpp | 42 ++++++++++++------------ 3 files changed, 68 insertions(+), 21 deletions(-) create mode 100644 src/CrawlTestLvl/private/boxitem.cpp create mode 100644 src/CrawlTestLvl/private/boxitem.h diff --git a/src/CrawlTestLvl/private/boxitem.cpp b/src/CrawlTestLvl/private/boxitem.cpp new file mode 100644 index 0000000..02a9963 --- /dev/null +++ b/src/CrawlTestLvl/private/boxitem.cpp @@ -0,0 +1,22 @@ +//# +//# 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 "boxitem.h" + +namespace TestLvl { + +BoxItem::BoxItem() +{ + +} + +void BoxItem::render(unsigned int tbfMsec) +{ + +} + +} diff --git a/src/CrawlTestLvl/private/boxitem.h b/src/CrawlTestLvl/private/boxitem.h new file mode 100644 index 0000000..2ebb2db --- /dev/null +++ b/src/CrawlTestLvl/private/boxitem.h @@ -0,0 +1,25 @@ +//# +//# 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 BOXITEM_H +#define BOXITEM_H + +#include "box.h" + +namespace TestLvl { + +class BoxItem: public Box { +public: + BoxItem(); + + // IRender interface +public: + void render(unsigned int tbfMsec); +}; + +} +#endif // BOXITEM_H diff --git a/src/CrawlTestLvl/private/groupobjbox.cpp b/src/CrawlTestLvl/private/groupobjbox.cpp index da2ade8..ced3e9f 100644 --- a/src/CrawlTestLvl/private/groupobjbox.cpp +++ b/src/CrawlTestLvl/private/groupobjbox.cpp @@ -5,7 +5,7 @@ //# of this license document, but changing it is not allowed. //# -#include "box.h" +#include "boxitem.h" #include "groupobjbox.h" namespace TestLvl { @@ -15,26 +15,26 @@ GroupObjBox::GroupObjBox(): CRAWL::IWorldItem("GroupObjBox") { setDistance(20); changeLayout(CRAWL::Refresh::CIRCLE); - add(new Box); - add(new Box); - add(new Box); - add(new Box); - add(new Box); - add(new Box); - add(new Box); - add(new Box); - add(new Box); - add(new Box); - add(new Box); - add(new Box); - add(new Box); - add(new Box); - add(new Box); - add(new Box); - add(new Box); - add(new Box); - add(new Box); - add(new Box); + add(new BoxItem); + add(new BoxItem); + add(new BoxItem); + add(new BoxItem); + add(new BoxItem); + add(new BoxItem); + add(new BoxItem); + add(new BoxItem); + add(new BoxItem); + add(new BoxItem); + add(new BoxItem); + add(new BoxItem); + add(new BoxItem); + add(new BoxItem); + add(new BoxItem); + add(new BoxItem); + add(new BoxItem); + add(new BoxItem); + add(new BoxItem); + add(new BoxItem); } From 35b3b448c652db8e27dafc851697fe4c5dcce4fe Mon Sep 17 00:00:00 2001 From: Igor loschinin Date: Sat, 18 Sep 2021 13:47:31 +0300 Subject: [PATCH 21/32] Update src/CrawlTestLvl/private/groupobjbox.cpp Co-authored-by: Andrei Yankovich --- src/CrawlTestLvl/private/groupobjbox.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/CrawlTestLvl/private/groupobjbox.cpp b/src/CrawlTestLvl/private/groupobjbox.cpp index ced3e9f..3b023c9 100644 --- a/src/CrawlTestLvl/private/groupobjbox.cpp +++ b/src/CrawlTestLvl/private/groupobjbox.cpp @@ -41,6 +41,7 @@ GroupObjBox::GroupObjBox(): CRAWL::IWorldItem("GroupObjBox") { void GroupObjBox::render(unsigned int tbfMsec) { Layout::render(tbfMsec); + IWorldItem::render(tbfMsec); } void GroupObjBox::init() From b1a49bd603eb5af38c040dba2a65b3ecaf43edf6 Mon Sep 17 00:00:00 2001 From: Igor loschinin Date: Sat, 18 Sep 2021 14:14:05 +0300 Subject: [PATCH 22/32] Update src/Core/Crawl/layout.cpp Co-authored-by: Andrei Yankovich --- src/Core/Crawl/layout.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Core/Crawl/layout.cpp b/src/Core/Crawl/layout.cpp index 9e6f62b..c224579 100644 --- a/src/Core/Crawl/layout.cpp +++ b/src/Core/Crawl/layout.cpp @@ -57,7 +57,7 @@ void Layout::updatePosition() { default: break; } - + updatePosition(); } void Layout::drawCircle() { From dfa9afca92264e23f7b4b1414dcb737d78166d74 Mon Sep 17 00:00:00 2001 From: IgorekLoschinin Date: Sat, 18 Sep 2021 19:46:31 +0300 Subject: [PATCH 23/32] ref #97 Added description for class and methods. --- src/Core/Crawl/layout.cpp | 4 +- src/Core/Crawl/layout.h | 59 ++++++++++++++++++++++-- src/CrawlTestLvl/private/groupobjbox.cpp | 25 ++-------- src/CrawlTestLvl/private/world.cpp | 8 ++-- 4 files changed, 64 insertions(+), 32 deletions(-) diff --git a/src/Core/Crawl/layout.cpp b/src/Core/Crawl/layout.cpp index c224579..b53ee3c 100644 --- a/src/Core/Crawl/layout.cpp +++ b/src/Core/Crawl/layout.cpp @@ -29,7 +29,7 @@ void Layout::remove(ClasterItem *object) { } -void Layout::changeLayout(const Refresh &fig) { +void Layout::changeLayout(const LayoutType &fig) { _shape = fig; updatePosition(); } @@ -57,7 +57,7 @@ void Layout::updatePosition() { default: break; } - updatePosition(); + } void Layout::drawCircle() { diff --git a/src/Core/Crawl/layout.h b/src/Core/Crawl/layout.h index ba5828f..502bbfa 100644 --- a/src/Core/Crawl/layout.h +++ b/src/Core/Crawl/layout.h @@ -14,16 +14,65 @@ namespace CRAWL { /** - * @brief The Refresh enum Lists the shapes to convert the group object to. + * @brief The LayoutType enum Lists the shapes to convert the group object to. */ -enum Refresh { +enum LayoutType { + /// The circle property calls the drawCircle method, which recalculates and updates + /// the coordinates of the passed object's positions. CIRCLE, + + /// The square property calls the drawSquare method, which updates the coordinates of + /// the objects' positions, giving them the shape of a square. SQUARE, + + /// The LINE property calls the drawLine method, which updates the coordinates of the + /// objects' positions, giving it a line shape. LINE }; /** - * @brief The ControlPos class The class that control position of group objects. + * @brief The Layout class The class that control position of group objects. + * ### Requried child classes: IWorldItem + * + * This class overloads the add() and remove() methods, which add objects to the cluster while updating positions according to the selected LayoutType. + * Has two public methods for setting the distance to the object and selecting the grouping of objects. + * + * ## Example of use + * + * ### For what this object uses + * This object is convenient to use if you want to create a cluster object directly, within which subobjects are grouped into a circle or square, depending on the selected property. + * For example : snake obstacle. + * + * ### Example of use + * + * 1. Create the GroupObjObstacle class. + * + * ```cpp + * + * class GroupObjObstacle: public CRAWL::Layout, public CRAWL::IWorldItem { + * + * // sets the distance to the object from the center. + * setDistance(20); + * + * // Set the property of grouping objects + * changeLayout(CRAWL::LayoutType::CIRCLE); + * + * for(int i(0); i < 20; i++) { + * add(new BoxItem); + * } + * + * }; + * ``` + * + * @note The added object must inherit from ClasterItem and have a child class required for overloading software renderers. + * + * All done. Now the added objects will be grouped into a circle shape. + * + * You can change the center-to-object distance and the shape of a group of objects using the setDistance and changeLayout methods. + * + * @note This class requried the GuiObject functions as a parent class. + * @note This class requires an overload of the render method; The implementation must call the render methods of the parent classes. + * */ class Layout: public GroupObject { public: @@ -38,7 +87,7 @@ public: * @brief changeLayout This method defines the shape of the group object. * @param fig This is the name of the figure to change the group object. */ - void changeLayout(const Refresh &fig); + void changeLayout(const LayoutType &fig); /** * @brief setDistance This method sets, depending on the shape selected, the radius for the circle or the indentation for the square. @@ -70,7 +119,7 @@ private: void drawLine(); int _distance; - Refresh _shape; + LayoutType _shape; }; diff --git a/src/CrawlTestLvl/private/groupobjbox.cpp b/src/CrawlTestLvl/private/groupobjbox.cpp index 3b023c9..ac53b5e 100644 --- a/src/CrawlTestLvl/private/groupobjbox.cpp +++ b/src/CrawlTestLvl/private/groupobjbox.cpp @@ -13,28 +13,11 @@ namespace TestLvl { GroupObjBox::GroupObjBox(): CRAWL::IWorldItem("GroupObjBox") { setDistance(20); - changeLayout(CRAWL::Refresh::CIRCLE); + changeLayout(CRAWL::LayoutType::CIRCLE); - add(new BoxItem); - add(new BoxItem); - add(new BoxItem); - add(new BoxItem); - add(new BoxItem); - add(new BoxItem); - add(new BoxItem); - add(new BoxItem); - add(new BoxItem); - add(new BoxItem); - add(new BoxItem); - add(new BoxItem); - add(new BoxItem); - add(new BoxItem); - add(new BoxItem); - add(new BoxItem); - add(new BoxItem); - add(new BoxItem); - add(new BoxItem); - add(new BoxItem); + for(int i(0); i < 20; i++) { + add(new BoxItem); + } } diff --git a/src/CrawlTestLvl/private/world.cpp b/src/CrawlTestLvl/private/world.cpp index 49dd068..f6e38f8 100644 --- a/src/CrawlTestLvl/private/world.cpp +++ b/src/CrawlTestLvl/private/world.cpp @@ -32,13 +32,13 @@ CRAWL::WorldRule *World::initWorldRules() { using Day = CRAWL::Day; return new CRAWL::WorldRule { - {0, {{registerObject(), 1}, -// {registerObject(), 10}, -// {registerObject(), 1}, + {0, {{registerObject(), 100}, + {registerObject(), 10}, + {registerObject(), 1}, {registerObject(), 1}, {registerObject(), 1}}}, - {30, + {300, { {registerObject(),5} } From 6a59445b2ebf798dd7c9f8747c497cb953551193 Mon Sep 17 00:00:00 2001 From: Igor loschinin Date: Mon, 20 Sep 2021 20:18:29 +0300 Subject: [PATCH 24/32] Update src/JungleLvl/private/ground.cpp Co-authored-by: Andrei Yankovich --- src/JungleLvl/private/ground.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/JungleLvl/private/ground.cpp b/src/JungleLvl/private/ground.cpp index ca56459..baf9bbb 100644 --- a/src/JungleLvl/private/ground.cpp +++ b/src/JungleLvl/private/ground.cpp @@ -14,6 +14,6 @@ Ground::Ground() : CRAWL::GroundClaster("JungelGroud") { } unsigned int Ground::itemsCount() const { - return 5; + return 3; } } From f7131f1677e48e3c40a058fcfa126baa69bde4c3 Mon Sep 17 00:00:00 2001 From: IgorekLoschinin Date: Tue, 21 Sep 2021 21:58:03 +0300 Subject: [PATCH 25/32] ref #105 Fixing: changed distance new objects. --- src/JungleLvl/private/ground.cpp | 4 ++++ src/JungleLvl/private/ground.h | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/src/JungleLvl/private/ground.cpp b/src/JungleLvl/private/ground.cpp index baf9bbb..82d819e 100644 --- a/src/JungleLvl/private/ground.cpp +++ b/src/JungleLvl/private/ground.cpp @@ -16,4 +16,8 @@ Ground::Ground() : CRAWL::GroundClaster("JungelGroud") { unsigned int Ground::itemsCount() const { return 3; } + +int Ground::newObjectDistance() const { + return 150; +} } diff --git a/src/JungleLvl/private/ground.h b/src/JungleLvl/private/ground.h index 6d49d65..6ab7983 100644 --- a/src/JungleLvl/private/ground.h +++ b/src/JungleLvl/private/ground.h @@ -21,6 +21,10 @@ class Ground : public CRAWL::GroundClaster public: Ground(); unsigned int itemsCount() const override; + + // GroundClaster interface +protected: + int newObjectDistance() const; }; } From d8b5059c7bead9c56d08935a076b6faedc5b89d5 Mon Sep 17 00:00:00 2001 From: IgorekLoschinin Date: Wed, 22 Sep 2021 22:14:43 +0300 Subject: [PATCH 26/32] ref #105 Added groupobject obstacle red. --- src/CrawlAbstractLvl/private/abslvlworld.cpp | 21 ++++++------ .../private/groupobstaclered.cpp | 33 +++++++++++++++++++ .../private/groupobstaclered.h | 27 +++++++++++++++ .../private/obstaclerebitem.cpp | 20 +++++++++++ .../private/obstaclerebitem.h | 26 +++++++++++++++ src/CrawlAbstractLvl/private/obstaclered.cpp | 2 +- src/CrawlAbstractLvl/private/obstaclered.h | 4 +-- 7 files changed, 120 insertions(+), 13 deletions(-) create mode 100644 src/CrawlAbstractLvl/private/groupobstaclered.cpp create mode 100644 src/CrawlAbstractLvl/private/groupobstaclered.h create mode 100644 src/CrawlAbstractLvl/private/obstaclerebitem.cpp create mode 100644 src/CrawlAbstractLvl/private/obstaclerebitem.h diff --git a/src/CrawlAbstractLvl/private/abslvlworld.cpp b/src/CrawlAbstractLvl/private/abslvlworld.cpp index 5d36d6c..5df1998 100644 --- a/src/CrawlAbstractLvl/private/abslvlworld.cpp +++ b/src/CrawlAbstractLvl/private/abslvlworld.cpp @@ -12,6 +12,7 @@ #include "abslvlworld.h" #include #include "Crawl/iworlditem.h" +#include "groupobstaclered.h" #include "Crawl/defaultlight.h" @@ -31,23 +32,23 @@ CRAWL::WorldRule *AbsLvlWorld::initWorldRules() { return new CRAWL::WorldRule { - {0, - { - {registerObject(), 10}, {registerObject(), 1} - } - }, - - {20, + {200, { {registerObject(), 10}, {registerObject(), 1} } }, - {30, + {300, { - {registerObject(), 40}, {registerObject(), 1} + {registerObject(), 1}, {registerObject(), 1} } - } + }, + +// {30, +// { +// {registerObject(), 40}, {registerObject(), 1} +// } +// } }; } diff --git a/src/CrawlAbstractLvl/private/groupobstaclered.cpp b/src/CrawlAbstractLvl/private/groupobstaclered.cpp new file mode 100644 index 0000000..c22da23 --- /dev/null +++ b/src/CrawlAbstractLvl/private/groupobstaclered.cpp @@ -0,0 +1,33 @@ +//# +//# 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 "obstaclerebitem.h" +#include "groupobstaclered.h" + +namespace AbstractLvl { + +GroupObstacleRed::GroupObstacleRed(): CRAWL::IWorldItem(AUTO_CLASS_NAME) { + + setDistance(20); + changeLayout(CRAWL::LayoutType::LINE); + + for(int i(0); i < 4; i++) { + add(new ObstacleRebItem); + } + +} + +void GroupObstacleRed::render(unsigned int tbfMsec) { + Layout::render(tbfMsec); + IWorldItem::render(tbfMsec); +} + +void GroupObstacleRed::init() { + +} + +} diff --git a/src/CrawlAbstractLvl/private/groupobstaclered.h b/src/CrawlAbstractLvl/private/groupobstaclered.h new file mode 100644 index 0000000..93d25c0 --- /dev/null +++ b/src/CrawlAbstractLvl/private/groupobstaclered.h @@ -0,0 +1,27 @@ +//# +//# 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 GROUPOBSTACLERED_H +#define GROUPOBSTACLERED_H + +#include "Crawl/layout.h" +#include "Crawl/clasteritem.h" + +namespace AbstractLvl { + +class GroupObstacleRed: public CRAWL::Layout, public CRAWL::IWorldItem { +public: + GroupObstacleRed(); + + // IRender interface +public: + void render(unsigned int tbfMsec); + void init(); +}; +} + +#endif // GROUPOBSTACLERED_H diff --git a/src/CrawlAbstractLvl/private/obstaclerebitem.cpp b/src/CrawlAbstractLvl/private/obstaclerebitem.cpp new file mode 100644 index 0000000..ff15027 --- /dev/null +++ b/src/CrawlAbstractLvl/private/obstaclerebitem.cpp @@ -0,0 +1,20 @@ +//# +//# 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 "obstaclerebitem.h" + +namespace AbstractLvl { + +ObstacleRebItem::ObstacleRebItem() { + +} + +void ObstacleRebItem::render(unsigned int tbfMsec) { + +} + +} diff --git a/src/CrawlAbstractLvl/private/obstaclerebitem.h b/src/CrawlAbstractLvl/private/obstaclerebitem.h new file mode 100644 index 0000000..829dabf --- /dev/null +++ b/src/CrawlAbstractLvl/private/obstaclerebitem.h @@ -0,0 +1,26 @@ +//# +//# 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 OBSTACLEREBITEM_H +#define OBSTACLEREBITEM_H + +#include "obstaclered.h" + +namespace AbstractLvl { + +class ObstacleRebItem: public ObstacleRed { +public: + ObstacleRebItem(); + + // IRender interface +public: + void render(unsigned int tbfMsec); +}; + +} + +#endif // OBSTACLEREBITEM_H diff --git a/src/CrawlAbstractLvl/private/obstaclered.cpp b/src/CrawlAbstractLvl/private/obstaclered.cpp index e0d03ac..f52ac5a 100644 --- a/src/CrawlAbstractLvl/private/obstaclered.cpp +++ b/src/CrawlAbstractLvl/private/obstaclered.cpp @@ -9,7 +9,7 @@ namespace AbstractLvl { -ObstacleRed::ObstacleRed() : IWorldItem(AUTO_CLASS_NAME) { +ObstacleRed::ObstacleRed() : CRAWL::ClasterItem(AUTO_CLASS_NAME) { setMash("qrc:/mesh/meshes/ObstacleRed.mesh"); setSize({1,1,1}); setColor("#ff1927"); diff --git a/src/CrawlAbstractLvl/private/obstaclered.h b/src/CrawlAbstractLvl/private/obstaclered.h index 24bd915..68130a6 100644 --- a/src/CrawlAbstractLvl/private/obstaclered.h +++ b/src/CrawlAbstractLvl/private/obstaclered.h @@ -7,11 +7,11 @@ #ifndef OBJOBSTACLERED_H #define OBJOBSTACLERED_H -#include "Crawl/iworlditem.h" +#include "Crawl/clasteritem.h" namespace AbstractLvl { -class ObstacleRed: public CRAWL::IWorldItem { +class ObstacleRed: public CRAWL::ClasterItem { public: ObstacleRed(); From db8b9b3f21d50db6cbd9762467de99ed752c3c72 Mon Sep 17 00:00:00 2001 From: IgorekLoschinin Date: Fri, 24 Sep 2021 23:44:09 +0300 Subject: [PATCH 27/32] ref #110 Bugfix in draw square and line. --- src/Core/Crawl/layout.cpp | 12 +++++++----- src/CrawlAbstractLvl/private/abslvlworld.cpp | 2 +- src/CrawlAbstractLvl/private/groupobstaclered.cpp | 6 +++++- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/Core/Crawl/layout.cpp b/src/Core/Crawl/layout.cpp index b53ee3c..a08db99 100644 --- a/src/Core/Crawl/layout.cpp +++ b/src/Core/Crawl/layout.cpp @@ -89,6 +89,7 @@ void Layout::drawSquare() { } int height = qFloor(qSqrt(objects().size())); + int width = qFloor(objects().size() / height); int indObject = 0; for (auto idObj = objects().keyBegin(); idObj != objects().keyEnd(); idObj++) { @@ -96,9 +97,8 @@ void Layout::drawSquare() { float x = indObject % height; float y = qCeil(indObject / height); - GroupObject::updatePosition(*idObj, {x + _distance, - y + _distance, - 0}); + GroupObject::updatePosition(*idObj, {(x * _distance) - (height * _distance / 2), + (y * _distance) - (width * _distance / 2), 0}); indObject++; } @@ -113,8 +113,10 @@ void Layout::drawLine() { } float xObject = 0; - for (ClasterItem* object: objects()) { - GroupObject::updatePosition(object->guiId(), {xObject + _distance, 0, 0}); + float height = objects().size() * _distance; + for (auto idObj = objects().keyBegin(); idObj != objects().keyEnd(); idObj++) { + + GroupObject::updatePosition(*idObj, {(xObject * _distance) - (height/2 * _distance), 0, 0}); xObject++; } diff --git a/src/CrawlAbstractLvl/private/abslvlworld.cpp b/src/CrawlAbstractLvl/private/abslvlworld.cpp index 5df1998..1837687 100644 --- a/src/CrawlAbstractLvl/private/abslvlworld.cpp +++ b/src/CrawlAbstractLvl/private/abslvlworld.cpp @@ -38,7 +38,7 @@ CRAWL::WorldRule *AbsLvlWorld::initWorldRules() { } }, - {300, + {210, { {registerObject(), 1}, {registerObject(), 1} } diff --git a/src/CrawlAbstractLvl/private/groupobstaclered.cpp b/src/CrawlAbstractLvl/private/groupobstaclered.cpp index c22da23..f261e3f 100644 --- a/src/CrawlAbstractLvl/private/groupobstaclered.cpp +++ b/src/CrawlAbstractLvl/private/groupobstaclered.cpp @@ -12,7 +12,11 @@ namespace AbstractLvl { GroupObstacleRed::GroupObstacleRed(): CRAWL::IWorldItem(AUTO_CLASS_NAME) { - setDistance(20); + QQuaternion rotation = + QQuaternion::fromAxisAndAngle(QVector3D(0,1,0), 90); + + setDistance(7); + setRotation(rotation); changeLayout(CRAWL::LayoutType::LINE); for(int i(0); i < 4; i++) { From 6dbb7debaf9925c0837af18e4e8876eebdfb7e7e Mon Sep 17 00:00:00 2001 From: IgorekLoschinin Date: Tue, 5 Oct 2021 23:33:30 +0300 Subject: [PATCH 28/32] ref #110 Added new method for recalculate position. --- src/Core/Crawl/groupobject.cpp | 39 ++++++++++++++++++- src/Core/Crawl/groupobject.h | 2 + src/CrawlAbstractLvl/private/abslvlworld.cpp | 2 +- .../private/groupobstaclered.cpp | 2 +- 4 files changed, 41 insertions(+), 4 deletions(-) diff --git a/src/Core/Crawl/groupobject.cpp b/src/Core/Crawl/groupobject.cpp index f4fa5c3..5302846 100644 --- a/src/Core/Crawl/groupobject.cpp +++ b/src/Core/Crawl/groupobject.cpp @@ -22,10 +22,20 @@ void GroupObject::render(unsigned int tbfMsec) { for (ClasterItem* object: objects()) { if (Localpropertys *props = getLocalpropertys(object->guiId())) { - if (!props->_rotation.isNull()) + + if (!props->_rotation.isNull()) { object->setRotation(_this->rotation() * props->_rotation); - object->setposition(_this->position() + props->_position); + QVector3D reCalcVectorPs = reCalcPos(props->_position, + _this->rotation().toEulerAngles()); + + object->setposition(_this->position() + reCalcVectorPs); + + } else { + object->setposition(_this->position() + props->_position); + } + + } } @@ -48,6 +58,31 @@ void GroupObject::updateRotation(int id, const QQuaternion &roatation) { _extrapropertys[id]._rotation = roatation; } +const QVector3D GroupObject::reCalcPos(const QVector3D& pos, const QVector3D &eulerAngles) const +{ + float alha = eulerAngles[0]; + float beta = eulerAngles[1]; + float gamma = eulerAngles[2]; + + float x = pos[0]; + float y = pos[1]; + float z = pos[2]; + + float newX = x*(qCos(alha)*qCos(beta)) + + y*(qCos(alha)*qSin(beta)*qSin(gamma) - qSin(alha)*qCos(gamma)) + + z*(qCos(alha)*qSin(beta)*qCos(gamma) + qSin(alha)*qSin(gamma)); + + float newY = x*(qSin(alha)*qCos(beta)) + + y*(qSin(alha)*qSin(beta)*qSin(gamma) + qCos(alha)*qCos(gamma)) + + z*(qSin(alha)*qSin(beta)*qCos(gamma) - qCos(alha)*qSin(gamma)); + + float newZ = x*(-qSin(beta)) + + y*(qCos(beta)*qSin(gamma)) + + z*(qCos(beta)*qCos(gamma)); + + return QVector3D({newX, newY, newZ}); +} + QQuaternion *GroupObject::getLocalrotation(int id) { if (_extrapropertys.contains(id)) { return &_extrapropertys[id]._rotation; diff --git a/src/Core/Crawl/groupobject.h b/src/Core/Crawl/groupobject.h index 63b4a85..f8208d9 100644 --- a/src/Core/Crawl/groupobject.h +++ b/src/Core/Crawl/groupobject.h @@ -123,6 +123,8 @@ protected: private: QHash _extrapropertys; + const QVector3D reCalcPos(const QVector3D& pos, const QVector3D& eulerAngles) const; + }; } #endif // GROUPOBJECT_H diff --git a/src/CrawlAbstractLvl/private/abslvlworld.cpp b/src/CrawlAbstractLvl/private/abslvlworld.cpp index 1837687..ffb1d8b 100644 --- a/src/CrawlAbstractLvl/private/abslvlworld.cpp +++ b/src/CrawlAbstractLvl/private/abslvlworld.cpp @@ -38,7 +38,7 @@ CRAWL::WorldRule *AbsLvlWorld::initWorldRules() { } }, - {210, + {250, { {registerObject(), 1}, {registerObject(), 1} } diff --git a/src/CrawlAbstractLvl/private/groupobstaclered.cpp b/src/CrawlAbstractLvl/private/groupobstaclered.cpp index f261e3f..eb23b4b 100644 --- a/src/CrawlAbstractLvl/private/groupobstaclered.cpp +++ b/src/CrawlAbstractLvl/private/groupobstaclered.cpp @@ -13,7 +13,7 @@ namespace AbstractLvl { GroupObstacleRed::GroupObstacleRed(): CRAWL::IWorldItem(AUTO_CLASS_NAME) { QQuaternion rotation = - QQuaternion::fromAxisAndAngle(QVector3D(0,1,0), 90); + QQuaternion::fromEulerAngles(QVector3D(0,0,60)); setDistance(7); setRotation(rotation); From 9465c0358bca4f5e274536d80e45f68edcc00d4f Mon Sep 17 00:00:00 2001 From: IgorekLoschinin Date: Wed, 6 Oct 2021 21:04:31 +0300 Subject: [PATCH 29/32] ref #110 Fix recalculate positon. --- src/Core/Crawl/groupobject.cpp | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/Core/Crawl/groupobject.cpp b/src/Core/Crawl/groupobject.cpp index 5302846..87ac60d 100644 --- a/src/Core/Crawl/groupobject.cpp +++ b/src/Core/Crawl/groupobject.cpp @@ -23,19 +23,13 @@ void GroupObject::render(unsigned int tbfMsec) { if (Localpropertys *props = getLocalpropertys(object->guiId())) { - if (!props->_rotation.isNull()) { + if (!props->_rotation.isNull()) object->setRotation(_this->rotation() * props->_rotation); - QVector3D reCalcVectorPs = reCalcPos(props->_position, - _this->rotation().toEulerAngles()); - - object->setposition(_this->position() + reCalcVectorPs); - - } else { - object->setposition(_this->position() + props->_position); - } - + QVector3D reCalcVectorPs = reCalcPos(props->_position, + _this->rotation().toEulerAngles()); + object->setposition(_this->position() + reCalcVectorPs); } } From 5674d686cf18c906771634cda11d5294306a0101 Mon Sep 17 00:00:00 2001 From: IgorekLoschinin Date: Wed, 6 Oct 2021 22:34:28 +0300 Subject: [PATCH 30/32] ref #110 Fixing method recalculate - change matrix angel. --- src/Core/Crawl/groupobject.cpp | 18 +++++++++--------- .../private/groupobstaclered.cpp | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/Core/Crawl/groupobject.cpp b/src/Core/Crawl/groupobject.cpp index 87ac60d..c675a93 100644 --- a/src/Core/Crawl/groupobject.cpp +++ b/src/Core/Crawl/groupobject.cpp @@ -58,21 +58,21 @@ const QVector3D GroupObject::reCalcPos(const QVector3D& pos, const QVector3D &eu float beta = eulerAngles[1]; float gamma = eulerAngles[2]; - float x = pos[0]; - float y = pos[1]; - float z = pos[2]; + float x = pos.x(); + float y = pos.y(); + float z = pos.z(); - float newX = x*(qCos(alha)*qCos(beta)) + - y*(qCos(alha)*qSin(beta)*qSin(gamma) - qSin(alha)*qCos(gamma)) + + float newX = x*(qCos(beta)*qCos(gamma)) + + y*(qCos(gamma)*qSin(alha)*qSin(beta) - qSin(gamma)*qCos(alha)) + z*(qCos(alha)*qSin(beta)*qCos(gamma) + qSin(alha)*qSin(gamma)); - float newY = x*(qSin(alha)*qCos(beta)) + + float newY = x*(qSin(gamma)*qCos(beta)) + y*(qSin(alha)*qSin(beta)*qSin(gamma) + qCos(alha)*qCos(gamma)) + - z*(qSin(alha)*qSin(beta)*qCos(gamma) - qCos(alha)*qSin(gamma)); + z*(qSin(gamma)*qSin(beta)*qCos(alha) - qCos(gamma)*qSin(gamma)); float newZ = x*(-qSin(beta)) + - y*(qCos(beta)*qSin(gamma)) + - z*(qCos(beta)*qCos(gamma)); + y*(qCos(beta)*qSin(alha)) + + z*(qCos(alha)*qCos(beta)); return QVector3D({newX, newY, newZ}); } diff --git a/src/CrawlAbstractLvl/private/groupobstaclered.cpp b/src/CrawlAbstractLvl/private/groupobstaclered.cpp index eb23b4b..ba3d760 100644 --- a/src/CrawlAbstractLvl/private/groupobstaclered.cpp +++ b/src/CrawlAbstractLvl/private/groupobstaclered.cpp @@ -13,7 +13,7 @@ namespace AbstractLvl { GroupObstacleRed::GroupObstacleRed(): CRAWL::IWorldItem(AUTO_CLASS_NAME) { QQuaternion rotation = - QQuaternion::fromEulerAngles(QVector3D(0,0,60)); + QQuaternion::fromEulerAngles(QVector3D(0,0,-90)); setDistance(7); setRotation(rotation); From a9c85d2a99ad8d281e5d8b249f784c53ea52c6dc Mon Sep 17 00:00:00 2001 From: IgorekLoschinin Date: Fri, 8 Oct 2021 20:40:17 +0300 Subject: [PATCH 31/32] ref #110 Added recent changes to the rotation matrix. --- src/Core/Crawl/groupobject.cpp | 18 +++++++++--------- .../private/groupobstaclered.cpp | 4 ++-- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/Core/Crawl/groupobject.cpp b/src/Core/Crawl/groupobject.cpp index c675a93..96e2cc9 100644 --- a/src/Core/Crawl/groupobject.cpp +++ b/src/Core/Crawl/groupobject.cpp @@ -54,25 +54,25 @@ void GroupObject::updateRotation(int id, const QQuaternion &roatation) { const QVector3D GroupObject::reCalcPos(const QVector3D& pos, const QVector3D &eulerAngles) const { - float alha = eulerAngles[0]; - float beta = eulerAngles[1]; - float gamma = eulerAngles[2]; + float alha = eulerAngles.z(); + float beta = eulerAngles.y(); + float gamma = eulerAngles.x(); float x = pos.x(); float y = pos.y(); float z = pos.z(); - float newX = x*(qCos(beta)*qCos(gamma)) + - y*(qCos(gamma)*qSin(alha)*qSin(beta) - qSin(gamma)*qCos(alha)) + + float newX = x*(qCos(alha)*qCos(beta)) + + y*(qCos(alha)*qSin(beta)*qSin(gamma) - qSin(alha)*qCos(gamma)) + z*(qCos(alha)*qSin(beta)*qCos(gamma) + qSin(alha)*qSin(gamma)); - float newY = x*(qSin(gamma)*qCos(beta)) + + float newY = x*(qSin(alha)*qCos(beta)) + y*(qSin(alha)*qSin(beta)*qSin(gamma) + qCos(alha)*qCos(gamma)) + - z*(qSin(gamma)*qSin(beta)*qCos(alha) - qCos(gamma)*qSin(gamma)); + z*(qSin(alha)*qSin(beta)*qCos(gamma) - qCos(alha)*qSin(gamma)); float newZ = x*(-qSin(beta)) + - y*(qCos(beta)*qSin(alha)) + - z*(qCos(alha)*qCos(beta)); + y*(qCos(beta)*qSin(gamma)) + + z*(qCos(beta)*qCos(gamma)); return QVector3D({newX, newY, newZ}); } diff --git a/src/CrawlAbstractLvl/private/groupobstaclered.cpp b/src/CrawlAbstractLvl/private/groupobstaclered.cpp index ba3d760..b2b1db6 100644 --- a/src/CrawlAbstractLvl/private/groupobstaclered.cpp +++ b/src/CrawlAbstractLvl/private/groupobstaclered.cpp @@ -13,13 +13,13 @@ namespace AbstractLvl { GroupObstacleRed::GroupObstacleRed(): CRAWL::IWorldItem(AUTO_CLASS_NAME) { QQuaternion rotation = - QQuaternion::fromEulerAngles(QVector3D(0,0,-90)); + QQuaternion::fromEulerAngles(QVector3D(0,0,90)); setDistance(7); setRotation(rotation); changeLayout(CRAWL::LayoutType::LINE); - for(int i(0); i < 4; i++) { + for(int i(0); i < 10; i++) { add(new ObstacleRebItem); } From b9f1f236d1173d5822df7be82600ee6e933a37d3 Mon Sep 17 00:00:00 2001 From: EndrII Date: Fri, 8 Oct 2021 22:16:33 +0300 Subject: [PATCH 32/32] fix test (ref #110) --- tests/units/groupobjecttest.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/units/groupobjecttest.cpp b/tests/units/groupobjecttest.cpp index cf60629..806eb12 100644 --- a/tests/units/groupobjecttest.cpp +++ b/tests/units/groupobjecttest.cpp @@ -73,14 +73,16 @@ void GroupObjectTest::testBehavior() const { QVector3D localPosition = {10,0,0}; QQuaternion localRotation = QQuaternion::fromEulerAngles(0,5,0); - object.updatePosition(item.guiId(), localPosition); object.updateRotation(item.guiId(), localRotation); + object.render(0); + // after invoke the render function all positions and rotations should be changed + QVERIFY(item.rotation() == (object.rotation() * localRotation)); + + object.updatePosition(item.guiId(), localPosition); + object.setRotation(QQuaternion::fromEulerAngles(0,0,0)); object.render(0); - - // after invoke the render function all positions and rotations should be changed QVERIFY(item.position() == (object.position() + localPosition)); - QVERIFY(item.rotation() == (object.rotation() * localRotation)); object.remove(&item);