18#include <assimp/cimport.h>
28LoaderFileTypeAssimp() : _loader(nullptr) {
35~LoaderFileTypeAssimp() {
41string LoaderFileTypeAssimp::
43 return "Assimp Importer";
49string LoaderFileTypeAssimp::
50get_extension()
const {
62 (
"assimp-disable-extensions",
"",
63 PRC_DESC(
"A list of extensions (without preceding dot) that should not be "
64 "loaded via the Assimp loader, even if Assimp supports these "
65 "formats. It is useful to set this for eg. gltf and glb files "
66 "to prevent them from being accidentally loaded via the Assimp "
67 "plug-in instead of via a superior plug-in like panda3d-gltf."));
69 bool has_disabled_exts = !assimp_disable_extensions.empty();
72 aiGetExtensionList(&aexts);
74 char *buffer = (
char *)alloca(aexts.length + 2);
78 char *sub = strtok(aexts.data,
";");
79 while (sub !=
nullptr) {
81 if (has_disabled_exts) {
82 for (
size_t i = 0; i < assimp_disable_extensions.
get_num_words(); ++i) {
83 std::string disabled_ext = assimp_disable_extensions.
get_word(i);
84 if (strcmp(sub + 2, disabled_ext.c_str()) == 0) {
92 size_t len = strlen(sub + 2);
93 memcpy(p, sub + 2, len);
97 sub = strtok(
nullptr,
";");
102 return std::string(buffer, p - buffer);
122 <<
"Reading " << path <<
"\n";
125 loader.local_object();
127 if (!loader.read(path)) {
131 loader.build_graph();
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
Class that interfaces with Assimp and builds Panda nodes to represent the Assimp structures.
An instance of this class is written to the front of a Bam or Txo file to make the file a cached inst...
This is a convenience class to specialize ConfigVariable as a string type.
std::string get_word(size_t n) const
Returns the variable's nth value.
size_t get_num_words() const
Returns the number of words in the variable's value.
The name of a file, such as a texture file or an Egg file.
virtual std::string get_additional_extensions() const
Returns a space-separated list of extension, in addition to the one returned by get_extension(),...
virtual bool supports_compressed() const
Returns true if this file type can transparently load compressed files (with a .pz or ....
Specifies parameters that may be passed to the loader.
A basic node of the scene graph or data graph.
TypeHandle is the identifier used to differentiate C++ class types.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.