Drawing3D.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. #pragma once
  2. #include "Mat4.h"
  3. #include "ReferenceCounter.h"
  4. namespace Framework
  5. {
  6. struct MouseEvent3D;
  7. struct KeyboardEvent;
  8. class Render3D; //! Render3D.h
  9. //! An object that can be drawn by the Screen3D class.
  10. class Drawable3D : public virtual ReferenceCounter
  11. {
  12. protected:
  13. Vec3<float> pos; //! Position of the object
  14. Vec3<float> angle; //! Rotation angles for x, y and z
  15. Mat4<float> welt; //! World translation matrix
  16. float radius; //! The radius of a sphere that encloses the entire object
  17. bool alpha; //! Stores whether the object contains partially or fully
  18. //! transparent areas
  19. bool rend;
  20. float size;
  21. public:
  22. //! Constructor
  23. DLLEXPORT Drawable3D();
  24. DLLEXPORT virtual ~Drawable3D();
  25. //! Sets the position of the drawing in the world
  26. //! \param p The position
  27. DLLEXPORT void setPosition(const Vec3<float>& p);
  28. //! Sets the position of the drawing in the world
  29. //! \param x The x position
  30. //! \param y The y position
  31. //! \param z The z position
  32. DLLEXPORT void setPosition(float x, float y, float z);
  33. //! Sets the position of the drawing in the world
  34. //! \param x The x position
  35. DLLEXPORT void setX(float x);
  36. //! Sets the position of the drawing in the world
  37. //! \param y The y position
  38. DLLEXPORT void setY(float y);
  39. //! Sets the position of the drawing in the world
  40. //! \param z The z position
  41. DLLEXPORT void setZ(float z);
  42. //! Sets the rotation of the drawing in the world
  43. //! \param d The rotation around the x, y and z axes
  44. DLLEXPORT void setDrehung(const Vec3<float>& d);
  45. //! Sets the rotation of the drawing in the world
  46. //! \param xWinkel The rotation around the x axis
  47. //! \param yWinkel The rotation around the y axis
  48. //! \param zWinkel The rotation around the z axis
  49. DLLEXPORT void setDrehung(float xWinkel, float yWinkel, float zWinkel);
  50. //! Sets the rotation of the drawing in the world
  51. //! \param winkel The rotation around the x axis
  52. DLLEXPORT void setDrehungX(float winkel);
  53. //! Sets the rotation of the drawing in the world
  54. //! \param winkel The rotation around the y axis
  55. DLLEXPORT void setDrehungY(float winkel);
  56. //! Sets the rotation of the drawing in the world
  57. //! \param winkel The rotation around the z axis
  58. DLLEXPORT void setDrehungZ(float winkel);
  59. //! Sets whether the object contains partially or fully transparent
  60. //! areas \param a true if partially or fully transparent areas exist
  61. DLLEXPORT void setAlpha(bool a);
  62. //! Sets the scaling
  63. DLLEXPORT void setSize(float size);
  64. //! Calculates the matrices of all bones in the drawing's skeleton
  65. //! \param viewProj The multiplied camera matrices
  66. //! \param matBuffer An array of matrices to fill
  67. //! \return The number of matrices the drawing requires
  68. DLLEXPORT virtual int errechneMatrizen(
  69. const Mat4<float>& viewProj, Mat4<float>* matBuffer);
  70. //! Processes a mouse event
  71. //! \param me The mouse event to process
  72. DLLEXPORT virtual void doMouseEvent(MouseEvent3D& me);
  73. //! Processes a keyboard event
  74. //! \param te The keyboard event to process
  75. DLLEXPORT virtual void doKeyboardEvent(KeyboardEvent& te);
  76. //! Processes elapsed time
  77. //! \param tickval The time in seconds since the last call of this
  78. //! function \return true if the object changed, false otherwise.
  79. DLLEXPORT virtual bool tick(double tickval);
  80. //! Returns whether the object contains partially or fully transparent areas
  81. DLLEXPORT bool hatAlpha() const;
  82. //! Returns the radius of a sphere that encloses the entire model
  83. DLLEXPORT inline float getRadius() const;
  84. //! Returns a point representing the position of the drawing in the world
  85. DLLEXPORT const Vec3<float>& getPos() const;
  86. //! Returns the X position of the drawing in the world
  87. DLLEXPORT float getX() const;
  88. //! Returns the Y position of the drawing in the world
  89. DLLEXPORT float getY() const;
  90. //! Returns the Z position of the drawing in the world
  91. DLLEXPORT float getZ() const;
  92. //! Returns a vector representing the rotation of the drawing in the world.
  93. //! x is the rotation around the X axis in radians, etc.
  94. DLLEXPORT const Vec3<float>& getDrehung() const;
  95. //! Returns the rotation around the X axis in radians
  96. DLLEXPORT float getXDrehung() const;
  97. //! Returns the rotation around the Y axis in radians
  98. DLLEXPORT float getYDrehung() const;
  99. //! Returns the rotation around the Z axis in radians
  100. DLLEXPORT float getZDrehung() const;
  101. //! Returns the matrix that translates the drawing into world space
  102. DLLEXPORT const Mat4<float>& getMatrix() const;
  103. //! Calculates a point in world coordinates from a point in local drawing
  104. //! coordinates by applying rotation, scaling and translation
  105. DLLEXPORT Vec3<float> applyWorldTransformation(
  106. const Vec3<float>& modelPos) const;
  107. };
  108. } // namespace Framework