Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

ugeentity.h 2.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. #ifndef UGEENTITY_H
  2. #define UGEENTITY_H
  3. #include <QObject>
  4. #include <QPoint>
  5. #include <QSharedPointer>
  6. #include "utils/vector3d.h"
  7. #include "utils/matrix3x3.h"
  8. #include "engine/abstractrenderdevice.h"
  9. class UGEEntity : public QObject
  10. {
  11. Q_OBJECT
  12. public:
  13. explicit UGEEntity(QObject *parent = 0);
  14. virtual ~UGEEntity();
  15. Vector3D getPosition() const;
  16. void setPosition(const Vector3D& position);
  17. void move(const Vector3D& move);
  18. // Vector3D getSpeed() const;
  19. // void setSpeed(const Vector3D& speed);
  20. // void accelerate(const Vector3D& speed);
  21. Vector3D getRotation() const;
  22. void setRotation(const Vector3D& rotation);
  23. void rotate(const Vector3D& rotation);
  24. Vector3D getScale() const;
  25. void setScale(const Vector3D& scale);
  26. void scale(const Vector3D& scale);
  27. bool isVisible() const;
  28. void setVisible(bool visible);
  29. void show();
  30. void hide();
  31. const QColor &getColor() const;
  32. void setColor(const QColor &color);
  33. Vector3D getRealPoint(const Vector3D& pos);
  34. ColorVector3D getRealPoint(const ColorVector3D& pos);
  35. TextureVector3D getRealPoint(const TextureVector3D& pos);
  36. Matrix3x3 getTransformationMatrix() const;
  37. Matrix3x3 getScaleMatrix() const;
  38. Matrix3x3 getRotationMatrix() const;
  39. void drawPoint(AbstractRenderDevice* device, const ColorVector3D& point);
  40. void drawLine(AbstractRenderDevice* device, const ColorVector3D& begin, const ColorVector3D& end, double width = 1.0);
  41. void drawPolygon(AbstractRenderDevice* device, QList<ColorVector3D> points);
  42. void drawPolygonTexture(AbstractRenderDevice *device, QList<TextureVector3D> points, const QVariant& textureId);
  43. void draw(AbstractRenderDevice* device);
  44. virtual void onDraw(AbstractRenderDevice* device) = 0;
  45. virtual Vector3D getVectorNearestIntesection(const Vector3D &vector, const Vector3D &pos, bool* ok) = 0;
  46. Vector3D getVectorNearestFaceIntersection(const Vector3D & p0, const Vector3D &p1, const Vector3D &p2, const Vector3D &vector, const Vector3D &pos, bool* ok);
  47. bool isZero(double v);
  48. void update();
  49. virtual void onUpdate();
  50. public slots:
  51. void needUpdate();
  52. signals:
  53. void positionChanged();
  54. void positionChanged(const Vector3D& position);
  55. void rotationChanged();
  56. void rotationChanged(const Vector3D& rotation);
  57. void scaleChanged();
  58. void scaleChanged(const Vector3D& scale);
  59. void visibilityChanged();
  60. void visibilityChanged(bool visible);
  61. void colorChanged();
  62. void colorChanged(QColor color);
  63. protected:
  64. Vector3D _position;
  65. // Vector3D _speed;
  66. Vector3D _rotation;
  67. Vector3D _scale;
  68. bool _visible;
  69. QColor _color;
  70. bool _needUpdate;
  71. Matrix3x3 _tranformation;
  72. double _zero;
  73. };
  74. #endif // UGEENTITY_H