Panda3D

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