Panda3D
loaderFileTypeAssimp.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 loaderFileTypeAssimp.cxx
10  * @author rdb
11  * @date 2011-03-29
12  */
13 
14 #include "loaderFileTypeAssimp.h"
15 #include "config_assimp.h"
16 #include "assimpLoader.h"
17 
18 using std::string;
19 
20 TypeHandle LoaderFileTypeAssimp::_type_handle;
21 
22 /**
23  *
24  */
25 LoaderFileTypeAssimp::
26 LoaderFileTypeAssimp() : _loader(new AssimpLoader) {
27 }
28 
29 /**
30  *
31  */
32 LoaderFileTypeAssimp::
33 ~LoaderFileTypeAssimp() {
34  if (_loader != nullptr) {
35  delete _loader;
36  }
37 }
38 
39 /**
40  *
41  */
42 string LoaderFileTypeAssimp::
43 get_name() const {
44  return "Assimp Importer";
45 }
46 
47 /**
48  *
49  */
50 string LoaderFileTypeAssimp::
51 get_extension() const {
52  return "";
53 }
54 
55 /**
56  * Returns a space-separated list of extension, in addition to the one
57  * returned by get_extension(), that are recognized by this converter.
58  */
61  string exts;
62  _loader->get_extensions(exts);
63  return exts;
64 }
65 
66 /**
67  * Returns true if this file type can transparently load compressed files
68  * (with a .pz or .gz extension), false otherwise.
69  */
72  return true;
73 }
74 
75 /**
76  *
77  */
78 PT(PandaNode) LoaderFileTypeAssimp::
79 load_file(const Filename &path, const LoaderOptions &options,
80  BamCacheRecord *record) const {
81 
82  assimp_cat.info()
83  << "Reading " << path << "\n";
84 
85  if (!_loader->read(path)) {
86  return nullptr;
87  }
88 
89  _loader->build_graph();
90  return DCAST(PandaNode, _loader->_root);
91 }
bool read(const Filename &filename)
Reads from the indicated file.
A basic node of the scene graph or data graph.
Definition: pandaNode.h:64
Specifies parameters that may be passed to the loader.
Definition: loaderOptions.h:23
void build_graph()
Converts scene graph structures into a Panda3D scene graph, with _root being the root node.
virtual bool supports_compressed() const
Returns true if this file type can transparently load compressed files (with a .pz or ....
void get_extensions(std::string &ext) const
Returns a space-separated list of extensions that Assimp can load, without the leading dots.
The name of a file, such as a texture file or an Egg file.
Definition: filename.h:39
An instance of this class is written to the front of a Bam or Txo file to make the file a cached inst...
virtual std::string get_additional_extensions() const
Returns a space-separated list of extension, in addition to the one returned by get_extension(),...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81
Class that interfaces with Assimp and builds Panda nodes to represent the Assimp structures.
Definition: assimpLoader.h:44