Panda3D

qtessSurface.I

00001 // Filename: qtessSurface.I
00002 // Created by:  drose (13Oct03)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 
00016 ////////////////////////////////////////////////////////////////////
00017 //     Function: QtessSurface::get_name
00018 //       Access: Public
00019 //  Description:
00020 ////////////////////////////////////////////////////////////////////
00021 INLINE const string &QtessSurface::
00022 get_name() const {
00023   return _egg_surface->get_name();
00024 }
00025 
00026 ////////////////////////////////////////////////////////////////////
00027 //     Function: QtessSurface::is_valid
00028 //       Access: Public
00029 //  Description: Returns true if the defined surface is valid, false
00030 //               otherwise.
00031 ////////////////////////////////////////////////////////////////////
00032 INLINE bool QtessSurface::
00033 is_valid() const {
00034   return (_nurbs != (NurbsSurfaceEvaluator *)NULL);
00035 }
00036 
00037 ////////////////////////////////////////////////////////////////////
00038 //     Function: QtessSurface::set_importance
00039 //       Access: Public
00040 //  Description: Sets the importance of the surface, as a ratio in
00041 //               proportion to the square of its size.
00042 ////////////////////////////////////////////////////////////////////
00043 INLINE void QtessSurface::
00044 set_importance(double importance2) {
00045   _importance = sqrt(importance2);
00046   _importance2 = importance2;
00047 }
00048 
00049 ////////////////////////////////////////////////////////////////////
00050 //     Function: QtessSurface::set_match_u
00051 //       Access: Public
00052 //  Description: Indicates the surface to which this surface must
00053 //               match in its U direction.  If u_to_u is true, it
00054 //               matches to the other surface's U direction;
00055 //               otherwise, it matches to the other surface's V
00056 //               direction.
00057 //
00058 //               Note that the surface pointer is an indirect pointer.
00059 //               The value passed in is the address of the pointer to
00060 //               the actual surface (which may or may not be filled in
00061 //               yet).  The actual pointer may be filled in later.
00062 ////////////////////////////////////////////////////////////////////
00063 INLINE void QtessSurface::
00064 set_match_u(QtessSurface **match_u, bool match_u_to_u) {
00065   _match_u = match_u;
00066   _match_u_to_u = match_u_to_u;
00067 }
00068 
00069 ////////////////////////////////////////////////////////////////////
00070 //     Function: QtessSurface::set_match_v
00071 //       Access: Public
00072 //  Description: Indicates the surface to which this surface must
00073 //               match in its V direction.  If v_to_v is true, it
00074 //               matches to the other surface's V direction;
00075 //               otherwise, it matches to the other surface's U
00076 //               direction.
00077 //
00078 //               Note that the surface pointer is an indirect pointer.
00079 //               The value passed in is the address of the pointer to
00080 //               the actual surface (which may or may not be filled in
00081 //               yet).  The actual pointer may be filled in later.
00082 ////////////////////////////////////////////////////////////////////
00083 INLINE void QtessSurface::
00084 set_match_v(QtessSurface **match_v, bool match_v_to_v) {
00085   _match_v = match_v;
00086   _match_v_to_v = match_v_to_v;
00087 }
00088 
00089 ////////////////////////////////////////////////////////////////////
00090 //     Function: QtessSurface::set_min_u
00091 //       Access: Public
00092 //  Description: Specifies the absolute minimum number of segments
00093 //               allowed in the U direction.
00094 ////////////////////////////////////////////////////////////////////
00095 INLINE void QtessSurface::
00096 set_min_u(int min_u) {
00097   _min_u = min_u;
00098 }
00099 
00100 ////////////////////////////////////////////////////////////////////
00101 //     Function: QtessSurface::set_min_v
00102 //       Access: Public
00103 //  Description: Specifies the absolute minimum number of segments
00104 //               allowed in the V direction.
00105 ////////////////////////////////////////////////////////////////////
00106 INLINE void QtessSurface::
00107 set_min_v(int min_v) {
00108   _min_v = min_v;
00109 }
00110 
00111 
00112 ////////////////////////////////////////////////////////////////////
00113 //     Function: QtessSurface::count_patches
00114 //       Access: Public
00115 //  Description: Returns the number of patches the NURBS contains.
00116 //               Each patch is a square area bounded by isoparams.
00117 //               This actually scales by the importance of the
00118 //               surface, if it is not 1.
00119 ////////////////////////////////////////////////////////////////////
00120 INLINE double QtessSurface::
00121 count_patches() const {
00122   return _num_u * _num_v * _importance2;
00123 }
00124 
00125 ////////////////////////////////////////////////////////////////////
00126 //     Function: QtessSurface::count_tris
00127 //       Access: Public
00128 //  Description: Returns the number of triangles that will be
00129 //               generated by the current tesselation parameters.
00130 ////////////////////////////////////////////////////////////////////
00131 INLINE int QtessSurface::
00132 count_tris() const {
00133   return _tess_u * _tess_v * 2;
00134 }
00135 
00136 ////////////////////////////////////////////////////////////////////
00137 //     Function: QtessSurface::get_joint_membership_index
00138 //       Access: Public
00139 //  Description: Returns the extra dimension number within the surface
00140 //               where the vertex membership in the indicated joint
00141 //               should be stored.
00142 ////////////////////////////////////////////////////////////////////
00143 INLINE int QtessSurface::
00144 get_joint_membership_index(EggGroup *joint) {
00145   JointTable::iterator jti = _joint_table.find(joint);
00146   if (jti != _joint_table.end()) {
00147     return (*jti).second;
00148   }
00149   int d = _next_d;
00150   _next_d++;
00151   _joint_table[joint] = d;
00152   return d;
00153 }
00154 
00155 ////////////////////////////////////////////////////////////////////
00156 //     Function: QtessSurface::get_dxyz_index
00157 //       Access: Public
00158 //  Description: Returns the extra dimension number within the surface
00159 //               where the indicated Dxyz morph offset should be stored.
00160 ////////////////////////////////////////////////////////////////////
00161 INLINE int QtessSurface::
00162 get_dxyz_index(const string &morph_name) {
00163   MorphTable::iterator mti = _dxyz_table.find(morph_name);
00164   if (mti != _dxyz_table.end()) {
00165     return (*mti).second;
00166   }
00167   int d = _next_d;
00168   _next_d += 3;
00169   _dxyz_table[morph_name] = d;
00170   return d;
00171 }
00172 
00173 ////////////////////////////////////////////////////////////////////
00174 //     Function: QtessSurface::get_drgba_index
00175 //       Access: Public
00176 //  Description: Returns the extra dimension number within the surface
00177 //               where the indicated Drgba morph offset should be stored.
00178 ////////////////////////////////////////////////////////////////////
00179 INLINE int QtessSurface::
00180 get_drgba_index(const string &morph_name) {
00181   MorphTable::iterator mti = _drgba_table.find(morph_name);
00182   if (mti != _drgba_table.end()) {
00183     return (*mti).second;
00184   }
00185   int d = _next_d;
00186   _next_d += 4;
00187   _drgba_table[morph_name] = d;
00188   return d;
00189 }
 All Classes Functions Variables Enumerations