Panda3D
assimpLoader.h
1 // Filename: assimpLoader.h
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 #ifndef ASSIMPLOADER_H
16 #define ASSIMPLOADER_H
17 
18 #include "config_assimp.h"
19 #include "filename.h"
20 #include "modelRoot.h"
21 #include "texture.h"
22 
23 #include "aiScene.h"
24 
25 ////////////////////////////////////////////////////////////////////
26 // Class : AssimpLoader
27 // Description : Class that interfaces with Assimp and builds Panda
28 // nodes to represent the Assimp structures.
29 // The loader should be reusable.
30 ////////////////////////////////////////////////////////////////////
32 public:
33  AssimpLoader();
34  virtual ~AssimpLoader();
35 
36  void get_extensions(string &ext) const;
37 
38  bool read(const Filename &filename);
39  void build_graph();
40 
41 public:
42  bool _error;
43  PT(ModelRoot) _root;
44  Filename _filename;
45  Mutex _lock;
46 
47 private:
48  Assimp::Importer _importer;
49  const aiScene *_scene;
50 
51  // These arrays are temporarily used during the build_graph run.
52  PT(Texture) *_textures;
53  CPT(RenderState) *_mat_states;
54  PT(Geom) *_geoms;
55  unsigned int *_geom_matindices;
56 
57  void load_texture(size_t index);
58  void load_texture_stage(const aiMaterial &mat, const aiTextureType &ttype, CPT(TextureAttrib) &tattr);
59  void load_material(size_t index);
60  void load_mesh(size_t index);
61  void load_node(const aiNode &node, PandaNode *parent);
62  void load_light(const aiLight &light);
63 };
64 
65 #include "assimpLoader.I"
66 
67 #endif
A node of this type is created automatically at the root of each model file that is loaded...
Definition: modelRoot.h:31
bool read(const Filename &filename)
Reads from the indicated file.
A basic node of the scene graph or data graph.
Definition: pandaNode.h:72
void build_graph()
Converts scene graph structures into a Panda3D scene graph, with _root being the root node...
Represents a texture object, which is typically a single 2-d image but may also represent a 1-d or 3-...
Definition: texture.h:75
A base class for things which need to inherit from both TypedObject and from ReferenceCount.
A standard mutex, or mutual exclusion lock.
Definition: pmutex.h:44
Indicates the set of TextureStages and their associated Textures that should be applied to (or remove...
Definition: textureAttrib.h:34
The name of a file, such as a texture file or an Egg file.
Definition: filename.h:44
A container for geometry primitives.
Definition: geom.h:58
This represents a unique collection of RenderAttrib objects that correspond to a particular renderabl...
Definition: renderState.h:53
Class that interfaces with Assimp and builds Panda nodes to represent the Assimp structures.
Definition: assimpLoader.h:31
void get_extensions(string &ext) const
Returns a space-separated list of extensions that Assimp can load, without the leading dots...