Transform.hpp 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. #ifndef TRANSFORM_H
  2. #define TRANSFORM_H
  3. #include "Basis.hpp"
  4. #include "Plane.hpp"
  5. #include "Rect3.hpp"
  6. namespace godot {
  7. class Transform {
  8. public:
  9. Basis basis;
  10. Vector3 origin;
  11. void invert();
  12. Transform inverse() const;
  13. void affine_invert();
  14. Transform affine_inverse() const;
  15. Transform rotated(const Vector3& p_axis,real_t p_phi) const;
  16. void rotate(const Vector3& p_axis,real_t p_phi);
  17. void rotate_basis(const Vector3& p_axis,real_t p_phi);
  18. void set_look_at( const Vector3& p_eye, const Vector3& p_target, const Vector3& p_up );
  19. Transform looking_at( const Vector3& p_target, const Vector3& p_up ) const;
  20. void scale(const Vector3& p_scale);
  21. Transform scaled(const Vector3& p_scale) const;
  22. void scale_basis(const Vector3& p_scale);
  23. void translate( real_t p_tx, real_t p_ty, real_t p_tz );
  24. void translate( const Vector3& p_translation );
  25. Transform translated( const Vector3& p_translation ) const;
  26. inline const Basis& get_basis() const { return basis; }
  27. inline void set_basis(const Basis& p_basis) { basis=p_basis; }
  28. inline const Vector3& get_origin() const { return origin; }
  29. inline void set_origin(const Vector3& p_origin) { origin=p_origin; }
  30. void orthonormalize();
  31. Transform orthonormalized() const;
  32. bool operator==(const Transform& p_transform) const;
  33. bool operator!=(const Transform& p_transform) const;
  34. Vector3 xform(const Vector3& p_vector) const;
  35. Vector3 xform_inv(const Vector3& p_vector) const;
  36. Plane xform(const Plane& p_plane) const;
  37. Plane xform_inv(const Plane& p_plane) const;
  38. Rect3 xform(const Rect3& p_aabb) const;
  39. Rect3 xform_inv(const Rect3& p_aabb) const;
  40. void operator*=(const Transform& p_transform);
  41. Transform operator*(const Transform& p_transform) const;
  42. Transform interpolate_with(const Transform& p_transform, real_t p_c) const;
  43. Transform inverse_xform(const Transform& t) const;
  44. void set(real_t xx, real_t xy, real_t xz, real_t yx, real_t yy, real_t yz, real_t zx, real_t zy, real_t zz,real_t tx, real_t ty, real_t tz);
  45. operator String() const;
  46. inline Transform(real_t xx, real_t xy, real_t xz, real_t yx, real_t yy, real_t yz, real_t zx, real_t zy, real_t zz,real_t tx, real_t ty, real_t tz) {
  47. set(xx, xy, xz, yx, yy, yz, zx, zy, zz,tx, ty, tz);
  48. }
  49. Transform(const Basis& p_basis, const Vector3& p_origin=Vector3());
  50. inline Transform() {}
  51. };
  52. }
  53. #endif // TRANSFORM_H