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