mirror of
https://github.com/QuasarApp/Snake.git
synced 2025-04-26 01:34:40 +00:00
added tests for the GroupObject class
This commit is contained in:
parent
0d614cf7cd
commit
fbb7725c2d
@ -12,7 +12,7 @@ namespace CRAWL {
|
||||
DefaultLight::DefaultLight(): IWorldLight(AUTO_CLASS_NAME) {
|
||||
setColor("#fff8e7");
|
||||
setposition({10000, 0, 10000});
|
||||
setRatation(QQuaternion::fromEulerAngles({-90,0,0}));
|
||||
setRotation(QQuaternion::fromEulerAngles({-90,0,0}));
|
||||
setLightForce(110);
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,7 @@ void GroupObject::render(unsigned int tbfMsec) {
|
||||
|
||||
if (LocalPropertyes *props = getLocalPropertyes(object->guiId())) {
|
||||
if (!props->_rotation.isNull())
|
||||
object->setRatation(_this->ratation() * props->_rotation);
|
||||
object->setRotation(_this->rotation() * props->_rotation);
|
||||
|
||||
object->setposition(_this->position() + props->_position);
|
||||
}
|
||||
|
@ -24,15 +24,15 @@ struct LocalPropertyes {
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief The GroupObject class is extansion with group object behavior.
|
||||
* ### Requeried functions: IWorldItem
|
||||
* @brief The GroupObject class is extension with group object behavior.
|
||||
* ### Requried child classes: IWorldItem
|
||||
*
|
||||
* This class have implementation of the render method that move all child object on selected local positions in parent object.
|
||||
* This class have implementation of the render method that move all child objects on selected local positions on parent object.
|
||||
*
|
||||
* ## Example of use
|
||||
*
|
||||
* ### For what this object uses
|
||||
* This object will be very convinent wher you want to create a difecly claster object with multiple subobjects that should contains in the parrent root object.
|
||||
*This object will be very convenient where you want to create a directly cluster object with multiple sub objects that should contains in the parent root object.
|
||||
* For example : weapon of the player.
|
||||
*
|
||||
* ### Example of use
|
||||
|
@ -17,7 +17,7 @@ GuiObject::GuiObject(const QString &name, const QString &viewTempalte, QObject *
|
||||
_viewTemplate = viewTempalte;
|
||||
_className = name;
|
||||
generateId();
|
||||
setRatation(QQuaternion::fromEulerAngles({0,0,0}));
|
||||
setRotation(QQuaternion::fromEulerAngles({0,0,0}));
|
||||
}
|
||||
|
||||
const QString& GuiObject::color() const {
|
||||
@ -173,15 +173,15 @@ void GuiObject::setSize(const QVector3D &newSize) {
|
||||
emit sizeChanged();
|
||||
}
|
||||
|
||||
const QQuaternion &GuiObject::ratation() const {
|
||||
return _ratation;
|
||||
const QQuaternion &GuiObject::rotation() const {
|
||||
return _rotation;
|
||||
}
|
||||
|
||||
void GuiObject::setRatation(const QQuaternion &newRatation) {
|
||||
if (_ratation == newRatation)
|
||||
void GuiObject::setRotation(const QQuaternion &newRotation) {
|
||||
if (_rotation == newRotation)
|
||||
return;
|
||||
_ratation = newRatation;
|
||||
emit ratationChanged();
|
||||
_rotation = newRotation;
|
||||
emit rotationChanged();
|
||||
}
|
||||
|
||||
const QString &GuiObject::mash() const {
|
||||
|
@ -30,7 +30,7 @@ namespace CRAWL {
|
||||
*
|
||||
* The gui objct contains base properties for drow objects on scane
|
||||
* * position
|
||||
* * ratation
|
||||
* * rotation
|
||||
* * mash
|
||||
* * and map textures
|
||||
*
|
||||
@ -66,7 +66,7 @@ class CRAWL_EXPORT GuiObject: public QObject, virtual public IRender {
|
||||
|
||||
Q_PROPERTY(QVector3D position READ position WRITE setposition NOTIFY positionChanged)
|
||||
Q_PROPERTY(QVector3D size READ size WRITE setSize NOTIFY sizeChanged)
|
||||
Q_PROPERTY(QQuaternion ratation READ ratation WRITE setRatation NOTIFY ratationChanged)
|
||||
Q_PROPERTY(QQuaternion rotation READ rotation WRITE setRotation NOTIFY rotationChanged)
|
||||
|
||||
Q_PROPERTY(QString mash READ mash WRITE setMash NOTIFY mashChanged)
|
||||
|
||||
@ -133,8 +133,8 @@ public:
|
||||
const QVector3D &size() const;
|
||||
void setSize(const QVector3D &newSize);
|
||||
|
||||
const QQuaternion &ratation() const;
|
||||
void setRatation(const QQuaternion &newRatation);
|
||||
const QQuaternion &rotation() const;
|
||||
void setRotation(const QQuaternion &newRotation);
|
||||
|
||||
const QString &mash() const;
|
||||
void setMash(const QString &newMash);
|
||||
@ -171,7 +171,7 @@ signals:
|
||||
|
||||
void positionChanged();
|
||||
void sizeChanged();
|
||||
void ratationChanged();
|
||||
void rotationChanged();
|
||||
|
||||
void mashChanged();
|
||||
|
||||
@ -217,7 +217,7 @@ private:
|
||||
|
||||
QVector3D _position;
|
||||
QVector3D _size;
|
||||
QQuaternion _ratation;
|
||||
QQuaternion _rotation;
|
||||
QString _mash;
|
||||
QString _className;
|
||||
bool _visible = true;
|
||||
|
@ -353,15 +353,15 @@ void IWorld::updateWorld() {
|
||||
}
|
||||
}
|
||||
|
||||
const QQuaternion &IWorld::cameraRatation() const {
|
||||
return _cameraRatation;
|
||||
const QQuaternion &IWorld::cameraRotation() const {
|
||||
return _cameraRotation;
|
||||
}
|
||||
|
||||
void IWorld::setCameraRatation(const QQuaternion &newCameraRatation) {
|
||||
if (_cameraRatation == newCameraRatation)
|
||||
void IWorld::setCameraRotation(const QQuaternion &newCameraRotation) {
|
||||
if (_cameraRotation == newCameraRotation)
|
||||
return;
|
||||
_cameraRatation = newCameraRatation;
|
||||
emit cameraRatationChanged();
|
||||
_cameraRotation = newCameraRotation;
|
||||
emit cameraRotationChanged();
|
||||
}
|
||||
|
||||
IAI *IWorld::backgroundAI() const {
|
||||
|
@ -49,7 +49,7 @@ class CRAWL_EXPORT IWorld : public QObject, public IRender
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QVector3D cameraReleativePosition READ cameraReleativePosition NOTIFY cameraReleativePositionChanged)
|
||||
Q_PROPERTY(QQuaternion cameraRatation READ cameraRatation NOTIFY cameraRatationChanged)
|
||||
Q_PROPERTY(QQuaternion cameraRotation READ cameraRotation NOTIFY cameraRotationChanged)
|
||||
Q_PROPERTY(QObject * player READ player WRITE setPlayer NOTIFY playerChanged)
|
||||
Q_PROPERTY(QString hdr READ hdr NOTIFY hdrChanged)
|
||||
|
||||
@ -210,10 +210,10 @@ public:
|
||||
IAI *backgroundAI() const;
|
||||
|
||||
/**
|
||||
* @brief cameraRatation This method return curent camera ratation.
|
||||
* @return Quaternion of camera ratation
|
||||
* @brief cameraRotation This method return curent camera rotation.
|
||||
* @return Quaternion of camera rotation
|
||||
*/
|
||||
const QQuaternion &cameraRatation() const;
|
||||
const QQuaternion &cameraRotation() const;
|
||||
|
||||
/**
|
||||
* @brief player This method return player object
|
||||
@ -263,9 +263,9 @@ signals:
|
||||
void worldStatusChanged();
|
||||
|
||||
/**
|
||||
* @brief cameraRatationChanged This method emited when ratation of the camera cahnged
|
||||
* @brief cameraRotationChanged This method emited when rotation of the camera cahnged
|
||||
*/
|
||||
void cameraRatationChanged();
|
||||
void cameraRotationChanged();
|
||||
|
||||
/**
|
||||
* @brief playerChanged This signal eited when player are changed.
|
||||
@ -320,10 +320,10 @@ protected:
|
||||
void setCameraReleativePosition(const QVector3D &newCameraReleativePosition);
|
||||
|
||||
/**
|
||||
* @brief setCameraRatation This method sets new ratation of the camera.
|
||||
* @param newCameraRatation new ratation of the camera.
|
||||
* @brief setCameraRotation This method sets new rotation of the camera.
|
||||
* @param newCameraRotation new rotation of the camera.
|
||||
*/
|
||||
void setCameraRatation(const QQuaternion &newCameraRatation);
|
||||
void setCameraRotation(const QQuaternion &newCameraRotation);
|
||||
|
||||
/**
|
||||
* @brief targetFps This method return current targetFps;
|
||||
@ -488,7 +488,7 @@ private:
|
||||
mutable QMutex _ItemsMutex;
|
||||
|
||||
QVector3D _cameraReleativePosition;
|
||||
QQuaternion _cameraRatation;
|
||||
QQuaternion _cameraRotation;
|
||||
|
||||
QString _hdrMap;
|
||||
WorldRule *_worldRules = nullptr;
|
||||
|
@ -27,15 +27,15 @@ void SnakeItem::render(unsigned int tbfMsec) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto ratationVector = (_prevObject->position() - position());
|
||||
auto rotationVector = (_prevObject->position() - position());
|
||||
|
||||
if (auto claster = static_cast<Snake*>(parentClaster())) {
|
||||
float ratationLength = ratationVector.length();
|
||||
float rotationLength = rotationVector.length();
|
||||
|
||||
if (ratationLength > lengthBetwinItems() * 10) {
|
||||
if (rotationLength > lengthBetwinItems() * 10) {
|
||||
setposition(_prevObject->position());
|
||||
} else if (ratationLength > lengthBetwinItems()) {
|
||||
setMovableVector(ratationVector.normalized() * claster->currentMovableVector().length());
|
||||
} else if (rotationLength > lengthBetwinItems()) {
|
||||
setMovableVector(rotationVector.normalized() * claster->currentMovableVector().length());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -34,7 +34,7 @@ Node {
|
||||
}
|
||||
}
|
||||
|
||||
rotation: (model)? model.ratation: Qt.quaternion(0, 0, 0, 0)
|
||||
rotation: (model)? model.rotation: 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
|
||||
|
@ -65,7 +65,7 @@ Model {
|
||||
(fMapColor)? objMaterial: defaultMaterial
|
||||
]
|
||||
|
||||
rotation: (model)? model.ratation: Qt.quaternion(0, 0, 0, 0)
|
||||
rotation: (model)? model.rotation: Qt.quaternion(0, 0, 0, 0)
|
||||
scale: (model)? model.size: Qt.vector3d(0, 0, 0);
|
||||
source: (model)? model.mash: "#Cube";
|
||||
position: (model) ? model.position: Qt.vector3d(0,0,0);
|
||||
|
@ -26,7 +26,7 @@ Node {
|
||||
|
||||
}
|
||||
|
||||
rotation: (model)? model.ratation: Qt.quaternion(0, 0, 0, 0)
|
||||
rotation: (model)? model.rotation: Qt.quaternion(0, 0, 0, 0)
|
||||
scale: (model)? model.size: Qt.vector3d(0, 0, 0);
|
||||
position: (model) ? model.position: Qt.vector3d(0,0,0);
|
||||
|
||||
|
@ -23,7 +23,7 @@ View3D {
|
||||
:
|
||||
Qt.vector3d(0,0,100)
|
||||
|
||||
rotation: (privateRoot.world)? privateRoot.world.cameraRatation: Qt.quaternion(0,0,0,0)
|
||||
rotation: (privateRoot.world)? privateRoot.world.cameraRotation: Qt.quaternion(0,0,0,0)
|
||||
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,7 @@ void BaseMotion::setStaticRotation(const QQuaternion &newStaticRotation) {
|
||||
void BaseMotion::render(unsigned int tbfMsec) {
|
||||
if (auto _this = checkminimumRequariedType<GuiObject>()) {
|
||||
renderPosition(_this, tbfMsec);
|
||||
renderRatation(_this, tbfMsec);
|
||||
renderRotation(_this, tbfMsec);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ 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
|
||||
* * renderRotation
|
||||
*/
|
||||
class CRAWL_EXPORT BaseMotion : public virtual IRender
|
||||
{
|
||||
@ -49,14 +49,14 @@ public:
|
||||
protected:
|
||||
|
||||
/**
|
||||
* @brief renderRatation This method recalc raration for an @a object. The Default do nothing.
|
||||
* @brief renderRotation 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;
|
||||
virtual void renderRotation(GuiObject* object, unsigned int tbfMsec) = 0;
|
||||
|
||||
/**
|
||||
* @brief renderRatation This method recalc position for an @a object.
|
||||
* @brief renderRotation 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.
|
||||
*/
|
||||
|
@ -20,7 +20,7 @@ void CircularMotion::render(unsigned int tbfMsec) {
|
||||
|
||||
if (auto _this = checkminimumRequariedType<GuiObject>()) {
|
||||
renderPosition(_this, tbfMsec);
|
||||
renderRatation(_this, tbfMsec);
|
||||
renderRotation(_this, tbfMsec);
|
||||
}
|
||||
}
|
||||
|
||||
@ -56,9 +56,9 @@ void CircularMotion::setAnglePosition(double newAngle) {
|
||||
_angle = newAngle;
|
||||
}
|
||||
|
||||
void CircularMotion::renderRatation(GuiObject *object,
|
||||
void CircularMotion::renderRotation(GuiObject *object,
|
||||
unsigned int ) {
|
||||
object->setRatation(QQuaternion::rotationTo({1.0f, 0.0, 0.0}, *_center) * staticRotation());
|
||||
object->setRotation(QQuaternion::rotationTo({1.0f, 0.0, 0.0}, *_center) * staticRotation());
|
||||
}
|
||||
|
||||
void CircularMotion::renderPosition(GuiObject *object,
|
||||
|
@ -80,14 +80,14 @@ public:
|
||||
protected:
|
||||
|
||||
/**
|
||||
* @brief renderRatation This method recalc raration for an @a object. The Default implementation rotate object to center.
|
||||
* @brief renderRotation 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;
|
||||
void renderRotation(GuiObject* object, unsigned int) override;
|
||||
|
||||
/**
|
||||
* @brief renderRatation This method recalc position for an @a object. The Default implementation move the current object around center.
|
||||
* @brief renderRotation 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.
|
||||
*/
|
||||
|
@ -21,7 +21,7 @@ void MovableObject::render(unsigned int tbfMsec) {
|
||||
|
||||
if (auto _this = checkminimumRequariedType<GuiObject>()) {
|
||||
renderPosition(_this, tbfMsec);
|
||||
renderRatation(_this, tbfMsec);
|
||||
renderRotation(_this, tbfMsec);
|
||||
}
|
||||
}
|
||||
|
||||
@ -49,9 +49,9 @@ void MovableObject::setBreakingForce(float newBreakingForce) {
|
||||
_breakingForce = newBreakingForce;
|
||||
}
|
||||
|
||||
void MovableObject::renderRatation(GuiObject *object, unsigned int) {
|
||||
void MovableObject::renderRotation(GuiObject *object, unsigned int) {
|
||||
if (_currentMovableVector.length() > 0) {
|
||||
object->setRatation(QQuaternion::rotationTo({1.0f, 0.0, 0.0}, _currentMovableVector) * staticRotation());
|
||||
object->setRotation(QQuaternion::rotationTo({1.0f, 0.0, 0.0}, _currentMovableVector) * staticRotation());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -89,14 +89,14 @@ public:
|
||||
protected:
|
||||
|
||||
/**
|
||||
* @brief renderRatation This method recalc raration for an @a object. The Default implementation converts movableVector to ratation of an @a object.
|
||||
* @brief renderRotation This method recalc raration for an @a object. The Default implementation converts movableVector to rotation of 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.
|
||||
*/
|
||||
void renderRatation(GuiObject* object, unsigned int tbfMsec) override;
|
||||
void renderRotation(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
|
||||
* @brief renderRotation 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.
|
||||
*/
|
||||
|
@ -12,7 +12,7 @@
|
||||
namespace AbstractLvl {
|
||||
|
||||
/**
|
||||
* @brief The AbsLvlControl class This controll support custom camera-ratation functions.
|
||||
* @brief The AbsLvlControl class This controll support custom camera-rotation functions.
|
||||
*/
|
||||
class AbsLvlControl: public CRAWL::DefaultControl
|
||||
{
|
||||
|
@ -20,7 +20,7 @@ namespace AbstractLvl {
|
||||
|
||||
AbsLvlWorld::AbsLvlWorld() {
|
||||
setCameraReleativePosition({20,0,100});
|
||||
setCameraRatation(QQuaternion::fromEulerAngles({0,0,0}));
|
||||
setCameraRotation(QQuaternion::fromEulerAngles({0,0,0}));
|
||||
}
|
||||
|
||||
CRAWL::IPlayer *AbsLvlWorld::initPlayer() const {
|
||||
|
@ -16,7 +16,7 @@ Box::Box(): IWorldItem("Box") {
|
||||
setSize({2,2,2});
|
||||
setColor(QColor::fromRgb(rand()).name());
|
||||
|
||||
setRatation(QQuaternion::fromEulerAngles(
|
||||
setRotation(QQuaternion::fromEulerAngles(
|
||||
rand() % 360 ,
|
||||
rand() % 360,
|
||||
rand() % 360));
|
||||
|
@ -12,7 +12,7 @@
|
||||
namespace TestLvl {
|
||||
|
||||
/**
|
||||
* @brief The TestControl class This controll support custom camera-ratation functions.
|
||||
* @brief The TestControl class This controll support custom camera-rotation functions.
|
||||
*/
|
||||
class TestControl: public CRAWL::DefaultControl
|
||||
{
|
||||
|
@ -22,7 +22,7 @@ namespace TestLvl {
|
||||
|
||||
World::World() {
|
||||
setCameraReleativePosition({50,0,100});
|
||||
setCameraRatation(QQuaternion::fromEulerAngles({0,0,0}));
|
||||
setCameraRotation(QQuaternion::fromEulerAngles({0,0,0}));
|
||||
}
|
||||
|
||||
CRAWL::WorldRule *World::initWorldRules() {
|
||||
@ -77,14 +77,14 @@ CRAWL::IAI *World::initBackGroundAI() const {
|
||||
}
|
||||
|
||||
void World::handleXViewChanged(double dx) {
|
||||
auto eilorRatation = cameraRatation().toEulerAngles();
|
||||
eilorRatation.setX(eilorRatation.x() + dx);
|
||||
setCameraRatation(QQuaternion::fromEulerAngles(eilorRatation));
|
||||
auto eilorRotation = cameraRotation().toEulerAngles();
|
||||
eilorRotation.setX(eilorRotation.x() + dx);
|
||||
setCameraRotation(QQuaternion::fromEulerAngles(eilorRotation));
|
||||
}
|
||||
|
||||
void World::handleYViewChanged(double dy) {
|
||||
auto eilorRatation = cameraRatation().toEulerAngles();
|
||||
eilorRatation.setY(eilorRatation.y() + dy );
|
||||
setCameraRatation(QQuaternion::fromEulerAngles(eilorRatation));
|
||||
auto eilorRotation = cameraRotation().toEulerAngles();
|
||||
eilorRotation.setY(eilorRotation.y() + dy );
|
||||
setCameraRotation(QQuaternion::fromEulerAngles(eilorRotation));
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ Egg::Egg(const QString name): CRAWL::IWorldItem(name)
|
||||
setMash(mashes[rand() % mashes.size()]);
|
||||
|
||||
setSize({1,1,1});
|
||||
setRatation(QQuaternion::fromEulerAngles({0,0, static_cast<float>(rand() % 360)}));
|
||||
setRotation(QQuaternion::fromEulerAngles({0,0, static_cast<float>(rand() % 360)}));
|
||||
}
|
||||
|
||||
void Egg::onIntersects(const IWorldItem *) {
|
||||
|
@ -13,7 +13,7 @@ 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)}));
|
||||
setRotation(QQuaternion::fromEulerAngles({0,0, static_cast<float>(rand() % 360)}));
|
||||
|
||||
}
|
||||
|
||||
|
@ -18,7 +18,7 @@ Ivy::Ivy(): CRAWL::IWorldItem(AUTO_CLASS_NAME) {
|
||||
|
||||
setBaseColorMap("qrc:/mesh/meshes/Plant/Ivy_Base.jpg");
|
||||
setSize({1,1,1});
|
||||
setRatation(QQuaternion::fromEulerAngles({0,0, static_cast<float>(rand() % 360)}));
|
||||
setRotation(QQuaternion::fromEulerAngles({0,0, static_cast<float>(rand() % 360)}));
|
||||
}
|
||||
|
||||
void Ivy::onIntersects(const IWorldItem *) {
|
||||
|
@ -12,7 +12,7 @@ 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)}));
|
||||
setRotation(QQuaternion::fromEulerAngles({0,0, static_cast<float>(rand() % 360)}));
|
||||
}
|
||||
|
||||
void LongGress::onIntersects(const IWorldItem *) {
|
||||
|
@ -20,7 +20,7 @@ Plant::Plant(): CRAWL::IWorldItem(AUTO_CLASS_NAME) {
|
||||
|
||||
setBaseColorMap("qrc:/mesh/meshes/Plant/Plant_Base.jpg");
|
||||
setSize({1,1,1});
|
||||
setRatation(QQuaternion::fromEulerAngles({0,0, static_cast<float>(rand() % 360)}));
|
||||
setRotation(QQuaternion::fromEulerAngles({0,0, static_cast<float>(rand() % 360)}));
|
||||
}
|
||||
|
||||
void Plant::onIntersects(const IWorldItem *) {
|
||||
|
@ -25,7 +25,7 @@ Stone::Stone(): CRAWL::IWorldItem(AUTO_CLASS_NAME)
|
||||
setNormalMap("qrc:/mesh/meshes/Stone/Stone_Normal.jpg");
|
||||
|
||||
setSize({1,1,1});
|
||||
setRatation(QQuaternion::fromEulerAngles({0,0, static_cast<float>(rand() % 360)}));
|
||||
setRotation(QQuaternion::fromEulerAngles({0,0, static_cast<float>(rand() % 360)}));
|
||||
}
|
||||
|
||||
void Stone::onIntersects(const IWorldItem *) {
|
||||
|
@ -23,7 +23,7 @@ Tree::Tree(): CRAWL::IWorldItem(AUTO_CLASS_NAME) {
|
||||
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),
|
||||
setRotation(QQuaternion::fromEulerAngles({static_cast<float>(rand() % 60 - 30),
|
||||
static_cast<float>(rand() % 60 - 30),
|
||||
static_cast<float>(rand() % 360)}));
|
||||
|
||||
|
@ -28,7 +28,7 @@ Wood::Wood(): CRAWL::IWorldItem(AUTO_CLASS_NAME) {
|
||||
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)}));
|
||||
setRotation(QQuaternion::fromEulerAngles({0,0, static_cast<float>(rand() % 360)}));
|
||||
}
|
||||
|
||||
void Wood::onIntersects(const IWorldItem *) {
|
||||
|
@ -30,7 +30,7 @@ namespace JungleLvl {
|
||||
|
||||
World::World() {
|
||||
setCameraReleativePosition({50,0,100});
|
||||
setCameraRatation(QQuaternion::fromEulerAngles({0,0,0}));
|
||||
setCameraRotation(QQuaternion::fromEulerAngles({0,0,0}));
|
||||
}
|
||||
|
||||
CRAWL::WorldRule *World::initWorldRules() {
|
||||
@ -117,15 +117,15 @@ CRAWL::IAI *World::initBackGroundAI() const {
|
||||
}
|
||||
|
||||
void World::handleXViewChanged(double dx) {
|
||||
auto eilorRatation = cameraRatation().toEulerAngles();
|
||||
eilorRatation.setX(eilorRatation.x() + dx);
|
||||
setCameraRatation(QQuaternion::fromEulerAngles(eilorRatation));
|
||||
auto eilorRotation = cameraRotation().toEulerAngles();
|
||||
eilorRotation.setX(eilorRotation.x() + dx);
|
||||
setCameraRotation(QQuaternion::fromEulerAngles(eilorRotation));
|
||||
}
|
||||
|
||||
void World::handleYViewChanged(double dy) {
|
||||
auto eilorRatation = cameraRatation().toEulerAngles();
|
||||
eilorRatation.setY(eilorRatation.y() + dy );
|
||||
setCameraRatation(QQuaternion::fromEulerAngles(eilorRatation));
|
||||
auto eilorRotation = cameraRotation().toEulerAngles();
|
||||
eilorRotation.setY(eilorRotation.y() + dy );
|
||||
setCameraRotation(QQuaternion::fromEulerAngles(eilorRotation));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -7,6 +7,7 @@
|
||||
|
||||
#include <QtTest>
|
||||
#include "clasterstest.h"
|
||||
#include "groupobjecttest.h"
|
||||
|
||||
// Use This macros for initialize your own test classes.
|
||||
// Check exampletests
|
||||
@ -33,6 +34,7 @@ private slots:
|
||||
|
||||
// BEGIN TESTS CASES
|
||||
TestCase(clastersTest, ClastersTest)
|
||||
TestCase(groupObjectTest, GroupObjectTest)
|
||||
|
||||
// END TEST CASES
|
||||
|
||||
|
95
tests/units/groupobjecttest.cpp
Normal file
95
tests/units/groupobjecttest.cpp
Normal file
@ -0,0 +1,95 @@
|
||||
//#
|
||||
//# 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 "groupobjecttest.h"
|
||||
#include "Crawl/groupobject.h"
|
||||
|
||||
#include <Crawl/clasteritem.h>
|
||||
|
||||
class TestGroupObject: public CRAWL::IWorldItem, public CRAWL::GroupObject {
|
||||
|
||||
public:
|
||||
|
||||
// IWorldItem interface
|
||||
TestGroupObject(): CRAWL::IWorldItem(AUTO_CLASS_NAME) {
|
||||
|
||||
}
|
||||
protected:
|
||||
void onIntersects(const IWorldItem *) override {};
|
||||
|
||||
// IRender interface
|
||||
void render(unsigned int tbfMsec) override {
|
||||
GroupObject::render(tbfMsec);
|
||||
};
|
||||
|
||||
void init() override {};
|
||||
|
||||
friend GroupObjectTest;
|
||||
};
|
||||
|
||||
class TestGroupObjectItem: public CRAWL::ClasterItem {
|
||||
|
||||
public:
|
||||
// IWorldItem interface
|
||||
|
||||
TestGroupObjectItem(): CRAWL::ClasterItem(AUTO_CLASS_NAME) {
|
||||
|
||||
}
|
||||
protected:
|
||||
void onIntersects(const IWorldItem *) override {};
|
||||
};
|
||||
|
||||
GroupObjectTest::GroupObjectTest() {
|
||||
|
||||
}
|
||||
|
||||
void GroupObjectTest::test() {
|
||||
testBehavior();
|
||||
}
|
||||
|
||||
void GroupObjectTest::testBehavior() const {
|
||||
TestGroupObject object;
|
||||
TestGroupObjectItem item;
|
||||
|
||||
object.setposition({100, 100, 0});
|
||||
object.setRotation(QQuaternion::fromEulerAngles(100,0,0));
|
||||
|
||||
object.installObject(&item);
|
||||
|
||||
// check if added object after install into claster or not
|
||||
QVERIFY(object.objects().size() == 1);
|
||||
|
||||
// The rotation and position of the main and child classes should be defferent
|
||||
QVERIFY(item.position() != object.position());
|
||||
QVERIFY(item.rotation() != object.rotation());
|
||||
|
||||
object.render(0);
|
||||
|
||||
// after invoke the render function all positions and rotations should be changed
|
||||
QVERIFY(item.position() == object.position());
|
||||
QVERIFY(item.rotation() == object.rotation());
|
||||
|
||||
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.position() == (object.position() + localPosition));
|
||||
QVERIFY(item.rotation() == (object.rotation() * localRotation));
|
||||
|
||||
|
||||
object.remove(&item);
|
||||
|
||||
QVERIFY(object.objects().size() == 0);
|
||||
|
||||
|
||||
}
|
31
tests/units/groupobjecttest.h
Normal file
31
tests/units/groupobjecttest.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.
|
||||
//#
|
||||
|
||||
#include "test.h"
|
||||
#include "testutils.h"
|
||||
|
||||
|
||||
#ifndef GROUPOBJECTTEST_H
|
||||
#define GROUPOBJECTTEST_H
|
||||
|
||||
/**
|
||||
* @brief The GroupObjectTest class will be tests the CRAWL::GroupObject class from the core library.
|
||||
*/
|
||||
class GroupObjectTest: public Test, protected TestUtils
|
||||
{
|
||||
public:
|
||||
GroupObjectTest();
|
||||
void test();
|
||||
|
||||
private:
|
||||
/**
|
||||
* @brief testBehavior This method check the install objects on the main object.
|
||||
*/
|
||||
void testBehavior() const;
|
||||
};
|
||||
|
||||
#endif // GROUPOBJECTTEST_H
|
@ -5,6 +5,7 @@
|
||||
//# of this license document, but changing it is not allowed.
|
||||
//#
|
||||
|
||||
#include <QtTest>
|
||||
|
||||
#ifndef TEST_H
|
||||
#define TEST_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user