Panda3D

eggVertexUV.I

00001 // Filename: eggVertexUV.I
00002 // Created by:  drose (20Jul04)
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: EggVertexUV::filter_name
00018 //       Access: Published, Static
00019 //  Description: Returns the actual name that should be set for a
00020 //               given name string.  Usually this is the same string
00021 //               that is input, but for historical reasons the texture
00022 //               coordinate name "default" is mapped to the empty
00023 //               string.
00024 ////////////////////////////////////////////////////////////////////
00025 INLINE string EggVertexUV::
00026 filter_name(const string &name) {
00027   if (name == "default") {
00028     return string();
00029   }
00030   return name;
00031 }
00032 
00033 ////////////////////////////////////////////////////////////////////
00034 //     Function: EggVertexUV::set_name
00035 //       Access: Published
00036 //  Description:
00037 ////////////////////////////////////////////////////////////////////
00038 INLINE void EggVertexUV::
00039 set_name(const string &name) {
00040   Namable::set_name(filter_name(name));
00041 }
00042 
00043 ////////////////////////////////////////////////////////////////////
00044 //     Function: EggVertexUV::get_num_dimensions
00045 //       Access: Published
00046 //  Description: Returns the number of components of the texture
00047 //               coordinate set.  This is either 2 (the normal case)
00048 //               or 3 (for a 3-d texture coordinate).
00049 ////////////////////////////////////////////////////////////////////
00050 INLINE int EggVertexUV::
00051 get_num_dimensions() const {
00052   return has_w() ? 3 : 2;
00053 }
00054 
00055 ////////////////////////////////////////////////////////////////////
00056 //     Function: EggVertexUV::has_w
00057 //       Access: Published
00058 //  Description: Returns true if the texture coordinate has a third, w
00059 //               component, false if it is just a normal 2-d texture
00060 //               coordinate.
00061 ////////////////////////////////////////////////////////////////////
00062 INLINE bool EggVertexUV::
00063 has_w() const {
00064   return (_flags & F_has_w) != 0;
00065 }
00066 
00067 ////////////////////////////////////////////////////////////////////
00068 //     Function: EggVertexUV::get_uv
00069 //       Access: Published
00070 //  Description: Returns the texture coordinate pair, if
00071 //               get_num_dimensions() is 2.
00072 ////////////////////////////////////////////////////////////////////
00073 INLINE LTexCoordd EggVertexUV::
00074 get_uv() const {
00075   nassertr(!has_w(), LTexCoordd::zero());
00076   return LTexCoordd(_uvw[0], _uvw[1]);
00077 }
00078 
00079 ////////////////////////////////////////////////////////////////////
00080 //     Function: EggVertexUV::get_uvw
00081 //       Access: Published
00082 //  Description: Returns the texture coordinate triple, if
00083 //               get_num_dimensions() is 3.  This is also legal to
00084 //               call if get_num_dimensions() is 2 (but the last
00085 //               dimension will be zero).
00086 ////////////////////////////////////////////////////////////////////
00087 INLINE const LTexCoord3d &EggVertexUV::
00088 get_uvw() const {
00089   return _uvw;
00090 }
00091 
00092 ////////////////////////////////////////////////////////////////////
00093 //     Function: EggVertexUV::set_uv
00094 //       Access: Published
00095 //  Description: Sets the texture coordinate pair.  This makes the
00096 //               texture coordinate a 2-d texture coordinate, which is
00097 //               the usual case.
00098 ////////////////////////////////////////////////////////////////////
00099 INLINE void EggVertexUV::
00100 set_uv(const LTexCoordd &uv) {
00101   _uvw.set(uv[0], uv[1], 0.0);
00102   _flags &= ~F_has_w;
00103 }
00104 
00105 ////////////////////////////////////////////////////////////////////
00106 //     Function: EggVertexUV::set_uvw
00107 //       Access: Published
00108 //  Description: Sets the texture coordinate triple.  This makes the
00109 //               texture coordinate a 3-d texture coordinate.
00110 ////////////////////////////////////////////////////////////////////
00111 INLINE void EggVertexUV::
00112 set_uvw(const LTexCoord3d &uvw) {
00113   _uvw = uvw;
00114   _flags |= F_has_w;
00115 }
00116 
00117 ////////////////////////////////////////////////////////////////////
00118 //     Function: EggVertexUV::has_tangent
00119 //       Access: Published
00120 //  Description:
00121 ////////////////////////////////////////////////////////////////////
00122 INLINE bool EggVertexUV::
00123 has_tangent() const {
00124   return (_flags & F_has_tangent) != 0;
00125 }
00126 
00127 ////////////////////////////////////////////////////////////////////
00128 //     Function: EggVertexUV::get_tangent
00129 //       Access: Published
00130 //  Description:
00131 ////////////////////////////////////////////////////////////////////
00132 INLINE const LNormald &EggVertexUV::
00133 get_tangent() const {
00134   nassertr(has_tangent(), _tangent);
00135   return _tangent;
00136 }
00137 
00138 ////////////////////////////////////////////////////////////////////
00139 //     Function: EggVertexUV::set_tangent
00140 //       Access: Published
00141 //  Description:
00142 ////////////////////////////////////////////////////////////////////
00143 INLINE void EggVertexUV::
00144 set_tangent(const LNormald &tangent) {
00145   _tangent = tangent;
00146   _flags |= F_has_tangent;
00147 }
00148 
00149 ////////////////////////////////////////////////////////////////////
00150 //     Function: EggVertexUV::clear_tangent
00151 //       Access: Published
00152 //  Description:
00153 ////////////////////////////////////////////////////////////////////
00154 INLINE void EggVertexUV::
00155 clear_tangent() {
00156   _flags &= ~F_has_tangent;
00157 }
00158 
00159 ////////////////////////////////////////////////////////////////////
00160 //     Function: EggVertexUV::has_binormal
00161 //       Access: Published
00162 //  Description:
00163 ////////////////////////////////////////////////////////////////////
00164 INLINE bool EggVertexUV::
00165 has_binormal() const {
00166   return (_flags & F_has_binormal) != 0;
00167 }
00168 
00169 ////////////////////////////////////////////////////////////////////
00170 //     Function: EggVertexUV::get_binormal
00171 //       Access: Published
00172 //  Description:
00173 ////////////////////////////////////////////////////////////////////
00174 INLINE const LNormald &EggVertexUV::
00175 get_binormal() const {
00176   nassertr(has_binormal(), _binormal);
00177   return _binormal;
00178 }
00179 
00180 ////////////////////////////////////////////////////////////////////
00181 //     Function: EggVertexUV::set_binormal
00182 //       Access: Published
00183 //  Description:
00184 ////////////////////////////////////////////////////////////////////
00185 INLINE void EggVertexUV::
00186 set_binormal(const LNormald &binormal) {
00187   _binormal = binormal;
00188   _flags |= F_has_binormal;
00189 }
00190 
00191 ////////////////////////////////////////////////////////////////////
00192 //     Function: EggVertexUV::clear_binormal
00193 //       Access: Published
00194 //  Description:
00195 ////////////////////////////////////////////////////////////////////
00196 INLINE void EggVertexUV::
00197 clear_binormal() {
00198   _flags &= ~F_has_binormal;
00199 }
 All Classes Functions Variables Enumerations