Panda3D

Loading...
Searching...
No Matches
config_assimp.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_assimp.cxx
10 * @author rdb
11 * @date 2011-03-29
12 */
13
14#include "config_assimp.h"
15
16#include "loaderFileTypeAssimp.h"
17
18#include "dconfig.h"
19#include "loaderFileTypeRegistry.h"
20
21ConfigureDef(config_assimp);
22NotifyCategoryDef(assimp, "");
23
24ConfigureFn(config_assimp) {
25 init_libassimp();
26}
27
28 ConfigVariableBool assimp_calc_tangent_space
29("assimp-calc-tangent-space", false,
30 PRC_DESC("Calculates tangents and binormals for meshes imported via Assimp."));
31
32 ConfigVariableBool assimp_join_identical_vertices
33("assimp-join-identical-vertices", true,
34 PRC_DESC("Merges duplicate vertices. Set this to false if you want each "
35 "vertex to only be in use on one triangle."));
36
37 ConfigVariableBool assimp_improve_cache_locality
38("assimp-improve-cache-locality", true,
39 PRC_DESC("Improves rendering performance of the loaded meshes by reordering "
40 "triangles for better vertex cache locality. Set this to false if "
41 "you need geometry to be loaded in the exact order that it was "
42 "specified in the file, or to improve load performance."));
43
44 ConfigVariableBool assimp_remove_redundant_materials
45("assimp-remove-redundant-materials", true,
46 PRC_DESC("Removes redundant/unreferenced materials from assets."));
47
48 ConfigVariableBool assimp_fix_infacing_normals
49("assimp-fix-infacing-normals", false,
50 PRC_DESC("Determines which normal vectors are facing inward and inverts them "
51 "so that they are facing outward."));
52
53 ConfigVariableBool assimp_optimize_meshes
54("assimp-optimize-meshes", true,
55 PRC_DESC("Reduces the number of draw calls by unifying geometry with the same "
56 "materials. Especially effective in conjunction with "
57 "assimp-optimize-graph and assimp-remove-redundant-materials."));
58
59 ConfigVariableBool assimp_optimize_graph
60("assimp-optimize-graph", false,
61 PRC_DESC("Optimizes the scene geometry by flattening the scene hierarchy. "
62 "This is very efficient (combined with assimp-optimize-meshes), but "
63 "it may result the hierarchy to become lost, so it is disabled by "
64 "default."));
65
66 ConfigVariableBool assimp_flip_winding_order
67("assimp-flip-winding-order", false,
68 PRC_DESC("Set this true to flip the winding order of all models loaded via "
69 "the Assimp loader. Note that you may need to clear the model-cache "
70 "after changing this."));
71
72 ConfigVariableBool assimp_gen_normals
73("assimp-gen-normals", false,
74 PRC_DESC("Set this true to generate normals (if absent from file) on import. "
75 "See assimp-smooth-normal-angle for more information. "
76 "Note that you may need to clear the model-cache after "
77 "changing this."));
78
79 ConfigVariableDouble assimp_smooth_normal_angle
80("assimp-smooth-normal-angle", 0.0,
81 PRC_DESC("Set this to anything other than 0.0 in degrees (so 180.0 is PI) to "
82 "specify the maximum angle that may be between two face normals at "
83 "the same vertex position that are smoothed together. Sometimes "
84 "referred to as 'crease angle'. Only has effect if "
85 "assimp-gen-normals is set to true and the file does not contain "
86 "normals. Note that you may need to clear the model-cache after "
87 "changing this."));
88
89 ConfigVariableBool assimp_collapse_dummy_root_node
90("assimp-collapse-dummy-root-node", false,
91 PRC_DESC("If set to true, collapses the root node that Assimp creates, if it "
92 "appears to be a synthetic dummy root node and contains no meshes. "
93 "This variable is new as of Panda3D 1.10.13 and will become true by "
94 "default as of Panda3D 1.11.0."));
95
96/**
97 * Initializes the library. This must be called at least once before any of
98 * the functions or classes in this library can be used. Normally it will be
99 * called by the static initializers and need not be called explicitly, but
100 * special cases exist.
101 */
102 void
103 init_libassimp() {
104 static bool initialized = false;
105 if (initialized) {
106 return;
107 }
108 initialized = true;
109
110 LoaderFileTypeAssimp::init_type();
111
112 LoaderFileTypeRegistry *reg = LoaderFileTypeRegistry::get_global_ptr();
113 reg->register_type(new LoaderFileTypeAssimp);
114}
ConfigVariableBool
This is a convenience class to specialize ConfigVariable as a boolean type.
Definition configVariableBool.h:23
ConfigVariableDouble
This is a convenience class to specialize ConfigVariable as a floating- point type.
Definition configVariableDouble.h:24
LoaderFileTypeAssimp
This defines the Loader interface that uses the Assimp library to load various model formats.
Definition loaderFileTypeAssimp.h:26
LoaderFileTypeRegistry
This class maintains the set of all known LoaderFileTypes in the universe.
Definition loaderFileTypeRegistry.h:28
LoaderFileTypeRegistry::register_type
void register_type(LoaderFileType *type)
Defines a new LoaderFileType in the universe.
Definition loaderFileTypeRegistry.cxx:46
LoaderFileTypeRegistry::get_global_ptr
static LoaderFileTypeRegistry * get_global_ptr()
Returns a pointer to the global LoaderFileTypeRegistry object.
Definition loaderFileTypeRegistry.cxx:270
init_libassimp
void init_libassimp()
Initializes the library.
Definition config_assimp.cxx:103
config_assimp.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
dconfig.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
loaderFileTypeAssimp.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
loaderFileTypeRegistry.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.