sheetNode.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. // Filename: sheetNode.h
  2. // Created by: drose (11Oct03)
  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 SHEETNODE_H
  19. #define SHEETNODE_H
  20. #include "pandabase.h"
  21. #include "nurbsSurfaceEvaluator.h"
  22. #include "pandaNode.h"
  23. #include "pStatCollector.h"
  24. ////////////////////////////////////////////////////////////////////
  25. // Class : SheetNode
  26. // Description : This class draws a visible representation of the
  27. // NURBS surface stored in its NurbsSurfaceEvaluator. It
  28. // automatically recomputes the surface every frame.
  29. //
  30. // This is not related to NurbsSurface, ClassicNurbsSurface,
  31. // CubicSurfaceseg or any of the ParametricSurface-derived
  32. // objects in this module. It is a completely parallel
  33. // implementation of NURBS surfaces, and will probably
  34. // eventually replace the whole ParametricSurface class
  35. // hierarchy.
  36. ////////////////////////////////////////////////////////////////////
  37. class EXPCL_PANDA SheetNode : public PandaNode {
  38. PUBLISHED:
  39. SheetNode(const string &name);
  40. protected:
  41. SheetNode(const SheetNode &copy);
  42. public:
  43. virtual void output(ostream &out) const;
  44. virtual void write(ostream &out, int indent_level = 0) const;
  45. virtual PandaNode *make_copy() const;
  46. virtual bool safe_to_transform() const;
  47. virtual bool has_cull_callback() const;
  48. virtual bool cull_callback(CullTraverser *trav, CullTraverserData &data);
  49. PUBLISHED:
  50. INLINE void set_surface(NurbsSurfaceEvaluator *surface);
  51. INLINE NurbsSurfaceEvaluator *get_surface() const;
  52. INLINE void set_use_vertex_color(bool flag);
  53. INLINE bool get_use_vertex_color() const;
  54. INLINE void set_num_u_subdiv(int num_u_subdiv);
  55. INLINE int get_num_u_subdiv() const;
  56. INLINE void set_num_v_subdiv(int num_v_subdiv);
  57. INLINE int get_num_v_subdiv() const;
  58. void reset_bound(const NodePath &rel_to);
  59. protected:
  60. virtual BoundingVolume *recompute_internal_bound();
  61. private:
  62. BoundingVolume *do_recompute_bound(const NodePath &rel_to);
  63. void render_sheet(CullTraverser *trav, CullTraverserData &data,
  64. NurbsSurfaceResult *result);
  65. private:
  66. // This is the data that must be cycled between pipeline stages.
  67. class EXPCL_PANDA CData : public CycleData {
  68. public:
  69. INLINE CData();
  70. INLINE CData(const CData &copy);
  71. virtual CycleData *make_copy() const;
  72. virtual void write_datagram(BamWriter *manager, Datagram &dg) const;
  73. virtual void fillin(DatagramIterator &scan, BamReader *manager);
  74. virtual TypeHandle get_parent_type() const {
  75. return SheetNode::get_class_type();
  76. }
  77. PT(NurbsSurfaceEvaluator) _surface;
  78. bool _use_vertex_color;
  79. int _num_u_subdiv;
  80. int _num_v_subdiv;
  81. };
  82. PipelineCycler<CData> _cycler;
  83. typedef CycleDataReader<CData> CDReader;
  84. typedef CycleDataWriter<CData> CDWriter;
  85. static PStatCollector _sheet_node_pcollector;
  86. public:
  87. static void register_with_read_factory();
  88. virtual void write_datagram(BamWriter *manager, Datagram &dg);
  89. protected:
  90. static TypedWritable *make_from_bam(const FactoryParams &params);
  91. void fillin(DatagramIterator &scan, BamReader *manager);
  92. public:
  93. static TypeHandle get_class_type() {
  94. return _type_handle;
  95. }
  96. static void init_type() {
  97. PandaNode::init_type();
  98. register_type(_type_handle, "SheetNode",
  99. PandaNode::get_class_type());
  100. }
  101. virtual TypeHandle get_type() const {
  102. return get_class_type();
  103. }
  104. virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
  105. private:
  106. static TypeHandle _type_handle;
  107. };
  108. #include "sheetNode.I"
  109. #endif