matrixTransition.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. // Filename: matrixTransition.h
  2. // Created by: drose (24Mar00)
  3. //
  4. ////////////////////////////////////////////////////////////////////
  5. //
  6. // PANDA 3D SOFTWARE
  7. // Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved
  8. //
  9. // All use of this software is subject to the terms of the Panda 3d
  10. // Software license. You should have received a copy of this license
  11. // along with this source code; you will also find a current copy of
  12. // the license at http://www.panda3d.org/license.txt .
  13. //
  14. // To contact the maintainers of this program write to
  15. // [email protected] .
  16. //
  17. ////////////////////////////////////////////////////////////////////
  18. #ifndef MATRIXTRANSITION_H
  19. #define MATRIXTRANSITION_H
  20. #include <pandabase.h>
  21. #include "nodeTransition.h"
  22. class NodeAttribute;
  23. class NodeRelation;
  24. ////////////////////////////////////////////////////////////////////
  25. // Class : MatrixTransition
  26. // Description : This is an abstract template class that encapsulates
  27. // all transitions that involve some kind of matrix,
  28. // either a 4x4 or a 3x3, either float or double. It
  29. // templates on the matrix type.
  30. //
  31. // It's the base class for a number of scene graph
  32. // transitions like TransformTransition and
  33. // TexMatrixTransition.
  34. ////////////////////////////////////////////////////////////////////
  35. template<class Matrix>
  36. class MatrixTransition : public NodeTransition {
  37. protected:
  38. INLINE_GRAPH MatrixTransition();
  39. INLINE_GRAPH MatrixTransition(const Matrix &matrix);
  40. INLINE_GRAPH MatrixTransition(const MatrixTransition &copy);
  41. INLINE_GRAPH void operator = (const MatrixTransition &copy);
  42. public:
  43. INLINE_GRAPH void set_matrix(const Matrix &mat);
  44. INLINE_GRAPH const Matrix &get_matrix() const;
  45. virtual NodeTransition *compose(const NodeTransition *other) const;
  46. virtual NodeTransition *invert() const;
  47. virtual NodeAttribute *apply(const NodeAttribute *attrib) const;
  48. virtual void output(ostream &out) const;
  49. virtual void write(ostream &out, int indent_level = 0) const;
  50. protected:
  51. virtual int internal_compare_to(const NodeTransition *other) const;
  52. virtual void internal_generate_hash(GraphHashGenerator &hash) const;
  53. protected:
  54. virtual MatrixTransition<Matrix> *
  55. make_with_matrix(const Matrix &matrix) const=0;
  56. private:
  57. Matrix _matrix;
  58. public:
  59. virtual void write_datagram(BamWriter* manager, Datagram &me);
  60. //Matrix has no factory method as it is a virtual template
  61. //class
  62. protected:
  63. virtual void fillin(DatagramIterator& scan, BamReader* manager);
  64. public:
  65. virtual TypeHandle get_type() const {
  66. return get_class_type();
  67. }
  68. virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
  69. static TypeHandle get_class_type() {
  70. return _type_handle;
  71. }
  72. static void init_type() {
  73. NodeTransition::init_type();
  74. Matrix::init_type();
  75. register_type(_type_handle,
  76. string("MatrixTransition<") +
  77. Matrix::get_class_type().get_name() + ">",
  78. NodeTransition::get_class_type());
  79. }
  80. private:
  81. static TypeHandle _type_handle;
  82. };
  83. #include "matrixTransition.T"
  84. #endif