OpenMW
components/nifogre/mesh.hpp
Go to the documentation of this file.
00001 #ifndef COMPONENTS_NIFOGRE_MESH_HPP
00002 #define COMPONENTS_NIFOGRE_MESH_HPP
00003 
00004 #include <iostream>
00005 #include <string>
00006 #include <map>
00007 #include <cassert>
00008 
00009 #include <OgreResource.h>
00010 
00011 namespace Nif
00012 {
00013     class NiTriShape;
00014 }
00015 
00016 namespace NifOgre
00017 {
00018 
00022 class NIFMeshLoader : Ogre::ManualResourceLoader
00023 {
00024     static void warn(const std::string &msg)
00025     {
00026         std::cerr << "NIFMeshLoader: Warn: " << msg << std::endl;
00027     }
00028 
00029     static void fail(const std::string &msg)
00030     {
00031         std::cerr << "NIFMeshLoader: Fail: "<< msg << std::endl;
00032         abort();
00033     }
00034 
00035     std::string mName;
00036     std::string mGroup;
00037     size_t mShapeIndex;
00038 
00039     // Convert NiTriShape to Ogre::SubMesh
00040     void createSubMesh(Ogre::Mesh *mesh, const Nif::NiTriShape *shape);
00041 
00042     typedef std::map<std::string,NIFMeshLoader> LoaderMap;
00043     static LoaderMap sLoaders;
00044 
00045     NIFMeshLoader(const std::string &name, const std::string &group, size_t idx);
00046 
00047     virtual void loadResource(Ogre::Resource *resource);
00048 
00049 public:
00050     static void createMesh(const std::string &name, const std::string &fullname, const std::string &group, size_t idx);
00051 };
00052 
00053 }
00054 
00055 #endif