nodeAttribute.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. // Filename: nodeAttribute.h
  2. // Created by: drose (20Mar00)
  3. //
  4. ////////////////////////////////////////////////////////////////////
  5. #ifndef NODEATTRIBUTE_H
  6. #define NODEATTRIBUTE_H
  7. #include <pandabase.h>
  8. #include <typedReferenceCount.h>
  9. class NodeTransition;
  10. class GraphicsStateGuardianBase;
  11. ////////////////////////////////////////////////////////////////////
  12. // Class : NodeAttribute
  13. // Description : This is an abstract class defining a single
  14. // Attribute, a state property such as color or texture
  15. // that may be in effect when rendering nodes of the
  16. // scene graph.
  17. //
  18. // In general, the scene graph represents state by
  19. // encoding transitions between various states on the
  20. // arcs of the graph. The attribute values themselves
  21. // are not explicitly stored; they are computed by
  22. // repeated application of the transitions.
  23. //
  24. // A NodeTransition (defined in nodeTransition.h)
  25. // represents a potential change from any one state (for
  26. // instance, the initial state) to any other. For
  27. // example, it might represent the change from the
  28. // untextured state to rendering with a particular
  29. // texture.
  30. //
  31. // Any number of Transitions may be applied along the
  32. // arcs leading from the top of the scene graph to a
  33. // geometry node. The Attribute state that will be in
  34. // effect when the geometry node is rendered will be
  35. // that computed by the consecutive application of each
  36. // Transition encountered to the initial state.
  37. ////////////////////////////////////////////////////////////////////
  38. class EXPCL_PANDA NodeAttribute : public TypedReferenceCount {
  39. protected:
  40. INLINE NodeAttribute();
  41. INLINE NodeAttribute(const NodeAttribute &copy);
  42. INLINE void operator = (const NodeAttribute &copy);
  43. public:
  44. INLINE bool operator == (const NodeAttribute &other) const;
  45. INLINE bool operator != (const NodeAttribute &other) const;
  46. INLINE bool operator < (const NodeAttribute &other) const;
  47. INLINE bool operator <= (const NodeAttribute &other) const;
  48. INLINE bool operator > (const NodeAttribute &other) const;
  49. INLINE bool operator >= (const NodeAttribute &other) const;
  50. INLINE int compare_to(const NodeAttribute &other) const;
  51. PUBLISHED:
  52. INLINE void set_priority(int priority);
  53. INLINE int get_priority() const;
  54. public:
  55. virtual NodeAttribute *make_copy() const=0;
  56. virtual NodeAttribute *make_initial() const=0;
  57. virtual TypeHandle get_handle() const=0;
  58. PUBLISHED:
  59. virtual void output(ostream &out) const;
  60. virtual void write(ostream &out, int indent_level = 0) const;
  61. public:
  62. virtual void issue(GraphicsStateGuardianBase *gsgbase);
  63. protected:
  64. virtual int internal_compare_to(const NodeAttribute *other) const=0;
  65. protected:
  66. int _priority;
  67. public:
  68. virtual TypeHandle get_type() const {
  69. return get_class_type();
  70. }
  71. virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
  72. static TypeHandle get_class_type() {
  73. return _type_handle;
  74. }
  75. static void init_type() {
  76. TypedReferenceCount::init_type();
  77. register_type(_type_handle, "NodeAttribute",
  78. TypedReferenceCount::get_class_type());
  79. }
  80. private:
  81. static TypeHandle _type_handle;
  82. };
  83. INLINE ostream &operator << (ostream &out, const NodeAttribute &nab) {
  84. nab.output(out);
  85. return out;
  86. }
  87. #include "nodeAttribute.I"
  88. #endif