Panda3D
qtessSurface.I
1 // Filename: qtessSurface.I
2 // Created by: drose (13Oct03)
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: QtessSurface::get_name
18 // Access: Public
19 // Description:
20 ////////////////////////////////////////////////////////////////////
21 INLINE const string &QtessSurface::
22 get_name() const {
23  return _egg_surface->get_name();
24 }
25 
26 ////////////////////////////////////////////////////////////////////
27 // Function: QtessSurface::is_valid
28 // Access: Public
29 // Description: Returns true if the defined surface is valid, false
30 // otherwise.
31 ////////////////////////////////////////////////////////////////////
32 INLINE bool QtessSurface::
33 is_valid() const {
34  return (_nurbs != (NurbsSurfaceEvaluator *)NULL);
35 }
36 
37 ////////////////////////////////////////////////////////////////////
38 // Function: QtessSurface::set_importance
39 // Access: Public
40 // Description: Sets the importance of the surface, as a ratio in
41 // proportion to the square of its size.
42 ////////////////////////////////////////////////////////////////////
43 INLINE void QtessSurface::
44 set_importance(double importance2) {
45  _importance = sqrt(importance2);
46  _importance2 = importance2;
47 }
48 
49 ////////////////////////////////////////////////////////////////////
50 // Function: QtessSurface::set_match_u
51 // Access: Public
52 // Description: Indicates the surface to which this surface must
53 // match in its U direction. If u_to_u is true, it
54 // matches to the other surface's U direction;
55 // otherwise, it matches to the other surface's V
56 // direction.
57 //
58 // Note that the surface pointer is an indirect pointer.
59 // The value passed in is the address of the pointer to
60 // the actual surface (which may or may not be filled in
61 // yet). The actual pointer may be filled in later.
62 ////////////////////////////////////////////////////////////////////
63 INLINE void QtessSurface::
64 set_match_u(QtessSurface **match_u, bool match_u_to_u) {
65  _match_u = match_u;
66  _match_u_to_u = match_u_to_u;
67 }
68 
69 ////////////////////////////////////////////////////////////////////
70 // Function: QtessSurface::set_match_v
71 // Access: Public
72 // Description: Indicates the surface to which this surface must
73 // match in its V direction. If v_to_v is true, it
74 // matches to the other surface's V direction;
75 // otherwise, it matches to the other surface's U
76 // direction.
77 //
78 // Note that the surface pointer is an indirect pointer.
79 // The value passed in is the address of the pointer to
80 // the actual surface (which may or may not be filled in
81 // yet). The actual pointer may be filled in later.
82 ////////////////////////////////////////////////////////////////////
83 INLINE void QtessSurface::
84 set_match_v(QtessSurface **match_v, bool match_v_to_v) {
85  _match_v = match_v;
86  _match_v_to_v = match_v_to_v;
87 }
88 
89 ////////////////////////////////////////////////////////////////////
90 // Function: QtessSurface::set_min_u
91 // Access: Public
92 // Description: Specifies the absolute minimum number of segments
93 // allowed in the U direction.
94 ////////////////////////////////////////////////////////////////////
95 INLINE void QtessSurface::
96 set_min_u(int min_u) {
97  _min_u = min_u;
98 }
99 
100 ////////////////////////////////////////////////////////////////////
101 // Function: QtessSurface::set_min_v
102 // Access: Public
103 // Description: Specifies the absolute minimum number of segments
104 // allowed in the V direction.
105 ////////////////////////////////////////////////////////////////////
106 INLINE void QtessSurface::
107 set_min_v(int min_v) {
108  _min_v = min_v;
109 }
110 
111 
112 ////////////////////////////////////////////////////////////////////
113 // Function: QtessSurface::count_patches
114 // Access: Public
115 // Description: Returns the number of patches the NURBS contains.
116 // Each patch is a square area bounded by isoparams.
117 // This actually scales by the importance of the
118 // surface, if it is not 1.
119 ////////////////////////////////////////////////////////////////////
120 INLINE double QtessSurface::
121 count_patches() const {
122  return _num_u * _num_v * _importance2;
123 }
124 
125 ////////////////////////////////////////////////////////////////////
126 // Function: QtessSurface::count_tris
127 // Access: Public
128 // Description: Returns the number of triangles that will be
129 // generated by the current tesselation parameters.
130 ////////////////////////////////////////////////////////////////////
131 INLINE int QtessSurface::
132 count_tris() const {
133  return _tess_u * _tess_v * 2;
134 }
135 
136 ////////////////////////////////////////////////////////////////////
137 // Function: QtessSurface::get_joint_membership_index
138 // Access: Public
139 // Description: Returns the extra dimension number within the surface
140 // where the vertex membership in the indicated joint
141 // should be stored.
142 ////////////////////////////////////////////////////////////////////
143 INLINE int QtessSurface::
144 get_joint_membership_index(EggGroup *joint) {
145  JointTable::iterator jti = _joint_table.find(joint);
146  if (jti != _joint_table.end()) {
147  return (*jti).second;
148  }
149  int d = _next_d;
150  _next_d++;
151  _joint_table[joint] = d;
152  return d;
153 }
154 
155 ////////////////////////////////////////////////////////////////////
156 // Function: QtessSurface::get_dxyz_index
157 // Access: Public
158 // Description: Returns the extra dimension number within the surface
159 // where the indicated Dxyz morph offset should be stored.
160 ////////////////////////////////////////////////////////////////////
161 INLINE int QtessSurface::
162 get_dxyz_index(const string &morph_name) {
163  MorphTable::iterator mti = _dxyz_table.find(morph_name);
164  if (mti != _dxyz_table.end()) {
165  return (*mti).second;
166  }
167  int d = _next_d;
168  _next_d += 3;
169  _dxyz_table[morph_name] = d;
170  return d;
171 }
172 
173 ////////////////////////////////////////////////////////////////////
174 // Function: QtessSurface::get_drgba_index
175 // Access: Public
176 // Description: Returns the extra dimension number within the surface
177 // where the indicated Drgba morph offset should be stored.
178 ////////////////////////////////////////////////////////////////////
179 INLINE int QtessSurface::
180 get_drgba_index(const string &morph_name) {
181  MorphTable::iterator mti = _drgba_table.find(morph_name);
182  if (mti != _drgba_table.end()) {
183  return (*mti).second;
184  }
185  int d = _next_d;
186  _next_d += 4;
187  _drgba_table[morph_name] = d;
188  return d;
189 }
A reference to an EggNurbsSurface in the egg file, and its parameters as set by the user input file a...
Definition: qtessSurface.h:34
int count_tris() const
Returns the number of triangles that will be generated by the current tesselation parameters...
Definition: qtessSurface.I:132
void set_importance(double importance2)
Sets the importance of the surface, as a ratio in proportion to the square of its size...
Definition: qtessSurface.I:44
void set_match_v(QtessSurface **match_v, bool match_v_to_v)
Indicates the surface to which this surface must match in its V direction.
Definition: qtessSurface.I:84
This class is an abstraction for evaluating NURBS surfaces.
void set_match_u(QtessSurface **match_u, bool match_u_to_u)
Indicates the surface to which this surface must match in its U direction.
Definition: qtessSurface.I:64
The main glue of the egg hierarchy, this corresponds to the <Group>, <Instance>, and <Joint> type nod...
Definition: eggGroup.h:36
void set_min_v(int min_v)
Specifies the absolute minimum number of segments allowed in the V direction.
Definition: qtessSurface.I:107
bool is_valid() const
Returns true if the defined surface is valid, false otherwise.
Definition: qtessSurface.I:33
void set_min_u(int min_u)
Specifies the absolute minimum number of segments allowed in the U direction.
Definition: qtessSurface.I:96
double count_patches() const
Returns the number of patches the NURBS contains.
Definition: qtessSurface.I:121