1 // Copyright © 2008-2021 Pioneer Developers. See AUTHORS.txt for details 2 // Licensed under the terms of the GPL v3. See licenses/GPL-3.txt 3 4 #ifndef _MATRIXTRANSFORM_H 5 #define _MATRIXTRANSFORM_H 6 7 #include "Group.h" 8 #include "matrix4x4.h" 9 10 namespace Graphics { 11 class Renderer; 12 } 13 14 namespace SceneGraph { 15 16 /* 17 * Applies a matrix transform to child nodes 18 * 19 * Note: transforms are not automatically serialized when saving to disk; 20 * they are derived from the original model and animations. 21 * If you have programmatically positioned a MatrixTransform, it is your 22 * responsibility to ensure the new position is properly serialized. 23 */ 24 class MatrixTransform : public Group { 25 public: 26 MatrixTransform(Graphics::Renderer *r, const matrix4x4f &m); 27 MatrixTransform(const MatrixTransform &, NodeCopyCache *cache = 0); 28 29 virtual Node *Clone(NodeCopyCache *cache = 0) override; GetTypeName()30 virtual const char *GetTypeName() const override { return "MatrixTransform"; } 31 virtual void Accept(NodeVisitor &v) override; 32 33 virtual void Save(NodeDatabase &) override; 34 static MatrixTransform *Load(NodeDatabase &); 35 36 virtual void Render(const matrix4x4f &trans, const RenderData *rd) override; 37 virtual void Render(const std::vector<matrix4x4f> &trans, const RenderData *rd) override; 38 GetTransform()39 const matrix4x4f &GetTransform() const { return m_transform; } SetTransform(const matrix4x4f & m)40 void SetTransform(const matrix4x4f &m) { m_transform = m; } 41 42 protected: ~MatrixTransform()43 virtual ~MatrixTransform() {} 44 45 private: 46 matrix4x4f m_transform; 47 }; 48 } // namespace SceneGraph 49 #endif 50