eggData.I 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. // Filename: eggData.I
  2. // Created by: drose (11Feb99)
  3. //
  4. ////////////////////////////////////////////////////////////////////
  5. //
  6. // PANDA 3D SOFTWARE
  7. // Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved
  8. //
  9. // All use of this software is subject to the terms of the Panda 3d
  10. // Software license. You should have received a copy of this license
  11. // along with this source code; you will also find a current copy of
  12. // the license at http://etc.cmu.edu/panda3d/docs/license/ .
  13. //
  14. // To contact the maintainers of this program write to
  15. // [email protected] .
  16. //
  17. ////////////////////////////////////////////////////////////////////
  18. ////////////////////////////////////////////////////////////////////
  19. // Function: EggData::Constructor
  20. // Access: Public
  21. // Description:
  22. ////////////////////////////////////////////////////////////////////
  23. INLINE EggData::
  24. EggData() {
  25. _auto_resolve_externals = false;
  26. _coordsys = CS_default;
  27. }
  28. ////////////////////////////////////////////////////////////////////
  29. // Function: EggData::Copy constructor
  30. // Access: Public
  31. // Description:
  32. ////////////////////////////////////////////////////////////////////
  33. INLINE EggData::
  34. EggData(const EggData &copy) :
  35. EggGroupNode(copy),
  36. _auto_resolve_externals(copy._auto_resolve_externals),
  37. _coordsys(copy._coordsys),
  38. _egg_filename(copy._egg_filename)
  39. {
  40. }
  41. ////////////////////////////////////////////////////////////////////
  42. // Function: EggData::Copy assignment operator
  43. // Access: Public
  44. // Description:
  45. ////////////////////////////////////////////////////////////////////
  46. INLINE EggData &EggData::
  47. operator = (const EggData &copy) {
  48. EggGroupNode::operator = (copy);
  49. _auto_resolve_externals = copy._auto_resolve_externals;
  50. _coordsys = copy._coordsys;
  51. _egg_filename = copy._egg_filename;
  52. return *this;
  53. }
  54. ////////////////////////////////////////////////////////////////////
  55. // Function: EggData::set_auto_resolve_externals
  56. // Access: Public
  57. // Description: Indicates whether the EggData object will
  58. // automatically resolve any external references when
  59. // read() is called. The default is false.
  60. ////////////////////////////////////////////////////////////////////
  61. INLINE void EggData::
  62. set_auto_resolve_externals(bool resolve) {
  63. _auto_resolve_externals = resolve;
  64. }
  65. ////////////////////////////////////////////////////////////////////
  66. // Function: EggData::get_auto_resolve_externals
  67. // Access: Public
  68. // Description: Indicates whether the EggData object will
  69. // automatically resolve any external references when
  70. // read() is called. The default is false.
  71. ////////////////////////////////////////////////////////////////////
  72. INLINE bool EggData::
  73. get_auto_resolve_externals() const {
  74. return _auto_resolve_externals;
  75. }
  76. ////////////////////////////////////////////////////////////////////
  77. // Function: EggData::get_coordinate_system
  78. // Access: Public
  79. // Description: Returns the coordinate system in which the egg file
  80. // is defined.
  81. ////////////////////////////////////////////////////////////////////
  82. INLINE CoordinateSystem EggData::
  83. get_coordinate_system() const {
  84. return _coordsys;
  85. }
  86. ////////////////////////////////////////////////////////////////////
  87. // Function: EggData::set_egg_filename
  88. // Access: Public
  89. // Description: Sets the filename--especially the directory part--in
  90. // which the egg file is considered to reside. This is
  91. // also implicitly set by read().
  92. ////////////////////////////////////////////////////////////////////
  93. INLINE void EggData::
  94. set_egg_filename(const Filename &egg_filename) {
  95. _egg_filename = egg_filename;
  96. }
  97. ////////////////////////////////////////////////////////////////////
  98. // Function: EggData::get_egg_filename
  99. // Access: Public
  100. // Description: Returns the directory in which the egg file is
  101. // considered to reside.
  102. ////////////////////////////////////////////////////////////////////
  103. INLINE const Filename &EggData::
  104. get_egg_filename() const {
  105. return _egg_filename;
  106. }
  107. ////////////////////////////////////////////////////////////////////
  108. // Function: EggData::recompute_vertex_normals
  109. // Access: Public
  110. // Description: Recomputes all the vertex normals for polygon
  111. // geometry at this group node and below so that they
  112. // accurately reflect the vertex positions. A shared
  113. // edge between two polygons (even in different groups)
  114. // is considered smooth if the angle between the two
  115. // edges is less than threshold degrees.
  116. //
  117. // This function also removes degenerate polygons that
  118. // do not have enough vertices to define a normal. It
  119. // does not affect normals for other kinds of primitives
  120. // like Nurbs or Points.
  121. //
  122. // This function does not remove or adjust vertices in
  123. // the vertex pool; it only adds new vertices with the
  124. // correct normals. Thus, it is a good idea to call
  125. // remove_unused_vertices() after calling this.
  126. ////////////////////////////////////////////////////////////////////
  127. INLINE void EggData::
  128. recompute_vertex_normals(double threshold) {
  129. EggGroupNode::recompute_vertex_normals(threshold, _coordsys);
  130. }
  131. ////////////////////////////////////////////////////////////////////
  132. // Function: EggData::recompute_polygon_normals
  133. // Access: Public
  134. // Description: Recomputes all the polygon normals for polygon
  135. // geometry at this group node and below so that they
  136. // accurately reflect the vertex positions. Normals are
  137. // removed from the vertices and defined only on
  138. // polygons, giving the geometry a faceted appearance.
  139. //
  140. // This function also removes degenerate polygons that
  141. // do not have enough vertices to define a normal. It
  142. // does not affect normals for other kinds of primitives
  143. // like Nurbs or Points.
  144. //
  145. // This function does not remove or adjust vertices in
  146. // the vertex pool; it only adds new vertices with the
  147. // normals removed. Thus, it is a good idea to call
  148. // remove_unused_vertices() after calling this.
  149. ////////////////////////////////////////////////////////////////////
  150. INLINE void EggData::
  151. recompute_polygon_normals() {
  152. EggGroupNode::recompute_polygon_normals(_coordsys);
  153. }
  154. ////////////////////////////////////////////////////////////////////
  155. // Function: EggData::strip_normals
  156. // Access: Public
  157. // Description: Removes all normals from primitives, and the vertices
  158. // they reference, at this node and below.
  159. //
  160. // This function does not remove or adjust vertices in
  161. // the vertex pool; it only adds new vertices with the
  162. // normal removed. Thus, it is a good idea to call
  163. // remove_unused_vertices() after calling this.
  164. ////////////////////////////////////////////////////////////////////
  165. INLINE void EggData::
  166. strip_normals() {
  167. EggGroupNode::strip_normals();
  168. }