4
1
mirror of https://github.com/QuasarApp/Snake.git synced 2025-05-13 09:59:46 +00:00

Merge pull request from QuasarApp/task_88

Jungle flora
This commit is contained in:
Andrei Yankovich 2021-07-18 20:07:36 +03:00 committed by GitHub
commit 8e953b7159
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
69 changed files with 1837 additions and 68 deletions

@ -39,7 +39,10 @@ int main(int argc, char *argv[])
QQmlApplicationEngine engine;
CRAWL::ClientApp client;
#ifdef QT_DEBUG
client.registerLevel<TestLevel>();
#endif
client.registerLevel<AbstractLvl>();
client.registerLevel<Jungle>();

@ -13,5 +13,7 @@
<file>CrawlModule/SelectLvlView.qml</file>
<file>CrawlModule/DefaultMenu.qml</file>
<file>CrawlModule/AbstractMenuView.qml</file>
<file>CrawlModule/Light.qml</file>
<file>CrawlModule/DayLight.qml</file>
</qresource>
</RCC>

10
src/Core/Crawl/day.cpp Normal file

@ -0,0 +1,10 @@
//#
//# 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 "day.h"

167
src/Core/Crawl/day.h Normal file

@ -0,0 +1,167 @@
//#
//# 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 DAY_H
#define DAY_H
#include "Extensions/claster.h"
#include "dayitem.h"
#include "iworlditem.h"
#include "math.h"
namespace CRAWL {
template <class Sun, class Moon>
/**
* @brief The Day class is template wrapper for the moon and sun objects.
* The moon and sun objects moving around world center for imitation of the day.
* @note All objects will be moving around this objects with radius. The Radius by default is 2000.
* @note This class automaticly sets ligth force for the light objects.
*/
class Day: public IWorldItem, public Claster
{
public:
Day(): IWorldItem(AUTO_CLASS_NAME) {
static_assert(std::is_base_of_v<DayItem, Sun>,
"The Day class can be works only with DayItem child classes");
DayItem* sun = new Sun(&position());
DayItem* moon1 = new Moon(&position());
DayItem* moon2 = new Moon(&position());
sun->setAnglePosition(0);
moon1->setAnglePosition(225);
moon2->setAnglePosition(135);
add(sun);
add(moon1);
add(moon2);
}
void render(unsigned int ) override {
setposition(getPlayer()->position() + QVector3D{0, 0, 0});
}
void add(ClasterItem *object) override {
if (auto item = dynamic_cast<DayItem*>(object)) {
item->setRadius(radius());
item->setAxis(_axis);
item->setAngularVelocity(lengthToSpeed(_dayLengthSec));
item->setLightForce(lengthForce());
Claster::add(item);
} else {
QuasarAppUtils::Params::log("The Day class can works only with "
" Child classes of the DayItem",
QuasarAppUtils::Error);
}
};
void remove(ClasterItem *object) override {
Claster::remove(object);
};
/**
* @brief radius This method return radius of the motion day objects.
* @return radius of the motions
*/
int radius() const {
return _radius;
}
/**
* @brief setRadius This method sets new value of the motions radius.
* @param newRadius This is new value o fthe motion.
*/
void setRadius(int newRadius) {
if (newRadius == _radius)
return;
_radius = newRadius;
for (auto object: objects()) {
reinterpret_cast<DayItem*>(object)->setLightForce(lengthForce());
reinterpret_cast<DayItem*>(object)->setRadius(_radius);
}
}
/**
* @brief axis This is sxis of rotation. all objects will be moving around this axis. The axis is general 3d vector object.
* @return rotation axis.
* @note By default it is y axis
*/
const QVector3D &axis() const {
return _axis;
}
/**
* @brief setAxis This method sets new value of the rotation axis. For get more information see the axis method.
* @param newAxis This is new value of the rotation axis.
*/
void setAxis(const QVector3D &newAxis) {
if (newAxis == _axis)
return;
_axis = newAxis;
for (auto object: objects()) {
reinterpret_cast<DayItem*>(object)->setAxis(_axis);
}
}
/**
* @brief dayLengthSec This method return length of the game day in real secs.
* @note by default this value is 60 sec
* @return length of the game day in real secs.
*/
float dayLengthSec() const {
return _dayLengthSec;
}
/**
* @brief setDayLengthSec This method sets new value of the day length.
* @param newDayLongSec This is new value of the day length.
* @note For get more information see the dayLengthSec method.
*/
void setDayLengthSec(float newDayLengthSec) {
if (newDayLengthSec == _dayLengthSec)
return;
_dayLengthSec = newDayLengthSec;
for (auto object: objects()) {
reinterpret_cast<DayItem*>(object)->setAngularVelocity(lengthToSpeed(_dayLengthSec));
}
}
protected:
void onIntersects(const IWorldItem *) override {};
private:
float lengthToSpeed(float length) const {
return (2 * M_PI * radius()) / length;
}
float lengthForce() const {
return _radius * 15;
}
int _radius = 1000;
float _dayLengthSec = 360;
QVector3D _axis = {1,0,0};
};
}
#endif // DAY_H

@ -0,0 +1,29 @@
//#
//# 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 "dayitem.h"
namespace CRAWL {
DayItem::DayItem(
const QVector3D* center,
const QString &name,
const QString &viewTempalte,
QObject *ptr):
IWorldLight(name, viewTempalte, ptr),
CircularMotion(center) {
}
void DayItem::render(unsigned int tbfMsec) {
CircularMotion::render(tbfMsec);
setVisible(position().z() > 0);
}
}

29
src/Core/Crawl/dayitem.h Normal file

@ -0,0 +1,29 @@
//#
//# 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 DAYITEM_H
#define DAYITEM_H
#include "iworldlight.h"
#include "Extensions/circularmotion.h"
namespace CRAWL {
/**
* @brief The DayItem class This is base class of the sun of moon of anther movable around center objects.
*/
class DayItem: public IWorldLight, public CircularMotion {
Q_OBJECT
public:
DayItem(const QVector3D* center,
const QString& name,
const QString& viewTempalte = "qrc:/CrawlModule/DayLight.qml",
QObject *ptr = nullptr);
void render(unsigned int tbfMsec);
};
}
#endif // DAYITEM_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.
//#
#include "defaultlight.h"
namespace CRAWL {
DefaultLight::DefaultLight(): IWorldLight(AUTO_CLASS_NAME) {
setColor("#fff8e7");
setposition({10000, 0, 10000});
setRatation(QQuaternion::fromEulerAngles({-90,0,0}));
setLightForce(110);
}
void DefaultLight::render(unsigned int) {
}
void DefaultLight::init() {
}
void DefaultLight::onIntersects(const IWorldItem *) {
}
}

