Panda3D
 All Classes Functions Variables Enumerations
config_egg2pg.cxx
00001 // Filename: config_egg2pg.cxx
00002 // Created by:  drose (26Feb02)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 #include "config_egg2pg.h"
00016 
00017 #include "dconfig.h"
00018 #include "loaderFileTypeEgg.h"
00019 #include "loaderFileTypeRegistry.h"
00020 #include "configVariableManager.h"
00021 #include "configVariableCore.h"
00022 #include "eggRenderState.h"
00023 
00024 ConfigureDef(config_egg2pg);
00025 NotifyCategoryDef(egg2pg, "");
00026 
00027 ConfigVariableDouble egg_normal_scale
00028 ("egg-normal-scale", 1.0);
00029 ConfigVariableBool egg_show_normals
00030 ("egg-show-normals", false);
00031 
00032 ConfigVariableEnum<CoordinateSystem> egg_coordinate_system
00033 ("egg-coordinate-system", CS_default);
00034 
00035 ConfigVariableBool egg_ignore_mipmaps
00036 ("egg-ignore-mipmaps", false);
00037 ConfigVariableBool egg_ignore_filters
00038 ("egg-ignore-filters", false);
00039 ConfigVariableBool egg_ignore_decals
00040 ("egg-ignore-decals", false);
00041 ConfigVariableBool egg_flatten
00042 ("egg-flatten", true,
00043  PRC_DESC("This is normally true to flatten out useless nodes after loading "
00044           "an egg file.  Set it false if you want to see the complete "
00045           "and true hierarchy as the egg loader created it (although the "
00046           "extra nodes may have a small impact on render performance)."));
00047 
00048 ConfigVariableDouble egg_flatten_radius
00049 ("egg-flatten-radius", 0.0,
00050  PRC_DESC("This specifies the minimum cull radius in the egg file.  Nodes "
00051           "whose bounding volume is smaller than this radius will be "
00052           "flattened tighter than nodes larger than this radius, to "
00053           "reduce the node count even further.  The idea is that small "
00054           "objects will not need to have their individual components "
00055           "culled separately, but large environments should.  This allows "
00056           "the user to specify what should be considered \"small\".  Set "
00057           "it to 0.0 to disable this feature."));
00058 
00059 ConfigVariableBool egg_unify
00060 ("egg-unify", true,
00061  PRC_DESC("When this is true, then in addition to flattening the scene graph "
00062           "nodes, the egg loader will also combine as many Geoms as "
00063           "possible within "
00064           "a given node into a single Geom.  This has theoretical performance "
00065           "benefits, especially on higher-end graphics cards, but it also "
00066           "slightly slows down egg loading."));
00067 
00068 ConfigVariableBool egg_combine_geoms
00069 ("egg-combine-geoms", false,
00070  PRC_DESC("Set this true to combine sibling GeomNodes into a single GeomNode, "
00071           "when possible.  This usually shouldn't be necessary, since the "
00072           "egg loader does a pretty good job of combining these by itself."));
00073 
00074 ConfigVariableBool egg_rigid_geometry
00075 ("egg-rigid-geometry", false,
00076  PRC_DESC("Set this true to create rigid pieces of an animated character as "
00077           "separate static nodes, or false to leave these in with the parent "
00078           "node as vertex-animated geometry.  Setting this true means less "
00079           "geometry has to be vertex-animated, but there will tend to be "
00080           "more separate pieces."));
00081 
00082 ConfigVariableBool egg_flat_shading
00083 ("egg-flat-shading", false,
00084  PRC_DESC("Set this true to allow the egg loader to create geometry with the "
00085           "ShadeModelAttrib::M_flat attribute set.  It will do this only "
00086           "for geometry that has per-polygon normals and/or colors.  This "
00087           "allows the egg loader to avoid duplicating vertices when they "
00088           "are shared between connected polygons with different normals or "
00089           "colors, but it prevents the flat-shaded geometry from being "
00090           "combined with any adjacent smooth-shaded geometry (for instance, "
00091           "as the result of a flatten_strong operation).  It is false by "
00092           "default, since flat-shaded geometry is rare; but you may wish "
00093           "to set it true if your scene largely or entirely consists of "
00094           "flat-shaded polygons."));
00095 
00096 ConfigVariableBool egg_flat_colors
00097 ("egg-flat-colors", true,
00098  PRC_DESC("Set this true to allow the egg loader to create geometry with the "
00099           "ColorAttrib::T_flat attribute set: that is, geometry that uses "
00100           "the scene graph color instead of per-vertex color.  Normally Panda "
00101           "will do this as an optimization for Geoms whose vertices are all "
00102           "the same color, or all white.  This allows the removal of the "
00103           "color attribute from the vertices where it is not necessary to "
00104           "specify colors per-vertex.  If this is false, the color attribute "
00105           "will always be specified per-vertex, even if all vertices have the "
00106           "same value."));
00107 
00108 ConfigVariableBool egg_load_old_curves
00109 ("egg-load-old-curves", true,
00110  PRC_DESC("When this is true, a <NurbsCurve> entry appearing in an egg file "
00111           "will load as a NurbsCurve or ClassicNurbsCurve object (see below). "
00112           "When this is false, it will load a RopeNode instead, which uses the "
00113           "new NurbsCurveEvaluator interface."));
00114 
00115 
00116 ConfigVariableBool egg_load_classic_nurbs_curves
00117 ("egg-load-classic-nurbs-curves", false,
00118  PRC_DESC("When this is true (and the above is also true), a <NurbsCurve> "
00119           "entry appearing in an egg file will load a ClassicNurbsCurve object "
00120           "instead of the default, a NurbsCurve object.  This only makes a "
00121           "difference when the NURBS++ library is available, in which case the "
00122           "default, NurbsCurve, is actually a NurbsPPCurve object."));
00123 
00124 
00125 ConfigVariableBool egg_accept_errors
00126 ("egg-accept-errors", true,
00127  PRC_DESC("When this is true, certain kinds of recoverable errors (not syntax "
00128           "errors) in an egg file will be allowed and ignored when an egg file "
00129           "is loaded.  When it is false, only perfectly pristine egg files may "
00130           "be loaded."));
00131 
00132 
00133 ConfigVariableBool egg_suppress_hidden
00134 ("egg-suppress-hidden", false,
00135  PRC_DESC("When this is true, objects flagged as \"hidden\" with the visibility "
00136           "scalar are not created at all.  When false, these objects are "
00137           "created, but initially stashed."));
00138 
00139 
00140 ConfigVariableEnum<EggRenderMode::AlphaMode> egg_alpha_mode
00141 ("egg-alpha-mode", EggRenderMode::AM_blend,
00142  PRC_DESC("Specifies the alpha mode to apply when the alpha specification "
00143           "\"on\" appears in the egg file (or when a primitive is implicitly "
00144           "transparent, because of a <RGBA> that involves a non-unity alpha, "
00145           "or because of a four-channel texture."));
00146 
00147 ConfigVariableInt egg_max_vertices
00148 ("egg-max-vertices", 65535,
00149  PRC_DESC("Specifies the maximum number of vertices that will be "
00150           "added to any one GeomVertexData by the egg loader."));
00151 
00152 ConfigVariableInt egg_max_indices
00153 ("egg-max-indices", 65535,
00154  PRC_DESC("Specifies the maximum number of vertex indices that will be "
00155           "added to any one GeomPrimitive by the egg loader."));
00156 
00157 ConfigVariableBool egg_emulate_bface
00158 ("egg-emulate-bface", true,
00159  PRC_DESC("When this is true, the bface flag applied to a polygon will "
00160           "cause two different polygons to be created, back-to-back.  When "
00161           "it is false, a single polygon will be created with the two_sided "
00162           "flag set on it."));
00163 
00164 ConfigVariableBool egg_preload_simple_textures
00165 ("egg-preload-simple-textures", true,
00166  PRC_DESC("This specifies whether the egg loader will generate simple "
00167           "texture images for each texture loaded.  This supercedes the "
00168           "preload-simple-textures global default, for egg files.  In "
00169           "fact, the egg loader will generate simple texture images if "
00170           "either this or preload-simple-textures is true."));
00171 
00172 ConfigVariableDouble egg_vertex_membership_quantize
00173 ("egg-vertex-membership-quantize", 0.1,
00174  PRC_DESC("Specifies the nearest amount to round each vertex joint "
00175           "membership value when loading an egg file.  This affects animated "
00176           "egg files only.  There is a substantial runtime "
00177           "performance advantage for reducing trivial differences in joint "
00178           "membership.  Set this to 0 to leave joint membership as it is."));
00179 
00180 ConfigVariableInt egg_vertex_max_num_joints
00181 ("egg-vertex-max-num-joints", 4,
00182  PRC_DESC("Specifies the maximum number of distinct joints that are allowed "
00183           "to control any one vertex.  If a vertex requests assignment to "
00184           "more than this number of joints, the joints with the lesser membership "
00185           "value are ignored.  Set this to -1 to allow any number of joints."));
00186 
00187 ConfigVariableBool egg_implicit_alpha_binary
00188 ("egg-implicit-alpha-binary", false,
00189  PRC_DESC("If this is true, then a <Scalar> alpha value appearing in an egg "
00190           "file that appears to specify only a binary (0 or 1) value for alpha "
00191           "will automatically be downgraded to alpha type \"binary\" instead of "
00192           "whatever appears in the egg file."));
00193 
00194 ConfigureFn(config_egg2pg) {
00195   init_libegg2pg();
00196 }
00197 
00198 ////////////////////////////////////////////////////////////////////
00199 //     Function: init_libegg2pg
00200 //  Description: Initializes the library.  This must be called at
00201 //               least once before any of the functions or classes in
00202 //               this library can be used.  Normally it will be
00203 //               called by the static initializers and need not be
00204 //               called explicitly, but special cases exist.
00205 ////////////////////////////////////////////////////////////////////
00206 void
00207 init_libegg2pg() {
00208   static bool initialized = false;
00209   if (initialized) {
00210     return;
00211   }
00212   initialized = true;
00213 
00214   // Define a template for all egg-object-type-* variables, so the
00215   // system knows that these variables are defined when it finds them
00216   // in a user's prc file, even if we haven't actually read an egg
00217   // file that uses the particular <ObjectType> field.
00218   ConfigVariableManager *cv_mgr = ConfigVariableManager::get_global_ptr();
00219   cv_mgr->make_variable_template
00220     ("egg-object-type-*",
00221      ConfigVariableCore::VT_string, "",
00222      "Defines egg syntax for the named object type.",
00223      ConfigVariableCore::F_dynamic);
00224 
00225   EggRenderState::init_type();
00226   LoaderFileTypeEgg::init_type();
00227 
00228   LoaderFileTypeRegistry *reg = LoaderFileTypeRegistry::get_global_ptr();
00229 
00230   reg->register_type(new LoaderFileTypeEgg);
00231 }
 All Classes Functions Variables Enumerations