config_assimp.cxx 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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. #include "config_assimp.h"
  14. #include "loaderFileTypeAssimp.h"
  15. #include "dconfig.h"
  16. #include "loaderFileTypeRegistry.h"
  17. ConfigureDef(config_assimp);
  18. NotifyCategoryDef(assimp, "");
  19. ConfigureFn(config_assimp) {
  20. init_libassimp();
  21. }
  22. ConfigVariableBool assimp_calc_tangent_space
  23. ("assimp-calc-tangent-space", false,
  24. PRC_DESC("Calculates tangents and binormals for meshes imported via Assimp."));
  25. ConfigVariableBool assimp_join_identical_vertices
  26. ("assimp-join-identical-vertices", true,
  27. PRC_DESC("Merges duplicate vertices. Set this to false if you want each "
  28. "vertex to only be in use on one triangle."));
  29. ConfigVariableBool assimp_improve_cache_locality
  30. ("assimp-improve-cache-locality", true,
  31. PRC_DESC("Improves rendering performance of the loaded meshes by reordering "
  32. "triangles for better vertex cache locality. Set this to false if "
  33. "you need geometry to be loaded in the exact order that it was "
  34. "specified in the file, or to improve load performance."));
  35. ConfigVariableBool assimp_remove_redundant_materials
  36. ("assimp-remove-redundant-materials", true,
  37. PRC_DESC("Removes redundant/unreferenced materials from assets."));
  38. ConfigVariableBool assimp_fix_infacing_normals
  39. ("assimp-fix-infacing-normals", false,
  40. PRC_DESC("Determines which normal vectors are facing inward and inverts them "
  41. "so that they are facing outward."));
  42. ConfigVariableBool assimp_optimize_meshes
  43. ("assimp-optimize-meshes", true,
  44. PRC_DESC("Removes the number of draw calls by unifying geometry with the same "
  45. "materials. Especially effective in conjunction with "
  46. "assimp-optimize-graph and assimp-remove-redundant-materials."));
  47. ConfigVariableBool assimp_optimize_graph
  48. ("assimp-optimize-graph", false,
  49. PRC_DESC("Optimizes the scene geometry by flattening the scene hierarchy. "
  50. "This is very efficient (combined with assimp-optimize-meshes), but "
  51. "it may result the hierarchy to become lost, so it is disabled by "
  52. "default."));
  53. ConfigVariableBool assimp_flip_winding_order
  54. ("assimp-flip-winding-order", false,
  55. PRC_DESC("Set this true to flip the winding order of all models loaded via "
  56. "the Assimp loader. Note that you may need to clear the model-cache "
  57. "after changing this."));
  58. ConfigVariableBool assimp_gen_normals
  59. ("assimp-gen-normals", false,
  60. PRC_DESC("Set this true to generate normals (if absent from file) on import. "
  61. "See assimp-smooth-normal-angle for more information. "
  62. "Note that you may need to clear the model-cache after "
  63. "changing this."));
  64. ConfigVariableDouble assimp_smooth_normal_angle
  65. ("assimp-smooth-normal-angle", 0.0,
  66. PRC_DESC("Set this to anything other than 0.0 in degrees (so 180.0 is PI) to "
  67. "specify the maximum angle that may be between two face normals at "
  68. "the same vertex position that are smoothed together. Sometimes "
  69. "referred to as 'crease angle'. Only has effect if "
  70. "assimp-gen-normals is set to true and the file does not contain "
  71. "normals. Note that you may need to clear the model-cache after "
  72. "changing this."));
  73. /**
  74. * Initializes the library. This must be called at least once before any of
  75. * the functions or classes in this library can be used. Normally it will be
  76. * called by the static initializers and need not be called explicitly, but
  77. * special cases exist.
  78. */
  79. void
  80. init_libassimp() {
  81. static bool initialized = false;
  82. if (initialized) {
  83. return;
  84. }
  85. initialized = true;
  86. LoaderFileTypeAssimp::init_type();
  87. LoaderFileTypeRegistry *reg = LoaderFileTypeRegistry::get_global_ptr();
  88. reg->register_type(new LoaderFileTypeAssimp);
  89. }