00001 // Filename: builderProperties.h 00002 // Created by: drose (17Sep97) 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 #ifndef BUILDERPROPERTIES_H 00019 #define BUILDERPROPERTIES_H 00020 00021 #include <pandabase.h> 00022 00023 #include "builderTypes.h" 00024 00025 #ifndef HAVE_IOSTREAM 00026 // We assume if your C++ library defines <iostream.h>, then it also 00027 // defines <stl_config.h>. 00028 #include <stl_config.h> 00029 #endif 00030 00031 00032 00033 //////////////////////////////////////////////////////////////////// 00034 // Class : BuilderProperties 00035 // Description : A class which defines several parameters used to 00036 // control specific behavior of the builder and mesher. 00037 // BuilderBucket inherits from this class, so each of 00038 // these properties may be set directly on a 00039 // BuilderBucket to control the geometry made with just 00040 // that bucket. There may in this way be several 00041 // different sets of properties in effect at a given 00042 // time. 00043 // 00044 // The initial values for these are set in the private 00045 // constructor to BuilderBucket, at the bottom of 00046 // builderBucket.cxx. 00047 //////////////////////////////////////////////////////////////////// 00048 class EXPCL_PANDAEGG BuilderProperties { 00049 public: 00050 bool operator < (const BuilderProperties &other) const; 00051 void output(ostream &out) const; 00052 00053 // If this is true, the mesher will be invoked to break up large 00054 // polygons and build triangles into tristrips wherever possible. 00055 bool _mesh; 00056 00057 // If this is true, a pair of adjacent coplanar triangles that form 00058 // a quad may be replaced with a pair of triangles forming the same 00059 // quad but with the opposite diagonal, if this will help the 00060 // building of tristrips. 00061 bool _retesselate_coplanar; 00062 00063 // If this is true, a coplanar fan may be treated as a single large 00064 // polygon, and then subdivided into a single tristrip, instead of 00065 // treating it as a fan. This can sometimes help form longer 00066 // continuous tristrips. 00067 bool _unroll_fans; 00068 00069 // The following three flags serve to illustrate the mesher's 00070 // effectiveness by coloring geometry. 00071 00072 // This colors each created triangle strip with a random color. The 00073 // first triangle of each strip is a little darker than the rest of 00074 // the strip. 00075 bool _show_tstrips; 00076 00077 // This colors each rectangular group of quads--called a quadsheet 00078 // by the mesher--with a random color. The mesher always creates 00079 // linear tristrips across whatever quadsheets it can identify. 00080 bool _show_qsheets; 00081 00082 // This colors quads blue, and doesn't mesh them further. Since a 00083 // large part of the mesher's algorithm is reassembling adjacent 00084 // triangles into quads, it's sometimes helpful to see where it 00085 // thinks the best quads lie. 00086 bool _show_quads; 00087 00088 // This shows normals created by creating little colored line 00089 // segments to represent each normal. 00090 bool _show_normals; 00091 double _normal_scale; 00092 BuilderC _normal_color; 00093 00094 // If this is true, large polygons will be subdivided into 00095 // triangles. Otherwise, they will remain large polygons. 00096 bool _subdivide_polys; 00097 00098 // This is the flatness tolerance below which two polygons will be 00099 // considered coplanar. Making it larger makes it easier for the 00100 // mesher to reverse triangle diagonals to achieve a good mesh, at 00101 // the expense of precision of the surface. 00102 double _coplanar_threshold; 00103 00104 // True if fans are to be considered at all. Sometimes making fans 00105 // is more trouble than they're worth, since they tend to get in the 00106 // way of long tristrips. 00107 bool _consider_fans; 00108 00109 // The maximum average angle of the apex of each triangle involved 00110 // in a fan. If the triangles are more loosely packed than this, 00111 // don't consider putting them into a fan. 00112 double _max_tfan_angle; 00113 00114 // The minimum number of triangles to be involved in a fan. Setting 00115 // this number lower results in more fans, probably at the expense 00116 // of tristrips. However, setting it to zero means no tfans will be 00117 // built (although fans may still be unrolled into tstrips if 00118 // _unroll_fans is true). 00119 int _min_tfan_tris; 00120 00121 protected: 00122 int sort_value() const; 00123 }; 00124 00125 INLINE ostream &operator << (ostream &out, const BuilderProperties &props) { 00126 props.output(out); 00127 return out; 00128 } 00129 00130 #endif