00001 // Filename: eggVertex.I 00002 // Created by: drose (16Jan99) 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 //////////////////////////////////////////////////////////////////// 00022 // Function: EggVertex::get_pool 00023 // Access: Public 00024 // Description: 00025 //////////////////////////////////////////////////////////////////// 00026 INLINE EggVertexPool *EggVertex:: 00027 get_pool() const { 00028 return _pool; 00029 } 00030 00031 00032 //////////////////////////////////////////////////////////////////// 00033 // Function: EggVertex::set_pos 00034 // Access: Public 00035 // Description: Sets the vertex position. This variant sets the 00036 // vertex to a one-dimensional value. 00037 //////////////////////////////////////////////////////////////////// 00038 INLINE void EggVertex:: 00039 set_pos(double pos) { 00040 _num_dimensions = 1; 00041 _pos.set(pos, 0.0, 0.0, 1.0); 00042 } 00043 00044 00045 //////////////////////////////////////////////////////////////////// 00046 // Function: EggVertex::set_pos 00047 // Access: Public 00048 // Description: Sets the vertex position. This variant sets the 00049 // vertex to a two-dimensional value. 00050 //////////////////////////////////////////////////////////////////// 00051 INLINE void EggVertex:: 00052 set_pos(const LPoint2d &pos) { 00053 _num_dimensions = 2; 00054 _pos.set(pos[0], pos[1], 0.0, 1.0); 00055 } 00056 00057 00058 //////////////////////////////////////////////////////////////////// 00059 // Function: EggVertex::set_pos 00060 // Access: Public 00061 // Description: Sets the vertex position. This variant sets the 00062 // vertex to a three-dimensional value. 00063 //////////////////////////////////////////////////////////////////// 00064 INLINE void EggVertex:: 00065 set_pos(const LPoint3d &pos) { 00066 _num_dimensions = 3; 00067 _pos.set(pos[0], pos[1], pos[2], 1.0); 00068 } 00069 00070 00071 //////////////////////////////////////////////////////////////////// 00072 // Function: EggVertex::set_pos 00073 // Access: Public 00074 // Description: Sets the vertex position. This variant sets the 00075 // vertex to a four-dimensional value. 00076 //////////////////////////////////////////////////////////////////// 00077 INLINE void EggVertex:: 00078 set_pos(const LPoint4d &pos) { 00079 _num_dimensions = 4; 00080 _pos = pos; 00081 } 00082 00083 00084 //////////////////////////////////////////////////////////////////// 00085 // Function: EggVertex::set_pos4 00086 // Access: Public 00087 // Description: This special flavor of set_pos() sets the vertex as a 00088 // four-component value, but does not change the set 00089 // number of dimensions. It's handy for retrieving the 00090 // vertex position via get_pos4, manipulating it, then 00091 // storing it back again, without worrying about the 00092 // number of dimensions it actually had. 00093 //////////////////////////////////////////////////////////////////// 00094 INLINE void EggVertex:: 00095 set_pos4(const LPoint4d &pos) { 00096 _pos = pos; 00097 } 00098 00099 00100 //////////////////////////////////////////////////////////////////// 00101 // Function: EggVertex::get_num_dimensions 00102 // Access: Public 00103 // Description: Returns the number of dimensions the vertex uses. 00104 // Usually this will be 3, but it may be 1, 2, 3, or 4. 00105 //////////////////////////////////////////////////////////////////// 00106 INLINE int EggVertex:: 00107 get_num_dimensions() const { 00108 return _num_dimensions; 00109 } 00110 00111 00112 //////////////////////////////////////////////////////////////////// 00113 // Function: EggVertex::get_pos1 00114 // Access: Public 00115 // Description: Only valid if get_num_dimensions() returns 1. 00116 // Returns the position as a one-dimensional value. 00117 //////////////////////////////////////////////////////////////////// 00118 INLINE double EggVertex:: 00119 get_pos1() const { 00120 nassertr(_num_dimensions == 1, 0.0); 00121 return _pos[0]; 00122 } 00123 00124 00125 //////////////////////////////////////////////////////////////////// 00126 // Function: EggVertex::get_pos2 00127 // Access: Public 00128 // Description: Only valid if get_num_dimensions() returns 2. 00129 // Returns the position as a two-dimensional value. 00130 //////////////////////////////////////////////////////////////////// 00131 INLINE LPoint2d EggVertex:: 00132 get_pos2() const { 00133 nassertr(_num_dimensions == 2, LPoint2d(0.0, 0.0)); 00134 return LPoint2d(_pos[0], _pos[1]); 00135 } 00136 00137 00138 //////////////////////////////////////////////////////////////////// 00139 // Function: EggVertex::get_pos3 00140 // Access: Public 00141 // Description: Only valid if get_num_dimensions() returns 3. 00142 // Returns the position as a three-dimensional value. 00143 //////////////////////////////////////////////////////////////////// 00144 INLINE Vertexd EggVertex:: 00145 get_pos3() const { 00146 nassertr(_num_dimensions == 3, LPoint3d(0.0, 0.0, 0.0)); 00147 return Vertexd(_pos[0], _pos[1], _pos[2]); 00148 } 00149 00150 00151 //////////////////////////////////////////////////////////////////// 00152 // Function: EggVertex::get_pos4 00153 // Access: Public 00154 // Description: This is always valid, regardless of the value of 00155 // get_num_dimensions. It returns the position as a 00156 // four-dimensional value. If the pos has fewer than 00157 // four dimensions, this value represents the pos 00158 // extended into four-dimensional homogenous space, 00159 // e.g. by adding 1 as the fourth component. 00160 //////////////////////////////////////////////////////////////////// 00161 INLINE LPoint4d EggVertex:: 00162 get_pos4() const { 00163 return _pos; 00164 } 00165 00166 00167 //////////////////////////////////////////////////////////////////// 00168 // Function: EggVertex::get_index 00169 // Access: Public 00170 // Description: Returns the index number of the vertex within its 00171 // pool. 00172 //////////////////////////////////////////////////////////////////// 00173 INLINE int EggVertex:: 00174 get_index() const { 00175 return _index; 00176 } 00177 00178 //////////////////////////////////////////////////////////////////// 00179 // Function: EggVertex::set_external_index 00180 // Access: Public 00181 // Description: Sets a special index number that is associated with 00182 // the EggVertex (but is not written to the egg file). 00183 // This number is not interpreted by any egg code; it is 00184 // simply maintained along with the vertex. It *is* 00185 // used to differentiate otherwise identical vertices in 00186 // EggVertexPool::create_unique_vertex(), however. 00187 // 00188 // The intention of this number is as an aid for file 00189 // converters, to associate an EggVertex back to the 00190 // index number of the original source vertex. 00191 //////////////////////////////////////////////////////////////////// 00192 INLINE void EggVertex:: 00193 set_external_index(int external_index) { 00194 _external_index = external_index; 00195 } 00196 00197 //////////////////////////////////////////////////////////////////// 00198 // Function: EggVertex::get_external_index 00199 // Access: Public 00200 // Description: Returns the number set by set_external_index(). See 00201 // set_external_index(). 00202 //////////////////////////////////////////////////////////////////// 00203 INLINE int EggVertex:: 00204 get_external_index() const { 00205 return _external_index; 00206 } 00207 00208 00209 //////////////////////////////////////////////////////////////////// 00210 // Function: EggVertex::gref_begin 00211 // Access: Public 00212 // Description: Returns an iterator that can, in conjunction with 00213 // gref_end(), be used to traverse the entire set of 00214 // groups that reference this vertex. Each iterator 00215 // returns a pointer to a group. 00216 // 00217 // This interface is not safe to use outside of 00218 // PANDAEGG.DLL. 00219 //////////////////////////////////////////////////////////////////// 00220 INLINE EggVertex::GroupRef::const_iterator EggVertex:: 00221 gref_begin() const { 00222 return _gref.begin(); 00223 } 00224 00225 //////////////////////////////////////////////////////////////////// 00226 // Function: EggVertex::gref_end 00227 // Access: Public 00228 // Description: Returns an iterator that can, in conjunction with 00229 // gref_begin(), be used to traverse the entire set of 00230 // groups that reference this vertex. Each iterator 00231 // returns a pointer to a group. 00232 // 00233 // This interface is not safe to use outside of 00234 // PANDAEGG.DLL. 00235 //////////////////////////////////////////////////////////////////// 00236 INLINE EggVertex::GroupRef::const_iterator EggVertex:: 00237 gref_end() const { 00238 return _gref.end(); 00239 } 00240 00241 //////////////////////////////////////////////////////////////////// 00242 // Function: EggVertex::gref_size 00243 // Access: Public 00244 // Description: Returns the number of elements between gref_begin() 00245 // and gref_end(). 00246 // 00247 // This interface is not safe to use outside of 00248 // PANDAEGG.DLL. 00249 //////////////////////////////////////////////////////////////////// 00250 INLINE EggVertex::GroupRef::size_type EggVertex:: 00251 gref_size() const { 00252 return _gref.size(); 00253 } 00254 00255 00256 //////////////////////////////////////////////////////////////////// 00257 // Function: EggVertex::pref_begin 00258 // Access: Public 00259 // Description: Returns an iterator that can, in conjunction with 00260 // pref_end(), be used to traverse the entire set of 00261 // primitives that reference this vertex. Each iterator 00262 // returns a pointer to a primitive. 00263 // 00264 // This interface is not safe to use outside of 00265 // PANDAEGG.DLL. 00266 //////////////////////////////////////////////////////////////////// 00267 INLINE EggVertex::PrimitiveRef::const_iterator EggVertex:: 00268 pref_begin() const { 00269 return _pref.begin(); 00270 } 00271 00272 //////////////////////////////////////////////////////////////////// 00273 // Function: EggVertex::pref_end 00274 // Access: Public 00275 // Description: Returns an iterator that can, in conjunction with 00276 // pref_begin(), be used to traverse the entire set of 00277 // primitives that reference this vertex. Each iterator 00278 // returns a pointer to a primitive. 00279 // 00280 // This interface is not safe to use outside of 00281 // PANDAEGG.DLL. 00282 //////////////////////////////////////////////////////////////////// 00283 INLINE EggVertex::PrimitiveRef::const_iterator EggVertex:: 00284 pref_end() const { 00285 return _pref.end(); 00286 } 00287 00288 //////////////////////////////////////////////////////////////////// 00289 // Function: EggVertex::pref_size 00290 // Access: Public 00291 // Description: Returns the number of elements between pref_begin() 00292 // and pref_end(). 00293 // 00294 // This interface is not safe to use outside of 00295 // PANDAEGG.DLL. 00296 //////////////////////////////////////////////////////////////////// 00297 INLINE EggVertex::GroupRef::size_type EggVertex:: 00298 pref_size() const { 00299 return _pref.size(); 00300 } 00301 00302 00303 00304 00305 //////////////////////////////////////////////////////////////////// 00306 // Function: UniqueEggVertices::Function operator 00307 // Access: Public 00308 // Description: 00309 //////////////////////////////////////////////////////////////////// 00310 INLINE bool UniqueEggVertices:: 00311 operator ()(const EggVertex *v1, const EggVertex *v2) const { 00312 return v1->sorts_less_than(*v2); 00313 } 00314