nodeAttribute.h 4.1 KB

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