Panda3D
|
00001 // Filename: sheetNode.h 00002 // Created by: drose (11Oct03) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 #ifndef SHEETNODE_H 00016 #define SHEETNODE_H 00017 00018 #include "pandabase.h" 00019 #include "nurbsSurfaceEvaluator.h" 00020 #include "pandaNode.h" 00021 #include "pStatCollector.h" 00022 00023 //////////////////////////////////////////////////////////////////// 00024 // Class : SheetNode 00025 // Description : This class draws a visible representation of the 00026 // NURBS surface stored in its NurbsSurfaceEvaluator. It 00027 // automatically recomputes the surface every frame. 00028 // 00029 // This is not related to NurbsSurface, CubicSurfaceseg 00030 // or any of the ParametricSurface-derived objects in 00031 // this module. It is a completely parallel 00032 // implementation of NURBS surfaces, and will probably 00033 // eventually replace the whole ParametricSurface class 00034 // hierarchy. 00035 //////////////////////////////////////////////////////////////////// 00036 class EXPCL_PANDA_PARAMETRICS SheetNode : public PandaNode { 00037 PUBLISHED: 00038 SheetNode(const string &name); 00039 00040 protected: 00041 SheetNode(const SheetNode ©); 00042 public: 00043 virtual void output(ostream &out) const; 00044 virtual void write(ostream &out, int indent_level = 0) const; 00045 00046 virtual PandaNode *make_copy() const; 00047 00048 virtual bool safe_to_transform() const; 00049 virtual bool cull_callback(CullTraverser *trav, CullTraverserData &data); 00050 virtual bool is_renderable() const; 00051 00052 PUBLISHED: 00053 INLINE void set_surface(NurbsSurfaceEvaluator *surface); 00054 INLINE NurbsSurfaceEvaluator *get_surface() const; 00055 00056 INLINE void set_use_vertex_color(bool flag); 00057 INLINE bool get_use_vertex_color() const; 00058 00059 INLINE void set_num_u_subdiv(int num_u_subdiv); 00060 INLINE int get_num_u_subdiv() const; 00061 INLINE void set_num_v_subdiv(int num_v_subdiv); 00062 INLINE int get_num_v_subdiv() const; 00063 00064 void reset_bound(const NodePath &rel_to); 00065 00066 protected: 00067 virtual void compute_internal_bounds(CPT(BoundingVolume) &internal_bounds, 00068 int &internal_vertices, 00069 int pipeline_stage, 00070 Thread *current_thread) const; 00071 00072 private: 00073 PT(BoundingVolume) do_recompute_bounds(const NodePath &rel_to, 00074 int pipeline_stage, 00075 Thread *current_thread) const; 00076 void render_sheet(CullTraverser *trav, CullTraverserData &data, 00077 NurbsSurfaceResult *result); 00078 00079 private: 00080 // This is the data that must be cycled between pipeline stages. 00081 class EXPCL_PANDA_PARAMETRICS CData : public CycleData { 00082 public: 00083 INLINE CData(); 00084 INLINE CData(const CData ©); 00085 virtual CycleData *make_copy() const; 00086 virtual void write_datagram(BamWriter *manager, Datagram &dg) const; 00087 virtual void fillin(DatagramIterator &scan, BamReader *manager); 00088 virtual TypeHandle get_parent_type() const { 00089 return SheetNode::get_class_type(); 00090 } 00091 00092 PT(NurbsSurfaceEvaluator) _surface; 00093 bool _use_vertex_color; 00094 int _num_u_subdiv; 00095 int _num_v_subdiv; 00096 }; 00097 00098 PipelineCycler<CData> _cycler; 00099 typedef CycleDataReader<CData> CDReader; 00100 typedef CycleDataWriter<CData> CDWriter; 00101 00102 static PStatCollector _sheet_node_pcollector; 00103 00104 public: 00105 static void register_with_read_factory(); 00106 virtual void write_datagram(BamWriter *manager, Datagram &dg); 00107 00108 protected: 00109 static TypedWritable *make_from_bam(const FactoryParams ¶ms); 00110 void fillin(DatagramIterator &scan, BamReader *manager); 00111 00112 public: 00113 static TypeHandle get_class_type() { 00114 return _type_handle; 00115 } 00116 static void init_type() { 00117 PandaNode::init_type(); 00118 register_type(_type_handle, "SheetNode", 00119 PandaNode::get_class_type()); 00120 } 00121 virtual TypeHandle get_type() const { 00122 return get_class_type(); 00123 } 00124 virtual TypeHandle force_init_type() {init_type(); return get_class_type();} 00125 00126 private: 00127 static TypeHandle _type_handle; 00128 }; 00129 00130 #include "sheetNode.I" 00131 00132 #endif