renderEffect.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. // Filename: renderEffect.h
  2. // Created by: drose (14Mar02)
  3. //
  4. ////////////////////////////////////////////////////////////////////
  5. //
  6. // PANDA 3D SOFTWARE
  7. // Copyright (c) 2001 - 2004, 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://etc.cmu.edu/panda3d/docs/license/ .
  13. //
  14. // To contact the maintainers of this program write to
  15. // [email protected] .
  16. //
  17. ////////////////////////////////////////////////////////////////////
  18. #ifndef RENDEREFFECT_H
  19. #define RENDEREFFECT_H
  20. #include "pandabase.h"
  21. #include "transformState.h"
  22. #include "renderState.h"
  23. #include "typedWritableReferenceCount.h"
  24. #include "pointerTo.h"
  25. #include "pset.h"
  26. #include "luse.h"
  27. class CullTraverser;
  28. class CullTraverserData;
  29. ////////////////////////////////////////////////////////////////////
  30. // Class : RenderEffect
  31. // Description : This is the base class for a number of special render
  32. // effects that may be set on scene graph nodes to
  33. // change the way they render. This includes
  34. // BillboardEffect, DecalEffect, etc.
  35. //
  36. // RenderEffect represents render properties that must
  37. // be applied as soon as they are encountered in the
  38. // scene graph, rather than propagating down to the
  39. // leaves. This is different from RenderAttrib, which
  40. // represents properties like color and texture that
  41. // don't do anything until they propagate down to a
  42. // GeomNode.
  43. //
  44. // You should not attempt to create or modify a
  45. // RenderEffect directly; instead, use the make() method
  46. // of the appropriate kind of effect you want. This
  47. // will allocate and return a new RenderEffect of the
  48. // appropriate type, and it may share pointers if
  49. // possible. Do not modify the new RenderEffect if you
  50. // wish to change its properties; instead, create a new
  51. // one.
  52. ////////////////////////////////////////////////////////////////////
  53. class EXPCL_PANDA RenderEffect : public TypedWritableReferenceCount {
  54. protected:
  55. RenderEffect();
  56. private:
  57. RenderEffect(const RenderEffect &copy);
  58. void operator = (const RenderEffect &copy);
  59. public:
  60. virtual ~RenderEffect();
  61. virtual bool safe_to_transform() const;
  62. virtual bool safe_to_combine() const;
  63. virtual CPT(RenderEffect) xform(const LMatrix4f &mat) const;
  64. virtual bool has_cull_callback() const;
  65. virtual void cull_callback(CullTraverser *trav, CullTraverserData &data,
  66. CPT(TransformState) &node_transform,
  67. CPT(RenderState) &node_state) const;
  68. PUBLISHED:
  69. INLINE int compare_to(const RenderEffect &other) const;
  70. virtual void output(ostream &out) const;
  71. virtual void write(ostream &out, int indent_level) const;
  72. static int get_num_effects();
  73. static void list_effects(ostream &out);
  74. static bool validate_effects();
  75. protected:
  76. static CPT(RenderEffect) return_new(RenderEffect *effect);
  77. virtual int compare_to_impl(const RenderEffect *other) const;
  78. private:
  79. typedef pset<const RenderEffect *, indirect_compare_to<const RenderEffect *> > Effects;
  80. static Effects *_effects;
  81. Effects::iterator _saved_entry;
  82. public:
  83. virtual void write_datagram(BamWriter *manager, Datagram &dg);
  84. static TypedWritable *change_this(TypedWritable *old_ptr, BamReader *manager);
  85. virtual void finalize();
  86. protected:
  87. static TypedWritable *new_from_bam(RenderEffect *effect, BamReader *manager);
  88. void fillin(DatagramIterator &scan, BamReader *manager);
  89. public:
  90. static TypeHandle get_class_type() {
  91. return _type_handle;
  92. }
  93. static void init_type() {
  94. TypedWritableReferenceCount::init_type();
  95. register_type(_type_handle, "RenderEffect",
  96. TypedWritableReferenceCount::get_class_type());
  97. }
  98. virtual TypeHandle get_type() const {
  99. return get_class_type();
  100. }
  101. virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
  102. private:
  103. static TypeHandle _type_handle;
  104. };
  105. INLINE ostream &operator << (ostream &out, const RenderEffect &effect) {
  106. effect.output(out);
  107. return out;
  108. }
  109. #include "renderEffect.I"
  110. #endif