You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ugeentity.cpp 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. #include "ugeentity.h"
  2. UGEEntity::UGEEntity(QObject *parent)
  3. : QObject(parent)
  4. , _visible(true)
  5. {
  6. }
  7. UGEEntity::~UGEEntity()
  8. {
  9. }
  10. Vector3D UGEEntity::getPosition() const
  11. {
  12. return _position;
  13. }
  14. void UGEEntity::setPosition(const Vector3D &position)
  15. {
  16. _position = position;
  17. }
  18. void UGEEntity::move(const Vector3D &move)
  19. {
  20. _position += move;
  21. }
  22. Vector3D UGEEntity::getSpeed() const
  23. {
  24. return _speed;
  25. }
  26. void UGEEntity::setSpeed(const Vector3D &speed)
  27. {
  28. _speed = speed;
  29. }
  30. void UGEEntity::accelerate(const Vector3D &speed)
  31. {
  32. _speed += speed;
  33. }
  34. Vector3D UGEEntity::getRotation() const
  35. {
  36. return _rotation;
  37. }
  38. void UGEEntity::setRotation(const Vector3D &rotation)
  39. {
  40. _rotation = rotation;
  41. }
  42. void UGEEntity::rotate(const Vector3D &rotation)
  43. {
  44. _rotation += rotation;
  45. }
  46. Vector3D UGEEntity::getScale() const
  47. {
  48. return _scale;
  49. }
  50. void UGEEntity::setScale(const Vector3D &scale)
  51. {
  52. _scale = scale;
  53. }
  54. void UGEEntity::scale(const Vector3D &scale)
  55. {
  56. _scale += scale;
  57. }
  58. bool UGEEntity::isVisible() const
  59. {
  60. return _visible;
  61. }
  62. void UGEEntity::setVisible(bool visible)
  63. {
  64. _visible = visible;
  65. }
  66. void UGEEntity::show()
  67. {
  68. _visible = true;
  69. }
  70. void UGEEntity::hide()
  71. {
  72. _visible = false;
  73. }
  74. Vector3D UGEEntity::getRealPoint(const Vector3D &pos)
  75. {
  76. return pos + _position;
  77. }
  78. ColorVector3D UGEEntity::getRealPoint(const ColorVector3D &pos)
  79. {
  80. return ColorVector3D(pos.getColor(), getRealPoint((Vector3D)pos));
  81. }
  82. void UGEEntity::drawPoint(AbstractRenderDevice *device, const ColorVector3D &point)
  83. {
  84. device->drawPoint(getRealPoint(point));
  85. }
  86. void UGEEntity::drawLine(AbstractRenderDevice *device, const ColorVector3D &begin, const ColorVector3D &end, double width)
  87. {
  88. device->drawLine(getRealPoint(begin), getRealPoint(end), width);
  89. }
  90. void UGEEntity::drawPolygon(AbstractRenderDevice *device, QList<ColorVector3D> points)
  91. {
  92. for (int i = 0; i < points.size(); ++i) {
  93. points[i] = getRealPoint(points[i]);
  94. }
  95. device->drawPolygon(points);
  96. }