mirror of
https://github.com/QuasarApp/Snake.git
synced 2025-04-27 02:04:41 +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) {
|
DefaultLight::DefaultLight(): IWorldLight(AUTO_CLASS_NAME) {
|
||||||
setColor("#fff8e7");
|
setColor("#fff8e7");
|
||||||
setposition({10000, 0, 10000});
|
setposition({10000, 0, 10000});
|
||||||
setRatation(QQuaternion::fromEulerAngles({-90,0,0}));
|
setRotation(QQuaternion::fromEulerAngles({-90,0,0}));
|
||||||
setLightForce(110);
|
setLightForce(110);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ void GroupObject::render(unsigned int tbfMsec) {
|
|||||||
|
|
||||||
if (LocalPropertyes *props = getLocalPropertyes(object->guiId())) {
|
if (LocalPropertyes *props = getLocalPropertyes(object->guiId())) {
|
||||||
if (!props->_rotation.isNull())
|
if (!props->_rotation.isNull())
|
||||||
object->setRatation(_this->ratation() * props->_rotation);
|
object->setRotation(_this->rotation() * props->_rotation);
|
||||||
|
|
||||||
object->setposition(_this->position() + props->_position);
|
object->setposition(_this->position() + props->_position);
|
||||||
}
|
}
|
||||||
|
@ -24,15 +24,15 @@ struct LocalPropertyes {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The GroupObject class is extansion with group object behavior.
|
* @brief The GroupObject class is extension with group object behavior.
|
||||||
* ### Requeried functions: IWorldItem
|
* ### 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
|
* ## Example of use
|
||||||
*
|
*
|
||||||
* ### For what this object uses
|
* ### 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.
|
* For example : weapon of the player.
|
||||||
*
|
*
|
||||||
* ### Example of use
|
* ### Example of use
|
||||||
|
@ -17,7 +17,7 @@ GuiObject::GuiObject(const QString &name, const QString &viewTempalte, QObject *
|
|||||||
_viewTemplate = viewTempalte;
|
_viewTemplate = viewTempalte;
|
||||||
_className = name;
|
_className = name;
|
||||||
generateId();
|
generateId();
|
||||||
setRatation(QQuaternion::fromEulerAngles({0,0,0}));
|
setRotation(QQuaternion::fromEulerAngles({0,0,0}));
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString& GuiObject::color() const {
|
const QString& GuiObject::color() const {
|
||||||
@ -173,15 +173,15 @@ void GuiObject::setSize(const QVector3D &newSize) {
|
|||||||
emit sizeChanged();
|
emit sizeChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
const QQuaternion &GuiObject::ratation() const {
|
const QQuaternion &GuiObject::rotation() const {
|
||||||
return _ratation;
|
return _rotation;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GuiObject::setRatation(const QQuaternion &newRatation) {
|
void GuiObject::setRotation(const QQuaternion &newRotation) {
|
||||||
if (_ratation == newRatation)
|
if (_rotation == newRotation)
|
||||||
return;
|
return;
|
||||||
_ratation = newRatation;
|
_rotation = newRotation;
|
||||||
emit ratationChanged();
|
emit rotationChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString &GuiObject::mash() const {
|
const QString &GuiObject::mash() const {
|
||||||
|
@ -30,7 +30,7 @@ namespace CRAWL {
|
|||||||
*
|
*
|
||||||
* The gui objct contains base properties for drow objects on scane
|
* The gui objct contains base properties for drow objects on scane
|
||||||
* * position
|
* * position
|
||||||
* * ratation
|
* * rotation
|
||||||
* * mash
|
* * mash
|
||||||
* * and map textures
|
* * 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 position READ position WRITE setposition NOTIFY positionChanged)
|
||||||
Q_PROPERTY(QVector3D size READ size WRITE setSize NOTIFY sizeChanged)
|
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)
|
Q_PROPERTY(QString mash READ mash WRITE setMash NOTIFY mashChanged)
|
||||||
|
|
||||||
@ -133,8 +133,8 @@ public:
|
|||||||
const QVector3D &size() const;
|
const QVector3D &size() const;
|
||||||
void setSize(const QVector3D &newSize);
|
void setSize(const QVector3D &newSize);
|
||||||
|
|
||||||
const QQuaternion &ratation() const;
|
const QQuaternion &rotation() const;
|
||||||
void setRatation(const QQuaternion &newRatation);
|
void setRotation(const QQuaternion &newRotation);
|
||||||
|
|
||||||
const QString &mash() const;
|
const QString &mash() const;
|
||||||
void setMash(const QString &newMash);
|
void setMash(const QString &newMash);
|
||||||
@ -171,7 +171,7 @@ signals:
|
|||||||
|
|
||||||
void positionChanged();
|
void positionChanged();
|
||||||
void sizeChanged();
|
void sizeChanged();
|
||||||
void ratationChanged();
|
void rotationChanged();
|
||||||
|
|
||||||
void mashChanged();
|
void mashChanged();
|
||||||
|
|
||||||
@ -217,7 +217,7 @@ private:
|
|||||||
|
|
||||||
QVector3D _position;
|
QVector3D _position;
|
||||||
QVector3D _size;
|
QVector3D _size;
|
||||||
QQuaternion _ratation;
|
QQuaternion _rotation;
|
||||||
QString _mash;
|
QString _mash;
|
||||||
QString _className;
|
QString _className;
|
||||||
bool _visible = true;
|
bool _visible = true;
|
||||||
|
@ -353,15 +353,15 @@ void IWorld::updateWorld() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const QQuaternion &IWorld::cameraRatation() const {
|
const QQuaternion &IWorld::cameraRotation() const {
|
||||||
return _cameraRatation;
|
return _cameraRotation;
|
||||||
}
|
}
|
||||||
|
|
||||||
void IWorld::setCameraRatation(const QQuaternion &newCameraRatation) {
|
void IWorld::setCameraRotation(const QQuaternion &newCameraRotation) {
|
||||||
if (_cameraRatation == newCameraRatation)
|
if (_cameraRotation == newCameraRotation)
|
||||||
return;
|
return;
|
||||||
_cameraRatation = newCameraRatation;
|
_cameraRotation = newCameraRotation;
|
||||||
emit cameraRatationChanged();
|
emit cameraRotationChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
IAI *IWorld::backgroundAI() const {
|
IAI *IWorld::backgroundAI() const {
|
||||||
|
@ -49,7 +49,7 @@ class CRAWL_EXPORT IWorld : public QObject, public IRender
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(QVector3D cameraReleativePosition READ cameraReleativePosition NOTIFY cameraReleativePositionChanged)
|
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(QObject * player READ player WRITE setPlayer NOTIFY playerChanged)
|
||||||
Q_PROPERTY(QString hdr READ hdr NOTIFY hdrChanged)
|
Q_PROPERTY(QString hdr READ hdr NOTIFY hdrChanged)
|
||||||
|
|
||||||
@ -210,10 +210,10 @@ public:
|
|||||||
IAI *backgroundAI() const;
|
IAI *backgroundAI() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief cameraRatation This method return curent camera ratation.
|
* @brief cameraRotation This method return curent camera rotation.
|
||||||
* @return Quaternion of camera ratation
|
* @return Quaternion of camera rotation
|
||||||
*/
|
*/
|
||||||
const QQuaternion &cameraRatation() const;
|
const QQuaternion &cameraRotation() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief player This method return player object
|
* @brief player This method return player object
|
||||||
@ -263,9 +263,9 @@ signals:
|
|||||||
void worldStatusChanged();
|
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.
|
* @brief playerChanged This signal eited when player are changed.
|
||||||
@ -320,10 +320,10 @@ protected:
|
|||||||
void setCameraReleativePosition(const QVector3D &newCameraReleativePosition);
|
void setCameraReleativePosition(const QVector3D &newCameraReleativePosition);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief setCameraRatation This method sets new ratation of the camera.
|
* @brief setCameraRotation This method sets new rotation of the camera.
|
||||||
* @param newCameraRatation new ratation 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;
|
* @brief targetFps This method return current targetFps;
|
||||||
@ -488,7 +488,7 @@ private:
|
|||||||
mutable QMutex _ItemsMutex;
|
mutable QMutex _ItemsMutex;
|
||||||
|
|
||||||
QVector3D _cameraReleativePosition;
|
QVector3D _cameraReleativePosition;
|
||||||
QQuaternion _cameraRatation;
|
QQuaternion _cameraRotation;
|
||||||
|
|
||||||
QString _hdrMap;
|
QString _hdrMap;
|
||||||
WorldRule *_worldRules = nullptr;
|
WorldRule *_worldRules = nullptr;
|
||||||
|
@ -27,15 +27,15 @@ void SnakeItem::render(unsigned int tbfMsec) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto ratationVector = (_prevObject->position() - position());
|
auto rotationVector = (_prevObject->position() - position());
|
||||||
|
|
||||||
if (auto claster = static_cast<Snake*>(parentClaster())) {
|
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());
|
setposition(_prevObject->position());
|
||||||
} else if (ratationLength > lengthBetwinItems()) {
|
} else if (rotationLength > lengthBetwinItems()) {
|
||||||
setMovableVector(ratationVector.normalized() * claster->currentMovableVector().length());
|
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);
|
scale: (model)? model.size: Qt.vector3d(0, 0, 0);
|
||||||
position: (model) ? model.position: Qt.vector3d(0,0,0);
|
position: (model) ? model.position: Qt.vector3d(0,0,0);
|
||||||
visible: sun.brightness
|
visible: sun.brightness
|
||||||
|
@ -65,7 +65,7 @@ Model {
|
|||||||
(fMapColor)? objMaterial: defaultMaterial
|
(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);
|
scale: (model)? model.size: Qt.vector3d(0, 0, 0);
|
||||||
source: (model)? model.mash: "#Cube";
|
source: (model)? model.mash: "#Cube";
|
||||||
position: (model) ? model.position: Qt.vector3d(0,0,0);
|
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);
|
scale: (model)? model.size: Qt.vector3d(0, 0, 0);
|
||||||
position: (model) ? model.position: Qt.vector3d(0,0,0);
|
position: (model) ? model.position: Qt.vector3d(0,0,0);
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ View3D {
|
|||||||
:
|
:
|
||||||
Qt.vector3d(0,0,100)
|
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) {
|
void BaseMotion::render(unsigned int tbfMsec) {
|
||||||
if (auto _this = checkminimumRequariedType<GuiObject>()) {
|
if (auto _this = checkminimumRequariedType<GuiObject>()) {
|
||||||
renderPosition(_this, tbfMsec);
|
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.
|
* @brief The BaseMotion class contains base functions of the motion.
|
||||||
* For Create your own motion alghoritm you need to override two methods:
|
* For Create your own motion alghoritm you need to override two methods:
|
||||||
* * renderPosition
|
* * renderPosition
|
||||||
* * renderRatation
|
* * renderRotation
|
||||||
*/
|
*/
|
||||||
class CRAWL_EXPORT BaseMotion : public virtual IRender
|
class CRAWL_EXPORT BaseMotion : public virtual IRender
|
||||||
{
|
{
|
||||||
@ -49,14 +49,14 @@ public:
|
|||||||
protected:
|
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 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.
|
* @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 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.
|
* @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>()) {
|
if (auto _this = checkminimumRequariedType<GuiObject>()) {
|
||||||
renderPosition(_this, tbfMsec);
|
renderPosition(_this, tbfMsec);
|
||||||
renderRatation(_this, tbfMsec);
|
renderRotation(_this, tbfMsec);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,9 +56,9 @@ void CircularMotion::setAnglePosition(double newAngle) {
|
|||||||
_angle = newAngle;
|
_angle = newAngle;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CircularMotion::renderRatation(GuiObject *object,
|
void CircularMotion::renderRotation(GuiObject *object,
|
||||||
unsigned int ) {
|
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,
|
void CircularMotion::renderPosition(GuiObject *object,
|
||||||
|
@ -80,14 +80,14 @@ public:
|
|||||||
protected:
|
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 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.
|
* @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 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.
|
* @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>()) {
|
if (auto _this = checkminimumRequariedType<GuiObject>()) {
|
||||||
renderPosition(_this, tbfMsec);
|
renderPosition(_this, tbfMsec);
|
||||||
renderRatation(_this, tbfMsec);
|
renderRotation(_this, tbfMsec);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,9 +49,9 @@ void MovableObject::setBreakingForce(float newBreakingForce) {
|
|||||||
_breakingForce = newBreakingForce;
|
_breakingForce = newBreakingForce;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MovableObject::renderRatation(GuiObject *object, unsigned int) {
|
void MovableObject::renderRotation(GuiObject *object, unsigned int) {
|
||||||
if (_currentMovableVector.length() > 0) {
|
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:
|
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 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.
|
* @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 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.
|
* @param tbfMsec This is time betwin frames argument. soame as in the IRender::render function.
|
||||||
*/
|
*/
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
namespace AbstractLvl {
|
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
|
class AbsLvlControl: public CRAWL::DefaultControl
|
||||||
{
|
{
|
||||||
|
@ -20,7 +20,7 @@ namespace AbstractLvl {
|
|||||||
|
|
||||||
AbsLvlWorld::AbsLvlWorld() {
|
AbsLvlWorld::AbsLvlWorld() {
|
||||||
setCameraReleativePosition({20,0,100});
|
setCameraReleativePosition({20,0,100});
|
||||||
setCameraRatation(QQuaternion::fromEulerAngles({0,0,0}));
|
setCameraRotation(QQuaternion::fromEulerAngles({0,0,0}));
|
||||||
}
|
}
|
||||||
|
|
||||||
CRAWL::IPlayer *AbsLvlWorld::initPlayer() const {
|
CRAWL::IPlayer *AbsLvlWorld::initPlayer() const {
|
||||||
|
@ -16,7 +16,7 @@ Box::Box(): IWorldItem("Box") {
|
|||||||
setSize({2,2,2});
|
setSize({2,2,2});
|
||||||
setColor(QColor::fromRgb(rand()).name());
|
setColor(QColor::fromRgb(rand()).name());
|
||||||
|
|
||||||
setRatation(QQuaternion::fromEulerAngles(
|
setRotation(QQuaternion::fromEulerAngles(
|
||||||
rand() % 360 ,
|
rand() % 360 ,
|
||||||
rand() % 360,
|
rand() % 360,
|
||||||
rand() % 360));
|
rand() % 360));
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
namespace TestLvl {
|
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
|
class TestControl: public CRAWL::DefaultControl
|
||||||
{
|
{
|
||||||
|
@ -22,7 +22,7 @@ namespace TestLvl {
|
|||||||
|
|
||||||
World::World() {
|
World::World() {
|
||||||
setCameraReleativePosition({50,0,100});
|
setCameraReleativePosition({50,0,100});
|
||||||
setCameraRatation(QQuaternion::fromEulerAngles({0,0,0}));
|
setCameraRotation(QQuaternion::fromEulerAngles({0,0,0}));
|
||||||
}
|
}
|
||||||
|
|
||||||
CRAWL::WorldRule *World::initWorldRules() {
|
CRAWL::WorldRule *World::initWorldRules() {
|
||||||
@ -77,14 +77,14 @@ CRAWL::IAI *World::initBackGroundAI() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void World::handleXViewChanged(double dx) {
|
void World::handleXViewChanged(double dx) {
|
||||||
auto eilorRatation = cameraRatation().toEulerAngles();
|
auto eilorRotation = cameraRotation().toEulerAngles();
|
||||||
eilorRatation.setX(eilorRatation.x() + dx);
|
eilorRotation.setX(eilorRotation.x() + dx);
|
||||||
setCameraRatation(QQuaternion::fromEulerAngles(eilorRatation));
|
setCameraRotation(QQuaternion::fromEulerAngles(eilorRotation));
|
||||||
}
|
}
|
||||||
|
|
||||||
void World::handleYViewChanged(double dy) {
|
void World::handleYViewChanged(double dy) {
|
||||||
auto eilorRatation = cameraRatation().toEulerAngles();
|
auto eilorRotation = cameraRotation().toEulerAngles();
|
||||||
eilorRatation.setY(eilorRatation.y() + dy );
|
eilorRotation.setY(eilorRotation.y() + dy );
|
||||||
setCameraRatation(QQuaternion::fromEulerAngles(eilorRatation));
|
setCameraRotation(QQuaternion::fromEulerAngles(eilorRotation));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@ Egg::Egg(const QString name): CRAWL::IWorldItem(name)
|
|||||||
setMash(mashes[rand() % mashes.size()]);
|
setMash(mashes[rand() % mashes.size()]);
|
||||||
|
|
||||||
setSize({1,1,1});
|
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 *) {
|
void Egg::onIntersects(const IWorldItem *) {
|
||||||
|
@ -13,7 +13,7 @@ Grees::Grees(): CRAWL::IWorldItem(AUTO_CLASS_NAME) {
|
|||||||
setMash("qrc:/mesh/meshes/Plant/Grass.mesh");
|
setMash("qrc:/mesh/meshes/Plant/Grass.mesh");
|
||||||
setBaseColorMap("qrc:/mesh/meshes/Plant/Grass_Base.jpg");
|
setBaseColorMap("qrc:/mesh/meshes/Plant/Grass_Base.jpg");
|
||||||
setSize({1,1,1});
|
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");
|
setBaseColorMap("qrc:/mesh/meshes/Plant/Ivy_Base.jpg");
|
||||||
setSize({1,1,1});
|
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 *) {
|
void Ivy::onIntersects(const IWorldItem *) {
|
||||||
|
@ -12,7 +12,7 @@ LongGress::LongGress(): CRAWL::IWorldItem(AUTO_CLASS_NAME) {
|
|||||||
setMash("qrc:/mesh/meshes/Plant/Long_grass.mesh");
|
setMash("qrc:/mesh/meshes/Plant/Long_grass.mesh");
|
||||||
setBaseColorMap("qrc:/mesh/meshes/Plant/LongGrass_Base.jpg");
|
setBaseColorMap("qrc:/mesh/meshes/Plant/LongGrass_Base.jpg");
|
||||||
setSize({1,1,1});
|
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 *) {
|
void LongGress::onIntersects(const IWorldItem *) {
|
||||||
|
@ -20,7 +20,7 @@ Plant::Plant(): CRAWL::IWorldItem(AUTO_CLASS_NAME) {
|
|||||||
|
|
||||||
setBaseColorMap("qrc:/mesh/meshes/Plant/Plant_Base.jpg");
|
setBaseColorMap("qrc:/mesh/meshes/Plant/Plant_Base.jpg");
|
||||||
setSize({1,1,1});
|
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 *) {
|
void Plant::onIntersects(const IWorldItem *) {
|
||||||
|
@ -25,7 +25,7 @@ Stone::Stone(): CRAWL::IWorldItem(AUTO_CLASS_NAME)
|
|||||||
setNormalMap("qrc:/mesh/meshes/Stone/Stone_Normal.jpg");
|
setNormalMap("qrc:/mesh/meshes/Stone/Stone_Normal.jpg");
|
||||||
|
|
||||||
setSize({1,1,1});
|
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 *) {
|
void Stone::onIntersects(const IWorldItem *) {
|
||||||
|
@ -23,7 +23,7 @@ Tree::Tree(): CRAWL::IWorldItem(AUTO_CLASS_NAME) {
|
|||||||
setMash(mashes[rand() % mashes.size()]);
|
setMash(mashes[rand() % mashes.size()]);
|
||||||
setBaseColorMap("qrc:/mesh/meshes/Plant/Tree_Base.jpg");
|
setBaseColorMap("qrc:/mesh/meshes/Plant/Tree_Base.jpg");
|
||||||
setSize({1,1,1});
|
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() % 60 - 30),
|
||||||
static_cast<float>(rand() % 360)}));
|
static_cast<float>(rand() % 360)}));
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ Wood::Wood(): CRAWL::IWorldItem(AUTO_CLASS_NAME) {
|
|||||||
setNormalMap("qrc:/mesh/meshes/Wood/Wood_Normal.jpg");
|
setNormalMap("qrc:/mesh/meshes/Wood/Wood_Normal.jpg");
|
||||||
setRoughnessMap("qrc:/mesh/meshes/Wood/Wood_Roughness.jpg");
|
setRoughnessMap("qrc:/mesh/meshes/Wood/Wood_Roughness.jpg");
|
||||||
setSize({1,1,1});
|
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 *) {
|
void Wood::onIntersects(const IWorldItem *) {
|
||||||
|
@ -30,7 +30,7 @@ namespace JungleLvl {
|
|||||||
|
|
||||||
World::World() {
|
World::World() {
|
||||||
setCameraReleativePosition({50,0,100});
|
setCameraReleativePosition({50,0,100});
|
||||||
setCameraRatation(QQuaternion::fromEulerAngles({0,0,0}));
|
setCameraRotation(QQuaternion::fromEulerAngles({0,0,0}));
|
||||||
}
|
}
|
||||||
|
|
||||||
CRAWL::WorldRule *World::initWorldRules() {
|
CRAWL::WorldRule *World::initWorldRules() {
|
||||||
@ -117,15 +117,15 @@ CRAWL::IAI *World::initBackGroundAI() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void World::handleXViewChanged(double dx) {
|
void World::handleXViewChanged(double dx) {
|
||||||
auto eilorRatation = cameraRatation().toEulerAngles();
|
auto eilorRotation = cameraRotation().toEulerAngles();
|
||||||
eilorRatation.setX(eilorRatation.x() + dx);
|
eilorRotation.setX(eilorRotation.x() + dx);
|
||||||
setCameraRatation(QQuaternion::fromEulerAngles(eilorRatation));
|
setCameraRotation(QQuaternion::fromEulerAngles(eilorRotation));
|
||||||
}
|
}
|
||||||
|
|
||||||
void World::handleYViewChanged(double dy) {
|
void World::handleYViewChanged(double dy) {
|
||||||
auto eilorRatation = cameraRatation().toEulerAngles();
|
auto eilorRotation = cameraRotation().toEulerAngles();
|
||||||
eilorRatation.setY(eilorRatation.y() + dy );
|
eilorRotation.setY(eilorRotation.y() + dy );
|
||||||
setCameraRatation(QQuaternion::fromEulerAngles(eilorRatation));
|
setCameraRotation(QQuaternion::fromEulerAngles(eilorRotation));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
#include <QtTest>
|
#include <QtTest>
|
||||||
#include "clasterstest.h"
|
#include "clasterstest.h"
|
||||||
|
#include "groupobjecttest.h"
|
||||||
|
|
||||||
// Use This macros for initialize your own test classes.
|
// Use This macros for initialize your own test classes.
|
||||||
// Check exampletests
|
// Check exampletests
|
||||||
@ -33,6 +34,7 @@ private slots:
|
|||||||
|
|
||||||
// BEGIN TESTS CASES
|
// BEGIN TESTS CASES
|
||||||
TestCase(clastersTest, ClastersTest)
|
TestCase(clastersTest, ClastersTest)
|
||||||
|
TestCase(groupObjectTest, GroupObjectTest)
|
||||||
|
|
||||||
// END TEST CASES
|
// 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.
|
//# of this license document, but changing it is not allowed.
|
||||||
//#
|
//#
|
||||||
|
|
||||||
|
#include <QtTest>
|
||||||
|
|
||||||
#ifndef TEST_H
|
#ifndef TEST_H
|
||||||
#define TEST_H
|
#define TEST_H
|
||||||
|
Loading…
x
Reference in New Issue
Block a user