Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

panda/src/builder/builderAttribTempl.I

Go to the documentation of this file.
00001 // Filename: builderAttribTempl.I
00002 // Created by:  drose (17Sep97)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
00008 //
00009 // All use of this software is subject to the terms of the Panda 3d
00010 // Software license.  You should have received a copy of this license
00011 // along with this source code; you will also find a current copy of
00012 // the license at http://www.panda3d.org/license.txt .
00013 //
00014 // To contact the maintainers of this program write to
00015 // panda3d@yahoogroups.com .
00016 //
00017 ////////////////////////////////////////////////////////////////////
00018 
00019 
00020 ////////////////////////////////////////////////////////////////////
00021 //     Function: BuilderAttribTempl::Constructor
00022 //       Access: Public
00023 //  Description:
00024 ////////////////////////////////////////////////////////////////////
00025 template <class VT, class NT, class TT, class CT>
00026 INLINE BuilderAttribTempl<VT, NT, TT, CT>::
00027 BuilderAttribTempl() {
00028   _flags = 0;
00029 }
00030 
00031 
00032 ////////////////////////////////////////////////////////////////////
00033 //     Function: BuilderAttribTempl::Copy constructor
00034 //       Access: Public
00035 //  Description:
00036 ////////////////////////////////////////////////////////////////////
00037 template <class VT, class NT, class TT, class CT>
00038 INLINE BuilderAttribTempl<VT, NT, TT, CT>::
00039 BuilderAttribTempl(const BuilderAttribTempl &copy) {
00040   (*this) = copy;
00041 }
00042 
00043 
00044 ////////////////////////////////////////////////////////////////////
00045 //     Function: BuilderAttribTempl::Copy assignment operator
00046 //       Access: Public
00047 //  Description:
00048 ////////////////////////////////////////////////////////////////////
00049 template <class VT, class NT, class TT, class CT>
00050 INLINE BuilderAttribTempl<VT, NT, TT, CT> &BuilderAttribTempl<VT, NT, TT, CT>::
00051 operator = (const BuilderAttribTempl<VT, NT, TT, CT> &copy) {
00052   _normal = copy._normal;
00053   _color = copy._color;
00054   _pixel_size = copy._pixel_size;
00055   _flags = copy._flags;
00056 
00057   return *this;
00058 }
00059 
00060 
00061 ////////////////////////////////////////////////////////////////////
00062 //     Function: BuilderAttribTempl::clear
00063 //       Access: Public
00064 //  Description: Resets the attribute flags to their original, empty
00065 //               state--where no attributes have been applied.
00066 ////////////////////////////////////////////////////////////////////
00067 template <class VT, class NT, class TT, class CT>
00068 INLINE BuilderAttribTempl<VT, NT, TT, CT> &BuilderAttribTempl<VT, NT, TT, CT>::
00069 clear() {
00070   _flags = 0;
00071   return *this;
00072 }
00073 
00074 
00075 ////////////////////////////////////////////////////////////////////
00076 //     Function: BuilderAttribTempl::has_normal
00077 //       Access: Public
00078 //  Description: Returns true if the attribute has a normal.
00079 ////////////////////////////////////////////////////////////////////
00080 template <class VT, class NT, class TT, class CT>
00081 INLINE bool BuilderAttribTempl<VT, NT, TT, CT>::
00082 has_normal() const {
00083   return (_flags & BAF_normal)!=0;
00084 }
00085 
00086 
00087 ////////////////////////////////////////////////////////////////////
00088 //     Function: BuilderAttribTempl::get_normal
00089 //       Access: Public
00090 //  Description: Returns the attribute's normal.  It is an error to
00091 //               call this without first verifying that has_normal() is
00092 //               true.
00093 ////////////////////////////////////////////////////////////////////
00094 template <class VT, class NT, class TT, class CT>
00095 INLINE TYPENAME BuilderAttribTempl<VT, NT, TT, CT>::NType BuilderAttribTempl<VT, NT, TT, CT>::
00096 get_normal() const {
00097   nassertr(has_normal(), _normal);
00098   return _normal;
00099 }
00100 
00101 
00102 ////////////////////////////////////////////////////////////////////
00103 //     Function: BuilderAttribTempl::set_normal
00104 //       Access: Public
00105 //  Description: Resets the attribute's normal.
00106 ////////////////////////////////////////////////////////////////////
00107 template <class VT, class NT, class TT, class CT>
00108 INLINE BuilderAttribTempl<VT, NT, TT, CT> &BuilderAttribTempl<VT, NT, TT, CT>::
00109 set_normal(const NType &n) {
00110   _flags |= BAF_normal;
00111   _normal = n;
00112   return *this;
00113 }
00114 
00115 ////////////////////////////////////////////////////////////////////
00116 //     Function: BuilderAttribTempl::clear_normal
00117 //       Access: Public
00118 //  Description: Removes the attribute's normal.
00119 ////////////////////////////////////////////////////////////////////
00120 template <class VT, class NT, class TT, class CT>
00121 INLINE BuilderAttribTempl<VT, NT, TT, CT> &BuilderAttribTempl<VT, NT, TT, CT>::
00122 clear_normal() {
00123   _flags &= ~BAF_normal;
00124   return *this;
00125 }
00126 
00127 
00128 ////////////////////////////////////////////////////////////////////
00129 //     Function: BuilderAttribTempl::has_color
00130 //       Access: Public
00131 //  Description: Returns true if the attribute has a color.
00132 ////////////////////////////////////////////////////////////////////
00133 template <class VT, class NT, class TT, class CT>
00134 INLINE bool BuilderAttribTempl<VT, NT, TT, CT>::
00135 has_color() const {
00136   return (_flags & BAF_color)!=0;
00137 }
00138 
00139 
00140 ////////////////////////////////////////////////////////////////////
00141 //     Function: BuilderAttribTempl::get_color
00142 //       Access: Public
00143 //  Description: Returns the attribute's color.  It is an error to
00144 //               call this without first verifying that has_color() is
00145 //               true.
00146 ////////////////////////////////////////////////////////////////////
00147 template <class VT, class NT, class TT, class CT>
00148 INLINE TYPENAME BuilderAttribTempl<VT, NT, TT, CT>::CType BuilderAttribTempl<VT, NT, TT, CT>::
00149 get_color() const {
00150   nassertr(has_color(), _color);
00151   return _color;
00152 }
00153 
00154 template <class VT, class NT, class TT, class CT>
00155 
00156 ////////////////////////////////////////////////////////////////////
00157 //     Function: BuilderAttribTempl::set_color
00158 //       Access: Public
00159 //  Description: Resets the attribute's color.
00160 ////////////////////////////////////////////////////////////////////
00161 INLINE BuilderAttribTempl<VT, NT, TT, CT> &BuilderAttribTempl<VT, NT, TT, CT>::
00162 set_color(const CType &c) {
00163   _flags |= BAF_color;
00164   _color = c;
00165   return *this;
00166 }
00167 
00168 ////////////////////////////////////////////////////////////////////
00169 //     Function: BuilderAttribTempl::clear_color
00170 //       Access: Public
00171 //  Description: Removes the attribute's color.
00172 ////////////////////////////////////////////////////////////////////
00173 template <class VT, class NT, class TT, class CT>
00174 INLINE BuilderAttribTempl<VT, NT, TT, CT> &BuilderAttribTempl<VT, NT, TT, CT>::
00175 clear_color() {
00176   _flags &= ~BAF_color;
00177   return *this;
00178 }
00179 
00180 
00181 ////////////////////////////////////////////////////////////////////
00182 //     Function: BuilderAttribTempl::has_pixel_size
00183 //       Access: Public
00184 //  Description: Returns true if the attribute has a pixel_size.
00185 ////////////////////////////////////////////////////////////////////
00186 template <class VT, class NT, class TT, class CT>
00187 INLINE bool BuilderAttribTempl<VT, NT, TT, CT>::
00188 has_pixel_size() const {
00189   return (_flags & BAF_pixel_size)!=0;
00190 }
00191 
00192 
00193 ////////////////////////////////////////////////////////////////////
00194 //     Function: BuilderAttribTempl::get_pixel_size
00195 //       Access: Public
00196 //  Description: Returns the attribute's pixel_size.  It is an error to
00197 //               call this without first verifying that has_pixel_size() is
00198 //               true.
00199 ////////////////////////////////////////////////////////////////////
00200 template <class VT, class NT, class TT, class CT>
00201 INLINE float BuilderAttribTempl<VT, NT, TT, CT>::
00202 get_pixel_size() const {
00203   nassertr(has_pixel_size(), _pixel_size);
00204   return _pixel_size;
00205 }
00206 
00207 
00208 ////////////////////////////////////////////////////////////////////
00209 //     Function: BuilderAttribTempl::set_pixel_size
00210 //       Access: Public
00211 //  Description: Resets the attribute's pixel_size.
00212 ////////////////////////////////////////////////////////////////////
00213 template <class VT, class NT, class TT, class CT>
00214 INLINE BuilderAttribTempl<VT, NT, TT, CT> &BuilderAttribTempl<VT, NT, TT, CT>::
00215 set_pixel_size(float s) {
00216   _flags |= BAF_pixel_size;
00217   _pixel_size = s;
00218   return *this;
00219 }
00220 
00221 ////////////////////////////////////////////////////////////////////
00222 //     Function: BuilderAttribTempl::clear_pixel_size
00223 //       Access: Public
00224 //  Description: Removes the attribute's pixel_size.
00225 ////////////////////////////////////////////////////////////////////
00226 template <class VT, class NT, class TT, class CT>
00227 INLINE BuilderAttribTempl<VT, NT, TT, CT> &BuilderAttribTempl<VT, NT, TT, CT>::
00228 clear_pixel_size() {
00229   _flags &= ~BAF_pixel_size;
00230   return *this;
00231 }
00232 
00233 ////////////////////////////////////////////////////////////////////
00234 //     Function: BuilderAttribTempl::operator ==
00235 //       Access: Public
00236 //  Description: Assigns an ordering to the vertices.  This is used by
00237 //               the Mesher to group identical vertices.  This assumes
00238 //               that all vertices in the locus of consideration will
00239 //               share the same state: with or without normals,
00240 //               texcoords, etc.
00241 ////////////////////////////////////////////////////////////////////
00242 template <class VT, class NT, class TT, class CT>
00243 INLINE bool BuilderAttribTempl<VT, NT, TT, CT>::
00244 operator == (const BuilderAttribTempl<VT, NT, TT, CT> &other) const {
00245   return compare_to(other) == 0;
00246 }
00247 
00248 ////////////////////////////////////////////////////////////////////
00249 //     Function: BuilderAttribTempl::operator !=
00250 //       Access: Public
00251 //  Description: Assigns an ordering to the vertices.  This is used by
00252 //               the Mesher to group identical vertices.  This assumes
00253 //               that all vertices in the locus of consideration will
00254 //               share the same state: with or without normals,
00255 //               texcoords, etc.
00256 ////////////////////////////////////////////////////////////////////
00257 template <class VT, class NT, class TT, class CT>
00258 INLINE bool BuilderAttribTempl<VT, NT, TT, CT>::
00259 operator != (const BuilderAttribTempl<VT, NT, TT, CT> &other) const {
00260   return !operator == (other);
00261 }
00262 
00263 ////////////////////////////////////////////////////////////////////
00264 //     Function: BuilderAttribTempl::operator <
00265 //       Access: Public
00266 //  Description: Assigns an ordering to the vertices.  This is used by
00267 //               the Mesher to group identical vertices.  This assumes
00268 //               that all vertices in the locus of consideration will
00269 //               share the same state: with or without normals,
00270 //               texcoords, etc.
00271 ////////////////////////////////////////////////////////////////////
00272 template <class VT, class NT, class TT, class CT>
00273 INLINE bool BuilderAttribTempl<VT, NT, TT, CT>::
00274 operator < (const BuilderAttribTempl<VT, NT, TT, CT> &other) const {
00275   return compare_to(other) < 0;
00276 }
00277 
00278 ////////////////////////////////////////////////////////////////////
00279 //     Function: BuilderAttribTempl::compare_to
00280 //       Access: Public
00281 //  Description: Returns a number less than zero if this object sorts
00282 //               before the indicated object, greater than zero if it
00283 //               sorts after, and zero if the objects are equivalent.
00284 ////////////////////////////////////////////////////////////////////
00285 template <class VT, class NT, class TT, class CT>
00286 int BuilderAttribTempl<VT, NT, TT, CT>::
00287 compare_to(const BuilderAttribTempl<VT, NT, TT, CT> &other) const {
00288   if (has_normal()) {
00289     int normal_compare = builder_compare(_normal, other._normal);
00290     if (normal_compare != 0) {
00291       return normal_compare;
00292     }
00293   }
00294 
00295   if (has_color()) {
00296     int color_compare = builder_compare(_color, other._color);
00297     if (color_compare != 0) {
00298       return color_compare;
00299     }
00300   }
00301 
00302   return 0;
00303 }
00304 
00305 ////////////////////////////////////////////////////////////////////
00306 //     Function: BuilderAttribTempl::output
00307 //       Access: Public
00308 //  Description: Formats the attribs for output in some sensible way.
00309 ////////////////////////////////////////////////////////////////////
00310 template <class VT, class NT, class TT, class CT>
00311 ostream &BuilderAttribTempl<VT, NT, TT, CT>::
00312 output(ostream &out) const {
00313   if (this!=NULL) {
00314     if (has_normal()) {
00315       out << " normal " << get_normal();
00316     }
00317 
00318     if (has_color()) {
00319       out << " color " << get_color();
00320     }
00321   }
00322   return out;
00323 }

Generated on Fri May 2 00:34:40 2003 for Panda by doxygen1.3