Panda3D
sheetNode.I
1 // Filename: sheetNode.I
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 
16 ////////////////////////////////////////////////////////////////////
17 // Function: SheetNode::CData::Constructor
18 // Access: Public
19 // Description:
20 ////////////////////////////////////////////////////////////////////
21 INLINE SheetNode::CData::
22 CData() {
23  _surface = new NurbsSurfaceEvaluator;
24  _use_vertex_color = false;
25  _num_u_subdiv = 2;
26  _num_v_subdiv = 2;
27 }
28 
29 ////////////////////////////////////////////////////////////////////
30 // Function: SheetNode::CData::Copy Constructor
31 // Access: Public
32 // Description:
33 ////////////////////////////////////////////////////////////////////
34 INLINE SheetNode::CData::
35 CData(const SheetNode::CData &copy) :
36  _surface(copy._surface),
37  _use_vertex_color(copy._use_vertex_color),
38  _num_u_subdiv(copy._num_u_subdiv),
39  _num_v_subdiv(copy._num_v_subdiv)
40 {
41 }
42 
43 ////////////////////////////////////////////////////////////////////
44 // Function: set_surface
45 // Access: Public
46 // Description: Sets the particular surface represented by the
47 // SheetNode.
48 ////////////////////////////////////////////////////////////////////
49 INLINE void SheetNode::
51  CDWriter cdata(_cycler);
52  cdata->_surface = surface;
53 }
54 
55 ////////////////////////////////////////////////////////////////////
56 // Function: get_surface
57 // Access: Public
58 // Description: Returns the surface represented by the SheetNode.
59 ////////////////////////////////////////////////////////////////////
61 get_surface() const {
62  CDReader cdata(_cycler);
63  return cdata->_surface;
64 }
65 
66 ////////////////////////////////////////////////////////////////////
67 // Function: set_use_vertex_color
68 // Access: Public
69 // Description: Sets the "use vertex color" flag. When this is true,
70 // the R, G, B, A vertex color is assumed to be stored
71 // as the dimensions 0, 1, 2, 3, respectively, of the
72 // extended vertex values. Use
73 // NurbsCurveEvaluator::set_extended_vertex() to set
74 // these values.
75 ////////////////////////////////////////////////////////////////////
76 INLINE void SheetNode::
78  CDWriter cdata(_cycler);
79  cdata->_use_vertex_color = flag;
80 }
81 
82 ////////////////////////////////////////////////////////////////////
83 // Function: get_use_vertex_color
84 // Access: Public
85 // Description: Returns the "use vertex color" flag. See
86 // set_use_vertex_color().
87 ////////////////////////////////////////////////////////////////////
88 INLINE bool SheetNode::
90  CDReader cdata(_cycler);
91  return cdata->_use_vertex_color;
92 }
93 
94 ////////////////////////////////////////////////////////////////////
95 // Function: set_num_u_subdiv
96 // Access: Public
97 // Description: Specifies the number of subdivisions per cubic
98 // segment (that is, per unique knot value) to draw in a
99 // fixed uniform tesselation of the surface in the U
100 // direction.
101 ////////////////////////////////////////////////////////////////////
102 INLINE void SheetNode::
103 set_num_u_subdiv(int num_u_subdiv) {
104  nassertv(num_u_subdiv >= 0);
105  CDWriter cdata(_cycler);
106  cdata->_num_u_subdiv = num_u_subdiv;
107 }
108 
109 ////////////////////////////////////////////////////////////////////
110 // Function: get_num_u_subdiv
111 // Access: Public
112 // Description: Returns the number of subdivisions per cubic segment
113 // to draw in the U direction. See set_num_u_subdiv().
114 ////////////////////////////////////////////////////////////////////
115 INLINE int SheetNode::
117  CDReader cdata(_cycler);
118  return cdata->_num_u_subdiv;
119 }
120 
121 ////////////////////////////////////////////////////////////////////
122 // Function: set_num_v_subdiv
123 // Access: Public
124 // Description: Specifies the number of subdivisions per cubic
125 // segment (that is, per unique knot value) to draw in a
126 // fixed uniform tesselation of the surface in the V
127 // direction.
128 ////////////////////////////////////////////////////////////////////
129 INLINE void SheetNode::
130 set_num_v_subdiv(int num_v_subdiv) {
131  nassertv(num_v_subdiv >= 0);
132  CDWriter cdata(_cycler);
133  cdata->_num_v_subdiv = num_v_subdiv;
134 }
135 
136 ////////////////////////////////////////////////////////////////////
137 // Function: get_num_v_subdiv
138 // Access: Public
139 // Description: Returns the number of subdivisions per cubic segment
140 // to draw in the V direction. See set_num_v_subdiv().
141 ////////////////////////////////////////////////////////////////////
142 INLINE int SheetNode::
144  CDReader cdata(_cycler);
145  return cdata->_num_v_subdiv;
146 }
void set_num_v_subdiv(int num_v_subdiv)
Specifies the number of subdivisions per cubic segment (that is, per unique knot value) to draw in a ...
Definition: sheetNode.I:130
int get_num_u_subdiv() const
Returns the number of subdivisions per cubic segment to draw in the U direction.
Definition: sheetNode.I:116
NurbsSurfaceEvaluator * get_surface() const
Returns the surface represented by the SheetNode.
Definition: sheetNode.I:61
This class is an abstraction for evaluating NURBS surfaces.
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...
void set_surface(NurbsSurfaceEvaluator *surface)
Sets the particular surface represented by the SheetNode.
Definition: sheetNode.I:50
void set_num_u_subdiv(int num_u_subdiv)
Specifies the number of subdivisions per cubic segment (that is, per unique knot value) to draw in a ...
Definition: sheetNode.I:103
void set_use_vertex_color(bool flag)
Sets the "use vertex color" flag.
Definition: sheetNode.I:77
int get_num_v_subdiv() const
Returns the number of subdivisions per cubic segment to draw in the V direction.
Definition: sheetNode.I:143
bool get_use_vertex_color() const
Returns the "use vertex color" flag.
Definition: sheetNode.I:89