00001 // Filename: eggData.I 00002 // Created by: drose (11Feb99) 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: EggData::Constructor 00018 // Access: Public 00019 // Description: 00020 //////////////////////////////////////////////////////////////////// 00021 INLINE EggData:: 00022 EggData() { 00023 _auto_resolve_externals = false; 00024 _had_absolute_pathnames = false; 00025 _coordsys = CS_default; 00026 } 00027 00028 00029 //////////////////////////////////////////////////////////////////// 00030 // Function: EggData::Copy constructor 00031 // Access: Public 00032 // Description: 00033 //////////////////////////////////////////////////////////////////// 00034 INLINE EggData:: 00035 EggData(const EggData ©) : 00036 EggGroupNode(copy), 00037 _auto_resolve_externals(copy._auto_resolve_externals), 00038 _had_absolute_pathnames(copy._had_absolute_pathnames), 00039 _coordsys(copy._coordsys), 00040 _egg_filename(copy._egg_filename) 00041 { 00042 } 00043 00044 //////////////////////////////////////////////////////////////////// 00045 // Function: EggData::Copy assignment operator 00046 // Access: Public 00047 // Description: 00048 //////////////////////////////////////////////////////////////////// 00049 INLINE EggData &EggData:: 00050 operator = (const EggData ©) { 00051 EggGroupNode::operator = (copy); 00052 _auto_resolve_externals = copy._auto_resolve_externals; 00053 _had_absolute_pathnames = copy._had_absolute_pathnames; 00054 _coordsys = copy._coordsys; 00055 _egg_filename = copy._egg_filename; 00056 return *this; 00057 } 00058 00059 //////////////////////////////////////////////////////////////////// 00060 // Function: EggData::set_auto_resolve_externals 00061 // Access: Public 00062 // Description: Indicates whether the EggData object will 00063 // automatically resolve any external references when 00064 // read() is called. The default is false. 00065 //////////////////////////////////////////////////////////////////// 00066 INLINE void EggData:: 00067 set_auto_resolve_externals(bool resolve) { 00068 _auto_resolve_externals = resolve; 00069 } 00070 00071 //////////////////////////////////////////////////////////////////// 00072 // Function: EggData::get_auto_resolve_externals 00073 // Access: Public 00074 // Description: Indicates whether the EggData object will 00075 // automatically resolve any external references when 00076 // read() is called. The default is false. 00077 //////////////////////////////////////////////////////////////////// 00078 INLINE bool EggData:: 00079 get_auto_resolve_externals() const { 00080 return _auto_resolve_externals; 00081 } 00082 00083 //////////////////////////////////////////////////////////////////// 00084 // Function: EggData::original_had_absolute_pathnames 00085 // Access: Public 00086 // Description: Returns true if the data processed in the last call 00087 // to read() contained absolute pathnames, or false if 00088 // those pathnames were all relative. 00089 // 00090 // This method is necessary because if 00091 // auto_resolve_externals() is in effect, it may modify 00092 // the pathnames to be absolute whether or not they were 00093 // as loaded from disk. This method can be used to 00094 // query the state of the original egg file from disk. 00095 //////////////////////////////////////////////////////////////////// 00096 INLINE bool EggData:: 00097 original_had_absolute_pathnames() const { 00098 return _had_absolute_pathnames; 00099 } 00100 00101 //////////////////////////////////////////////////////////////////// 00102 // Function: EggData::get_coordinate_system 00103 // Access: Public 00104 // Description: Returns the coordinate system in which the egg file 00105 // is defined. 00106 //////////////////////////////////////////////////////////////////// 00107 INLINE CoordinateSystem EggData:: 00108 get_coordinate_system() const { 00109 return _coordsys; 00110 } 00111 00112 00113 //////////////////////////////////////////////////////////////////// 00114 // Function: EggData::set_egg_filename 00115 // Access: Public 00116 // Description: Sets the filename--especially the directory part--in 00117 // which the egg file is considered to reside. This is 00118 // also implicitly set by read(). 00119 //////////////////////////////////////////////////////////////////// 00120 INLINE void EggData:: 00121 set_egg_filename(const Filename &egg_filename) { 00122 _egg_filename = egg_filename; 00123 } 00124 00125 //////////////////////////////////////////////////////////////////// 00126 // Function: EggData::get_egg_filename 00127 // Access: Public 00128 // Description: Returns the directory in which the egg file is 00129 // considered to reside. 00130 //////////////////////////////////////////////////////////////////// 00131 INLINE const Filename &EggData:: 00132 get_egg_filename() const { 00133 return _egg_filename; 00134 } 00135 00136 //////////////////////////////////////////////////////////////////// 00137 // Function: EggData::recompute_vertex_normals 00138 // Access: Public 00139 // Description: Recomputes all the vertex normals for polygon 00140 // geometry at this group node and below so that they 00141 // accurately reflect the vertex positions. A shared 00142 // edge between two polygons (even in different groups) 00143 // is considered smooth if the angle between the two 00144 // edges is less than threshold degrees. 00145 // 00146 // This function also removes degenerate polygons that 00147 // do not have enough vertices to define a normal. It 00148 // does not affect normals for other kinds of primitives 00149 // like Nurbs or Points. 00150 // 00151 // This function does not remove or adjust vertices in 00152 // the vertex pool; it only adds new vertices with the 00153 // correct normals. Thus, it is a good idea to call 00154 // remove_unused_vertices() after calling this. 00155 //////////////////////////////////////////////////////////////////// 00156 INLINE void EggData:: 00157 recompute_vertex_normals(double threshold) { 00158 EggGroupNode::recompute_vertex_normals(threshold, _coordsys); 00159 } 00160 00161 //////////////////////////////////////////////////////////////////// 00162 // Function: EggData::recompute_polygon_normals 00163 // Access: Public 00164 // Description: Recomputes all the polygon normals for polygon 00165 // geometry at this group node and below so that they 00166 // accurately reflect the vertex positions. Normals are 00167 // removed from the vertices and defined only on 00168 // polygons, giving the geometry a faceted appearance. 00169 // 00170 // This function also removes degenerate polygons that 00171 // do not have enough vertices to define a normal. It 00172 // does not affect normals for other kinds of primitives 00173 // like Nurbs or Points. 00174 // 00175 // This function does not remove or adjust vertices in 00176 // the vertex pool; it only adds new vertices with the 00177 // normals removed. Thus, it is a good idea to call 00178 // remove_unused_vertices() after calling this. 00179 //////////////////////////////////////////////////////////////////// 00180 INLINE void EggData:: 00181 recompute_polygon_normals() { 00182 EggGroupNode::recompute_polygon_normals(_coordsys); 00183 } 00184 00185 //////////////////////////////////////////////////////////////////// 00186 // Function: EggData::strip_normals 00187 // Access: Public 00188 // Description: Removes all normals from primitives, and the vertices 00189 // they reference, at this node and below. 00190 // 00191 // This function does not remove or adjust vertices in 00192 // the vertex pool; it only adds new vertices with the 00193 // normal removed. Thus, it is a good idea to call 00194 // remove_unused_vertices() after calling this. 00195 //////////////////////////////////////////////////////////////////// 00196 INLINE void EggData:: 00197 strip_normals() { 00198 EggGroupNode::strip_normals(); 00199 }