@ -0,0 +1,34 @@
//#
//# 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 DEFAULTLIGHT_H
#define DEFAULTLIGHT_H
#include "iworldlight.h"
namespace CRAWL {
/**
* @brief The DefaultLight class This is default implementation of the wirld light.
*/
class DefaultLight final: public IWorldLight
{
Q_OBJECT
public:
DefaultLight();
void render(unsigned int tbfMsec) override;
void init() override;
// IWorldItem interface
protected:
void onIntersects(const IWorldItem *item) override;
};
}
#endif // DEFAULTLIGHT_H

@ -1,3 +1,11 @@
//#
//# 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 "diff.h"
namespace CRAWL {

@ -5,9 +5,9 @@
//# of this license document, but changing it is not allowed.
//#
#include "clasteritem.h"
#include "groundclaster.h"
#include "iworld.h"
#include "clasteritem.h"
namespace CRAWL {
@ -31,7 +31,7 @@ void GroundClaster::render(unsigned int ) {
auto object = _itemsOrder.at(_index % _itemsOrder.size());
if (playerObject->position().x() - object->position().x() >
if (playerObject->position().distanceToPoint(object->position()) >
newObjectDistance()) {
auto prewObject = _itemsOrder.at((_index - 1) % _itemsOrder.size());
@ -45,7 +45,6 @@ void GroundClaster::render(unsigned int ) {
}
void GroundClaster::add(ClasterItem *object) {
object->setX(newObjectDistance() * _itemsOrder.count());
_itemsOrder.push_back(object);

@ -48,7 +48,7 @@ protected:
virtual int newObjectDistance() const;
private:
QList<IWorldItem*> _itemsOrder;
QList<ClasterItem*> _itemsOrder;
unsigned int _index = 0;
};

@ -9,6 +9,7 @@
#define GROUNDTILE_H
#include "clasteritem.h"
#include "iworlditem.h"
namespace CRAWL {

@ -20,11 +20,11 @@ GuiObject::GuiObject(const QString &name, const QString &viewTempalte, QObject *
setRatation(QQuaternion::fromEulerAngles({0,0,0}));
}
QString GuiObject::color() const {
const QString& GuiObject::color() const {
return _color;
}
void GuiObject::setColor(QString color) {
void GuiObject::setColor(const QString& color) {
if (_color == color)
return;
@ -37,6 +37,17 @@ void GuiObject::generateId() {
setGuiId(id++);
}
bool GuiObject::visible() const {
return _visible;
}
void GuiObject::setVisible(bool newVisible) {
if (_visible == newVisible)
return;
_visible = newVisible;
emit visibleChanged();
}
const QString &GuiObject::className() const {
return _className;
}

@ -16,6 +16,9 @@
#include "Crawl/irender.h"
#define DEFAULT_VIEW_TEMPLATE "qrc:/CrawlModule/GraphicItem.qml"
/** the AUTO_CLASS_NAME define gets name from the class and namespace.
*/
#define AUTO_CLASS_NAME typeid(this).name()
namespace CRAWL {
@ -79,8 +82,8 @@ public:
const QString& viewTempalte = DEFAULT_VIEW_TEMPLATE,
QObject *ptr = nullptr);
QString color() const;
void setColor(QString color);
const QString &color() const;
void setColor(const QString &color);
virtual void reset();
QString viewTemplate() const;
@ -144,6 +147,18 @@ public:
*/
const QString &className() const;
/**
* @brief visible This property sets to true if object visibel else false.
* @return true if object is visible
*/
bool visible() const;
/**
* @brief setVisible This method sets new vlaue of the visible property
* @param newVisible new value of visible
*/
void setVisible(bool newVisible);
signals:
void guiIdChanged(int guiId);
void colorChanged(QString color);
@ -160,6 +175,8 @@ signals:
void mashChanged();
void visibleChanged();
protected:
/**
@ -203,6 +220,8 @@ private:
QQuaternion _ratation;
QString _mash;
QString _className;
bool _visible = true;
Q_PROPERTY(bool visible READ visible WRITE setVisible NOTIFY visibleChanged)
};
}

@ -24,7 +24,8 @@ namespace CRAWL {
IWorld::IWorld() {
qRegisterMetaType<WorldRule::const_iterator>("WorldRule::const_iterator");
connect(this, &IWorld::sigWorldChanged, this, &IWorld::worldChanged, Qt::QueuedConnection);
}
IWorld::~IWorld() {
@ -62,6 +63,7 @@ void IWorld::render(unsigned int tbfMsec) {
emit sigGameFinished(_player->getCurrentStatus());
}
updateWorld();
int waitTime = 1000 / _targetFps - tbfMsec;
if (waitTime > 0)
@ -84,7 +86,7 @@ bool IWorld::start() {
_player->setControl(_userInterface);
worldChanged(*_worldRules->begin());
worldChanged(_worldRules->cbegin());
setTargetFps(60);
setRunning(true);
@ -216,7 +218,8 @@ void IWorld::removeItem(IWorldItem* item, QList<int> *removedObjectsList) {
if (auto claster = dynamic_cast<Claster*>(item)) {
const auto copyOfObjectsList = claster->objects();
for (auto item : copyOfObjectsList) {
if (!item || item->parentClastersCount() > 1)
auto clasterItem = dynamic_cast<ClasterItem*>(item);
if (!clasterItem || clasterItem->parentClastersCount() > 1)
continue;
int id = item->guiId();
@ -338,6 +341,18 @@ void IWorld::setHdr(const QString &hdr) {
emit hdrChanged();
}
void IWorld::updateWorld() {
if (_currendWorldLevel->isEmpty() || !_worldRules || !_player)
return;
float distance = _player->position().x();
auto nextLevel = _currendWorldLevel + 1;
if (nextLevel != _worldRules->cend() && distance > nextLevel.key()) {
emit sigWorldChanged(nextLevel);
}
}
const QQuaternion &IWorld::cameraRatation() const {
return _cameraRatation;
}
@ -377,8 +392,12 @@ const QVector3D &IWorld::cameraReleativePosition() const {
return _cameraReleativePosition;
}
void IWorld::worldChanged(WorldObjects objects) {
void IWorld::worldChanged(WorldRule::const_iterator iterator) {
if (_currendWorldLevel == iterator)
return;
auto objects = iterator.value();
objects[_player->className()] = 1;
for (auto it = objects.begin(); it != objects.end(); ++it) {
@ -395,6 +414,8 @@ void IWorld::worldChanged(WorldObjects objects) {
}
}
}
_currendWorldLevel = iterator;
}
int IWorld::wordlStatus() const {

@ -30,6 +30,7 @@ class IPlayer;
class GroundClaster;
class IControl;
class IAI;
class IWorldLight;
/**
* @brief WorldObjects This is map list of the avalable objects and its count on a lvl-long point.
@ -276,6 +277,13 @@ signals:
*/
void hdrChanged();
/**
* @brief sigWorldChanged emit this signal if you want to change level of the world.
* @note this signal needed for the move WorldChange method into main thread.
* @param objects this is iterator of the world rule object.
*/
void sigWorldChanged(WorldRule::const_iterator objects);
protected:
/**
@ -369,6 +377,11 @@ protected:
return type;
}
/**
* @brief updateWorld This method check current distance and load neede level and level objects.
*/
void updateWorld();
private slots:
/**
@ -376,6 +389,13 @@ private slots:
*/
void handleStop();
/**
* @brief worldChanged This method generate diff for the qml
* @param objects This is iterator of the world rules object that contains list of object on lvl
* @note This method addd player object to this list.
*/
void worldChanged(WorldRule::const_iterator objects);
private:
/**
* @brief prepare This method initialize world object.
@ -383,6 +403,10 @@ private:
* @return true if world initialized successful
*/
bool prepare();
/**
* @brief reset This method reset all world objects.
*/
void reset();
@ -399,12 +423,8 @@ private:
void setRunning(bool newRunning);
/**
* @brief worldChanged This method generate diff for the qml
* @param objects This is list of object on lvl
* @note This method addd player object to this list.
* @brief clearItems This method remove all created items from world.
*/
void worldChanged(WorldObjects objects);
void clearItems();
/**
@ -472,6 +492,8 @@ private:
QString _hdrMap;
WorldRule *_worldRules = nullptr;
WorldRule::const_iterator _currendWorldLevel;
IPlayer *_player = nullptr;
IControl *_userInterface = nullptr;
IAI *_backgroundAI = nullptr;

@ -34,16 +34,16 @@ const IWorldItem *IWorldItem::getPlayer() const {
}
void IWorldItem::render(unsigned int) {
if (_playerObject->position().x() - _world->cameraReleativePosition().z() >
position().x()) {
if (_playerObject->position().distanceToPoint(position()) >
_world->cameraReleativePosition().z() * 3) {
float dX = _world->cameraReleativePosition().z() * 2 +
(rand() % static_cast<int>(_world->cameraReleativePosition().z()));
setX(_playerObject->position().x() + dX);
float dY = (rand() % static_cast<int>(_world->cameraReleativePosition().z() * 4)
- _world->cameraReleativePosition().z() * 2);
float dY = (rand() % static_cast<int>(_world->cameraReleativePosition().z() * 3)
- _world->cameraReleativePosition().z() * 1.5);
setY(_playerObject->position().y() + dY);
}

@ -0,0 +1,84 @@
//#
//# 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 "iworldlight.h"
namespace CRAWL {
IWorldLight::IWorldLight(const QString &name,
const QString &viewTempalte,
QObject *ptr):
ClasterItem(name, viewTempalte, ptr) {
}
int IWorldLight::lightForce() const {
return _lightForce;
}
void IWorldLight::setLightForce(int newLightForce) {
if (_lightForce == newLightForce)
return;
_lightForce = newLightForce;
emit lightForceChanged();
}
bool IWorldLight::castsShadow() const {
return _castsShadow;
}
void IWorldLight::setCastsShadow(bool newCastsShadow) {
if (_castsShadow == newCastsShadow)
return;
_castsShadow = newCastsShadow;
emit castsShadowChanged();
}
float IWorldLight::shadowFactor() const {
return _shadowFactor;
}
void IWorldLight::setShadowFactor(float newShadowFactor) {
if (qFuzzyCompare(_shadowFactor, newShadowFactor))
return;
_shadowFactor = newShadowFactor;
emit shadowFactorChanged();
}
float IWorldLight::shadowFilter() const {
return _shadowFilter;
}
void IWorldLight::setShadowFilter(float newShadowFilter) {
if (qFuzzyCompare(_shadowFilter, newShadowFilter))
return;
_shadowFilter = newShadowFilter;
emit shadowFilterChanged();
}
float IWorldLight::shadowMapFar() const {
return _shadowMapFar;
}
void IWorldLight::setShadowMapFar(float newShadowMapFar) {
if (qFuzzyCompare(_shadowMapFar, newShadowMapFar))
return;
_shadowMapFar = newShadowMapFar;
emit shadowMapFarChanged();
}
float IWorldLight::shadowBias() const {
return _shadowBias;
}
void IWorldLight::setShadowBias(float newShadowBias) {
if (qFuzzyCompare(_shadowBias, newShadowBias))
return;
_shadowBias = newShadowBias;
emit shadowBiasChanged();
}
}

@ -0,0 +1,154 @@
//#
//# 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 "clasteritem.h"
#ifndef IWORLDLIGHT_H
#define IWORLDLIGHT_H
namespace CRAWL {
/**
* @brief The IWorldLight class Is base interaface of the light object.
* Override this class for the create own light system for level.
* You need to create own qml file with light.
*
* @note If you wnat to create a new qml file the you need to inherit from the Light.qml file.
*/
class CRAWL_EXPORT IWorldLight: public ClasterItem
{
Q_OBJECT
Q_PROPERTY(int lightForce READ lightForce WRITE setLightForce NOTIFY lightForceChanged)
Q_PROPERTY(bool castsShadow READ castsShadow WRITE setCastsShadow NOTIFY castsShadowChanged)
Q_PROPERTY(float shadowFactor READ shadowFactor WRITE setShadowFactor NOTIFY shadowFactorChanged)
Q_PROPERTY(float shadowFilter READ shadowFilter WRITE setShadowFilter NOTIFY shadowFilterChanged)
Q_PROPERTY(float shadowMapFar READ shadowMapFar WRITE setShadowMapFar NOTIFY shadowMapFarChanged)
Q_PROPERTY(float shadowBias READ shadowBias WRITE setShadowBias NOTIFY shadowBiasChanged)
public:
IWorldLight(const QString& name,
const QString& viewTempalte = "qrc:/CrawlModule/Light.qml",
QObject *ptr = nullptr);
/**
* @brief lightForce This method return light force
* @return light force value.
*/
int lightForce() const;
/**
* @brief setLightForce This method sets new value for the light force.
* @param newLightForce this is new value of the light force.
*/
void setLightForce(int newLightForce);
/**
* @brief castsShadow When this property is enabled, the light will cast shadows. The default value is false.
* @return current value of the castsShadow property.
*/
bool castsShadow() const;
/**
* @brief setCastsShadow This method sets new value of the castsShadow property. for get more information see the castsShadow method.
* @param newCastsShadow this is new value of the castsShadow property.
*/
void setCastsShadow(bool newCastsShadow);
/**
* @brief shadowFactor This property determines how dark the cast shadows should be. The value range is [0, 100], where 0 mean no shadows and 100 means the light is fully shadowed. The default value is 5.
* @return current value of the shadow factor
*/
float shadowFactor() const;
/**
* @brief setShadowFactor This method return current value of the shadow factor.
* @param newShadowFactor This is new value of the shadow factor property.
* @note for get more information see the shadowFactor method.
*/
void setShadowFactor(float newShadowFactor);
/**
* @brief shadowFilter This property sets how much blur is applied to the shadows. The default value is 5.
* @return current value of the shadow filter property.
*/
float shadowFilter() const;
/**
* @brief setShadowFilter This method return current value of the shadow filter property.
* @param newShadowFilter This is new value of the shadow filter property.
* @note for get more information see the shadowFilter method.
*/
void setShadowFilter(float newShadowFilter);
/**
* @brief shadowMapFar The property determines the maximum distance for the shadow map. Smaller values improve the precision and effects of the map. The default value is 5000.
* @return current value of the shadow map far property.
*/
float shadowMapFar() const;
/**
* @brief setShadowMapFar This method return current value of the shadow map far property.
* @param newShadowMapFar This is new value of the shadow map far property.
* @note for get more information see the shadowMapFar method.
*/
void setShadowMapFar(float newShadowMapFar);
/**
* @brief shadowBias This property is used to tweak the shadowing effect when when objects are casting shadows on themselves. The value range is [-1.0, 1.0]. Generally value inside [-0.1, 0.1] is sufficient. The default value is 0.
* @return current value of the shadow bias property.
*/
float shadowBias() const;
/**
* @brief setShadowBias This method return current value of the shadow bias property.
* @param newShadowBias This is new value of the shadow bias property.
* @note for get more information see the shadowBias method.
*/
void setShadowBias(float newShadowBias);
signals:
/**
* @brief lightForceChanged This signal emits when light force has changed.
*/
void lightForceChanged();
/**
* @brief castsShadowChanged This signal emits when the castsShadow property has changed.
*/
void castsShadowChanged();
/**
* @brief shadowFactorChanged This signal emits when the shadowFactor propertye has changed.
*/
void shadowFactorChanged();
/**
* @brief shadowFilterChanged This signal emits when the shadowFilter propertye has changed.
*/
void shadowFilterChanged();
/**
* @brief shadowMapFarChanged This signal emits when the shadowMapFar propertye has changed.
*/
void shadowMapFarChanged();
/**
* @brief shadowBiasChanged This signal emits when the shadowBias propertye has changed.
*/
void shadowBiasChanged();
private:
int _lightForce = 100;
bool _castsShadow = false;
float _shadowFactor = 5;
float _shadowFilter = 5;
float _shadowMapFar = 5000;
float _shadowBias = 0;
};
}
#endif // IWORLDLIGHT_H

21
src/Core/Crawl/moon.cpp Normal file

@ -0,0 +1,21 @@
//#
//# 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 "moon.h"
namespace CRAWL {
Moon::Moon(const QVector3D* center):
DayItem(center, AUTO_CLASS_NAME) {
setColor("#022648");
}
void Moon::init() {}
void Moon::onIntersects(const IWorldItem *) {}
}

31
src/Core/Crawl/moon.h Normal file

@ -0,0 +1,31 @@
//#
//# 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 MOON_H
#define MOON_H
#include "Crawl/dayitem.h"
namespace CRAWL {
/**
* @brief The Moon class This is default implementation of the moon for the Dat class.
*/
class CRAWL_EXPORT Moon: public DayItem {
Q_OBJECT
public:
Moon(const QVector3D *center);
void init();
// IWorldItem interface
protected:
void onIntersects(const IWorldItem *item);
};
}
#endif // MOON_H

@ -5,7 +5,6 @@
//# of this license document, but changing it is not allowed.
//#
#include "clasteritem.h"
#include "snake.h"
#include "snakeitem.h"
#include <QQuaternion>

@ -9,6 +9,7 @@
#ifndef SNAKEITEM_H
#define SNAKEITEM_H
#include "iworlditem.h"
#include "singleclasterworlditem.h"
#include "Extensions/movableobject.h"

21
src/Core/Crawl/sun.cpp Normal file

@ -0,0 +1,21 @@
//#
//# 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 "sun.h"
namespace CRAWL {
Sun::Sun(const QVector3D* center):
DayItem(center, AUTO_CLASS_NAME) {
setColor("#fff6d0");
}
void Sun::onIntersects(const IWorldItem *) {}
void Sun::init() {}
}

35
src/Core/Crawl/sun.h Normal file

@ -0,0 +1,35 @@
//#
//# 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 SUN_H
#define SUN_H
#include "Crawl/dayitem.h"
namespace CRAWL {
/**
* @brief The Sun class This is default implementation of the sun for the Day class.
*/
class CRAWL_EXPORT Sun: public DayItem
{
Q_OBJECT
public:
Sun(const QVector3D* center);
// IWorldItem interface
protected:
void onIntersects(const IWorldItem *item);
// IRender interface
public:
void init();
};
}
#endif // SUN_H

@ -0,0 +1,42 @@
//#
//# 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.
//#
import QtQuick 2.15
import QtQuick3D 1.15
Node {
id: graphicItem
property var model: null
property int guiId: (model) ? model.guiId : -1;
PointLight {
id : sun
brightness: (model)? model.lightForce * model.visible: 100
color: (model)? model.color: "#ffffff"
castsShadow: (model)? model.castsShadow: 0
shadowFactor: (model)? model.shadowFactor: 0
shadowFilter: (model)? model.shadowFilter: 0
shadowMapFar: (model)? model.shadowMapFar: 0
shadowBias: (model)? model.shadowBias: 0
shadowMapQuality: Light.ShadowMapQualityHigh
Behavior on brightness {
NumberAnimation {
duration: 5000
}
}
}
rotation: (model)? model.ratation: Qt.quaternion(0, 0, 0, 0)
scale: (model)? model.size: Qt.vector3d(0, 0, 0);
position: (model) ? model.position: Qt.vector3d(0,0,0);
visible: sun.brightness
}

@ -70,4 +70,6 @@ Model {
source: (model)? model.mash: "#Cube";
position: (model) ? model.position: Qt.vector3d(0,0,0);
visible: (model)? model.visible: false
}

@ -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.
//#
import QtQuick 2.15
import QtQuick3D 1.15
Node {
id: graphicItem
property var model: null
property int guiId: (model) ? model.guiId : -1;
DirectionalLight {
position: Qt.vector3d(0, 0, 0);
brightness: (model)? model.lightForce: 100
color: (model)? model.color: "#ffffff"
castsShadow: (model)? model.castsShadow: 0
shadowFactor: (model)? model.shadowFactor: 0
shadowFilter: (model)? model.shadowFilter: 0
shadowMapFar: (model)? model.shadowMapFar: 0
shadowBias: (model)? model.shadowBias: 0
}
rotation: (model)? model.ratation: Qt.quaternion(0, 0, 0, 0)
scale: (model)? model.size: Qt.vector3d(0, 0, 0);
position: (model) ? model.position: Qt.vector3d(0,0,0);
}

@ -27,13 +27,6 @@ View3D {
}
DirectionalLight {
position: Qt.vector3d(10000, 0, 10000);
rotation: camera.rotation
brightness: 120
}
environment: SceneEnvironment {
id: background
backgroundMode: SceneEnvironment.SkyBox
@ -89,7 +82,9 @@ View3D {
for (var i = 0; i < arrayObjects.length; ++i) {
if (id === arrayObjects[i].guiId) {
arrayObjects[i].destroy();
arrayObjects.splice(i,1);
}
}
}

@ -21,7 +21,7 @@ void AutoGenerateClaster::generateItems() {
return;
}
add(_factory());
add(factory());
}
}

@ -47,11 +47,11 @@ protected:
* @brief factory This method create new item of the claster. See the registerItemType for get more information.
* @return return new item of the claster item. If the object not registered return nullptr.
*/
ClasterItem* factory() const;
ClasterItem *factory() const;
/**
* @brief isClasterItemRegistered
* @return
* @return tru if the class is registered.
*/
bool isClasterItemRegistered() const;

@ -0,0 +1,32 @@
//#
//# 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 "basemotion.h"
#include "Crawl/guiobject.h"
namespace CRAWL {
BaseMotion::BaseMotion() {
}
const QQuaternion &BaseMotion::staticRotation() const {
return _staticRotation;
}
void BaseMotion::setStaticRotation(const QQuaternion &newStaticRotation) {
_staticRotation = newStaticRotation;
}
void BaseMotion::render(unsigned int tbfMsec) {
if (auto _this = checkminimumRequariedType<GuiObject>()) {
renderPosition(_this, tbfMsec);
renderRatation(_this, tbfMsec);
}
}
}

@ -0,0 +1,71 @@
//#
//# 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 BASEMOTION_H
#define BASEMOTION_H
#include "Crawl/irender.h"
#include <QQuaternion>
namespace CRAWL {
class GuiObject;
/**
* @brief The BaseMotion class contains base functions of the motion.
* For Create your own motion alghoritm you need to override two methods:
* * renderPosition
* * renderRatation
*/
class CRAWL_EXPORT BaseMotion : public virtual IRender
{
public:
BaseMotion();
// IRender interface
public:
void render(unsigned int tbfMsec);
/**
* @brief staticRotation This method retur nstatic rotation in quaternion. The static rotation rotate object to setted value independet then movable vector.
* @return quterion of the static rotation
*/
const QQuaternion &staticRotation() const;
/**
* @brief setStaticRotation This metho sets new value of the static rotation of this object.
* @param newStaticRotation new value of the static rotation.
* @note if you want use eilor angles then use the QQuaternion::fromEulerAngles method.
* @note See the staticRotation method for get more information.
*/
void setStaticRotation(const QQuaternion &newStaticRotation);
protected:
/**
* @brief renderRatation This method recalc raration for an @a object. The Default do nothing.
* @param object This is provessing object. Usually @a an object is casted pointer of this to GuiObject type.
* @param tbfMsec This is time betwin frames argument. soame as in the IRender::render function.
*/
virtual void renderRatation(GuiObject* object, unsigned int tbfMsec) = 0;
/**
* @brief renderRatation This method recalc position for an @a object.
* @param object This is provessing object. Usually @a an object is casted pointer of this to GuiObject type.
* @param tbfMsec This is time betwin frames argument. soame as in the IRender::render function.
*/
virtual void renderPosition(GuiObject* object, unsigned int tbfMsec) = 0;
private:
QQuaternion _staticRotation = QQuaternion::fromEulerAngles(0,0,0);
};
}
#endif // BASEMOTION_H

@ -0,0 +1,77 @@
//#
//# 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 "circularmotion.h"
#include <Crawl/guiobject.h>
#include "cmath"
namespace CRAWL {
CircularMotion::CircularMotion(const QVector3D *center) {
_center = center;
}
void CircularMotion::render(unsigned int tbfMsec) {
if (auto _this = checkminimumRequariedType<GuiObject>()) {
renderPosition(_this, tbfMsec);
renderRatation(_this, tbfMsec);
}
}
float CircularMotion::angularVelocity() const {
return _angularVelocity;
}
void CircularMotion::setAngularVelocity(float newAngularVelocity) {
_angularVelocity = newAngularVelocity;
}
const QVector3D &CircularMotion::axis() const {
return _axis;
}
void CircularMotion::setAxis(const QVector3D &newAxis) {
_axis = newAxis;
}
float CircularMotion::radius() const {
return _radius;
}
void CircularMotion::setRadius(float newRadius) {
_radius = newRadius;
}
double CircularMotion::anglePosition() const {
return _angle;
}
void CircularMotion::setAnglePosition(double newAngle) {
_angle = newAngle;
}
void CircularMotion::renderRatation(GuiObject *object,
unsigned int ) {
object->setRatation(QQuaternion::rotationTo({1.0f, 0.0, 0.0}, *_center) * staticRotation());
}
void CircularMotion::renderPosition(GuiObject *object,
unsigned int tbfMsec) {
if (!_center)
return;
double motionCoef = 360 / (2 * M_PI * radius());
_angle += motionCoef * angularVelocity() * (tbfMsec / 1000.f);
auto normal = (QQuaternion::fromAxisAndAngle(_axis, _angle) * QVector3D{0,0,1}).normalized();
object->setposition(*_center + normal * radius());
}
}

@ -0,0 +1,106 @@
//#
//# 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 CIRCULARMOTION_H
#define CIRCULARMOTION_H
#include <Extensions/basemotion.h>
#include <QVector3D>
namespace CRAWL {
class GuiObject;
/**
* @brief The CircularMotion class. This class contains render function for the moving guiobject by round.
* @note For motion set motion asix and angular velocity
*/
class CRAWL_EXPORT CircularMotion: public BaseMotion
{
public:
CircularMotion(const QVector3D* center);
// IRender interface
public:
void render(unsigned int tbfMsec) override;
/**
* @brief angularVelocity This is property are speed of motion.
* @return current speed of the motion object.
*/
float angularVelocity() const;
/**
* @brief setAngularVelocity This method sets new value of the current speed of the object.
* @param newAngularVelocity This is new value of the motion speed
*/
void setAngularVelocity(float newAngularVelocity);
/**
* @brief axis This method are asix of motion. This object will moving around this axis.
* @return curretn asix value.
*/
const QVector3D &axis() const;
/**
* @brief setAxis This method sets new value of the motion axis.
* @param newAxis This is new value of the motion asix.
*/
void setAxis(const QVector3D &newAxis);
/**
* @brief radius This method return current radius of the circular motion
* @return current radius
*/
float radius() const;
/**
* @brief setRadius This method sets new value of the circular motion radius.
* @param newRadius This is new value of the circular motion radius.
*/
void setRadius(float newRadius);
/**
* @brief anglePosition This method return current angel of the item position arountd center.
* @return current angle position around center.
*/
double anglePosition() const;
/**
* @brief setAnglePosition This method sets new angel of the item position arountd center.
* @return newAngle angle position around center.
*/
void setAnglePosition(double newAngle);
protected:
/**
* @brief renderRatation This method recalc raration for an @a object. The Default implementation rotate object to center.
* @param object This is provessing object. Usually @a an object is casted pointer of this to GuiObject type.
* @param tbfMsec This is time betwin frames argument. soame as in the IRender::render function.
*/
void renderRatation(GuiObject* object, unsigned int) override;
/**
* @brief renderRatation This method recalc position for an @a object. The Default implementation move the current object around center.
* @param object This is provessing object. Usually @a an object is casted pointer of this to GuiObject type.
* @param tbfMsec This is time betwin frames argument. soame as in the IRender::render function.
*/
void renderPosition(GuiObject* object, unsigned int tbfMsec) override;
private:
float _angularVelocity = 0;
QVector3D _axis;
const QVector3D *_center = nullptr;
float _radius;
double _angle = 0;
};
}
#endif // CIRCULARMOTION_H

@ -14,7 +14,8 @@ Claster::Claster() {}
Claster::~Claster() {
for (auto child : qAsConst(_objects)) {
child->removeClaster(this);
if (auto obj = dynamic_cast<ClasterItem*>(child))
obj->removeClaster(this);
}
}

@ -87,14 +87,6 @@ void MovableObject::renderPosition(GuiObject *object, unsigned int tbfMsec) {
}
const QQuaternion &MovableObject::staticRotation() const {
return _staticRotation;
}
void MovableObject::setStaticRotation(const QQuaternion &newStaticRotation) {
_staticRotation = newStaticRotation;
}
const QVector3D &MovableObject::currentMovableVector() const {
return _currentMovableVector;
}

@ -9,7 +9,7 @@
#ifndef MOVABLEOBJECT_H
#define MOVABLEOBJECT_H
#include "Crawl/irender.h"
#include "Extensions/basemotion.h"
#include <QQuaternion>
#include <QVector3D>
@ -27,7 +27,7 @@ class GuiObject;
* * **Angular velocity** This property sets spead of the angle moving.
* * **Braking force** This property are delta decriment the Power of the movable vector on time.
*/
class CRAWL_EXPORT MovableObject: public virtual IRender
class CRAWL_EXPORT MovableObject: public BaseMotion
{
public:
@ -86,20 +86,6 @@ public:
*/
const QVector3D &currentMovableVector() const;
/**
* @brief staticRotation This method retur nstatic rotation in quaternion. The static rotation rotate object to setted value independet then movable vector.
* @return quterion of the static rotation
*/
const QQuaternion &staticRotation() const;
/**
* @brief setStaticRotation This metho sets new value of the static rotation of this object.
* @param newStaticRotation new value of the static rotation.
* @note if you want use eilor angles then use the QQuaternion::fromEulerAngles method.
* @note See the staticRotation method for get more information.
*/
void setStaticRotation(const QQuaternion &newStaticRotation);
protected:
/**
@ -107,14 +93,14 @@ protected:
* @param object This is provessing object. Usually @a an object is casted pointer of this to GuiObject type.
* @param tbfMsec This is time betwin frames argument. soame as in the IRender::render function.
*/
virtual void renderRatation(GuiObject* object, unsigned int tbfMsec);
void renderRatation(GuiObject* object, unsigned int tbfMsec) override;
/**
* @brief renderRatation This method recalc position for an @a object. The Default implementation move the current movable vector to setts movable vector. For example if you invoke the MovableObject::setMovableVector method then object change current movable vector with spead MovableObject::angularVelocity. If you sets
* @param object This is provessing object. Usually @a an object is casted pointer of this to GuiObject type.
* @param tbfMsec This is time betwin frames argument. soame as in the IRender::render function.
*/
virtual void renderPosition(GuiObject* object, unsigned int tbfMsec);
void renderPosition(GuiObject* object, unsigned int tbfMsec) override;
private:
QVector3D _movableVector;

@ -12,19 +12,26 @@
#include "world.h"
#include <testsnake.h>
#include "Crawl/iworlditem.h"
#include <Crawl/day.h>
#include <Crawl/defaultlight.h>
#include <Crawl/moon.h>
#include <Crawl/sun.h>
namespace TestLvl {
World::World() {
setCameraReleativePosition({0,0,100});
setCameraRatation(QQuaternion::fromEulerAngles({0,0,-90}));
setCameraReleativePosition({50,0,100});
setCameraRatation(QQuaternion::fromEulerAngles({0,0,0}));
}
CRAWL::WorldRule *World::initWorldRules() {
using Day = CRAWL::Day<CRAWL::Sun, CRAWL::Moon>;
return new CRAWL::WorldRule {
{0, {{registerObject<Box>(), 1000},
{registerObject<Background>(), 1}}}
{registerObject<Background>(), 1},
{registerObject<Day>(), 1}}}
};
}

@ -1 +1 @@
Subproject commit 858c0f949ac542d8a4c00b07bfb74ae5091d456c
Subproject commit 9b108d2698eda11bd7b263c2dd0a0d46cfa877d3

@ -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 "absaluteplate.h"
namespace JungleLvl {
AbsalutePlate::AbsalutePlate(): CRAWL::IWorldItem(AUTO_CLASS_NAME) {
setMash("#Cube");
setSize({1000, 1000, 1});
setColor("#000000");
}
void AbsalutePlate::onIntersects(const IWorldItem *) {}
void AbsalutePlate::render(unsigned int ) {
setposition(getPlayer()->position() + QVector3D{0,0,-100});
}
}

@ -0,0 +1,24 @@
#ifndef ABSALUTEPLATE_H
#define ABSALUTEPLATE_H
#include "Crawl/iworlditem.h"
namespace JungleLvl {
class AbsalutePlate : public CRAWL::IWorldItem
{
Q_OBJECT
public:
AbsalutePlate();
// IWorldItem interface
protected:
void onIntersects(const IWorldItem *item) override;
// IRender interface
public:
void render(unsigned int tbfMsec) override;
};
}
#endif // ABSALUTEPLATE_H

@ -0,0 +1,15 @@
//#
//# 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 "blueegg.h"
namespace JungleLvl {
BlueEgg::BlueEgg(): Egg(AUTO_CLASS_NAME) {
setBaseColorMap("qrc:/mesh/meshes/Other/EggBlue_Base.jpg");
}
}

@ -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.
//#
#ifndef BLUEEGG_H
#define BLUEEGG_H
#include "egg.h"
namespace JungleLvl {
class BlueEgg: public Egg
{
Q_OBJECT
public:
BlueEgg();
};
}
#endif // BLUEEGG_H

@ -0,0 +1,28 @@
//#
//# 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 "egg.h"
namespace JungleLvl {
Egg::Egg(const QString name): CRAWL::IWorldItem(name)
{
QStringList mashes {
"qrc:/mesh/meshes/Other/Egg.mesh",
};
setMash(mashes[rand() % mashes.size()]);
setSize({1,1,1});
setRatation(QQuaternion::fromEulerAngles({0,0, static_cast<float>(rand() % 360)}));
}
void Egg::onIntersects(const IWorldItem *) {
}
}

@ -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 EGG_H
#define EGG_H
#include <Crawl/iworlditem.h>
#include <jungle_global.h>
namespace JungleLvl {
class CRAWL_JUNGLE_LEVEL_EXPORT Egg: public CRAWL::IWorldItem
{
Q_OBJECT
public:
Egg(const QString name);
void onIntersects(const IWorldItem *);
};
}
#endif // EGG_H

@ -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 "grees.h"
namespace JungleLvl {
Grees::Grees(): CRAWL::IWorldItem(AUTO_CLASS_NAME) {
setMash("qrc:/mesh/meshes/Plant/Grass.mesh");
setBaseColorMap("qrc:/mesh/meshes/Plant/Grass_Base.jpg");
setSize({1,1,1});
setRatation(QQuaternion::fromEulerAngles({0,0, static_cast<float>(rand() % 360)}));
}
void Grees::onIntersects(const IWorldItem *) {
}
}

@ -0,0 +1,32 @@
//#
//# 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 GREES_H
#define GREES_H
#include <Crawl/iworlditem.h>
#include <jungle_global.h>
namespace JungleLvl {
/**
* @brief The Grees class
*/
class CRAWL_JUNGLE_LEVEL_EXPORT Grees: public CRAWL::IWorldItem
{
Q_OBJECT
public:
Grees();
// IWorldItem interface
protected:
void onIntersects(const IWorldItem *item) override;
};
}
#endif // GREES_H

@ -12,7 +12,7 @@ namespace JungleLvl {
GroundPlate::GroundPlate(): CRAWL::GroundTile("JungleGroundTile",
"qrc:/qml/Models/Ground.qml") {
setMash("#Cube");
setSize({6, 6, 0.01});
setSize({6, 6, 0.001});
setBaseColorMap("qrc:/mesh/meshes/Other/Terrain_Base.jpg");
setNormalMap("qrc:/mesh/meshes/Other/Terrain_Normal.jpg");
// setRoughnessMap("qrc:/mesh/meshes/Other/Roughness_without.jpg");

@ -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.
//#
#include "ivy.h"
namespace JungleLvl {
Ivy::Ivy(): CRAWL::IWorldItem(AUTO_CLASS_NAME) {
QStringList mashes {
"qrc:/mesh/meshes/Plant/ivy.mesh",
};
setMash(mashes[rand() % mashes.size()]);
setBaseColorMap("qrc:/mesh/meshes/Plant/Ivy_Base.jpg");
setSize({1,1,1});
setRatation(QQuaternion::fromEulerAngles({0,0, static_cast<float>(rand() % 360)}));
}
void Ivy::onIntersects(const IWorldItem *) {
}
}

@ -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 IVY_H
#define IVY_H
#include <Crawl/iworlditem.h>
#include <jungle_global.h>
namespace JungleLvl {
class CRAWL_JUNGLE_LEVEL_EXPORT Ivy: public CRAWL::IWorldItem
{
Q_OBJECT
public:
Ivy();
void onIntersects(const IWorldItem *);
};
}
#endif // IVY_H

@ -0,0 +1,6 @@
#include "junglesun.h"
JungleSun::JungleSun()
{
}

@ -0,0 +1,11 @@
#ifndef JUNGLESUN_H
#define JUNGLESUN_H
class JungleSun
{
public:
JungleSun();
};
#endif // JUNGLESUN_H

@ -0,0 +1,21 @@
//#
//# 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 "longgress.h"
namespace JungleLvl {
LongGress::LongGress(): CRAWL::IWorldItem(AUTO_CLASS_NAME) {
setMash("qrc:/mesh/meshes/Plant/Long_grass.mesh");
setBaseColorMap("qrc:/mesh/meshes/Plant/LongGrass_Base.jpg");
setSize({1,1,1});
setRatation(QQuaternion::fromEulerAngles({0,0, static_cast<float>(rand() % 360)}));
}
void LongGress::onIntersects(const IWorldItem *) {
}
}

@ -0,0 +1,32 @@
//#
//# 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 LONGGRESS_H
#define LONGGRESS_H
#include <Crawl/iworlditem.h>
#include <jungle_global.h>
namespace JungleLvl {
class CRAWL_JUNGLE_LEVEL_EXPORT LongGress: public CRAWL::IWorldItem
{
Q_OBJECT
public:
LongGress();
// IWorldItem interface
protected:
void onIntersects(const IWorldItem *item) override;
};
}
#endif // LONGGRESS_H

@ -0,0 +1,29 @@
//#
//# 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 "plant.h"
namespace JungleLvl {
Plant::Plant(): CRAWL::IWorldItem(AUTO_CLASS_NAME) {
QStringList mashes {
"qrc:/mesh/meshes/Plant/Plant_1.mesh",
"qrc:/mesh/meshes/Plant/Plant_2.mesh"
};
setMash(mashes[rand() % mashes.size()]);
setBaseColorMap("qrc:/mesh/meshes/Plant/Plant_Base.jpg");
setSize({1,1,1});
setRatation(QQuaternion::fromEulerAngles({0,0, static_cast<float>(rand() % 360)}));
}
void Plant::onIntersects(const IWorldItem *) {
}
}

@ -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 PLANT_H
#define PLANT_H
#include <Crawl/iworlditem.h>
#include <jungle_global.h>
namespace JungleLvl {
class CRAWL_JUNGLE_LEVEL_EXPORT Plant: public CRAWL::IWorldItem
{
Q_OBJECT
public:
Plant();
void onIntersects(const IWorldItem *);
};
}
#endif // PLANT_H

@ -0,0 +1,16 @@
//#
//# 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 "purpleegg.h"
namespace JungleLvl {
PurpleEgg::PurpleEgg(): Egg(AUTO_CLASS_NAME) {
setBaseColorMap("qrc:/mesh/meshes/Other/EggPurple_Base.jpg");
}
}

@ -0,0 +1,21 @@
//#
//# 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 EGGPURPLE_H
#define EGGPURPLE_H
#include "egg.h"
namespace JungleLvl {
class PurpleEgg: public Egg
{
Q_OBJECT
public:
PurpleEgg();
};
}
#endif // EGGPURPLE_H

@ -0,0 +1,15 @@
//#
//# 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 "redegg.h"
namespace JungleLvl {
RedEgg::RedEgg(): Egg(AUTO_CLASS_NAME) {
setBaseColorMap("qrc:/mesh/meshes/Other/EggRed_Base.jpg");
}
}

@ -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 REDEGG_H
#define REDEGG_H
#include "egg.h"
namespace JungleLvl {
class RedEgg: public Egg
{
Q_OBJECT
public:
RedEgg();
};
}
#endif // REDEGG_H

@ -0,0 +1,35 @@
//#
//# 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 "stone.h"
namespace JungleLvl {
Stone::Stone(): CRAWL::IWorldItem(AUTO_CLASS_NAME)
{
QStringList mashes {
"qrc:/mesh/meshes/Stone/Stone_1.mesh",
"qrc:/mesh/meshes/Stone/Stone_2.mesh",
"qrc:/mesh/meshes/Stone/Stone_3.mesh",
};
setMash(mashes[rand() % mashes.size()]);
setBaseColorMap("qrc:/mesh/meshes/Stone/Stone_Base.jpg");
setNormalMap("qrc:/mesh/meshes/Stone/Stone_Normal.jpg");
setSize({1,1,1});
setRatation(QQuaternion::fromEulerAngles({0,0, static_cast<float>(rand() % 360)}));
}
void Stone::onIntersects(const IWorldItem *) {
}
}

@ -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 STONE_H
#define STONE_H
#include <Crawl/iworlditem.h>
#include <jungle_global.h>
namespace JungleLvl {
class CRAWL_JUNGLE_LEVEL_EXPORT Stone: public CRAWL::IWorldItem
{
Q_OBJECT
public:
Stone();
void onIntersects(const IWorldItem *);
};
}
#endif // STONE_H

@ -0,0 +1,37 @@
//#
//# 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 "tree.h"
namespace JungleLvl {
Tree::Tree(): CRAWL::IWorldItem(AUTO_CLASS_NAME) {
QStringList mashes {
"qrc:/mesh/meshes/Plant/Tree_1.mesh",
"qrc:/mesh/meshes/Plant/Tree_2.mesh",
"qrc:/mesh/meshes/Plant/Tree_3.mesh",
"qrc:/mesh/meshes/Plant/Tree_4.mesh",
"qrc:/mesh/meshes/Plant/Tree_5.mesh",
"qrc:/mesh/meshes/Plant/Tree_6.mesh",
};
setMash(mashes[rand() % mashes.size()]);
setBaseColorMap("qrc:/mesh/meshes/Plant/Tree_Base.jpg");
setSize({1,1,1});
setRatation(QQuaternion::fromEulerAngles({static_cast<float>(rand() % 60 - 30),
static_cast<float>(rand() % 60 - 30),
static_cast<float>(rand() % 360)}));
if (rand() % 2)
setZ(-static_cast<float>(rand() % 10));
}
void Tree::onIntersects(const IWorldItem *) {
}
}

@ -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 TREE_H
#define TREE_H
#include <Crawl/iworlditem.h>
#include <jungle_global.h>
namespace JungleLvl {
/**
* @brief The Tree class
*/
class CRAWL_JUNGLE_LEVEL_EXPORT Tree : public CRAWL::IWorldItem
{
Q_OBJECT
public:
Tree();
// IWorldItem interface
protected:
void onIntersects(const IWorldItem *) override;
};
}
#endif // TREE_H

@ -0,0 +1,37 @@
//#
//# 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 "wood.h"
namespace JungleLvl {
Wood::Wood(): CRAWL::IWorldItem(AUTO_CLASS_NAME) {
QStringList mashes {
"qrc:/mesh/meshes/Wood/Wood_1.mesh",
"qrc:/mesh/meshes/Wood/Wood_2.mesh",
"qrc:/mesh/meshes/Wood/Wood_3.mesh",
"qrc:/mesh/meshes/Wood/Wood_4.mesh",
"qrc:/mesh/meshes/Wood/Wood_5.mesh",
"qrc:/mesh/meshes/Wood/Wood_6.mesh",
"qrc:/mesh/meshes/Wood/Wood_7.mesh",
"qrc:/mesh/meshes/Wood/Wood_8.mesh",
};
setMash(mashes[rand() % mashes.size()]);
setBaseColorMap("qrc:/mesh/meshes/Wood/Wood_Base.jpg");
setNormalMap("qrc:/mesh/meshes/Wood/Wood_Normal.jpg");
setRoughnessMap("qrc:/mesh/meshes/Wood/Wood_Roughness.jpg");
setSize({1,1,1});
setRatation(QQuaternion::fromEulerAngles({0,0, static_cast<float>(rand() % 360)}));
}
void Wood::onIntersects(const IWorldItem *) {
}
}

@ -0,0 +1,20 @@
#ifndef WOOD_H
#define WOOD_H
#include <Crawl/iworlditem.h>
#include <jungle_global.h>
namespace JungleLvl {
class CRAWL_JUNGLE_LEVEL_EXPORT Wood: public CRAWL::IWorldItem
{
Q_OBJECT
public:
Wood();
void onIntersects(const IWorldItem *);
};
}
#endif // WOOD_H

@ -5,23 +5,78 @@
//# of this license document, but changing it is not allowed.
//#
#include "grees.h"
#include "ground.h"
#include "longgress.h"
#include "snake.h"
#include "tree.h"
#include "world.h"
#include "Crawl/iworlditem.h"
#include "ivy.h"
#include "plant.h"
#include "stone.h"
#include "wood.h"
#include "redegg.h"
#include "purpleegg.h"
#include "blueegg.h"
#include "absaluteplate.h"
#include "Crawl/sun.h"
#include "Crawl/moon.h"
#include <Crawl/day.h>
#include <Crawl/defaultlight.h>
#include <Crawl/snake.h>
namespace JungleLvl {
World::World() {
setCameraReleativePosition({0,0,100});
setCameraRatation(QQuaternion::fromEulerAngles({0,0,-90}));
setCameraReleativePosition({50,0,100});
setCameraRatation(QQuaternion::fromEulerAngles({0,0,0}));
}
CRAWL::WorldRule *World::initWorldRules() {
using Day = CRAWL::Day<CRAWL::Sun, CRAWL::Moon>;
return new CRAWL::WorldRule {
{0, {
{registerObject<Ground>(), 1}}}
{registerObject<AbsalutePlate>(), 1},
{registerObject<Day>(), 1},
{registerObject<Ground>(), 1},
{registerObject<Grees>(), 500},
{registerObject<LongGress>(), 100},
}
},
{1000, {
{registerObject<AbsalutePlate>(), 1},
{registerObject<Day>(), 1},
{registerObject<Ground>(), 1},
{registerObject<Grees>(), 500},
{registerObject<LongGress>(), 100},
{registerObject<Plant>(), 20},
{registerObject<Wood>(), 25},
}
},
{2000, {
{registerObject<AbsalutePlate>(), 1},
{registerObject<Day>(), 1},
{registerObject<Ground>(), 1},
{registerObject<Grees>(), 500},
{registerObject<LongGress>(), 100},
{registerObject<Tree>(), 50},
{registerObject<Plant>(), 20},
{registerObject<Ivy>(), 25},
{registerObject<Stone>(), 25},
{registerObject<Wood>(), 25},
{registerObject<RedEgg>(), 5},
{registerObject<PurpleEgg>(), 5},
{registerObject<BlueEgg>(), 5},
}
}
};
}

@ -1 +1 @@
Subproject commit 97b2580498216c178f5e4fac63e5f259ce461caa
Subproject commit ed3be09bde4cb1457106a3863c396d2a07cd3d3d