Panda3D
 All Classes Functions Variables Enumerations
loaderFileTypeAssimp.cxx
1 // Filename: loaderFileTypeAssimp.cxx
2 // Created by: rdb (29Mar11)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #include "loaderFileTypeAssimp.h"
16 #include "config_assimp.h"
17 #include "assimpLoader.h"
18 
19 TypeHandle LoaderFileTypeAssimp::_type_handle;
20 
21 ////////////////////////////////////////////////////////////////////
22 // Function: LoaderFileTypeAssimp::Constructor
23 // Access: Public
24 // Description:
25 ////////////////////////////////////////////////////////////////////
26 LoaderFileTypeAssimp::
27 LoaderFileTypeAssimp() : _loader(new AssimpLoader) {
28 }
29 
30 ////////////////////////////////////////////////////////////////////
31 // Function: LoaderFileTypeAssimp::Destructor
32 // Access: Public, Virtual
33 // Description:
34 ////////////////////////////////////////////////////////////////////
35 LoaderFileTypeAssimp::
36 ~LoaderFileTypeAssimp() {
37  if (_loader != NULL) {
38  delete _loader;
39  }
40 }
41 
42 ////////////////////////////////////////////////////////////////////
43 // Function: LoaderFileTypeAssimp::get_name
44 // Access: Public, Virtual
45 // Description:
46 ////////////////////////////////////////////////////////////////////
47 string LoaderFileTypeAssimp::
48 get_name() const {
49  return "Assimp Importer";
50 }
51 
52 ////////////////////////////////////////////////////////////////////
53 // Function: LoaderFileTypeAssimp::get_extension
54 // Access: Public, Virtual
55 // Description:
56 ////////////////////////////////////////////////////////////////////
57 string LoaderFileTypeAssimp::
58 get_extension() const {
59  return "";
60 }
61 
62 ////////////////////////////////////////////////////////////////////
63 // Function: LoaderFileTypeAssimp::get_additional_extensions
64 // Access: Public, Virtual
65 // Description: Returns a space-separated list of extension, in
66 // addition to the one returned by get_extension(), that
67 // are recognized by this converter.
68 ////////////////////////////////////////////////////////////////////
71  string exts;
72  _loader->get_extensions(exts);
73  return exts;
74 }
75 
76 ////////////////////////////////////////////////////////////////////
77 // Function: LoaderFileTypeAssimp::supports_compressed
78 // Access: Published, Virtual
79 // Description: Returns true if this file type can transparently load
80 // compressed files (with a .pz extension), false
81 // otherwise.
82 ////////////////////////////////////////////////////////////////////
85  return true;
86 }
87 
88 ////////////////////////////////////////////////////////////////////
89 // Function: LoaderFileTypeAssimp::load_file
90 // Access: Public, Virtual
91 // Description:
92 ////////////////////////////////////////////////////////////////////
94 load_file(const Filename &path, const LoaderOptions &options,
95  BamCacheRecord *record) const {
96 
97  assimp_cat.info()
98  << "Reading " << path << "\n";
99 
100  if (!_loader->read(path)) {
101  return NULL;
102  }
103 
104  _loader->build_graph();
105  return DCAST(PandaNode, _loader->_root);
106 }
virtual string get_additional_extensions() const
Returns a space-separated list of extension, in addition to the one returned by get_extension(), that are recognized by this converter.
A basic node of the scene graph or data graph.
Definition: pandaNode.h:72
Specifies parameters that may be passed to the loader.
Definition: loaderOptions.h:26
This defines the Loader interface that uses the Assimp library to load various model formats...
void get_extensions(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:44
An instance of this class is written to the front of a Bam or Txo file to make the file a cached inst...
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85
virtual bool supports_compressed() const
Returns true if this file type can transparently load compressed files (with a .pz extension)...
Class that interfaces with Assimp and builds Panda nodes to represent the Assimp structures.
Definition: assimpLoader.h:31