Panda3D
 All Classes Functions Variables Enumerations
eggData.I
1 // Filename: eggData.I
2 // Created by: drose (11Feb99)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 
16 ////////////////////////////////////////////////////////////////////
17 // Function: EggData::Constructor
18 // Access: Public
19 // Description:
20 ////////////////////////////////////////////////////////////////////
21 INLINE EggData::
22 EggData() {
23  _auto_resolve_externals = false;
24  _had_absolute_pathnames = false;
25  _coordsys = CS_default;
26  _egg_timestamp = 0;
27 }
28 
29 
30 ////////////////////////////////////////////////////////////////////
31 // Function: EggData::Copy constructor
32 // Access: Public
33 // Description:
34 ////////////////////////////////////////////////////////////////////
35 INLINE EggData::
36 EggData(const EggData &copy) :
37  EggGroupNode(copy),
38  _auto_resolve_externals(copy._auto_resolve_externals),
39  _had_absolute_pathnames(copy._had_absolute_pathnames),
40  _coordsys(copy._coordsys),
41  _egg_filename(copy._egg_filename),
42  _egg_timestamp(copy._egg_timestamp)
43 {
44 }
45 
46 ////////////////////////////////////////////////////////////////////
47 // Function: EggData::Copy assignment operator
48 // Access: Public
49 // Description:
50 ////////////////////////////////////////////////////////////////////
51 INLINE EggData &EggData::
52 operator = (const EggData &copy) {
53  EggGroupNode::operator = (copy);
54  _auto_resolve_externals = copy._auto_resolve_externals;
55  _had_absolute_pathnames = copy._had_absolute_pathnames;
56  _coordsys = copy._coordsys;
57  _egg_filename = copy._egg_filename;
58  _egg_timestamp = copy._egg_timestamp;
59  return *this;
60 }
61 
62 ////////////////////////////////////////////////////////////////////
63 // Function: EggData::set_auto_resolve_externals
64 // Access: Public
65 // Description: Indicates whether the EggData object will
66 // automatically resolve any external references when
67 // read() is called. The default is false.
68 ////////////////////////////////////////////////////////////////////
69 INLINE void EggData::
71  _auto_resolve_externals = resolve;
72 }
73 
74 ////////////////////////////////////////////////////////////////////
75 // Function: EggData::get_auto_resolve_externals
76 // Access: Public
77 // Description: Indicates whether the EggData object will
78 // automatically resolve any external references when
79 // read() is called. The default is false.
80 ////////////////////////////////////////////////////////////////////
81 INLINE bool EggData::
83  return _auto_resolve_externals;
84 }
85 
86 ////////////////////////////////////////////////////////////////////
87 // Function: EggData::original_had_absolute_pathnames
88 // Access: Public
89 // Description: Returns true if the data processed in the last call
90 // to read() contained absolute pathnames, or false if
91 // those pathnames were all relative.
92 //
93 // This method is necessary because if
94 // auto_resolve_externals() is in effect, it may modify
95 // the pathnames to be absolute whether or not they were
96 // as loaded from disk. This method can be used to
97 // query the state of the original egg file from disk.
98 ////////////////////////////////////////////////////////////////////
99 INLINE bool EggData::
101  return _had_absolute_pathnames;
102 }
103 
104 ////////////////////////////////////////////////////////////////////
105 // Function: EggData::get_coordinate_system
106 // Access: Public
107 // Description: Returns the coordinate system in which the egg file
108 // is defined.
109 ////////////////////////////////////////////////////////////////////
110 INLINE CoordinateSystem EggData::
112  return _coordsys;
113 }
114 
115 
116 ////////////////////////////////////////////////////////////////////
117 // Function: EggData::set_egg_filename
118 // Access: Public
119 // Description: Sets the filename--especially the directory part--in
120 // which the egg file is considered to reside. This is
121 // also implicitly set by read().
122 ////////////////////////////////////////////////////////////////////
123 INLINE void EggData::
124 set_egg_filename(const Filename &egg_filename) {
125  _egg_filename = egg_filename;
126 }
127 
128 ////////////////////////////////////////////////////////////////////
129 // Function: EggData::get_egg_filename
130 // Access: Public
131 // Description: Returns the directory in which the egg file is
132 // considered to reside.
133 ////////////////////////////////////////////////////////////////////
134 INLINE const Filename &EggData::
136  return _egg_filename;
137 }
138 
139 ////////////////////////////////////////////////////////////////////
140 // Function: EggData::set_egg_timestamp
141 // Access: Public
142 // Description: Sets the timestamp of the egg file on disk, at the
143 // time it was opened for reading. This is also
144 // implicitly set by read().
145 ////////////////////////////////////////////////////////////////////
146 INLINE void EggData::
147 set_egg_timestamp(time_t egg_timestamp) {
148  _egg_timestamp = egg_timestamp;
149 }
150 
151 ////////////////////////////////////////////////////////////////////
152 // Function: EggData::get_egg_timestamp
153 // Access: Public
154 // Description: Returns the timestamp of the egg file on disk, at the
155 // time it was opened for reading, or 0 if this
156 // information is not available.
157 ////////////////////////////////////////////////////////////////////
158 INLINE time_t EggData::
160  return _egg_timestamp;
161 }
162 
163 ////////////////////////////////////////////////////////////////////
164 // Function: EggData::recompute_vertex_normals
165 // Access: Public
166 // Description: Recomputes all the vertex normals for polygon
167 // geometry at this group node and below so that they
168 // accurately reflect the vertex positions. A shared
169 // edge between two polygons (even in different groups)
170 // is considered smooth if the angle between the two
171 // edges is less than threshold degrees.
172 //
173 // This function also removes degenerate polygons that
174 // do not have enough vertices to define a normal. It
175 // does not affect normals for other kinds of primitives
176 // like Nurbs or Points.
177 //
178 // This function does not remove or adjust vertices in
179 // the vertex pool; it only adds new vertices with the
180 // correct normals. Thus, it is a good idea to call
181 // remove_unused_vertices() after calling this.
182 ////////////////////////////////////////////////////////////////////
183 INLINE void EggData::
184 recompute_vertex_normals(double threshold) {
185  EggGroupNode::recompute_vertex_normals(threshold, _coordsys);
186 }
187 
188 ////////////////////////////////////////////////////////////////////
189 // Function: EggData::recompute_polygon_normals
190 // Access: Public
191 // Description: Recomputes all the polygon normals for polygon
192 // geometry at this group node and below so that they
193 // accurately reflect the vertex positions. Normals are
194 // removed from the vertices and defined only on
195 // polygons, giving the geometry a faceted appearance.
196 //
197 // This function also removes degenerate polygons that
198 // do not have enough vertices to define a normal. It
199 // does not affect normals for other kinds of primitives
200 // like Nurbs or Points.
201 //
202 // This function does not remove or adjust vertices in
203 // the vertex pool; it only adds new vertices with the
204 // normals removed. Thus, it is a good idea to call
205 // remove_unused_vertices() after calling this.
206 ////////////////////////////////////////////////////////////////////
207 INLINE void EggData::
210 }
211 
212 ////////////////////////////////////////////////////////////////////
213 // Function: EggData::strip_normals
214 // Access: Public
215 // Description: Removes all normals from primitives, and the vertices
216 // they reference, at this node and below.
217 //
218 // This function does not remove or adjust vertices in
219 // the vertex pool; it only adds new vertices with the
220 // normal removed. Thus, it is a good idea to call
221 // remove_unused_vertices() after calling this.
222 ////////////////////////////////////////////////////////////////////
223 INLINE void EggData::
226 }
void strip_normals()
Removes all normals from primitives, and the vertices they reference, at this node and below...
A base class for nodes in the hierarchy that are not leaf nodes.
Definition: eggGroupNode.h:51
void recompute_polygon_normals(CoordinateSystem cs=CS_default)
Recomputes all the polygon normals for polygon geometry at this group node and below so that they acc...
bool original_had_absolute_pathnames() const
Returns true if the data processed in the last call to read() contained absolute pathnames, or false if those pathnames were all relative.
Definition: eggData.I:100
void set_egg_filename(const Filename &egg_filename)
Sets the filename–especially the directory part–in which the egg file is considered to reside...
Definition: eggData.I:124
void recompute_polygon_normals()
Recomputes all the polygon normals for polygon geometry at this group node and below so that they acc...
Definition: eggData.I:208
This is the primary interface into all the egg data, and the root of the egg file structure...
Definition: eggData.h:41
void set_auto_resolve_externals(bool resolve)
Indicates whether the EggData object will automatically resolve any external references when read() i...
Definition: eggData.I:70
void strip_normals()
Removes all normals from primitives, and the vertices they reference, at this node and below...
Definition: eggData.I:224
CoordinateSystem get_coordinate_system() const
Returns the coordinate system in which the egg file is defined.
Definition: eggData.I:111
The name of a file, such as a texture file or an Egg file.
Definition: filename.h:44
bool get_auto_resolve_externals() const
Indicates whether the EggData object will automatically resolve any external references when read() i...
Definition: eggData.I:82
void set_egg_timestamp(time_t egg_timestamp)
Sets the timestamp of the egg file on disk, at the time it was opened for reading.
Definition: eggData.I:147
void recompute_vertex_normals(double threshold)
Recomputes all the vertex normals for polygon geometry at this group node and below so that they accu...
Definition: eggData.I:184
const Filename & get_egg_filename() const
Returns the directory in which the egg file is considered to reside.
Definition: eggData.I:135
time_t get_egg_timestamp() const
Returns the timestamp of the egg file on disk, at the time it was opened for reading, or 0 if this information is not available.
Definition: eggData.I:159
void recompute_vertex_normals(double threshold, CoordinateSystem cs=CS_default)
Recomputes all the vertex normals for polygon geometry at this group node and below so that they accu...