Panda3D
 All Classes Functions Variables Enumerations
sheetNode.h
1 // Filename: sheetNode.h
2 // Created by: drose (11Oct03)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef SHEETNODE_H
16 #define SHEETNODE_H
17 
18 #include "pandabase.h"
19 #include "nurbsSurfaceEvaluator.h"
20 #include "pandaNode.h"
21 #include "pStatCollector.h"
22 
23 ////////////////////////////////////////////////////////////////////
24 // Class : SheetNode
25 // Description : This class draws a visible representation of the
26 // NURBS surface stored in its NurbsSurfaceEvaluator. It
27 // automatically recomputes the surface every frame.
28 //
29 // This is not related to NurbsSurface, CubicSurfaceseg
30 // or any of the ParametricSurface-derived objects in
31 // this module. It is a completely parallel
32 // implementation of NURBS surfaces, and will probably
33 // eventually replace the whole ParametricSurface class
34 // hierarchy.
35 ////////////////////////////////////////////////////////////////////
36 class EXPCL_PANDA_PARAMETRICS SheetNode : public PandaNode {
37 PUBLISHED:
38  SheetNode(const string &name);
39 
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 
46  virtual PandaNode *make_copy() const;
47 
48  virtual bool safe_to_transform() const;
49  virtual bool cull_callback(CullTraverser *trav, CullTraverserData &data);
50  virtual bool is_renderable() const;
51 
52 PUBLISHED:
53  INLINE void set_surface(NurbsSurfaceEvaluator *surface);
54  INLINE NurbsSurfaceEvaluator *get_surface() const;
55 
56  INLINE void set_use_vertex_color(bool flag);
57  INLINE bool get_use_vertex_color() const;
58 
59  INLINE void set_num_u_subdiv(int num_u_subdiv);
60  INLINE int get_num_u_subdiv() const;
61  INLINE void set_num_v_subdiv(int num_v_subdiv);
62  INLINE int get_num_v_subdiv() const;
63 
64  void reset_bound(const NodePath &rel_to);
65 
66 protected:
67  virtual void compute_internal_bounds(CPT(BoundingVolume) &internal_bounds,
68  int &internal_vertices,
69  int pipeline_stage,
70  Thread *current_thread) const;
71 
72 private:
73  PT(BoundingVolume) do_recompute_bounds(const NodePath &rel_to,
74  int pipeline_stage,
75  Thread *current_thread) const;
76  void render_sheet(CullTraverser *trav, CullTraverserData &data,
77  NurbsSurfaceResult *result);
78 
79 private:
80  // This is the data that must be cycled between pipeline stages.
81  class EXPCL_PANDA_PARAMETRICS CData : public CycleData {
82  public:
83  INLINE CData();
84  INLINE CData(const CData &copy);
85  virtual CycleData *make_copy() const;
86  virtual void write_datagram(BamWriter *manager, Datagram &dg) const;
87  virtual void fillin(DatagramIterator &scan, BamReader *manager);
88  virtual TypeHandle get_parent_type() const {
89  return SheetNode::get_class_type();
90  }
91 
92  PT(NurbsSurfaceEvaluator) _surface;
93  bool _use_vertex_color;
94  int _num_u_subdiv;
95  int _num_v_subdiv;
96  };
97 
98  PipelineCycler<CData> _cycler;
101 
102  static PStatCollector _sheet_node_pcollector;
103 
104 public:
105  static void register_with_read_factory();
106  virtual void write_datagram(BamWriter *manager, Datagram &dg);
107 
108 protected:
109  static TypedWritable *make_from_bam(const FactoryParams &params);
110  void fillin(DatagramIterator &scan, BamReader *manager);
111 
112 public:
113  static TypeHandle get_class_type() {
114  return _type_handle;
115  }
116  static void init_type() {
117  PandaNode::init_type();
118  register_type(_type_handle, "SheetNode",
119  PandaNode::get_class_type());
120  }
121  virtual TypeHandle get_type() const {
122  return get_class_type();
123  }
124  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
125 
126 private:
127  static TypeHandle _type_handle;
128 };
129 
130 #include "sheetNode.I"
131 
132 #endif
A basic node of the scene graph or data graph.
Definition: pandaNode.h:72
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Definition: bamReader.h:122
A single page of data maintained by a PipelineCycler.
Definition: cycleData.h:50
Base class for objects that can be written to and read from Bam files.
Definition: typedWritable.h:37
This collects together the pieces of data that are accumulated for each node while walking the scene ...
virtual PandaNode * make_copy() const
Returns a newly-allocated PandaNode that is a shallow copy of this one.
Definition: pandaNode.cxx:604
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
Definition: bamWriter.h:73
This class is an abstraction for evaluating NURBS surfaces.
This template class calls PipelineCycler::read_unlocked(), and then provides a transparent read-only ...
This is an abstract class for any volume in any sense which can be said to define the locality of ref...
A lightweight class that represents a single element that may be timed and/or counted via stats...
This class draws a visible representation of the NURBS surface stored in its NurbsSurfaceEvaluator.
Definition: sheetNode.h:36
virtual bool safe_to_transform() const
Returns true if it is generally safe to transform this particular kind of PandaNode by calling the xf...
Definition: pandaNode.cxx:249
The result of a NurbsSurfaceEvaluator.
An instance of this class is passed to the Factory when requesting it to do its business and construc...
Definition: factoryParams.h:40
virtual bool is_renderable() const
Returns true if there is some value to visiting this particular node during the cull traversal for an...
Definition: pandaNode.cxx:578
This template class calls PipelineCycler::write() in the constructor and PipelineCycler::release_writ...
virtual void fillin(DatagramIterator &scan, BamReader *manager)
This internal function is intended to be called by each class&#39;s make_from_bam() method to read in all...
Definition: cycleData.cxx:68
A thread; that is, a lightweight process.
Definition: thread.h:51
A class to retrieve the individual data elements previously stored in a Datagram. ...
virtual void write_datagram(BamWriter *, Datagram &) const
Writes the contents of this object to the datagram for shipping out to a Bam file.
Definition: cycleData.cxx:34
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition: datagram.h:43
NodePath is the fundamental system for disambiguating instances, and also provides a higher-level int...
Definition: nodePath.h:165
This object performs a depth-first traversal of the scene graph, with optional view-frustum culling...
Definition: cullTraverser.h:48
virtual bool cull_callback(CullTraverser *trav, CullTraverserData &data)
This function will be called during the cull traversal to perform any additional operations that shou...
Definition: pandaNode.cxx:477