Panda3D
|
00001 // Filename: assimpLoader.h 00002 // Created by: rdb (29Mar11) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 #ifndef ASSIMPLOADER_H 00016 #define ASSIMPLOADER_H 00017 00018 #include "config_assimp.h" 00019 #include "filename.h" 00020 #include "modelRoot.h" 00021 #include "texture.h" 00022 00023 #include "aiScene.h" 00024 00025 //////////////////////////////////////////////////////////////////// 00026 // Class : AssimpLoader 00027 // Description : Class that interfaces with Assimp and builds Panda 00028 // nodes to represent the Assimp structures. 00029 // The loader should be reusable. 00030 //////////////////////////////////////////////////////////////////// 00031 class AssimpLoader : public TypedReferenceCount { 00032 public: 00033 AssimpLoader(); 00034 virtual ~AssimpLoader(); 00035 00036 void get_extensions(string &ext) const; 00037 00038 bool read(const Filename &filename); 00039 void build_graph(); 00040 00041 public: 00042 bool _error; 00043 PT(ModelRoot) _root; 00044 Filename _filename; 00045 Mutex _lock; 00046 00047 private: 00048 Assimp::Importer _importer; 00049 const aiScene *_scene; 00050 00051 // These arrays are temporarily used during the build_graph run. 00052 PT(Texture) *_textures; 00053 CPT(RenderState) *_mat_states; 00054 PT(Geom) *_geoms; 00055 unsigned int *_geom_matindices; 00056 00057 void load_texture(size_t index); 00058 void load_texture_stage(const aiMaterial &mat, const aiTextureType &ttype, CPT(TextureAttrib) &tattr); 00059 void load_material(size_t index); 00060 void load_mesh(size_t index); 00061 void load_node(const aiNode &node, PandaNode *parent); 00062 void load_light(const aiLight &light); 00063 }; 00064 00065 #include "assimpLoader.I" 00066 00067 #endif