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