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