Panda3D
config_egg2pg.cxx
1 // Filename: config_egg2pg.cxx
2 // Created by: drose (26Feb02)
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 #include "config_egg2pg.h"
16 
17 #include "dconfig.h"
18 #include "loaderFileTypeEgg.h"
19 #include "loaderFileTypeRegistry.h"
20 #include "configVariableManager.h"
21 #include "configVariableCore.h"
22 #include "eggRenderState.h"
23 
24 ConfigureDef(config_egg2pg);
25 NotifyCategoryDef(egg2pg, "");
26 
27 ConfigVariableDouble egg_normal_scale
28 ("egg-normal-scale", 1.0);
29 ConfigVariableBool egg_show_normals
30 ("egg-show-normals", false);
31 
32 ConfigVariableEnum<CoordinateSystem> egg_coordinate_system
33 ("egg-coordinate-system", CS_default);
34 
35 ConfigVariableBool egg_ignore_mipmaps
36 ("egg-ignore-mipmaps", false);
37 ConfigVariableBool egg_ignore_filters
38 ("egg-ignore-filters", false);
39 ConfigVariableBool egg_ignore_decals
40 ("egg-ignore-decals", false);
41 ConfigVariableBool egg_flatten
42 ("egg-flatten", true,
43  PRC_DESC("This is normally true to flatten out useless nodes after loading "
44  "an egg file. Set it false if you want to see the complete "
45  "and true hierarchy as the egg loader created it (although the "
46  "extra nodes may have a small impact on render performance)."));
47 
48 ConfigVariableDouble egg_flatten_radius
49 ("egg-flatten-radius", 0.0,
50  PRC_DESC("This specifies the minimum cull radius in the egg file. Nodes "
51  "whose bounding volume is smaller than this radius will be "
52  "flattened tighter than nodes larger than this radius, to "
53  "reduce the node count even further. The idea is that small "
54  "objects will not need to have their individual components "
55  "culled separately, but large environments should. This allows "
56  "the user to specify what should be considered \"small\". Set "
57  "it to 0.0 to disable this feature."));
58 
59 ConfigVariableBool egg_unify
60 ("egg-unify", true,
61  PRC_DESC("When this is true, then in addition to flattening the scene graph "
62  "nodes, the egg loader will also combine as many Geoms as "
63  "possible within "
64  "a given node into a single Geom. This has theoretical performance "
65  "benefits, especially on higher-end graphics cards, but it also "
66  "slightly slows down egg loading."));
67 
68 ConfigVariableBool egg_combine_geoms
69 ("egg-combine-geoms", false,
70  PRC_DESC("Set this true to combine sibling GeomNodes into a single GeomNode, "
71  "when possible. This usually shouldn't be necessary, since the "
72  "egg loader does a pretty good job of combining these by itself."));
73 
74 ConfigVariableBool egg_rigid_geometry
75 ("egg-rigid-geometry", false,
76  PRC_DESC("Set this true to create rigid pieces of an animated character as "
77  "separate static nodes, or false to leave these in with the parent "
78  "node as vertex-animated geometry. Setting this true means less "
79  "geometry has to be vertex-animated, but there will tend to be "
80  "more separate pieces."));
81 
82 ConfigVariableBool egg_flat_shading
83 ("egg-flat-shading", false,
84  PRC_DESC("Set this true to allow the egg loader to create geometry with the "
85  "ShadeModelAttrib::M_flat attribute set. It will do this only "
86  "for geometry that has per-polygon normals and/or colors. This "
87  "allows the egg loader to avoid duplicating vertices when they "
88  "are shared between connected polygons with different normals or "
89  "colors, but it prevents the flat-shaded geometry from being "
90  "combined with any adjacent smooth-shaded geometry (for instance, "
91  "as the result of a flatten_strong operation). It is false by "
92  "default, since flat-shaded geometry is rare; but you may wish "
93  "to set it true if your scene largely or entirely consists of "
94  "flat-shaded polygons."));
95 
96 ConfigVariableBool egg_flat_colors
97 ("egg-flat-colors", true,
98  PRC_DESC("Set this true to allow the egg loader to create geometry with the "
99  "ColorAttrib::T_flat attribute set: that is, geometry that uses "
100  "the scene graph color instead of per-vertex color. Normally Panda "
101  "will do this as an optimization for Geoms whose vertices are all "
102  "the same color, or all white. This allows the removal of the "
103  "color attribute from the vertices where it is not necessary to "
104  "specify colors per-vertex. If this is false, the color attribute "
105  "will always be specified per-vertex, even if all vertices have the "
106  "same value."));
107 
108 ConfigVariableBool egg_load_old_curves
109 ("egg-load-old-curves", true,
110  PRC_DESC("When this is true, a <NurbsCurve> entry appearing in an egg file "
111  "will load as a NurbsCurve or ClassicNurbsCurve object (see below). "
112  "When this is false, it will load a RopeNode instead, which uses the "
113  "new NurbsCurveEvaluator interface."));
114 
115 
116 ConfigVariableBool egg_load_classic_nurbs_curves
117 ("egg-load-classic-nurbs-curves", false,
118  PRC_DESC("When this is true (and the above is also true), a <NurbsCurve> "
119  "entry appearing in an egg file will load a ClassicNurbsCurve object "
120  "instead of the default, a NurbsCurve object. This only makes a "
121  "difference when the NURBS++ library is available, in which case the "
122  "default, NurbsCurve, is actually a NurbsPPCurve object."));
123 
124 
125 ConfigVariableBool egg_accept_errors
126 ("egg-accept-errors", true,
127  PRC_DESC("When this is true, certain kinds of recoverable errors (not syntax "
128  "errors) in an egg file will be allowed and ignored when an egg file "
129  "is loaded. When it is false, only perfectly pristine egg files may "
130  "be loaded."));
131 
132 
133 ConfigVariableBool egg_suppress_hidden
134 ("egg-suppress-hidden", false,
135  PRC_DESC("When this is true, objects flagged as \"hidden\" with the visibility "
136  "scalar are not created at all. When false, these objects are "
137  "created, but initially stashed."));
138 
139 
141 ("egg-alpha-mode", EggRenderMode::AM_blend,
142  PRC_DESC("Specifies the alpha mode to apply when the alpha specification "
143  "\"on\" appears in the egg file (or when a primitive is implicitly "
144  "transparent, because of a <RGBA> that involves a non-unity alpha, "
145  "or because of a four-channel texture."));
146 
147 ConfigVariableInt egg_max_vertices
148 ("egg-max-vertices", 65534,
149  PRC_DESC("Specifies the maximum number of vertices that will be "
150  "added to any one GeomVertexData by the egg loader."));
151 
152 ConfigVariableInt egg_max_indices
153 ("egg-max-indices", 65535,
154  PRC_DESC("Specifies the maximum number of vertex indices that will be "
155  "added to any one GeomPrimitive by the egg loader."));
156 
157 ConfigVariableBool egg_emulate_bface
158 ("egg-emulate-bface", true,
159  PRC_DESC("When this is true, the bface flag applied to a polygon will "
160  "cause two different polygons to be created, back-to-back. When "
161  "it is false, a single polygon will be created with the two_sided "
162  "flag set on it."));
163 
164 ConfigVariableBool egg_preload_simple_textures
165 ("egg-preload-simple-textures", true,
166  PRC_DESC("This specifies whether the egg loader will generate simple "
167  "texture images for each texture loaded. This supercedes the "
168  "preload-simple-textures global default, for egg files. In "
169  "fact, the egg loader will generate simple texture images if "
170  "either this or preload-simple-textures is true."));
171 
172 ConfigVariableDouble egg_vertex_membership_quantize
173 ("egg-vertex-membership-quantize", 0.1,
174  PRC_DESC("Specifies the nearest amount to round each vertex joint "
175  "membership value when loading an egg file. This affects animated "
176  "egg files only. There is a substantial runtime "
177  "performance advantage for reducing trivial differences in joint "
178  "membership. Set this to 0 to leave joint membership as it is."));
179 
180 ConfigVariableInt egg_vertex_max_num_joints
181 ("egg-vertex-max-num-joints", 4,
182  PRC_DESC("Specifies the maximum number of distinct joints that are allowed "
183  "to control any one vertex. If a vertex requests assignment to "
184  "more than this number of joints, the joints with the lesser membership "
185  "value are ignored. Set this to -1 to allow any number of joints."));
186 
187 ConfigVariableBool egg_implicit_alpha_binary
188 ("egg-implicit-alpha-binary", false,
189  PRC_DESC("If this is true, then a <Scalar> alpha value appearing in an egg "
190  "file that appears to specify only a binary (0 or 1) value for alpha "
191  "will automatically be downgraded to alpha type \"binary\" instead of "
192  "whatever appears in the egg file."));
193 
194 ConfigureFn(config_egg2pg) {
195  init_libegg2pg();
196 }
197 
198 ////////////////////////////////////////////////////////////////////
199 // Function: init_libegg2pg
200 // Description: Initializes the library. This must be called at
201 // least once before any of the functions or classes in
202 // this library can be used. Normally it will be
203 // called by the static initializers and need not be
204 // called explicitly, but special cases exist.
205 ////////////////////////////////////////////////////////////////////
206 void
207 init_libegg2pg() {
208  static bool initialized = false;
209  if (initialized) {
210  return;
211  }
212  initialized = true;
213 
214  // Define a template for all egg-object-type-* variables, so the
215  // system knows that these variables are defined when it finds them
216  // in a user's prc file, even if we haven't actually read an egg
217  // file that uses the particular <ObjectType> field.
218  ConfigVariableManager *cv_mgr = ConfigVariableManager::get_global_ptr();
219  cv_mgr->make_variable_template
220  ("egg-object-type-*",
221  ConfigVariableCore::VT_string, "",
222  "Defines egg syntax for the named object type.",
223  ConfigVariableCore::F_dynamic);
224 
225  EggRenderState::init_type();
226  LoaderFileTypeEgg::init_type();
227 
229 
231 }
ConfigVariableCore * make_variable_template(const string &pattern, ConfigFlags::ValueType type, const string &default_value, const string &description=string(), int flags=0)
Defines a variable "template" to match against dynamically-defined variables that may or may not be c...
This is a convenience class to specialize ConfigVariable as a boolean type.
static LoaderFileTypeRegistry * get_global_ptr()
Returns a pointer to the global LoaderFileTypeRegistry object.
This defines the Loader interface to read Egg files.
A global object that maintains the set of ConfigVariables (actually, ConfigVariableCores) everywhere ...
void register_type(LoaderFileType *type)
Defines a new LoaderFileType in the universe.
This is a convenience class to specialize ConfigVariable as a floating-point type.
This class specializes ConfigVariable as an enumerated type.
This class maintains the set of all known LoaderFileTypes in the universe.
This is a convenience class to specialize ConfigVariable as an integer type.